Skip to content
This repository has been archived by the owner on Jul 24, 2022. It is now read-only.

Commit

Permalink
feat: 👷 add zh-TW supported language, fix turning off the screen bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomotoes committed Jun 13, 2020
1 parent 8284db1 commit c8c9c1d
Show file tree
Hide file tree
Showing 10 changed files with 245 additions and 25 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "scrcpy-gui",
"version": "1.5.0",
"version": "1.5.1",
"author": "SimonMa <simon@tomotoes.com>",
"homepage": "https://github.com/Tomotoes/scrcpy-gui",
"description": "✨ A simple & beautiful GUI application for scrcpy",
Expand Down
7 changes: 3 additions & 4 deletions src/main/scrcpy/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
}
Expand All @@ -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')
Expand Down Expand Up @@ -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
Expand Down
33 changes: 28 additions & 5 deletions src/renderer/components/dashboard/Configuration.vue
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,16 @@
<el-checkbox v-model="config.fullscreen" border size="medium">{{
$t("configuration.other.fullscreen")
}}</el-checkbox>
<el-checkbox v-model="config.awake" border size="medium">{{
$t("configuration.other.awake")
}}</el-checkbox>
<el-tooltip
class="item"
effect="dark"
:content="$t('configuration.other.awake.tooltip')"
placement="top"
>
<el-checkbox v-model="config.awake" border size="medium">{{
$t("configuration.other.awake.content")
}}</el-checkbox>
</el-tooltip>
<el-checkbox v-model="config.touch" border size="medium">{{
$t("configuration.other.touch")
}}</el-checkbox>
Expand All @@ -270,7 +277,7 @@
</el-tooltip>
</el-form-item>
<el-divider content-position="right">
<el-button type="text" @click="changeLocale">/English</el-button>
<el-button type="text" @click="changeLocale">简/繁/English</el-button>
</el-divider>
<div style="margin:10px auto;text-align:center">
<el-button type="primary" @click.native.prevent="save" plain v-waves>{{
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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();
}
Expand Down
20 changes: 16 additions & 4 deletions src/renderer/components/menu/Menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
}
Expand Down
7 changes: 6 additions & 1 deletion src/renderer/components/menu/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
}
7 changes: 5 additions & 2 deletions src/renderer/lang/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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: {
Expand Down
3 changes: 2 additions & 1 deletion src/renderer/lang/index.js
Original file line number Diff line number Diff line change
@@ -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'
5 changes: 4 additions & 1 deletion src/renderer/lang/zh.js → src/renderer/lang/zh_CN.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@ export default {
touch: '显示点按位置',
render: '渲染所有帧 会增加延迟',
screen: '打开镜像时关闭屏幕',
awake: '关闭锁屏',
awake: {
tooltip: '关闭锁屏前须打开电脑控制选项',
content: '关闭锁屏'
},
auto: '自动打开新连接的设备',
hidden: {
tooltip: '需要重启应用才会生效',
Expand Down
173 changes: 173 additions & 0 deletions src/renderer/lang/zh_TW.js
Original file line number Diff line number Diff line change
@@ -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} 開啟失敗,請您仔細確認以下項目:
<p>1. scrcpy 是否配置正確</p>
<p>2. scrcpy-gui 本應用是否設置為以系統管理員身分啟動</p>
<p>3. scrcpy 命令行是否可以開啟裝置</p>
<p>4. 執行\`adb-devices\`命令 查看是否出現裝置</p>
<p>5. 手机是否開啟偵錯選項</p>
如以上皆配置正常,請您到原作者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: '退出'
}
}
13 changes: 7 additions & 6 deletions src/renderer/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
})


Expand Down

0 comments on commit c8c9c1d

Please sign in to comment.