mirror of
https://gitee.com/spark-store-project/spark-store
synced 2026-04-26 09:20:18 +08:00
feat: 通过 IPC 实现应用版本号获取功能
移除预加载脚本中的版本号获取逻辑,改为通过 IPC 从主进程获取
This commit is contained in:
@@ -111,11 +111,15 @@ const emit = defineEmits<{
|
||||
|
||||
const version = ref("unknown");
|
||||
|
||||
onMounted(() => {
|
||||
// 从预加载脚本获取版本号
|
||||
const apmStore = (window as any).apm_store;
|
||||
if (apmStore?.version) {
|
||||
version.value = apmStore.version;
|
||||
onMounted(async () => {
|
||||
// 通过 IPC 从主进程获取版本号
|
||||
try {
|
||||
const appVersion = await window.ipcRenderer.invoke("get-app-version");
|
||||
if (appVersion) {
|
||||
version.value = appVersion;
|
||||
}
|
||||
} catch {
|
||||
version.value = "unknown";
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
5
src/vite-env.d.ts
vendored
5
src/vite-env.d.ts
vendored
@@ -15,4 +15,9 @@ interface Window {
|
||||
};
|
||||
}
|
||||
|
||||
// IPC channel type definitions
|
||||
declare interface IpcChannels {
|
||||
"get-app-version": () => string;
|
||||
}
|
||||
|
||||
declare const __APP_VERSION__: string;
|
||||
|
||||
Reference in New Issue
Block a user