Skip to content

Commit

Permalink
更新优化代理设置
Browse files Browse the repository at this point in the history
  • Loading branch information
antoor committed Mar 23, 2016
1 parent 60e309b commit 474dc45
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 20 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

### /22
1. 数据分类重命名
2. 新增代理连接配置
2. 新增代理连接配置 // 感谢[@Medicean](https://github.com/Medicean)

### /21
1. 优化UI组建自适应,在调整窗口大小的时候不刷新就能调整UI尺寸
Expand Down
4 changes: 4 additions & 0 deletions modules/menubar.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ class Menubar {
label: LANG['main']['language'],
accelerator: 'Shift+CmdOrCtrl+L',
click: event.sender.send.bind(event.sender, 'menubar', 'settings-language')
}, {
label: LANG['main']['aproxy'],
accelerator: 'Shift+CmdOrCtrl+A',
click: event.sender.send.bind(event.sender, 'menubar', 'settings-aproxy')
}, {
label: LANG['main']['update'],
accelerator: 'Shift+CmdOrCtrl+U',
Expand Down
32 changes: 17 additions & 15 deletions modules/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ class Request {

constructor(electron) {
// 监听请求
const userAgent = 'antSword/1.1';
const timeout = 5000;
const ipcMain = electron.ipcMain;

// 代理测试
Expand All @@ -26,19 +28,19 @@ class Request {
logger.debug("[aProxy] Test Proxy - " + _aproxyuri + " - Connect to " + opts['url']);
require('superagent-proxy')(superagent);
_superagent
.get(opts['url'])
.proxy(_aproxyuri)
.timeout(5000)
.end((err, ret) => {
if (err) {
logger.debug("[aProxy] Test Error");
return event.sender.send('aproxytest-error', err);
}else{
logger.debug("[aProxy] Test Success");
return event.sender.send('aproxytest-success', ret);
}
});

.get(opts['url'])
.set('User-Agent', userAgent)
.proxy(_aproxyuri)
.timeout(timeout)
.end((err, ret) => {
if (err) {
logger.debug("[aProxy] Test Error");
return event.sender.send('aproxytest-error', err);
}else{
logger.debug("[aProxy] Test Success");
return event.sender.send('aproxytest-success', ret);
}
});
});
// 加载代理设置
ipcMain.on('aproxy', (event, opts) => {
Expand All @@ -59,10 +61,10 @@ class Request {
logger.debug(opts['url'] + '\n', opts['data']);
superagent
.post(opts['url'])
.set('User-Agent', 'antSword/1.0')
.set('User-Agent', userAgent)
.proxy(aproxyuri)
.type('form')
.timeout(5000)
.timeout(timeout)
.send(opts['data'])
.parse((res, callback) => {
this.parse(opts['tag_s'], opts['tag_e'], (chunk) => {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "antsword",
"version": "1.0.0",
"version": "1.1.0",
"description": "中国蚁剑是一款跨平台的开源网站管理工具",
"main": "app.js",
"dependencies": {
Expand Down Expand Up @@ -30,5 +30,5 @@
"bugs": {
"url": "https://github.com/antoor/antSword/issues"
},
"homepage": "https://github.com/antoor/antSword"
"homepage": "http://uyu.us"
}
34 changes: 34 additions & 0 deletions source/language/en.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ module.exports = {
plugin: 'Plugin center',
settings: 'System setting',
language: 'Language setting',
aproxy: 'Proxy setting',
update: 'Check update',
quit: 'Quit'
},
Expand Down Expand Up @@ -405,6 +406,39 @@ module.exports = {
toolbar: {
check: 'Check'
}
},
aproxy: {
title: 'Proxy setting',
toolbar: {
save: 'Save',
test: 'Test connect'
},
form: {
label: 'Configure proxy for access to the Internet',
mode:{
noproxy: 'Do not use agent',
manualproxy: 'Manually set the proxy'
},
proxy: {
protocol: 'Agency agreement',
server: 'Proxy server',
port: 'Port',
username: 'AuthUser',
password: 'Password',
authtip: 'If there is no authentication if'
}
},
success: 'Save proxy settings successfully!',
error: 'Failed to save the proxy settings!',
confirm: {
content: 'Restart the application to take effect, whether to restart?',
title: 'Change proxy settings'
},
prompt:{
title: 'Enter the Test-URL',
success: 'Connect to proxy server successfully',
error: 'Failed to connect to the proxy server'
}
}
},
aproxy: {
Expand Down
1 change: 1 addition & 0 deletions source/language/zh.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ module.exports = {
plugin: '插件中心',
settings: '系统设置',
language: '语言设置',
aproxy: '代理设置',
update: '检查更新',
quit: '退出程序'
},
Expand Down
2 changes: 1 addition & 1 deletion source/modules/settings/aproxy.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class AProxy {

// 表单
const form = cell.attachForm([
{ type: 'settings', position: 'label-left', labelWidth: 150, inputWidth: 100 },
{ type: 'settings', position: 'label-left', labelWidth: 150, inputWidth: 200 },
{ type: 'block', inputWidth: 'auto', offsetTop: 12, list: [
{ type: 'label', label: LANG['form']['label'] },

Expand Down
2 changes: 1 addition & 1 deletion source/modules/settings/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Settings {

constructor() {
antSword['menubar'].reg('settings', this::this.open);
['about', 'update', 'language'].map((_) => {
['about', 'update', 'language', 'aproxy'].map((_) => {
antSword['menubar'].reg(`settings-${_}`, this.setActive.bind(this, _));
});
}
Expand Down

0 comments on commit 474dc45

Please sign in to comment.