feat(i18n): Mask page i18n

This commit is contained in:
AkiChase 2024-05-10 17:38:28 +08:00
parent 16bcce30b3
commit 4bcaf7b18f
4 changed files with 58 additions and 20 deletions

View File

@ -25,7 +25,9 @@ import {
AndroidMetastate, AndroidMetastate,
} from "../frontcommand/android"; } from "../frontcommand/android";
import { Store } from "@tauri-apps/plugin-store"; import { Store } from "@tauri-apps/plugin-store";
import { useI18n } from "vue-i18n";
const { t } = useI18n();
const store = useGlobalStore(); const store = useGlobalStore();
const router = useRouter(); const router = useRouter();
const message = useMessage(); const message = useMessage();
@ -60,7 +62,7 @@ onActivated(async () => {
) { ) {
listenToEvent(); listenToEvent();
} else { } else {
message.error("按键方案异常,请删除此方案"); message.error(t("pages.Mask.keyconfigException"));
} }
} }
}); });
@ -107,7 +109,7 @@ async function loadLocalStore() {
keyMappingConfigList = [ keyMappingConfigList = [
{ {
relativeSize, relativeSize,
title: "空白方案", title: t("pages.Mask.blankConfig"),
list: [], list: [],
}, },
]; ];
@ -235,20 +237,20 @@ async function checkUpdate() {
} }
); );
if (res.status !== 200) { if (res.status !== 200) {
message.error("检查更新失败"); message.error(t("pages.Mask.checkUpdate.failed"));
} else { } else {
const data = await res.json(); const data = await res.json();
const latestVersion = (data.tag_name as string).slice(1); const latestVersion = (data.tag_name as string).slice(1);
if (latestVersion <= curVersion) { if (latestVersion <= curVersion) {
message.success(`最新版本: ${latestVersion},当前已是最新版本`); message.success(t("pages.Mask.checkUpdate.isLatest", [latestVersion]));
return; return;
} }
const body = data.body as string; const body = data.body as string;
dialog.info({ dialog.info({
title: `最新版本:${data.tag_name}`, title: t("pages.Mask.checkUpdate.notLatest.title", [latestVersion]),
content: () => renderUpdateInfo(body), content: () => renderUpdateInfo(body),
positiveText: "前往发布页", positiveText: t("pages.Mask.checkUpdate.notLatest.positiveText"),
negativeText: "取消", negativeText: t("pages.Mask.checkUpdate.notLatest.negativeText"),
onPositiveClick: () => { onPositiveClick: () => {
open(data.html_url); open(data.html_url);
}, },
@ -256,7 +258,7 @@ async function checkUpdate() {
} }
} catch (e) { } catch (e) {
console.error(e); console.error(e);
message.error("检查更新失败"); message.error(t("pages.Mask.checkUpdate.failed"));
} }
} }
</script> </script>
@ -266,9 +268,9 @@ async function checkUpdate() {
<div class="content"> <div class="content">
<NDialog <NDialog
:closable="false" :closable="false"
title="未找到受控设备" :title="$t('pages.Mask.noControledDevice.title')"
content="请启动服务端并控制任意设备" :content="$t('pages.Mask.noControledDevice.content')"
positive-text="去启动" :positive-text="$t('pages.Mask.noControledDevice.positiveText')"
type="warning" type="warning"
@positive-click="toStartServer" @positive-click="toStartServer"
/> />
@ -286,7 +288,7 @@ async function checkUpdate() {
ref="inputInstRef" ref="inputInstRef"
v-model:value="inputBoxVal" v-model:value="inputBoxVal"
type="text" type="text"
placeholder="Input text and then press enter/esc" :placeholder="$t('pages.Mask.inputBoxPlaceholder')"
/> />
</div> </div>
<div <div

View File

@ -13,7 +13,6 @@ import {
useDialog, useDialog,
NCard, NCard,
NIcon, NIcon,
NFormItem,
NSelect, NSelect,
} from "naive-ui"; } from "naive-ui";
import { relaunch } from "@tauri-apps/plugin-process"; import { relaunch } from "@tauri-apps/plugin-process";
@ -92,13 +91,12 @@ function changeLanguage(language: "zh-CN" | "en-US") {
<template> <template>
<div class="setting-page"> <div class="setting-page">
<NH4 prefix="bar">语言</NH4> <NH4 prefix="bar">语言</NH4>
<NFormItem> <NSelect
<NSelect :value="curLanguage"
:value="curLanguage" @update:value="changeLanguage"
@update:value="changeLanguage" :options="languageOptions"
:options="languageOptions" style="max-width: 300px; margin: 20px 0"
/> />
</NFormItem>
<NFlex justify="space-between"> <NFlex justify="space-between">
<NH4 prefix="bar">本地数据</NH4> <NH4 prefix="bar">本地数据</NH4>
<NFlex> <NFlex>

View File

@ -36,6 +36,25 @@
"controledDevice": "Controlled device", "controledDevice": "Controlled device",
"availableDevice": "Available devices", "availableDevice": "Available devices",
"noControledDevice": "No Controled Device" "noControledDevice": "No Controled Device"
},
"Mask": {
"inputBoxPlaceholder": "Input text and then press enter/esc",
"keyconfigException": "The key mapping config is abnormal, please delete this config",
"blankConfig": "Blank config",
"checkUpdate": {
"failed": "Check for updates failed",
"isLatest": "Latest version: {0}, currently the latest version",
"notLatest": {
"title": "Latest version: {0}",
"positiveText": "Release page",
"negativeText": "Cancel"
}
},
"noControledDevice": {
"title": "Controlled device not found",
"content": "Please go to the device page to control any device",
"positiveText": "To control"
}
} }
} }
} }

View File

@ -36,6 +36,25 @@
"controledDevice": "受控设备", "controledDevice": "受控设备",
"noControledDevice": "无受控设备", "noControledDevice": "无受控设备",
"availableDevice": "可用设备" "availableDevice": "可用设备"
},
"Mask": {
"keyconfigException": "按键方案异常,请删除此方案",
"blankConfig": "空白方案",
"checkUpdate": {
"failed": "检查更新失败",
"isLatest": "最新版本: {0},当前已是最新版本",
"notLatest": {
"title": "最新版本:{0}",
"positiveText": "前往发布页",
"negativeText": "取消"
}
},
"noControledDevice": {
"title": "未找到受控设备",
"content": "请前往设备页面,控制任意设备",
"positiveText": "去控制"
},
"inputBoxPlaceholder": "输入文本后按Enter/Esc"
} }
} }
} }