fix: 修复获取版本号问题

This commit is contained in:
xlsea 2024-05-23 09:40:52 +08:00
parent 6f4cde6ba3
commit f0341d6078
2 changed files with 6 additions and 2 deletions

View File

@ -170,8 +170,10 @@ async function initRoute(to: RouteLocationNormalized): Promise<RouteLocationRaw
const authStore = useAuthStore(); const authStore = useAuthStore();
await authStore.getInfo(); await authStore.getInfo();
const { data, error } = await fetchVersion(); const { data, error } = await fetchVersion();
if (!error) { if (!error && data) {
localStg.set('version', data!); localStg.set('version', data!);
} else {
localStg.remove('version');
} }
} }
} }

View File

@ -27,10 +27,12 @@ const version = ref<string>(`v${localStg.get('version') || VITE_APP_VERSION}`);
const getVersion = async () => { const getVersion = async () => {
const { data, error } = await fetchVersion(); const { data, error } = await fetchVersion();
if (!error) { if (!error && data) {
version.value = data; version.value = data;
localStg.set('version', data); localStg.set('version', data);
return;
} }
localStg.remove('version');
}; };
getVersion(); getVersion();