Skip to content

Commit

Permalink
Merge pull request #71 from xVanTuring/v0.3.0
Browse files Browse the repository at this point in the history
0.3.0-alpha.5
  • Loading branch information
xVanTuring authored Mar 12, 2020
2 parents 09375b8 + 46ebc5c commit 112b6db
Show file tree
Hide file tree
Showing 20 changed files with 114 additions and 3,381 deletions.
2 changes: 0 additions & 2 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
src/renderer/qrcode/**

test/unit/coverage/**
test/unit/*.js
test/e2e/*.js
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "electron-ssr",
"version": "0.3.0-alpha.4",
"version": "0.3.0-alpha.5",
"description": "Cross platform ShadowsocksR GUI client built with electron",
"author": {
"name": "The Electron-SSR Authors",
Expand All @@ -24,6 +24,7 @@
"fs-extra": "^8.1.0",
"http-shutdown": "^1.2.2",
"iview": "^3.5.4",
"jsqr": "^1.2.0",
"mousetrap": "^1.6.3",
"qr-image": "^3.2.0",
"sudo-prompt": "^9.1.1",
Expand Down
3 changes: 2 additions & 1 deletion src/main/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ function runPythonSSR (params) {
})
pythonSSRInstance.once('exit', (code) => {
if (!quitByCommand) {
logger.debug(`Python SSR exit with code: ${code}`)
// todo: notify user python quit
logger.error(`Python SSR quit with code: ${code}`)
pythonSSRInstance = null
}
})
Expand Down
6 changes: 5 additions & 1 deletion src/main/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,9 @@
"NOTI_PYTHON_MISSING_TITLE": "No python detected",
"NOTI_PYTHON_MISSING_DETAIL": "The backend of this program requires python\n Please Make sure you have it installed",
"NOTI_PAC_UPDATE_SUCC":"PAC File Updated",
"NOTI_PAC_UPDATE_FAILED":"PAC Updating Failed, Please check your network and DNS"
"NOTI_PAC_UPDATE_FAILED":"PAC Updating Failed, Please check your network and DNS",
"NOTI_SHORTCUT_REGISTERED": "{length} global failed to registered, go Shortcut Panel and set it again",

"NOTI_TYPE_ERROR":"Error",
"NOTI":"Notification"
}
6 changes: 5 additions & 1 deletion src/main/locales/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,9 @@
"NOTI_PYTHON_MISSING_TITLE": "未检测到python",
"NOTI_PYTHON_MISSING_DETAIL": "本程序所使用的后端为python版ssr/ssrr\n请确保已安装python且可正常使用,否则软件可能无法正常运行",
"NOTI_PAC_UPDATE_SUCC":"PAC文件更新成功",
"NOTI_PAC_UPDATE_FAILED":"PAC文件更新失败, 请检查你的网络和DNS"
"NOTI_PAC_UPDATE_FAILED":"PAC文件更新失败, 请检查你的网络和DNS",
"NOTI_SHORTCUT_REGISTERED": "检测到 {length} 个全局快捷键注册失败,请在快捷键页面重新设置",

"NOTI_TYPE_ERROR":"错误",
"NOTI":"通知"
}
9 changes: 6 additions & 3 deletions src/main/notification.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ import { EVENT_APP_NOTIFY_MAIN } from '../shared/events'
import { isMac } from '../shared/env'
import { notificationIcon } from '../shared/icon'
import logger from './logger'

import $t from './locales'
const isDesktopNotificationSupported = Notification.isSupported()

export function showNotification (body, title = '通知', onClick) {
export function showNotification (body, title, onClick) {
if (!title) {
title = $t('NOTI')
}
if (isDesktopNotificationSupported) {
const notification = new Notification({
title, body, silent: false, icon: !isMac ? notificationIcon : undefined
Expand All @@ -17,7 +20,7 @@ export function showNotification (body, title = '通知', onClick) {
}
notification.show()
} else {
logger.debug('不支持原生通知,将使用HTML5通知')
logger.debug('Using HTML Notification')
sendData(EVENT_APP_NOTIFY_MAIN, { title, body })
}
}
4 changes: 2 additions & 2 deletions src/main/shortcut.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { toggleWindow, showWindow, sendData } from './window'
import { appConfig$ } from './data'
import { showNotification } from './notification'
import { EVENT_APP_SHOW_PAGE } from '../shared/events'

import $t from './locales'
const func = {
toggleWindow,
switchSystemProxy
Expand Down Expand Up @@ -70,7 +70,7 @@ app.on('ready', () => {
return false
})
if (failed.length) {
showNotification(`检测到${failed.length}个全局快捷键注册失败,请在快捷键页面重新设置`, '错误', () => {
showNotification($t('NOTI_SHORTCUT_REGISTERED', { length: failed.length }), $t('NOTI_TYPE_ERROR'), () => {
showWindow()
sendData(EVENT_APP_SHOW_PAGE, { page: 'Options', tab: 'shortcuts' })
})
Expand Down
1 change: 0 additions & 1 deletion src/main/tray.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ async function generateMenus (appConfig) {
{ label: $t('MENU_SUB_OPEN_CF'), click: handler.openConfigFile }
]
},
{ label: $t('MENU_SUB_CHECK_UPDATE'), click: handler.copyHttpProxyCode },
menuHelp,
{ role: 'quit' }
]
Expand Down
3 changes: 1 addition & 2 deletions src/main/window.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ let readyPromise
*/
export function createWindow () {
mainWindow = new BrowserWindow({
height: 480,
height: 500,
width: 800,
center: true,
resizable: false,
Expand All @@ -21,7 +21,6 @@ export function createWindow () {
show: false,
webPreferences: { webSecurity: process.env.NODE_ENV === 'production', nodeIntegration: true }
})
if (process.platform === 'darwin') { app.dock.show() }
if (process.env.WEBPACK_DEV_SERVER_URL) {
// Load the url of the dev server if in development mode
mainWindow.loadURL(process.env.WEBPACK_DEV_SERVER_URL)
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/components/form/SSRNodeForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<i-input :value="editingConfig.remarks" @input="v=>onInput('remarks', v)"/>
</i-form-item>
<i-form-item :label="$t('SSR_GROUP')">
<i-auto-complete :data="filteredGroups" clearable placeholder="未分组" placement="top"
<i-auto-complete :data="filteredGroups" clearable :placeholder="$t('SSR_UNGROUPED')" placement="top"
:value="editingConfig.group" @input="v=>onInput('group', v)"/>
</i-form-item>
</i-form>
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/components/node/SSRQrcode.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import qr from 'qr-image'
import clickoutside from 'iview/src/directives/clickoutside'
import { mapState, mapGetters, mapMutations, mapActions } from 'vuex'
import { getSSLink, getSSRLink } from '@/shared/ssr'
import { merge } from '../../../shared/utils'
import { merge } from '@/shared/utils'
const COPY_TOOLTIP = '点击复制链接'
const COPY_TOOLTIP_COPIED = '链接已复制'
Expand Down
14 changes: 8 additions & 6 deletions src/renderer/ipc.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import { showNotification, showHtmlNotification } from './notification'
import scanQrcode from './qrcode/scan-screenshot'
import * as events from '../shared/events'
import { loadConfigsFromString } from '../shared/ssr'

import i18n from './i18n'
// const $t = i18n.t
console.log(i18n.t('NOTI_SUB_FAIL_UPDATE'))
/**
* ipc-render事件
*/
Expand All @@ -16,12 +18,12 @@ export function register () {
// 扫描二维码
scanQrcode((e, result) => {
if (e) {
showNotification('未找到相关二维码', '扫码失败')
showNotification(i18n.t('NOTI_FAILED_TO_FIND_QRCODE'), i18n.t('NOTI_TYPE_ERROR_QRCODE'))
} else {
const configs = loadConfigsFromString(result)
if (configs.length) {
store.dispatch('addConfigs', configs)
showNotification(`已成功添加${configs.length}条记录`)
showNotification(i18n.t('NOTI_SUCC_ADD_CONFIGS', { count: configs.length }))
}
}
})
Expand All @@ -36,12 +38,12 @@ export function register () {
// 更新订阅服务器
store.dispatch('updateSubscribes').then(updatedCount => {
if (updatedCount > 0) {
showNotification(`服务器订阅更新成功,共更新了${updatedCount}个节点`)
showNotification(i18n.t('NOTI_SUB_SUCC_UPDATE_COUNT', { count: updatedCount }))
} else {
showNotification(`服务器订阅更新完成,没有新节点`)
showNotification(i18n.t('NOTI_SUB_SUCC_UPDATE_NO_COUNT'))
}
}).catch(() => {
showNotification('服务器订阅更新失败')
showNotification(i18n.t('NOTI_SUB_FAIL_UPDATE'))
})
}).on(events.EVENT_RX_SYNC_MAIN, (e, appConfig) => {
// 同步数据
Expand Down
16 changes: 14 additions & 2 deletions src/renderer/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"UI_SETTING_COMMON": "Common",
"UI_SETTING_SSR": "SSR",
"UI_SETTING_SUBSCRIPTION": "Subscription",
"UI_SETTING_SHORTCUT": "Shortcut",

"UI_SETTING_SSR_PYTHON_DIR": "SSR python Dir",
"UI_SETTING_SELECT_SSR_PYTHON_DIR": "Select SSR Dir",
Expand All @@ -32,7 +33,9 @@
"UI_SETTING_HTTP_PORT": "Http Proxy Port",
"UI_SETTING_ENABLE_HTTP_PORT": "Enable Http Proxy",
"UI_SETTING_SSR_INPUT_PLACEHOLDER": "Please select shadowsocks Dir",

"UI_SETTING_SHORTCUT_TOGGLE_VISI": "Toggle Windows",
"UI_SETTING_SHORTCUT_CHANGE_SYS_PROXY": "Change Sys Proxy Mode",
"UI_SETTING_SHORTCUT_REGISTED":"Shortcut {shortcutStr} has been registered.",
"UI_DONE":"Done",
"UI_BACK":"Back",

Expand Down Expand Up @@ -73,5 +76,14 @@
"UI_CLICK_TO_RETRY":"Click To Retry",
"UI_PLEASE_SELECT_SS_FOLDER":"Please Select shadowsocks Folder",
"UI_INCORRECT_FOLDER":"Incorrect folder, please reselect",
"UI_DOWNLOADING_FOR_YOU":"Downloading for you"
"UI_DOWNLOADING_FOR_YOU":"Downloading for you",


"NOTI_FAILED_TO_FIND_QRCODE": "Failed to find any Qr Code",
"NOTI_TYPE_ERROR_QRCODE": "Scanning Failed",
"NOTI_SUCC_ADD_CONFIGS":"Add {count} configs",
"NOTI_SUB_SUCC_UPDATE_COUNT":"Subscription Updated, {count} nodes updated",
"NOTI_SUB_SUCC_UPDATE_NO_COUNT":"Subscription Updated",
"NOTI_SUB_FAIL_UPDATE": "Failed to update subscription",
"NOTI":"Notification"
}
16 changes: 15 additions & 1 deletion src/renderer/locales/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
"UI_SETTING_COMMON": "通用设置",
"UI_SETTING_SSR": "SSR设置",
"UI_SETTING_SUBSCRIPTION": "订阅管理",
"UI_SETTING_SHORTCUT": "快捷键",

"UI_SETTING_SSR_PYTHON_DIR": "ssr python 目录",
"UI_SETTING_SELECT_SSR_PYTHON_DIR": "选择ssr目录",
"UI_SETTING_AUTO_START": "自动启动",
Expand All @@ -32,6 +34,9 @@
"UI_SETTING_ENABLE_HTTP_PORT": "启用HTTP代理",
"UI_SETTING_SSR_INPUT_PLACEHOLDER": "请选择shadowsocks目录",

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

Expand Down Expand Up @@ -72,5 +77,14 @@
"UI_CLICK_TO_RETRY":"点击重试",
"UI_PLEASE_SELECT_SS_FOLDER":"请选择shadowsocks目录",
"UI_INCORRECT_FOLDER":"该目录不正确,请重新选择",
"UI_DOWNLOADING_FOR_YOU":"正在为您下载"
"UI_DOWNLOADING_FOR_YOU":"正在为您下载",


"NOTI_FAILED_TO_FIND_QRCODE": "未找到相关二维码",
"NOTI_TYPE_ERROR_QRCODE": "扫码失败",
"NOTI_SUCC_ADD_CONFIGS":"已成功添加{count}条记录",
"NOTI_SUB_SUCC_UPDATE_COUNT":"服务器订阅更新成功,共更新了{count}个节点",
"NOTI_SUB_SUCC_UPDATE_NO_COUNT":"服务器订阅更新完成,没有新节点",
"NOTI_SUB_FAIL_UPDATE": "服务器订阅更新失败",
"NOTI":"通知"
}
12 changes: 9 additions & 3 deletions src/renderer/notification.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import { ipcRenderer } from 'electron'
import { EVENT_APP_NOTIFY_RENDERER } from '../shared/events'

import i18n from './i18n'
/**
* 显示HTML5通知
* @param {String} body 要显示的内容
* @param {String} title 标题
*/
export function showHtmlNotification (body, title = '通知') {
export function showHtmlNotification (body, title = '') {
if (title === '') {
title = i18n.t('NOTI')
}
console.log('using html5 notification')
// eslint-disable-next-line no-new
new Notification(title, {
Expand All @@ -19,6 +22,9 @@ export function showHtmlNotification (body, title = '通知') {
* @param {String} body 要显示的内容
* @param {String} title 标题
*/
export function showNotification (body, title = '通知') {
export function showNotification (body, title = '') {
if (title === '') {
title = i18n.t('NOTI')
}
ipcRenderer.send(EVENT_APP_NOTIFY_RENDERER, body, title)
}
Loading

0 comments on commit 112b6db

Please sign in to comment.