Skip to content

Commit

Permalink
Merge pull request #74 from xVanTuring/v0.3.0
Browse files Browse the repository at this point in the history
0.3.0-alpha.5 fixes
  • Loading branch information
xVanTuring authored Mar 13, 2020
2 parents 112b6db + bab2e72 commit 21c6b77
Show file tree
Hide file tree
Showing 10 changed files with 82 additions and 99 deletions.
23 changes: 8 additions & 15 deletions src/main/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,14 @@
"MENU_PAC": "PAC",
"MENU_SETTINGS": "Settings",
"MENU_HELP": "Help",

"MENU_SUB_ENABLE_APP": "Enable",
"MENU_SUB_COPY_HTTP_PROXY": "Copy HTTP Proxy Settings",
"MENU_QUIT": "Quit",

"MENU_SUB_NO_PROXY": "No Proxy",
"MENU_SUB_PAC_PROXY": "PAC Proxy",
"MENU_SUB_GLOBAL_PROXY": "Global Proxy",

"MENU_SUB_UPDATE_PAC": "Update PAC",
"MENU_SUB_PAC_MODE": "PAC Mode",

"MENU_SUB_SETTING_OPTIONS": "Options",
"MENU_SUB_CONFIG_FILE": "Config File",
"MENU_SUB_LOAD_CF": "Import gui-config.json",
Expand All @@ -26,26 +22,23 @@
"MENU_SUB_ADD_NODE": "Node",
"MENU_SUB_ADD_FROM_CB": "From Clipboard",
"MENU_SUB_ADD_FROM_QR_SCAN": "Qrcode Scan",

"MENU_SUB_CHECK_UPDATE": "Check Update",
"MENU_SUB_DEVS": "Dev",
"MENU_SUB_DEVS_INSPECT_LOG": "Inspect Logs",

"TRAY_EDIT_SERVER": "Edit Server",
"TRAY_SUB_SETTINGS": "Subscription",
"TRAY_UPDATE_SUB_LINK": "Update Subscription",
"TRAY_MAIN_PAGE": "Main Page",
"TRAY_SERVERS": "Servers",

"NOTI_PORT_TAKEN":"Port {port} has been taken",
"NOTI_CHECK_PORT":"Please check yout port",
"NOTI_PROCESS_CANT_KILL":"Process {pid} may not be closed, please try close it manually",
"NOTI_PORT_TAKEN": "Port {port} has been taken",
"NOTI_CHECK_PORT": "Please check yout port",
"NOTI_PROCESS_CANT_KILL": "Process {pid} may not be closed, please try close it manually",
"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_SUCC": "PAC File Updated",
"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"
"NOTI_TYPE_ERROR": "Error",
"NOTI": "Notification",
"NOTO_WIND_GLOBAL_PROXY": "Windows does not play well with socks5 provided by ssr-python.\nUse HTTP Proxy instead?"
}
23 changes: 8 additions & 15 deletions src/main/locales/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,14 @@
"MENU_PAC": "PAC",
"MENU_SETTINGS": "设置",
"MENU_HELP": "帮助",

"MENU_SUB_ENABLE_APP": "开启应用",
"MENU_SUB_COPY_HTTP_PROXY": "复制HTTP代理设置",
"MENU_QUIT": "退出",

"MENU_SUB_NO_PROXY": "不启用代理",
"MENU_SUB_PAC_PROXY": "PAC代理",
"MENU_SUB_GLOBAL_PROXY": "全局代理",

"MENU_SUB_UPDATE_PAC": "更新PAC",
"MENU_SUB_PAC_MODE": "PAC模式",

"MENU_SUB_SETTING_OPTIONS": "选项设置",
"MENU_SUB_CONFIG_FILE": "配置文件",
"MENU_SUB_LOAD_CF": "导入gui-config.json文件",
Expand All @@ -26,26 +22,23 @@
"MENU_SUB_ADD_NODE": "添加节点",
"MENU_SUB_ADD_FROM_CB": "从剪贴板中添加",
"MENU_SUB_ADD_FROM_QR_SCAN": "二维码扫描",

"MENU_SUB_CHECK_UPDATE": "检查更新",
"MENU_SUB_DEVS": "开发者",
"MENU_SUB_DEVS_INSPECT_LOG": "查看日志",

"TRAY_EDIT_SERVER": "编辑服务器",
"TRAY_SUB_SETTINGS": "订阅管理",
"TRAY_UPDATE_SUB_LINK": "更新订阅服务器",
"TRAY_MAIN_PAGE": "主界面",
"TRAY_SERVERS": "服务器",

"NOTI_PORT_TAKEN":"端口 {port} 被占用",
"NOTI_CHECK_PORT":"请检查你端口占用",
"NOTI_PROCESS_CANT_KILL":"进程 {pid} 可能无法关闭,尝试手动关闭",
"NOTI_PORT_TAKEN": "端口 {port} 被占用",
"NOTI_CHECK_PORT": "请检查你端口占用",
"NOTI_PROCESS_CANT_KILL": "进程 {pid} 可能无法关闭,尝试手动关闭",
"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_SUCC": "PAC文件更新成功",
"NOTI_PAC_UPDATE_FAILED": "PAC文件更新失败, 请检查你的网络和DNS",
"NOTI_SHORTCUT_REGISTERED": "检测到 {length} 个全局快捷键注册失败,请在快捷键页面重新设置",

"NOTI_TYPE_ERROR":"错误",
"NOTI":"通知"
"NOTI_TYPE_ERROR": "错误",
"NOTI": "通知",
"NOTO_WIND_GLOBAL_PROXY": "Windows 系统与 Socks5 协议不兼容,是否切换使用HTTP协议?"
}
9 changes: 6 additions & 3 deletions src/main/proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export async function setProxyToNone (force = true) {
export async function setProxyToGlobal (host, port) {
let command
if (isWin && await pathExists(winToolPath)) {
command = `${winToolPath} global ${host}:${port}`
command = `${winToolPath} global ${host}:${port} "localhost;127.*;10.*;172.16.*;172.17.*;172.18.*;172.19.*;172.20.*;172.21.*;172.22.*;172.23.*;172.24.*;172.25.*;172.26.*;172.27.*;172.28.*;172.29.*;172.30.*;172.31.*;192.168.*;<local>"`
} else if (isMac && await pathExists(macToolPath) && !await isOldMacVersion) {
command = `"${macToolPath}" -m global -p ${port}`
} else if (isLinux && await isGsettingsAvaliable) {
Expand Down Expand Up @@ -98,7 +98,7 @@ async function setProxyByMode (mode) {
} else if (mode === 1) {
await setProxyToPac(`http://127.0.0.1:${currentConfig.pacPort}/proxy.pac`)
} else if (mode === 2) {
await setProxyToGlobal('127.0.0.1', currentConfig.localPort)
await setProxyToGlobal('127.0.0.1', currentConfig.preferHTTPGlobal ? currentConfig.httpProxyPort : currentConfig.localPort)
}
}

Expand All @@ -116,6 +116,9 @@ export function startProxy (mode) {
if (mode === undefined) {
mode = currentConfig.sysProxyMode
}
if (isWin && mode === 2 && currentConfig.preferHTTPGlobal === 1 && !currentConfig.httpProxyEnable) {
updateAppConfig({ httpProxyEnable: true })
}
setProxyByMode(mode)
}

Expand All @@ -129,7 +132,7 @@ appConfig$.subscribe(data => {
if (appConfig.sysProxyMode === 1 && (changed.indexOf('pacPort') > -1 || changed.indexOf('enable') > -1)) {
// pacPort changes or enable changed
startProxy(1)
} else if (appConfig.sysProxyMode === 2 && (changed.indexOf('localPort') > -1 || changed.indexOf('enable') > -1)) {
} else if (appConfig.sysProxyMode === 2 && (changed.indexOf('localPort') > -1 || changed.indexOf('enable') > -1 || changed.indexOf('preferHTTPGlobal') > -1)) {
startProxy(2)
}
}
Expand Down
33 changes: 18 additions & 15 deletions src/main/tray-handler.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { app, shell, clipboard } from 'electron'
import { app, shell, clipboard, dialog } from 'electron'
import { readJson, writeJson } from 'fs-extra'
import path from 'path'
import sudo from 'sudo-prompt'
Expand All @@ -11,7 +11,6 @@ import { startProxy } from './proxy'
import { showNotification } from './notification'
import * as events from '../shared/events'
import { loadConfigsFromString } from '../shared/ssr'
import { chooseFile, chooseSavePath } from '../shared/dialog'
import * as i18n from './locales'
const $t = i18n.default
export { openDevtool } from './window'
Expand All @@ -21,7 +20,6 @@ export { updateSubscribes } from './subscribe'
export function toggleEnable () {
updateAppConfig({ enable: !currentConfig.enable })
}

// 切换代理方式
export function toggleProxy (mode) {
startProxy(mode)
Expand All @@ -48,26 +46,31 @@ export function scanQRCode () {
sendData(events.EVENT_APP_SCAN_DESKTOP)
}

// 打开选项设置页面
export function openOptionsWindow () {
sendData(events.EVENT_APP_SHOW_PAGE, 'Options')
}

// 导入配置文件
export function importConfigFromFile () {
const _path = chooseFile('选择gui-config.json', [{ name: 'Json', extensions: ['json'] }])
if (_path) {
readJson(_path).then(fileConfig => {
export async function importConfigFromFile () {
const result = await dialog.showOpenDialog({
title: 'Open from',
properties: ['openFile'],
filters: [{ name: 'Json', extensions: ['json'] },
{ name: 'All', extensions: ['*'] }]
})
if (result.filePaths.length === 1) {
readJson(result.filePaths[0]).then(fileConfig => {
updateAppConfig(fileConfig, false, true)
}).catch(() => {})
}).catch(() => { })
}
}

// 导出配置文件
export function exportConfigToFile () {
const _path = chooseSavePath('选择导出的目录')
if (_path) {
writeJson(path.join(_path, 'gui-config.json'), currentConfig, { spaces: '\t' })
export async function exportConfigToFile () {
const result = await dialog.showOpenDialog({
title: 'Save to',
properties: ['openDirectory']
})
if (result.filePaths.length === 1) {
writeJson(path.join(result.filePaths[0], 'gui-config.json'), currentConfig, { spaces: '\t' })
}
}

Expand Down
20 changes: 17 additions & 3 deletions src/main/tray.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Menu, nativeImage, Tray } from 'electron'
import { appConfig$ } from './data'
import { Menu, nativeImage, Tray, dialog } from 'electron'
import { appConfig$, updateAppConfig } from './data'
import * as handler from './tray-handler'
import { groupConfigs } from '../shared/utils'
import { groupConfigs } from '@/shared/utils'
import { isMac, isWin, isOldMacVersion } from '../shared/env'
import { disabledTray, enabledHighlightTray, enabledTray, globalHighlightTray, globalTray, pacHighlightTray, pacTray } from '../shared/icon'
import * as i18n from './locales'
Expand Down Expand Up @@ -121,6 +121,20 @@ export function changeProxy (e, mode, appConfig) {
if (mode === appConfig.sysProxyMode) {
e.checked = true
} else {
if (isWin && mode === 2 && appConfig.preferHTTPGlobal === -1) {
dialog.showMessageBox({
title: $t('MENU_SUB_GLOBAL_PROXY'),
message: $t('NOTO_WIND_GLOBAL_PROXY'),
buttons: ['Yes', 'No'],
type: 'info'
}).then((response) => {
if (response.response === 0) {
updateAppConfig({ preferHTTPGlobal: 1 })
} else {
updateAppConfig({ preferHTTPGlobal: 0 })
}
})
}
handler.toggleProxy(mode)
}
}
Expand Down
1 change: 1 addition & 0 deletions src/renderer/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"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_PREFER_HTTP":"Use Http as Global",
"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.",
Expand Down
1 change: 1 addition & 0 deletions src/renderer/locales/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"UI_SETTING_HTTP_PORT": "HTTP代理端口",
"UI_SETTING_ENABLE_HTTP_PORT": "启用HTTP代理",
"UI_SETTING_SSR_INPUT_PLACEHOLDER": "请选择shadowsocks目录",
"UI_SETTING_PREFER_HTTP":"使用Http全局代理",

"UI_SETTING_SHORTCUT_TOGGLE_VISI": "切换窗口显隐",
"UI_SETTING_SHORTCUT_CHANGE_SYS_PROXY": "切换系统代理模式",
Expand Down
34 changes: 21 additions & 13 deletions src/renderer/views/option/Common.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div class="options-container px-2 pb-2 scroll-y">
<i-form ref="form" class="mt-1" :model="form" :rules="rules" :label-width="120">
<i-form ref="form" class="mt-1" :model="form" :rules="rules">
<i-form-item prop="ssrPath" :label="$t('UI_SETTING_SSR_PYTHON_DIR')">
<i-input
v-model="form.ssrPath"
Expand All @@ -10,47 +10,50 @@
/>
<i-button type="primary" @click="selectPath">{{$t('UI_SETTING_SELECT_SSR_PYTHON_DIR')}}</i-button>
</i-form-item>
<div class="flex">
<i-form-item class="flex-1" :label="$t('UI_SETTING_AUTO_START')">
<div class="flex flex-jc-between">
<i-form-item class="flex" :label="$t('UI_SETTING_AUTO_START')">
<i-checkbox v-model="form.autoLaunch" @on-change="update('autoLaunch')" />
</i-form-item>
<i-form-item class="flex-1" :label="$t('UI_SETTING_HIDE_WINDOW')">
<i-form-item class="flex" :label="$t('UI_SETTING_HIDE_WINDOW')">
<i-checkbox v-model="form.hideWindow" @on-change="update('hideWindow')" />
</i-form-item>
<i-form-item class="flex-1" :label="$t('UI_SETTING_SHARE_LAN')">
<i-form-item class="flex" :label="$t('UI_SETTING_SHARE_LAN')">
<i-checkbox v-model="form.shareOverLan" @on-change="update('shareOverLan')" />
</i-form-item>
<i-form-item class="flex-1" :label="$t('UI_SETTING_ENABLE_HTTP_PORT')">
<i-form-item class="flex" :label="$t('UI_SETTING_ENABLE_HTTP_PORT')">
<i-checkbox v-model="form.httpProxyEnable" @on-change="update('httpProxyEnable')" />
</i-form-item>
</div>
<div class="flex">
<i-form-item class="flex-1" :label="$t('UI_SETTING_PAC_PORT')">
<div class="flex flex-jc-between">
<i-form-item class="flex" :label="$t('UI_SETTING_PAC_PORT')">
<i-input-number
v-model="form.pacPort"
:min="0"
:max="65535"
@on-change="update('pacPort')"
/>
</i-form-item>
<i-form-item class="flex-1" :label="$t('UI_SETTING_LOCAL_LISTEN_PORT')">
<i-form-item class="flex" :label="$t('UI_SETTING_LOCAL_LISTEN_PORT')">
<i-input-number
v-model="form.localPort"
:min="0"
:max="65535"
@on-change="update('localPort')"
/>
</i-form-item>
<i-form-item class="flex-1" :label="$t('UI_SETTING_HTTP_PORT')">
<i-form-item class="flex" :label="$t('UI_SETTING_HTTP_PORT')">
<i-input-number
v-model="form.httpProxyPort"
:min="0"
:max="65535"
@on-change="update('httpProxyPort')"
/>
</i-form-item>
<i-form-item class="flex" :label="$t('UI_SETTING_PREFER_HTTP')">
<i-checkbox v-model="form.preferHTTPGlobal" @on-change="update('preferHTTPGlobal')" />
</i-form-item>
</div>
<i-form-item prop="lang" label="Language" :label-width="120">
<i-form-item prop="lang" label="Language">
<i-select v-model="form.lang" class="language-selector-view" @input="update('lang')">
<i-option value="zh-CN">简体中文</i-option>
<i-option value="en-US">English</i-option>
Expand All @@ -61,7 +64,7 @@
</template>
<script>
import { mapActions } from 'vuex'
import { isSSRPathAvaliable, debounce } from '../../../shared/utils'
import { isSSRPathAvaliable, debounce } from '@/shared/utils'
import { openDialog } from '@/renderer/ipc'
import i18n from '@/renderer/i18n'
export default {
Expand All @@ -77,7 +80,8 @@ export default {
pacPort: appConfig.pacPort,
httpProxyEnable: appConfig.httpProxyEnable,
httpProxyPort: appConfig.httpProxyPort,
lang: appConfig.lang
lang: appConfig.lang,
preferHTTPGlobal: appConfig.preferHTTPGlobal === 1
},
rules: {
ssrPath: [
Expand Down Expand Up @@ -138,6 +142,10 @@ export default {
}
},
update: debounce(function (field) {
if (field === 'preferHTTPGlobal') {
this.updateConfig({ [field]: this.form[field] ? 1 : 0 })
return
}
if (this.form[field] !== this.$store.state.appConfig[field]) {
this.updateConfig({ [field]: this.form[field] })
if (field === 'lang') {
Expand Down
3 changes: 2 additions & 1 deletion src/shared/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ const defaultConfig = {
subscribeUpdateInterval: 24,
lang: 'en-US',
isMacToolInstalled: false,
noMacToolInstall: false
noMacToolInstall: false,
preferHTTPGlobal: -1
}

export default defaultConfig
Expand Down
Loading

0 comments on commit 21c6b77

Please sign in to comment.