Skip to content

Commit 112b6db

Browse files
author
xVanTuring
authored
Merge pull request #71 from xVanTuring/v0.3.0
0.3.0-alpha.5
2 parents 09375b8 + 46ebc5c commit 112b6db

File tree

20 files changed

+114
-3381
lines changed

20 files changed

+114
-3381
lines changed

.eslintignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
src/renderer/qrcode/**
2-
31
test/unit/coverage/**
42
test/unit/*.js
53
test/e2e/*.js

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "electron-ssr",
3-
"version": "0.3.0-alpha.4",
3+
"version": "0.3.0-alpha.5",
44
"description": "Cross platform ShadowsocksR GUI client built with electron",
55
"author": {
66
"name": "The Electron-SSR Authors",
@@ -24,6 +24,7 @@
2424
"fs-extra": "^8.1.0",
2525
"http-shutdown": "^1.2.2",
2626
"iview": "^3.5.4",
27+
"jsqr": "^1.2.0",
2728
"mousetrap": "^1.6.3",
2829
"qr-image": "^3.2.0",
2930
"sudo-prompt": "^9.1.1",

src/main/client.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ function runPythonSSR (params) {
6060
})
6161
pythonSSRInstance.once('exit', (code) => {
6262
if (!quitByCommand) {
63-
logger.debug(`Python SSR exit with code: ${code}`)
63+
// todo: notify user python quit
64+
logger.error(`Python SSR quit with code: ${code}`)
6465
pythonSSRInstance = null
6566
}
6667
})

src/main/locales/en-US.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,9 @@
4343
"NOTI_PYTHON_MISSING_TITLE": "No python detected",
4444
"NOTI_PYTHON_MISSING_DETAIL": "The backend of this program requires python\n Please Make sure you have it installed",
4545
"NOTI_PAC_UPDATE_SUCC":"PAC File Updated",
46-
"NOTI_PAC_UPDATE_FAILED":"PAC Updating Failed, Please check your network and DNS"
46+
"NOTI_PAC_UPDATE_FAILED":"PAC Updating Failed, Please check your network and DNS",
47+
"NOTI_SHORTCUT_REGISTERED": "{length} global failed to registered, go Shortcut Panel and set it again",
48+
49+
"NOTI_TYPE_ERROR":"Error",
50+
"NOTI":"Notification"
4751
}

src/main/locales/zh-CN.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,9 @@
4343
"NOTI_PYTHON_MISSING_TITLE": "未检测到python",
4444
"NOTI_PYTHON_MISSING_DETAIL": "本程序所使用的后端为python版ssr/ssrr\n请确保已安装python且可正常使用,否则软件可能无法正常运行",
4545
"NOTI_PAC_UPDATE_SUCC":"PAC文件更新成功",
46-
"NOTI_PAC_UPDATE_FAILED":"PAC文件更新失败, 请检查你的网络和DNS"
46+
"NOTI_PAC_UPDATE_FAILED":"PAC文件更新失败, 请检查你的网络和DNS",
47+
"NOTI_SHORTCUT_REGISTERED": "检测到 {length} 个全局快捷键注册失败,请在快捷键页面重新设置",
48+
49+
"NOTI_TYPE_ERROR":"错误",
50+
"NOTI":"通知"
4751
}

src/main/notification.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@ import { EVENT_APP_NOTIFY_MAIN } from '../shared/events'
44
import { isMac } from '../shared/env'
55
import { notificationIcon } from '../shared/icon'
66
import logger from './logger'
7-
7+
import $t from './locales'
88
const isDesktopNotificationSupported = Notification.isSupported()
99

10-
export function showNotification (body, title = '通知', onClick) {
10+
export function showNotification (body, title, onClick) {
11+
if (!title) {
12+
title = $t('NOTI')
13+
}
1114
if (isDesktopNotificationSupported) {
1215
const notification = new Notification({
1316
title, body, silent: false, icon: !isMac ? notificationIcon : undefined
@@ -17,7 +20,7 @@ export function showNotification (body, title = '通知', onClick) {
1720
}
1821
notification.show()
1922
} else {
20-
logger.debug('不支持原生通知,将使用HTML5通知')
23+
logger.debug('Using HTML Notification')
2124
sendData(EVENT_APP_NOTIFY_MAIN, { title, body })
2225
}
2326
}

src/main/shortcut.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { toggleWindow, showWindow, sendData } from './window'
55
import { appConfig$ } from './data'
66
import { showNotification } from './notification'
77
import { EVENT_APP_SHOW_PAGE } from '../shared/events'
8-
8+
import $t from './locales'
99
const func = {
1010
toggleWindow,
1111
switchSystemProxy
@@ -70,7 +70,7 @@ app.on('ready', () => {
7070
return false
7171
})
7272
if (failed.length) {
73-
showNotification(`检测到${failed.length}个全局快捷键注册失败,请在快捷键页面重新设置`, '错误', () => {
73+
showNotification($t('NOTI_SHORTCUT_REGISTERED', { length: failed.length }), $t('NOTI_TYPE_ERROR'), () => {
7474
showWindow()
7575
sendData(EVENT_APP_SHOW_PAGE, { page: 'Options', tab: 'shortcuts' })
7676
})

src/main/tray.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ async function generateMenus (appConfig) {
9191
{ label: $t('MENU_SUB_OPEN_CF'), click: handler.openConfigFile }
9292
]
9393
},
94-
{ label: $t('MENU_SUB_CHECK_UPDATE'), click: handler.copyHttpProxyCode },
9594
menuHelp,
9695
{ role: 'quit' }
9796
]

src/main/window.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ let readyPromise
1212
*/
1313
export function createWindow () {
1414
mainWindow = new BrowserWindow({
15-
height: 480,
15+
height: 500,
1616
width: 800,
1717
center: true,
1818
resizable: false,
@@ -21,7 +21,6 @@ export function createWindow () {
2121
show: false,
2222
webPreferences: { webSecurity: process.env.NODE_ENV === 'production', nodeIntegration: true }
2323
})
24-
if (process.platform === 'darwin') { app.dock.show() }
2524
if (process.env.WEBPACK_DEV_SERVER_URL) {
2625
// Load the url of the dev server if in development mode
2726
mainWindow.loadURL(process.env.WEBPACK_DEV_SERVER_URL)

src/renderer/components/form/SSRNodeForm.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
<i-input :value="editingConfig.remarks" @input="v=>onInput('remarks', v)"/>
3838
</i-form-item>
3939
<i-form-item :label="$t('SSR_GROUP')">
40-
<i-auto-complete :data="filteredGroups" clearable placeholder="未分组" placement="top"
40+
<i-auto-complete :data="filteredGroups" clearable :placeholder="$t('SSR_UNGROUPED')" placement="top"
4141
:value="editingConfig.group" @input="v=>onInput('group', v)"/>
4242
</i-form-item>
4343
</i-form>

src/renderer/components/node/SSRQrcode.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import qr from 'qr-image'
3131
import clickoutside from 'iview/src/directives/clickoutside'
3232
import { mapState, mapGetters, mapMutations, mapActions } from 'vuex'
3333
import { getSSLink, getSSRLink } from '@/shared/ssr'
34-
import { merge } from '../../../shared/utils'
34+
import { merge } from '@/shared/utils'
3535
3636
const COPY_TOOLTIP = '点击复制链接'
3737
const COPY_TOOLTIP_COPIED = '链接已复制'

src/renderer/ipc.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ import { showNotification, showHtmlNotification } from './notification'
44
import scanQrcode from './qrcode/scan-screenshot'
55
import * as events from '../shared/events'
66
import { loadConfigsFromString } from '../shared/ssr'
7-
7+
import i18n from './i18n'
8+
// const $t = i18n.t
9+
console.log(i18n.t('NOTI_SUB_FAIL_UPDATE'))
810
/**
911
* ipc-render事件
1012
*/
@@ -16,12 +18,12 @@ export function register () {
1618
// 扫描二维码
1719
scanQrcode((e, result) => {
1820
if (e) {
19-
showNotification('未找到相关二维码', '扫码失败')
21+
showNotification(i18n.t('NOTI_FAILED_TO_FIND_QRCODE'), i18n.t('NOTI_TYPE_ERROR_QRCODE'))
2022
} else {
2123
const configs = loadConfigsFromString(result)
2224
if (configs.length) {
2325
store.dispatch('addConfigs', configs)
24-
showNotification(`已成功添加${configs.length}条记录`)
26+
showNotification(i18n.t('NOTI_SUCC_ADD_CONFIGS', { count: configs.length }))
2527
}
2628
}
2729
})
@@ -36,12 +38,12 @@ export function register () {
3638
// 更新订阅服务器
3739
store.dispatch('updateSubscribes').then(updatedCount => {
3840
if (updatedCount > 0) {
39-
showNotification(`服务器订阅更新成功,共更新了${updatedCount}个节点`)
41+
showNotification(i18n.t('NOTI_SUB_SUCC_UPDATE_COUNT', { count: updatedCount }))
4042
} else {
41-
showNotification(`服务器订阅更新完成,没有新节点`)
43+
showNotification(i18n.t('NOTI_SUB_SUCC_UPDATE_NO_COUNT'))
4244
}
4345
}).catch(() => {
44-
showNotification('服务器订阅更新失败')
46+
showNotification(i18n.t('NOTI_SUB_FAIL_UPDATE'))
4547
})
4648
}).on(events.EVENT_RX_SYNC_MAIN, (e, appConfig) => {
4749
// 同步数据

src/renderer/locales/en-US.json

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"UI_SETTING_COMMON": "Common",
2222
"UI_SETTING_SSR": "SSR",
2323
"UI_SETTING_SUBSCRIPTION": "Subscription",
24+
"UI_SETTING_SHORTCUT": "Shortcut",
2425

2526
"UI_SETTING_SSR_PYTHON_DIR": "SSR python Dir",
2627
"UI_SETTING_SELECT_SSR_PYTHON_DIR": "Select SSR Dir",
@@ -32,7 +33,9 @@
3233
"UI_SETTING_HTTP_PORT": "Http Proxy Port",
3334
"UI_SETTING_ENABLE_HTTP_PORT": "Enable Http Proxy",
3435
"UI_SETTING_SSR_INPUT_PLACEHOLDER": "Please select shadowsocks Dir",
35-
36+
"UI_SETTING_SHORTCUT_TOGGLE_VISI": "Toggle Windows",
37+
"UI_SETTING_SHORTCUT_CHANGE_SYS_PROXY": "Change Sys Proxy Mode",
38+
"UI_SETTING_SHORTCUT_REGISTED":"Shortcut {shortcutStr} has been registered.",
3639
"UI_DONE":"Done",
3740
"UI_BACK":"Back",
3841

@@ -73,5 +76,14 @@
7376
"UI_CLICK_TO_RETRY":"Click To Retry",
7477
"UI_PLEASE_SELECT_SS_FOLDER":"Please Select shadowsocks Folder",
7578
"UI_INCORRECT_FOLDER":"Incorrect folder, please reselect",
76-
"UI_DOWNLOADING_FOR_YOU":"Downloading for you"
79+
"UI_DOWNLOADING_FOR_YOU":"Downloading for you",
80+
81+
82+
"NOTI_FAILED_TO_FIND_QRCODE": "Failed to find any Qr Code",
83+
"NOTI_TYPE_ERROR_QRCODE": "Scanning Failed",
84+
"NOTI_SUCC_ADD_CONFIGS":"Add {count} configs",
85+
"NOTI_SUB_SUCC_UPDATE_COUNT":"Subscription Updated, {count} nodes updated",
86+
"NOTI_SUB_SUCC_UPDATE_NO_COUNT":"Subscription Updated",
87+
"NOTI_SUB_FAIL_UPDATE": "Failed to update subscription",
88+
"NOTI":"Notification"
7789
}

src/renderer/locales/zh-CN.json

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
"UI_SETTING_COMMON": "通用设置",
2222
"UI_SETTING_SSR": "SSR设置",
2323
"UI_SETTING_SUBSCRIPTION": "订阅管理",
24+
"UI_SETTING_SHORTCUT": "快捷键",
25+
2426
"UI_SETTING_SSR_PYTHON_DIR": "ssr python 目录",
2527
"UI_SETTING_SELECT_SSR_PYTHON_DIR": "选择ssr目录",
2628
"UI_SETTING_AUTO_START": "自动启动",
@@ -32,6 +34,9 @@
3234
"UI_SETTING_ENABLE_HTTP_PORT": "启用HTTP代理",
3335
"UI_SETTING_SSR_INPUT_PLACEHOLDER": "请选择shadowsocks目录",
3436

37+
"UI_SETTING_SHORTCUT_TOGGLE_VISI": "切换窗口显隐",
38+
"UI_SETTING_SHORTCUT_CHANGE_SYS_PROXY": "切换系统代理模式",
39+
"UI_SETTING_SHORTCUT_REGISTED":"快捷键 {shortcutStr} 已被注册,请更换.",
3540
"UI_DONE":"完成",
3641
"UI_BACK":"返回",
3742

@@ -72,5 +77,14 @@
7277
"UI_CLICK_TO_RETRY":"点击重试",
7378
"UI_PLEASE_SELECT_SS_FOLDER":"请选择shadowsocks目录",
7479
"UI_INCORRECT_FOLDER":"该目录不正确,请重新选择",
75-
"UI_DOWNLOADING_FOR_YOU":"正在为您下载"
80+
"UI_DOWNLOADING_FOR_YOU":"正在为您下载",
81+
82+
83+
"NOTI_FAILED_TO_FIND_QRCODE": "未找到相关二维码",
84+
"NOTI_TYPE_ERROR_QRCODE": "扫码失败",
85+
"NOTI_SUCC_ADD_CONFIGS":"已成功添加{count}条记录",
86+
"NOTI_SUB_SUCC_UPDATE_COUNT":"服务器订阅更新成功,共更新了{count}个节点",
87+
"NOTI_SUB_SUCC_UPDATE_NO_COUNT":"服务器订阅更新完成,没有新节点",
88+
"NOTI_SUB_FAIL_UPDATE": "服务器订阅更新失败",
89+
"NOTI":"通知"
7690
}

src/renderer/notification.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
import { ipcRenderer } from 'electron'
22
import { EVENT_APP_NOTIFY_RENDERER } from '../shared/events'
3-
3+
import i18n from './i18n'
44
/**
55
* 显示HTML5通知
66
* @param {String} body 要显示的内容
77
* @param {String} title 标题
88
*/
9-
export function showHtmlNotification (body, title = '通知') {
9+
export function showHtmlNotification (body, title = '') {
10+
if (title === '') {
11+
title = i18n.t('NOTI')
12+
}
1013
console.log('using html5 notification')
1114
// eslint-disable-next-line no-new
1215
new Notification(title, {
@@ -19,6 +22,9 @@ export function showHtmlNotification (body, title = '通知') {
1922
* @param {String} body 要显示的内容
2023
* @param {String} title 标题
2124
*/
22-
export function showNotification (body, title = '通知') {
25+
export function showNotification (body, title = '') {
26+
if (title === '') {
27+
title = i18n.t('NOTI')
28+
}
2329
ipcRenderer.send(EVENT_APP_NOTIFY_RENDERER, body, title)
2430
}

0 commit comments

Comments
 (0)