update:英文版代码备份
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { t } from "@/locales";
|
||||
import { computed, ref } from "vue";
|
||||
import { sendHardwareBoxUpdateAPI } from "@/apis";
|
||||
import useStore from "@/store";
|
||||
@@ -8,9 +9,9 @@ const OTA_RESULT_EVENT = "/addons/shoot/otaResult";
|
||||
const UPDATE_TIMEOUT = 10 * 60 * 1000;
|
||||
|
||||
const phaseTextMap = {
|
||||
started: "正在准备固件更新",
|
||||
downloading: "正在下载固件",
|
||||
installing: "正在安装固件",
|
||||
started: t('preparing_firmware_update'),
|
||||
downloading: t('downloading_firmware'),
|
||||
installing: t('installing_firmware'),
|
||||
};
|
||||
|
||||
// 设备详情中的 latestVersion 是升级目标,version 是当前固件版本。
|
||||
@@ -39,14 +40,14 @@ let successCallback = null;
|
||||
let socketListening = false;
|
||||
|
||||
const phaseText = computed(
|
||||
() => phaseTextMap[phase.value] || "正在进行固件更新"
|
||||
() => phaseTextMap[phase.value] || t('updating_firmware')
|
||||
);
|
||||
const resultTitle = computed(() =>
|
||||
resultStatus.value === "success" ? "固件更新完成" : "固件更新失败"
|
||||
resultStatus.value === "success" ? t('firmware_update_complete_250') : t('firmware_update_failed')
|
||||
);
|
||||
const resultContent = computed(() => {
|
||||
if (resultStatus.value === "success") return "固件更新已完成";
|
||||
return resultReason.value || "更新失败,请检查设备及网络后重试";
|
||||
if (resultStatus.value === "success") return t('firmware_update_complete');
|
||||
return resultReason.value || t('update_failed_check_your_device_and_network_then_retry');
|
||||
});
|
||||
|
||||
const clearTimers = () => {
|
||||
@@ -101,7 +102,7 @@ const recoverUpdateFromMessage = (data) => {
|
||||
updating.value = true;
|
||||
clearTimers();
|
||||
timeoutTimer = setTimeout(() => {
|
||||
finishUpdate("failed", "固件更新超时,请稍后重试", runId);
|
||||
finishUpdate("failed", t('firmware_update_timed_out_please_try_again'), runId);
|
||||
}, UPDATE_TIMEOUT);
|
||||
};
|
||||
|
||||
@@ -178,7 +179,7 @@ export const useOtaUpdate = () => {
|
||||
if (updating.value) return false;
|
||||
const nextVersion = String(versionNumber || "").trim();
|
||||
if (!nextVersion) {
|
||||
uni.showToast({ title: "缺少固件目标版本", icon: "none" });
|
||||
uni.showToast({ title: t('target_firmware_version_is_missing'), icon: "none" });
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -195,7 +196,7 @@ export const useOtaUpdate = () => {
|
||||
updating.value = true;
|
||||
clearTimers();
|
||||
timeoutTimer = setTimeout(() => {
|
||||
finishUpdate("failed", "固件更新超时,请稍后重试", runId);
|
||||
finishUpdate("failed", t('firmware_update_timed_out_please_try_again'), runId);
|
||||
}, UPDATE_TIMEOUT);
|
||||
|
||||
try {
|
||||
@@ -206,7 +207,7 @@ export const useOtaUpdate = () => {
|
||||
});
|
||||
if (runId !== updateRunId || !updating.value) return false;
|
||||
if (!updateResult?.taskId) {
|
||||
finishUpdate("failed", "固件更新任务创建失败,请稍后重试", runId);
|
||||
finishUpdate("failed", t('could_not_create_the_firmware_update_task_please_retry'), runId);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -214,7 +215,7 @@ export const useOtaUpdate = () => {
|
||||
if (runId === updateRunId) {
|
||||
finishUpdate(
|
||||
"failed",
|
||||
error?.message || "固件更新请求失败,请稍后重试",
|
||||
error?.message || t('firmware_update_request_failed_please_retry'),
|
||||
runId
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user