Skip to content

Commit

Permalink
add redis define.
Browse files Browse the repository at this point in the history
  • Loading branch information
fuyoo committed Jun 28, 2024
1 parent 814eac5 commit 9aeda62
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 0 deletions.
43 changes: 43 additions & 0 deletions src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ serde_json = "1"
window-shadows = "0.2.2"
log = { version = "0.4.21", features = [] }
tauri-plugin-shell = "2.0.0-beta.7"
redis = { version = "0.25.4", features = ["tokio-comp"] }

[features]
# This feature is used for production builds or when a dev server is not specified, DO NOT REMOVE!!
Expand Down
18 changes: 18 additions & 0 deletions src-tauri/src/api/defines.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
use serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize, Debug)]
pub struct ConnectionInfo{
pub host: string,
pub port: Option<String>,
pub db: Option<String>,
pub username: Option<String>,
pub password: Option<String>
}

#[derive(Serialize, Deserialize, Debug)]
pub struct ConnectionImpl {
pub id: usize,
pub name: String,
pub node: Vec<ConnectionInfo>,
pub cluster: Option<boolean>
}
1 change: 1 addition & 0 deletions src-tauri/src/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ impl Response {
}
}


// Learn more about Tauri commands at https://tauri.app/v1/guides/features/command
#[command]
pub fn request(rid: &str, action: &str, connection_info: &str, data: &str) -> String {
Expand Down
29 changes: 29 additions & 0 deletions src/api/backend.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { useRoute } from "vue-router"
import db from "@/database"
import { invoke } from "@tauri-apps/api/core"
const getConnectionInfo = async () => {
const route = useRoute()
const id = Number(route.query.id)
return await db.connection.get(id)
}

export interface ResponseBody<T> {
code: number,
data:T,
msg: string
}

export const RReq = async <T>(action:string, data: any) => {
const info = await getConnectionInfo()
return invoke<ResponseBody<T>>("request",{
rid:Math.random().toString(36),
action,
data:JSON.stringify(data),
connectionInfo:JSON.stringify(info)
})
}


export function status<T>(data:any) {
return RReq("/status",data)
}
4 changes: 4 additions & 0 deletions src/views/TabView.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
<script setup lang="ts">
import {ref} from 'vue'
import {useRoute} from 'vue-router'
import { status } from '@/api/backend';
const route = useRoute()
const count = ref(0)
status<any>({})
.then( console.log)
</script>

<template>
Expand Down

0 comments on commit 9aeda62

Please sign in to comment.