From e53b0ed883a0a824ffab08d3b8b514cbc7e7ee8e Mon Sep 17 00:00:00 2001 From: kerms Date: Mon, 15 Jul 2024 13:05:24 +0800 Subject: [PATCH] feat(sys) add serial number display --- src/api/apiSystem.ts | 13 +++++++++++++ src/composables/useSystemModule.ts | 8 +++++++- src/stores/useSystemStore.ts | 5 +++++ src/views/About.vue | 1 + src/views/Wifi.vue | 1 - 5 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/api/apiSystem.ts b/src/api/apiSystem.ts index c1e8692..0ac8227 100644 --- a/src/api/apiSystem.ts +++ b/src/api/apiSystem.ts @@ -3,6 +3,7 @@ import {type ApiJsonMsg, sendJsonMsg, WtModuleID} from '@/api' export enum WtSytemCmd { WT_SYS_GET_FM_INFO = 1, WT_SYS_REBOOT = 2, + WT_SYS_GET_SYS_INFO = 3, } export interface ISysFmInfo extends ApiJsonMsg { @@ -15,6 +16,10 @@ export interface ISysHwInfo extends ApiJsonMsg { mf_date: string; } +export interface ISysInfo { + sn: string; +} + export function wt_sys_get_fm_info() { const msg: ApiJsonMsg = { module: WtModuleID.SYSTEM, @@ -30,3 +35,11 @@ export function wt_sys_reboot() { }; sendJsonMsg(msg); } + +export function wt_sys_get_sys_info() { + const msg: ApiJsonMsg = { + module: WtModuleID.SYSTEM, + cmd: WtSytemCmd.WT_SYS_GET_SYS_INFO, + }; + sendJsonMsg(msg); +} diff --git a/src/composables/useSystemModule.ts b/src/composables/useSystemModule.ts index 3c9a5f3..52a07ce 100644 --- a/src/composables/useSystemModule.ts +++ b/src/composables/useSystemModule.ts @@ -1,7 +1,7 @@ import {useSystemStore} from "@/stores/useSystemStore"; import {registerModule} from "@/router/msgRouter"; import {type ApiJsonMsg, ControlEvent, type ControlMsg, ControlMsgType, WtModuleID} from "@/api"; -import {type ISysFmInfo, wt_sys_get_fm_info, WtSytemCmd} from "@/api/apiSystem"; +import {type ISysFmInfo, type ISysInfo, wt_sys_get_fm_info, wt_sys_get_sys_info, WtSytemCmd} from "@/api/apiSystem"; import {isDevMode} from "@/composables/buildMode"; @@ -15,6 +15,7 @@ export function useSystemModule() { if (msg.data === ControlEvent.CONNECTED) { wt_sys_get_fm_info(); + wt_sys_get_sys_info(); sysStore.rebootInProgress = false; } } @@ -30,6 +31,11 @@ export function useSystemModule() { sysStore.curFmInfo.ver = fm_info.fm_ver; break; } + case WtSytemCmd.WT_SYS_GET_SYS_INFO: { + const sysInfo: ISysInfo = msg as ISysInfo & ApiJsonMsg; + Object.assign(sysStore.sysInfo, sysInfo); + break; + } } if (isDevMode()) { console.log(msg); diff --git a/src/stores/useSystemStore.ts b/src/stores/useSystemStore.ts index 9fe58a2..44974d3 100644 --- a/src/stores/useSystemStore.ts +++ b/src/stores/useSystemStore.ts @@ -13,11 +13,16 @@ export const useSystemStore = defineStore('system', () => { date: "-", }) + const sys_info = ref({ + sn: "-", + }); + const rebootInProgress = ref(false); return { curFmInfo, hwInfo, + sysInfo: sys_info, rebootInProgress, } }); diff --git a/src/views/About.vue b/src/views/About.vue index b59959d..d33f5c4 100644 --- a/src/views/About.vue +++ b/src/views/About.vue @@ -47,6 +47,7 @@ const sysStore = useSystemStore(); https://yunsi.studio/wireless-debugger {{ sysStore.curFmInfo.ver }} {{ sysStore.curFmInfo.date }} + {{ sysStore.sysInfo.sn }} diff --git a/src/views/Wifi.vue b/src/views/Wifi.vue index 1ceb0b1..1f06fc1 100644 --- a/src/views/Wifi.vue +++ b/src/views/Wifi.vue @@ -540,7 +540,6 @@ const onClientMsg = (msg: ApiJsonMsg) => { } case WifiCmd.WIFI_API_JSON_STA_GET_STATIC_INFO: { const staticInfo = msg as IWifiStaStaticInfo & ApiJsonMsg; - console.log("@@@", staticInfo); Object.assign(wifiStaticInfo, staticInfo); break; }