feat: 通过 IPC 实现应用版本号获取功能

移除预加载脚本中的版本号获取逻辑,改为通过 IPC 从主进程获取
This commit is contained in:
2026-03-24 20:58:15 +08:00
parent 7b71522afb
commit 308f5b7ce6
4 changed files with 16 additions and 14 deletions

View File

@@ -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
View File

@@ -15,4 +15,9 @@ interface Window {
};
}
// IPC channel type definitions
declare interface IpcChannels {
"get-app-version": () => string;
}
declare const __APP_VERSION__: string;