From 93f37a54c908d7cb05bec682508e8a0a3fa3e84b Mon Sep 17 00:00:00 2001 From: luoqiz Date: Thu, 10 Oct 2024 16:57:33 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E5=A4=B4=E5=83=8F=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src-tauri/config.json5 | 2 +- src/components.d.ts | 1 + src/components/layouts/BaseHeader.vue | 12 +++++++----- src/store/modules/wechat.ts | 9 +++++++-- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src-tauri/config.json5 b/src-tauri/config.json5 index 0247ad2..3c8ae5b 100644 --- a/src-tauri/config.json5 +++ b/src-tauri/config.json5 @@ -1 +1 @@ -{"cburl":[],"http_server_port":10080,"wsurl":"","file_dir":"","front_msg_show":true} \ No newline at end of file +{"cburl":[],"http_server_port":10010,"wsurl":"","file_dir":"","front_msg_show":true} \ No newline at end of file diff --git a/src/components.d.ts b/src/components.d.ts index d91c4d9..9ac036b 100644 --- a/src/components.d.ts +++ b/src/components.d.ts @@ -10,6 +10,7 @@ declare module 'vue' { 404: typeof import('./components/404.vue')['default'] BaseHeader: typeof import('./components/layouts/BaseHeader.vue')['default'] ElAutoResizer: typeof import('element-plus/es')['ElAutoResizer'] + ElAvatar: typeof import('element-plus/es')['ElAvatar'] ElButton: typeof import('element-plus/es')['ElButton'] ElCard: typeof import('element-plus/es')['ElCard'] ElCol: typeof import('element-plus/es')['ElCol'] diff --git a/src/components/layouts/BaseHeader.vue b/src/components/layouts/BaseHeader.vue index e33772b..89a55eb 100644 --- a/src/components/layouts/BaseHeader.vue +++ b/src/components/layouts/BaseHeader.vue @@ -27,6 +27,10 @@ const startOrStop = async () => { await wechatStore.stop(); } else { await wechatStore.start(); + var getUserInfoTask = window.setInterval(async function logname() { + await wechatStore.updateSlefInfo(); + clearInterval(getUserInfoTask) + }, 5000); } } catch (err: any) { console.error(err); @@ -72,11 +76,9 @@ onMounted(async () => { - + + + diff --git a/src/store/modules/wechat.ts b/src/store/modules/wechat.ts index 88fe49b..cb25969 100644 --- a/src/store/modules/wechat.ts +++ b/src/store/modules/wechat.ts @@ -14,18 +14,23 @@ export const useWechatStore = defineStore('wechat', { this.selfInfo = selfInfo; sessionStorage.setItem('selfInfo', JSON.stringify(selfInfo)); }, + async updateSlefInfo() { + if(this.isServerRunning){ + this.selfInfo = await wcf_api.userinfo(); + console.log(this.selfInfo); + } + }, async getRunningFlag() { this.isServerRunning = await wcf.is_http_server_running(); }, async start() { await wcf.start_server('0.0.0.0', 10010); this.isServerRunning = await wcf.is_http_server_running(); - this.selfInfo = await wcf_api.userinfo(); - console.log(this.selfInfo); }, async stop() { await wcf.stop_server(); this.isServerRunning = await wcf.is_http_server_running(); + this.setSelfInfo({}); }, }, });