feat: 添加应用版本更新功能;实现版本检查、更新提示及国际化支持
This commit is contained in:
@@ -5,7 +5,7 @@ import { checkbox, close, contrastOutline, information, languageOutline, refresh
|
||||
const { t } = useI18n();
|
||||
const router = useIonRouter();
|
||||
const { cacheSize, calculateCacheSize, clearCache } = useCacheSize();
|
||||
const { isChecking, checkForUpdate } = useAppUpdate();
|
||||
const { isChecking, checkAndPromptUpdate } = useAppUpdate();
|
||||
const { currentLanguage } = useLanguage();
|
||||
const { theme } = useTheme();
|
||||
const themeNames = {
|
||||
@@ -27,48 +27,7 @@ function handleClearCache() {
|
||||
}
|
||||
|
||||
async function handleCheckUpdate() {
|
||||
try {
|
||||
const result = await checkForUpdate();
|
||||
|
||||
if (result.hasUpdate) {
|
||||
const alert = await alertController.create({
|
||||
header: t("settings.updateAvailable"),
|
||||
message: `${t("settings.currentVersion")}: ${result.currentVersion}\n${t("settings.latestVersion")}: ${result.latestVersion || t("settings.newVersion")}`,
|
||||
buttons: [
|
||||
{
|
||||
text: t("settings.cancel"),
|
||||
role: "cancel",
|
||||
},
|
||||
{
|
||||
text: t("settings.updateNow"),
|
||||
handler: () => {
|
||||
window.location.reload();
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
await alert.present();
|
||||
}
|
||||
else {
|
||||
const toast = await toastController.create({
|
||||
message: t("settings.alreadyLatest"),
|
||||
duration: 2000,
|
||||
icon: checkbox,
|
||||
position: "bottom",
|
||||
color: "success",
|
||||
});
|
||||
await toast.present();
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
const toast = await toastController.create({
|
||||
message: t("settings.checkUpdateFailed"),
|
||||
duration: 2000,
|
||||
position: "bottom",
|
||||
color: "danger",
|
||||
});
|
||||
await toast.present();
|
||||
}
|
||||
checkAndPromptUpdate();
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
|
||||
Reference in New Issue
Block a user