ljw 1 год назад
Родитель
Сommit
4d1da2e89e
6 измененных файлов с 48 добавлено и 23 удалено
  1. 22 0
      src/api/config.js
  2. 0 14
      src/api/rustdesk.js
  3. 14 2
      src/store/app.js
  4. 3 3
      src/store/user.js
  5. 2 2
      src/utils/webclient.js
  6. 7 2
      src/views/my/info.vue

+ 22 - 0
src/api/config.js

@@ -0,0 +1,22 @@
1
+import request from '@/utils/request'
2
+
3
+export function server () {
4
+  return request({
5
+    url: '/config/server',
6
+    method: 'get',
7
+  })
8
+}
9
+
10
+export function app () {
11
+  return request({
12
+    url: '/config/app',
13
+    method: 'get',
14
+  })
15
+}
16
+
17
+export function admin () {
18
+  return request({
19
+    url: '/config/admin',
20
+    method: 'get',
21
+  })
22
+}

+ 0 - 14
src/api/rustdesk.js

@@ -1,14 +0,0 @@
1
-import request from '@/utils/request'
2
-
3
-export function config () {
4
-  return request({
5
-    url: '/server-config',
6
-    method: 'get',
7
-  })
8
-}
9
-export function appConfig () {
10
-  return request({
11
-    url: '/app-config',
12
-    method: 'get',
13
-  })
14
-}

+ 14 - 2
src/store/app.js

@@ -4,7 +4,7 @@ import zhCn from 'element-plus/es/locale/lang/zh-cn'
4 4
 import en from 'element-plus/es/locale/lang/en'
5 5
 import ko from 'element-plus/es/locale/lang/ko'
6 6
 import ru from 'element-plus/es/locale/lang/ru'
7
-import { appConfig } from '@/api/rustdesk'
7
+import { admin, app } from '@/api/config'
8 8
 
9 9
 const langs = {
10 10
   'zh-CN': { name: '中文', value: zhCn },
@@ -17,6 +17,7 @@ export const useAppStore = defineStore({
17 17
   state: () => ({
18 18
     setting: {
19 19
       title: 'Rustdesk-Api-Admin',
20
+      hello: '',
20 21
       sideIsCollapse: false,
21 22
       logo,
22 23
       langs: langs,
@@ -41,12 +42,23 @@ export const useAppStore = defineStore({
41 42
     changeLang (v) {
42 43
       this.setLang(v)
43 44
     },
45
+    loadConfig(){
46
+      this.getAppConfig()
47
+      this.getAdminConfig()
48
+    },
44 49
     getAppConfig () {
45 50
       console.log('getAppConfig')
46
-      appConfig().then(res => {
51
+      app().then(res => {
47 52
         this.setting.appConfig = res.data
48 53
       })
49 54
     },
55
+    getAdminConfig(){
56
+      console.log('getAdminConfig')
57
+      admin().then(res => {
58
+        this.setting.title = res.data.title
59
+        this.setting.hello = res.data.hello
60
+      })
61
+    }
50 62
   },
51 63
 })
52 64
 

+ 3 - 3
src/store/user.js

@@ -43,7 +43,7 @@ export const useUserStore = defineStore({
43 43
     async login (form) {
44 44
       const res = await login(form).catch(_ => false)
45 45
       if (res) {
46
-        useAppStore().getAppConfig()
46
+        useAppStore().loadConfig()
47 47
         const userData = res.data
48 48
         this.saveUserData(userData)
49 49
         return userData
@@ -54,7 +54,7 @@ export const useUserStore = defineStore({
54 54
     async info () {
55 55
       const res = await current().catch(_ => false)
56 56
       if (res) {
57
-        useAppStore().getAppConfig()
57
+        useAppStore().loadConfig()
58 58
         const userData = res.data
59 59
         setToken(userData.token)
60 60
         this.$patch({
@@ -93,7 +93,7 @@ export const useUserStore = defineStore({
93 93
       const res = await oidcQuery(params).catch(_ => false)
94 94
       if (res) {
95 95
         removeCode()
96
-        useAppStore().getAppConfig()
96
+        useAppStore().loadConfig()
97 97
         const userData = res.data
98 98
         this.saveUserData(userData)
99 99
         return userData

+ 2 - 2
src/utils/webclient.js

@@ -1,5 +1,5 @@
1 1
 import { ref } from 'vue'
2
-import { config } from '@/api/rustdesk'
2
+import { server } from '@/api/config'
3 3
 import Websock from '@/utils/webclient/websock'
4 4
 import * as rendezvous from '@/utils/webclient/rendezvous'
5 5
 import * as message from '@/utils/webclient/message'
@@ -13,7 +13,7 @@ export const toWebClientLink = (row) => {
13 13
 export function loadRustdeskConfig () {
14 14
   const rustdeskConfig = ref({})
15 15
   const fetchConfig = async () => {
16
-    const res = await config().catch(_ => false)
16
+    const res = await server().catch(_ => false)
17 17
     if (res) {
18 18
       rustdeskConfig.value = res.data
19 19
       localStorage.setItem('custom-rendezvous-server', res.data.id_server)

+ 7 - 2
src/views/my/info.vue

@@ -1,7 +1,7 @@
1 1
 <template>
2 2
   <div>
3
-    <el-card :title="T('Userinfo')">
4
-      <el-form class="info-form" ref="form" label-width="120px" label-suffix=":">
3
+    <el-card :title="T('Userinfo')" shadow="hover">
4
+      <el-form class="info-form" ref="form" label-width="120px" label-suffix=":" >
5 5
         <el-form-item :label="T('Username')">
6 6
           <div>{{ userStore.username }}</div>
7 7
         </el-form-item>
@@ -30,6 +30,9 @@
30 30
         </el-form-item>
31 31
       </el-form>
32 32
     </el-card>
33
+    <el-card shadow="hover" style="margin-top: 20px">
34
+      <div v-html="appStore.setting.hello"></div>
35
+    </el-card>
33 36
     <changePwdDialog v-model:visible="changePwdVisible"></changePwdDialog>
34 37
   </div>
35 38
 </template>
@@ -38,11 +41,13 @@
38 41
   import changePwdDialog from '@/components/changePwdDialog.vue'
39 42
   import { ref } from 'vue'
40 43
   import { useUserStore } from '@/store/user'
44
+  import { useAppStore } from '@/store/app'
41 45
   import { bind, unbind } from '@/api/oauth'
42 46
   import { myOauth } from '@/api/user'
43 47
   import { ElMessageBox } from 'element-plus'
44 48
   import { T } from '@/utils/i18n'
45 49
 
50
+  const appStore = useAppStore()
46 51
   const userStore = useUserStore()
47 52
   const changePwdVisible = ref(false)
48 53
   const showChangePwd = () => {