更新服务

This commit is contained in:
24kycj
2024-12-06 20:28:24 +08:00
parent ef7eab3cf9
commit dddb5dd918
52 changed files with 172 additions and 14 deletions
+43 -11
View File
@@ -1,5 +1,8 @@
<template>
<div class="container_box">
<div class="container_box" v-loading="serviceLoading"
:element-loading-text="serviceText"
element-loading-spinner="el-icon-loading"
element-loading-background="rgba(0, 0, 0, 0.8)">
<!-- 头部 -->
<div class="flex_box flex_row_between top_box">
<div class="flex_box top_left">
@@ -18,7 +21,7 @@
<div class="top_left_line"></div>
<el-tooltip :content="workStatus?'关闭服务':'打开服务'" placement="bottom">
<div class="flex_box flex_row_center top_left_status_box">
<el-switch :disabled="!serviceStatus" @change="serviceChange" class="top_left_status" v-model="workStatus" active-color="#07C160" inactive-color="#aaa"> </el-switch>
<el-switch @change="serviceChange" class="top_left_status" :value="workStatus" active-color="#07C160" inactive-color="#aaa"> </el-switch>
</div>
</el-tooltip>
<div class="flex_box top_left_option">
@@ -299,11 +302,13 @@
let that
let outTimer
let fs = require('fs')
let path = require('path')
import { mapGetters } from 'vuex'
const { app, dialog } = require('@electron/remote')
import UserInfo from '@/components/userInfo/userInfo.vue'
import WorkAdd from '@/components/workAdd/workAdd.vue'
const exePath = process.cwd();
const shPath = path.join(exePath, 'cardsoonServer', 'control.sh')
export default {
name: 'dashboard',
components: { UserInfo, WorkAdd },
@@ -312,6 +317,8 @@ export default {
// 服务状态
isConnect: false,
serviceStatus: false,
serviceLoading: false,
serviceText: '服务关闭中',
// 工作状态
infoStatus: 0,
// 运行选项
@@ -425,6 +432,8 @@ export default {
})
this.taskNum = nums
this.task_list = list
} else {
this.task_list = []
}
},
deep: true,
@@ -516,6 +525,8 @@ export default {
},
mounted() {
that = this
let name = 'ERR_ELECTRON_BUILDER_CANNOT_EXECUTE'
console.log(name.toLowerCase())
},
methods: {
// 服务打开/关闭
@@ -523,16 +534,37 @@ export default {
if (!that.serviceStatus) {
return
}
that.serviceLoading = true
if (e) {
that.store.commit('setData', { name: 'workStatus', data: true })
setTimeout(() => {
that.$store.dispatch('chat/initWebSocket')
}, 500);
that.serviceTextex = '服务启动中'
this.$runCmd(`bash ${shPath} start`).then(res => {
that.$store.dispatch('chat/changeWorkStatus', true)
setTimeout(() => {
that.$store.dispatch('chat/initWebSocket')
that.serviceLoading = false
}, 500);
}).catch(err => {
that.$message({
message: err,
type: 'error'
})
that.serviceLoading = false
})
} else {
that.store.commit('setData', { name: 'workStatus', data: false })
setTimeout(() => {
that.$store.dispatch('chat/closeWebsocket')
}, 500);
that.serviceTextex = '服务关闭中'
this.$runCmd(`bash ${shPath} stop`).then(res => {
that.$store.dispatch('chat/changeWorkStatus', false)
setTimeout(() => {
that.$store.dispatch('chat/closeWebsocket')
that.serviceLoading = false
}, 500);
}).catch(err => {
that.$message({
message: err,
type: 'error'
})
that.serviceLoading = false
})
}
},
// 执行