@@ -41,9 +41,9 @@ const statusConfig = {
|
|||||||
text: "有更新",
|
text: "有更新",
|
||||||
},
|
},
|
||||||
error: {
|
error: {
|
||||||
color: "#909399",
|
color: "#d03050",
|
||||||
icon: undefined,
|
icon: WarningOutline,
|
||||||
text: "",
|
text: "检查失败",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -68,7 +68,10 @@ const checkVersion = async () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleVersionClick = () => {
|
const handleVersionClick = () => {
|
||||||
if (versionInfo.value.status === "update-available" && versionInfo.value.releaseUrl) {
|
if (
|
||||||
|
(versionInfo.value.status === "update-available" || versionInfo.value.status === "latest") &&
|
||||||
|
versionInfo.value.releaseUrl
|
||||||
|
) {
|
||||||
window.open(versionInfo.value.releaseUrl, "_blank", "noopener,noreferrer");
|
window.open(versionInfo.value.releaseUrl, "_blank", "noopener,noreferrer");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -95,7 +98,8 @@ onMounted(() => {
|
|||||||
<div
|
<div
|
||||||
class="version-container"
|
class="version-container"
|
||||||
:class="{
|
:class="{
|
||||||
'version-clickable': versionInfo.status === 'update-available',
|
'version-clickable':
|
||||||
|
versionInfo.status === 'update-available' || versionInfo.status === 'latest',
|
||||||
'version-checking': isChecking,
|
'version-checking': isChecking,
|
||||||
}"
|
}"
|
||||||
@click="handleVersionClick"
|
@click="handleVersionClick"
|
||||||
@@ -110,22 +114,12 @@ onMounted(() => {
|
|||||||
<span class="version-text">
|
<span class="version-text">
|
||||||
{{ formatVersion(versionInfo.currentVersion) }}
|
{{ formatVersion(versionInfo.currentVersion) }}
|
||||||
-
|
-
|
||||||
<template v-if="versionInfo.status === 'latest'">
|
<span :style="{ color: statusConfig[versionInfo.status].color }">
|
||||||
<span :style="{ color: statusConfig[versionInfo.status].color }">
|
{{ statusConfig[versionInfo.status].text }}
|
||||||
{{ statusConfig[versionInfo.status].text }}
|
<template v-if="versionInfo.status === 'update-available'">
|
||||||
</span>
|
|
||||||
</template>
|
|
||||||
<template v-else-if="versionInfo.status === 'update-available'">
|
|
||||||
<span :style="{ color: statusConfig[versionInfo.status].color }">
|
|
||||||
{{ statusConfig[versionInfo.status].text }}
|
|
||||||
[{{ formatVersion(versionInfo.latestVersion || "") }}]
|
[{{ formatVersion(versionInfo.latestVersion || "") }}]
|
||||||
</span>
|
</template>
|
||||||
</template>
|
</span>
|
||||||
<template v-else-if="versionInfo.status === 'checking'">
|
|
||||||
<span :style="{ color: statusConfig[versionInfo.status].color }">
|
|
||||||
{{ statusConfig[versionInfo.status].text }}
|
|
||||||
</span>
|
|
||||||
</template>
|
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@@ -45,6 +45,12 @@ class VersionService {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 检查缓存中的版本号是否与当前应用版本号一致
|
||||||
|
if (versionInfo.currentVersion !== this.currentVersion) {
|
||||||
|
this.clearCache();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return versionInfo;
|
return versionInfo;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.warn("Failed to parse cached version info:", error);
|
console.warn("Failed to parse cached version info:", error);
|
||||||
@@ -144,6 +150,9 @@ class VersionService {
|
|||||||
versionInfo.isLatest = comparison >= 0;
|
versionInfo.isLatest = comparison >= 0;
|
||||||
versionInfo.hasUpdate = comparison < 0;
|
versionInfo.hasUpdate = comparison < 0;
|
||||||
versionInfo.status = comparison < 0 ? "update-available" : "latest";
|
versionInfo.status = comparison < 0 ? "update-available" : "latest";
|
||||||
|
|
||||||
|
// 只在成功时缓存结果
|
||||||
|
this.setCachedVersionInfo(versionInfo);
|
||||||
} else {
|
} else {
|
||||||
versionInfo.status = "error";
|
versionInfo.status = "error";
|
||||||
}
|
}
|
||||||
@@ -152,9 +161,6 @@ class VersionService {
|
|||||||
versionInfo.status = "error";
|
versionInfo.status = "error";
|
||||||
}
|
}
|
||||||
|
|
||||||
// 缓存结果
|
|
||||||
this.setCachedVersionInfo(versionInfo);
|
|
||||||
|
|
||||||
return versionInfo;
|
return versionInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user