From 4d1da2e89e38884ee44271b6b815ed0ce5a95a1a Mon Sep 17 00:00:00 2001 From: ljw <84855512@qq.com> Date: Mon, 11 Nov 2024 22:26:55 +0800 Subject: [PATCH] add admin conf --- src/api/config.js | 22 ++++++++++++++++++++++ src/api/rustdesk.js | 14 -------------- src/store/app.js | 16 ++++++++++++++-- src/store/user.js | 6 +++--- src/utils/webclient.js | 4 ++-- src/views/my/info.vue | 9 +++++++-- 6 files changed, 48 insertions(+), 23 deletions(-) create mode 100644 src/api/config.js delete mode 100644 src/api/rustdesk.js diff --git a/src/api/config.js b/src/api/config.js new file mode 100644 index 0000000..dcd39c0 --- /dev/null +++ b/src/api/config.js @@ -0,0 +1,22 @@ +import request from '@/utils/request' + +export function server () { + return request({ + url: '/config/server', + method: 'get', + }) +} + +export function app () { + return request({ + url: '/config/app', + method: 'get', + }) +} + +export function admin () { + return request({ + url: '/config/admin', + method: 'get', + }) +} diff --git a/src/api/rustdesk.js b/src/api/rustdesk.js deleted file mode 100644 index 9a70451..0000000 --- a/src/api/rustdesk.js +++ /dev/null @@ -1,14 +0,0 @@ -import request from '@/utils/request' - -export function config () { - return request({ - url: '/server-config', - method: 'get', - }) -} -export function appConfig () { - return request({ - url: '/app-config', - method: 'get', - }) -} diff --git a/src/store/app.js b/src/store/app.js index 26ee0f2..e825e1b 100644 --- a/src/store/app.js +++ b/src/store/app.js @@ -4,7 +4,7 @@ import zhCn from 'element-plus/es/locale/lang/zh-cn' import en from 'element-plus/es/locale/lang/en' import ko from 'element-plus/es/locale/lang/ko' import ru from 'element-plus/es/locale/lang/ru' -import { appConfig } from '@/api/rustdesk' +import { admin, app } from '@/api/config' const langs = { 'zh-CN': { name: '中文', value: zhCn }, @@ -17,6 +17,7 @@ export const useAppStore = defineStore({ state: () => ({ setting: { title: 'Rustdesk-Api-Admin', + hello: '', sideIsCollapse: false, logo, langs: langs, @@ -41,12 +42,23 @@ export const useAppStore = defineStore({ changeLang (v) { this.setLang(v) }, + loadConfig(){ + this.getAppConfig() + this.getAdminConfig() + }, getAppConfig () { console.log('getAppConfig') - appConfig().then(res => { + app().then(res => { this.setting.appConfig = res.data }) }, + getAdminConfig(){ + console.log('getAdminConfig') + admin().then(res => { + this.setting.title = res.data.title + this.setting.hello = res.data.hello + }) + } }, }) diff --git a/src/store/user.js b/src/store/user.js index 66863c2..28f5a7e 100644 --- a/src/store/user.js +++ b/src/store/user.js @@ -43,7 +43,7 @@ export const useUserStore = defineStore({ async login (form) { const res = await login(form).catch(_ => false) if (res) { - useAppStore().getAppConfig() + useAppStore().loadConfig() const userData = res.data this.saveUserData(userData) return userData @@ -54,7 +54,7 @@ export const useUserStore = defineStore({ async info () { const res = await current().catch(_ => false) if (res) { - useAppStore().getAppConfig() + useAppStore().loadConfig() const userData = res.data setToken(userData.token) this.$patch({ @@ -93,7 +93,7 @@ export const useUserStore = defineStore({ const res = await oidcQuery(params).catch(_ => false) if (res) { removeCode() - useAppStore().getAppConfig() + useAppStore().loadConfig() const userData = res.data this.saveUserData(userData) return userData diff --git a/src/utils/webclient.js b/src/utils/webclient.js index 847fab2..50f426f 100644 --- a/src/utils/webclient.js +++ b/src/utils/webclient.js @@ -1,5 +1,5 @@ import { ref } from 'vue' -import { config } from '@/api/rustdesk' +import { server } from '@/api/config' import Websock from '@/utils/webclient/websock' import * as rendezvous from '@/utils/webclient/rendezvous' import * as message from '@/utils/webclient/message' @@ -13,7 +13,7 @@ export const toWebClientLink = (row) => { export function loadRustdeskConfig () { const rustdeskConfig = ref({}) const fetchConfig = async () => { - const res = await config().catch(_ => false) + const res = await server().catch(_ => false) if (res) { rustdeskConfig.value = res.data localStorage.setItem('custom-rendezvous-server', res.data.id_server) diff --git a/src/views/my/info.vue b/src/views/my/info.vue index 5d2df6d..e80e03d 100644 --- a/src/views/my/info.vue +++ b/src/views/my/info.vue @@ -1,7 +1,7 @@ @@ -38,11 +41,13 @@ import changePwdDialog from '@/components/changePwdDialog.vue' import { ref } from 'vue' import { useUserStore } from '@/store/user' + import { useAppStore } from '@/store/app' import { bind, unbind } from '@/api/oauth' import { myOauth } from '@/api/user' import { ElMessageBox } from 'element-plus' import { T } from '@/utils/i18n' + const appStore = useAppStore() const userStore = useUserStore() const changePwdVisible = ref(false) const showChangePwd = () => {