From 9afb630902937a12fe88ade85c7ba7ebd5ffd78e Mon Sep 17 00:00:00 2001 From: 24kycj <1637269896@qq.com> Date: Sun, 22 Dec 2024 00:49:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/renderer/components/userInfo/userInfo.vue | 2 +- src/renderer/router/index.js | 2 +- src/renderer/store/modules/user.js | 4 +- src/renderer/views/dashboard/index.vue | 118 +++++++++--------- 4 files changed, 64 insertions(+), 62 deletions(-) diff --git a/src/renderer/components/userInfo/userInfo.vue b/src/renderer/components/userInfo/userInfo.vue index 611e7d4..5d93c33 100644 --- a/src/renderer/components/userInfo/userInfo.vue +++ b/src/renderer/components/userInfo/userInfo.vue @@ -2,7 +2,7 @@
你好,{{name}}
-
登出
+
diff --git a/src/renderer/router/index.js b/src/renderer/router/index.js index 7b6055a..14850cf 100644 --- a/src/renderer/router/index.js +++ b/src/renderer/router/index.js @@ -5,9 +5,9 @@ Vue.use(Router) export default new Router({ routes: [ + { path: '/', component: () => import('@/views/dashboard/index'), name: '首页' }, { path: '/login', component: () => import('@/views/login/index') }, { path: '/404', component: () => import('@/views/404') }, - { path: '/', component: () => import('@/views/dashboard/index'), name: '首页' }, { path: '/manage', component: () => import('@/views/manage/index'), name: '系统管理' }, { path: '/user', component: () => import('@/views/user/index'), name: '用户管理' }, { path: '/set', component: () => import('@/views/set/index'), name: '系统配置' } diff --git a/src/renderer/store/modules/user.js b/src/renderer/store/modules/user.js index bf9c6d2..2b9b23b 100644 --- a/src/renderer/store/modules/user.js +++ b/src/renderer/store/modules/user.js @@ -13,12 +13,12 @@ const setFormDefault = { } const user = { state: { - token: getToken(), + token: 'getToken()', name: 'admin', avatar: 'https://image.baidu.com/search/detail?ct=503316480&z=&tn=baiduimagedetail&ipn=d&word=admin&step_word=&lid=8980923753406439282&ie=utf-8&in=&cl=2&lm=-1&st=-1&hd=&latest=©right=&cs=1902119677,258344230&os=3526618670,2431782315&simid=3426573763,123057590&pn=11&rn=1&di=7410818322373017601&ln=1928&fr=&fmq=1730735680169_R&ic=&s=undefined&se=&sme=&tab=0&width=&height=&face=undefined&is=0,0&istype=2&ist=&jit=&bdtype=0&spn=0&pi=0&gsm=1e&objurl=https%3A%2F%2Fclearhub.tech%2Fwp-content%2Fuploads%2F2018%2F11%2F12.png&rpstart=0&rpnum=0&adpicid=0&nojc=undefined&dyTabStr=MCwzLDEsMiwxMyw3LDYsNSwxMiw5', roles: ['admin'], - oneLogin: false, + oneLogin: true, // 高级设置 setForm: setFormDefault, }, diff --git a/src/renderer/views/dashboard/index.vue b/src/renderer/views/dashboard/index.vue index b836179..42b2977 100644 --- a/src/renderer/views/dashboard/index.vue +++ b/src/renderer/views/dashboard/index.vue @@ -567,71 +567,73 @@ export default { // return // } if (e) { - that - .$confirm('确定执行开启服务操作吗?', '温馨提示', { - confirmButtonText: '确定', - cancelButtonText: '取消', - type: 'warning' - }) - .then(() => { - that.startService() - }) - .catch(() => { - that.serviceLoading = false - }) + that.startService() } else { - that - .$confirm('确定执行关闭服务操作吗?', '温馨提示', { - confirmButtonText: '确定', - cancelButtonText: '取消', - type: 'warning' - }) - .then(() => { - that.serviceLoading = true - that.serviceText = '服务关闭中' - that - .$runCmd(`bash ${shPath} stop`) - .then((res) => { - that.$store.dispatch('chat/setDatas', { name: 'workStatus', data: false }) - setTimeout(() => { - that.$store.dispatch('chat/closeWebsocket') - that.serviceLoading = false - that.$message({ - message: '服务已关闭', - type: 'success' - }) - }, 500) - }) - .catch((err) => { - that.$message({ - message: err, - type: 'error' - }) - that.serviceLoading = false - }) - }) - .catch(() => { - that.serviceLoading = false - }) + that.stopService() } }, startService() { let that = this - that.serviceLoading = true - that.serviceText = '服务启动中' that - .$runCmd(`bash ${shPath} start`) - .then((res) => { - that.$store.dispatch('chat/setDatas', { name: 'workStatus', data: true }) - setTimeout(() => { - that.$store.dispatch('chat/initWebSocket') - }, 500) + .$prompt('请输入管理员密码并点击确定以执行开启服务操作', '温馨提示', { + confirmButtonText: '确定', + cancelButtonText: '取消' }) - .catch((err) => { - that.$message({ - message: err, - type: 'error' - }) + .then(({ value }) => { + that.serviceLoading = true + that.serviceText = '服务启动中' + that + .$runCmd(`bash ${shPath} start ${value}`) + .then((res) => { + that.$store.dispatch('chat/setDatas', { name: 'workStatus', data: true }) + setTimeout(() => { + that.$store.dispatch('chat/initWebSocket') + }, 500) + }) + .catch((err) => { + that.$message({ + message: err, + type: 'error' + }) + that.serviceLoading = false + }) + }) + .catch(() => { + that.serviceLoading = false + }) + }, + stopService() { + let that = this + that + .$prompt('请输入管理员密码并点击确定以执行关闭服务操作', '温馨提示', { + confirmButtonText: '确定', + cancelButtonText: '取消' + }) + .then(({ value }) => { + that.serviceLoading = true + that.serviceText = '服务关闭中' + that + .$runCmd(`bash ${shPath} stop ${value}`) + .then((res) => { + that.$store.dispatch('chat/setDatas', { name: 'workStatus', data: false }) + setTimeout(() => { + that.$store.dispatch('chat/closeWebsocket') + that.serviceLoading = false + that.$message({ + message: '服务已关闭', + type: 'success' + }) + }, 500) + }) + .catch((err) => { + that.$message({ + message: err, + type: 'error' + }) + that.serviceLoading = false + }) + }) + .catch(() => { that.serviceLoading = false }) },