From c8c9c1d609f2fe15ffc02c2eb0336d8632976e01 Mon Sep 17 00:00:00 2001 From: Simon Date: Sat, 13 Jun 2020 15:14:56 +0800 Subject: [PATCH] feat: :construction_worker: add zh-TW supported language, fix turning off the screen bug. --- package.json | 2 +- src/main/scrcpy/index.js | 7 +- .../components/dashboard/Configuration.vue | 33 +++- src/renderer/components/menu/Menu.js | 20 +- src/renderer/components/menu/index.js | 7 +- src/renderer/lang/en.js | 7 +- src/renderer/lang/index.js | 3 +- src/renderer/lang/{zh.js => zh_CN.js} | 5 +- src/renderer/lang/zh_TW.js | 173 ++++++++++++++++++ src/renderer/main.js | 13 +- 10 files changed, 245 insertions(+), 25 deletions(-) rename src/renderer/lang/{zh.js => zh_CN.js} (97%) create mode 100644 src/renderer/lang/zh_TW.js diff --git a/package.json b/package.json index 6494c40..2305b57 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "scrcpy-gui", - "version": "1.5.0", + "version": "1.5.1", "author": "SimonMa ", "homepage": "https://github.com/Tomotoes/scrcpy-gui", "description": "✨ A simple & beautiful GUI application for scrcpy", diff --git a/src/main/scrcpy/index.js b/src/main/scrcpy/index.js index eca2fe5..962dfd1 100644 --- a/src/main/scrcpy/index.js +++ b/src/main/scrcpy/index.js @@ -36,9 +36,6 @@ const open = ({ sender }, options) => { if (fixed) { args.push('--always-on-top') } - if (!control) { - args.push('--no-control') - } if (!border) { args.push('--window-borderless') } @@ -47,6 +44,8 @@ const open = ({ sender }, options) => { } if (awake) { args.push('--stay-awake') + } else if (!control) { + args.push('--no-control') } if (touch) { args.push('--show-touches') @@ -95,7 +94,7 @@ const open = ({ sender }, options) => { devices.forEach(({ id }) => { const { spawn } = require('child_process') - const scrcpy = spawn(cmd, [...args, '-s',`${id}`]) + const scrcpy = spawn(cmd, [...args, '-s', `${id}`]) let opened = false let exited = false diff --git a/src/renderer/components/dashboard/Configuration.vue b/src/renderer/components/dashboard/Configuration.vue index 7a43aca..642486f 100644 --- a/src/renderer/components/dashboard/Configuration.vue +++ b/src/renderer/components/dashboard/Configuration.vue @@ -243,9 +243,16 @@ {{ $t("configuration.other.fullscreen") }} - {{ - $t("configuration.other.awake") - }} + + {{ + $t("configuration.other.awake.content") + }} + {{ $t("configuration.other.touch") }} @@ -270,7 +277,7 @@ - 中/English + 简/繁/English
{{ @@ -350,6 +357,16 @@ export default { ] }; }, + watch: { + "config.control"(newVal, oldVal) { + if (this.config.awake && !newVal) { + this.config.awake = false + } + }, + "config.awake"(newVal, oldVal) { + newVal && (this.config.control = true); + } + }, created() { if (this.$store.has("config")) { this.config = this.$store.get("config"); @@ -409,7 +426,13 @@ export default { this.$store.put("config", this.config); }, changeLocale() { - localStorage.setItem("lang", this.$i18n.locale === "zh" ? "en" : "zh"); + let nextLang = "en"; + if (this.$i18n.locale === "zhCN") { + nextLang = "zhTW"; + } else if (this.$i18n.locale === "en") { + nextLang = "zhCN"; + } + localStorage.setItem("lang", nextLang); window.tray.destroy(); window.location.reload(); } diff --git a/src/renderer/components/menu/Menu.js b/src/renderer/components/menu/Menu.js index fa21bec..4b41057 100644 --- a/src/renderer/components/menu/Menu.js +++ b/src/renderer/components/menu/Menu.js @@ -21,11 +21,11 @@ export default (vue) => (tray, ...items) => { const submenu = [] if (!items.length) { submenu.push({ - label: '' + label: 'Supported languages: ' }) } submenu.push({ - label: 'English', + label: '- English', click: () => { localStorage.setItem('lang', 'en') tray.destroy() @@ -37,9 +37,21 @@ export default (vue) => (tray, ...items) => { }) submenu.push( { - label: '中文', + label: '- 简体中文', click: () => { - localStorage.setItem('lang', 'zh') + localStorage.setItem('lang', 'zhCN') + tray.destroy() + window.location.reload() + } + }) + submenu.push({ + type: 'separator' + }) + submenu.push( + { + label: '- 繁体中文', + click: () => { + localStorage.setItem('lang', 'zhTW') tray.destroy() window.location.reload() } diff --git a/src/renderer/components/menu/index.js b/src/renderer/components/menu/index.js index 861c1bc..50d2232 100644 --- a/src/renderer/components/menu/index.js +++ b/src/renderer/components/menu/index.js @@ -6,12 +6,17 @@ export default vue => { const Menu = getMenu(vue) const tray = Tray(Menu) window.tray = tray + let hideWhenClickingClose = false + const config = vue.$store.get('config') + if(config) { + hideWhenClickingClose = config.hidden + } new Titlebar({ backgroundColor: Color.fromHex('#868686'), shadow: true, icon: 'https://cdn.jsdelivr.net/gh/Tomotoes/images/blog/favicon.ico', maximizable: false, - hideWhenClickingClose: vue.$store.get('config').hidden || false, + hideWhenClickingClose, menu: Menu(tray) }) } diff --git a/src/renderer/lang/en.js b/src/renderer/lang/en.js index aad7979..e86d4fb 100644 --- a/src/renderer/lang/en.js +++ b/src/renderer/lang/en.js @@ -81,7 +81,10 @@ export default { touch: 'Show phone tap location', render: 'Rendering all frames', screen: 'Turn off the phone screen', - awake: 'Turn off the lock screen', + awake: { + tooltip: 'The computer control option must be opened before turning off the lock screen', + content: 'Turn off the lock screen' + }, auto: 'Automatically turn on connected devices', hidden: { tooltip: 'Need to restart the application to take effect', @@ -147,7 +150,7 @@ export default { success: '{name} already disconnected' }, error: { - 'unknownScrcpyPathException':'The path of the Scrcpy folder is incorrectly configured. Make sure that `scrcpy.exe` exists in this folder' + 'unknownScrcpyPathException': 'The path of the Scrcpy folder is incorrectly configured. Make sure that `scrcpy.exe` exists in this folder' } }, titleBar: { diff --git a/src/renderer/lang/index.js b/src/renderer/lang/index.js index b0f405a..8dcd9f1 100644 --- a/src/renderer/lang/index.js +++ b/src/renderer/lang/index.js @@ -1,2 +1,3 @@ export { default as en } from './en' -export { default as zh } from './zh' +export { default as zhCN } from './zh_CN' +export { default as zhTW } from './zh_TW' diff --git a/src/renderer/lang/zh.js b/src/renderer/lang/zh_CN.js similarity index 97% rename from src/renderer/lang/zh.js rename to src/renderer/lang/zh_CN.js index 0d3fd34..17883dd 100644 --- a/src/renderer/lang/zh.js +++ b/src/renderer/lang/zh_CN.js @@ -87,7 +87,10 @@ export default { touch: '显示点按位置', render: '渲染所有帧 会增加延迟', screen: '打开镜像时关闭屏幕', - awake: '关闭锁屏', + awake: { + tooltip: '关闭锁屏前须打开电脑控制选项', + content: '关闭锁屏' + }, auto: '自动打开新连接的设备', hidden: { tooltip: '需要重启应用才会生效', diff --git a/src/renderer/lang/zh_TW.js b/src/renderer/lang/zh_TW.js new file mode 100644 index 0000000..d0e422c --- /dev/null +++ b/src/renderer/lang/zh_TW.js @@ -0,0 +1,173 @@ +export default { + notify: { + 'error': '錯誤', + 'info': '提示', + 'success': '成功', + 'warning': '警告' + }, + footer: { + powerBy: '基於', + author: '作者' + }, + dashboard: { + configuration: '投影配置', + management: '投影管理' + }, + configuration: { + source: { + label: 'Scrcpy', + placeholder: 'Scrcpy資料夾路徑 - 例如: C:\\scrcpy-win64', + tooltip: '如果不設定,請將scrcpy資料夾路徑配置到環境變數' + }, + title: { + label: '視窗標題', + placeholder: '預設為手機型號' + }, + record: { + label: '錄製投影畫面', + tip: '開啟後,將錄製投影畫面;關閉後,將儲存已錄製的影片文件到指定路徑', + filepath: '螢幕錄影文件路徑', + tooltip: '路徑包括影片名,影片格式為.mkv', + mirror: '錄影時啟動投影' + }, + bitRate: { + label: '投影傳輸比特率', + popover: '8M為預設比特率' + }, + maxSize: { + label: '等比最大解析度', + popover: '0為預設解析度' + }, + maxFps: { + label: '最大FPS幀數', + popover: '0為預設FPS幀數' + }, + orientation: { + label: '旋轉角度', + popover: '0°為預設值' + }, + crop: { + label: '裁剪畫面', + x: '裁剪位置的横座標', + y: '裁剪位置的縱座標', + height: { + title: '裁剪尺寸中的高度', + content: '高寬為0,則不裁剪' + }, + width: { + title: '裁剪尺寸中的寬度', + content: '高寬為0,則不裁剪' + }, + }, + window: { + label: '初始化', + x: { + title: '投影的横座標', + content: '橫縱座標為0, 則以預設的位置打開' + }, + y: { + title: '投影的縱坐標', + content: '橫縱座標為0, 則以預設的位置打開' + }, + height: { + title: '投影畫面的高度', + content: '高寬為0,則以預設尺寸顯示' + }, + width: { + title: '投影畫面的寬度', + content: '高寬為0,則以預設尺寸顯示' + }, + }, + other: { + label: '其他設置', + fixed: '最上層顯示視窗', + control: '允許由電腦控制裝置', + fullscreen: '全螢幕顯示', + border: '顯示邊框', + touch: '顯示點擊位置', + render: '渲染所有幀會增加延遲', + screen: '開啟螢幕投影時關閉裝置螢幕', + awake: { + tooltip: '關閉鎖屏前須打開電腦控制選項', + content: '關閉螢幕鎖定' + }, + auto: '自動打開新連接的裝置', + hidden: { + tooltip: '需要重新啟動應用才會生效', + content: '退出後隐藏到系统欄' + } + }, + button: { + save: '保存目前配置', + default: '恢復預設配置' + }, + notify: { + saveSuccess: '配置保存成功' + } + }, + management: { + ip: { + tip: '裝置區域連線 IP 地址', + remove: '删除', + connect: '開啟無線連接' + }, + devices: { + name: '名稱', + edit: '點擊即可修改', + method: { + label: '連接方式', + wired: '有線', + wireless: '無線' + }, + operation: '操作', + disconnect: '中斷連接' + }, + button: { + open: '開啟選中裝置的投影' + }, + whenEmpty: '暫時沒有裝置連接', + notify: { + firstLoad: '正在載入裝置', + reduceDevices: '裝置發生變動', + newDevices: '偵測到新裝置', + open: '已成功開啟 {name}' + }, + open: { + loading: '正在啟動投影,請稍候...', + success: '{name} 已正常關閉', + error: `{name} 開啟失敗,請您仔細確認以下項目: +

1. scrcpy 是否配置正確

+

2. scrcpy-gui 本應用是否設置為以系統管理員身分啟動

+

3. scrcpy 命令行是否可以開啟裝置

+

4. 執行\`adb-devices\`命令 查看是否出現裝置

+

5. 手机是否開啟偵錯選項

+ 如以上皆配置正常,請您到原作者Github提出issue,以協助解决。` + }, + connect: { + error: { + ip: '請輸入正確的 IP 地址', + exist: '{name} 已經連接' + }, + loading: '正在啟動無線連接...', + success: '已成功開啟無線連接', + fail: '開啟無線連接失敗' + }, + disconnect: { + success: '{name} 已中斷連接' + }, + error: { + unknownScrcpyPathException: 'Scrcpy 資料夾路徑配置錯誤,請確認該資料夾中存在`scrcpy.exe`' + } + }, + titleBar: { + document: '使用說明', + checkForUpdates: '檢查更新', + feedback: '回報與建議', + switchLanguage: '切換語言', + about: '關於' + }, + tray: { + hide: '隐藏', + exit: '退出' + } +} diff --git a/src/renderer/main.js b/src/renderer/main.js index 39ad67f..9c811e8 100644 --- a/src/renderer/main.js +++ b/src/renderer/main.js @@ -6,20 +6,21 @@ import ElementUI from 'element-ui' import 'element-ui/lib/theme-chalk/index.css' import locale from 'element-ui/lib/locale' import _en from 'element-ui/lib/locale/lang/en' -import _zh from 'element-ui/lib/locale/lang/zh-CN' +import _zhCN from 'element-ui/lib/locale/lang/zh-CN' +import _zhTW from 'element-ui/lib/locale/lang/zh-TW' -const lang = localStorage.getItem('lang') || 'zh' -locale.use(lang === 'en' ? _en : _zh) +const lang = localStorage.getItem('lang') || 'zhCN' +locale.use(lang === 'en' ? _en : _zhCN) Vue.use(ElementUI) -import { en, zh } from './lang' +import { en, zhCN, zhTW } from './lang' import VueI18n from 'vue-i18n' Vue.use(VueI18n) const i18n = new VueI18n({ - locale: (localStorage.getItem('lang') || 'zh'), - messages: { zh, en } + locale: (localStorage.getItem('lang') || 'zhCN'), + messages: { zhCN, zhTW, en } })