Commit 474dc45f authored by antoor's avatar antoor

更新优化代理设置

parent 60e309b2
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
### /22 ### /22
1. 数据分类重命名 1. 数据分类重命名
2. 新增代理连接配置 2. 新增代理连接配置 // 感谢[@Medicean](https://github.com/Medicean)
### /21 ### /21
1. 优化UI组建自适应,在调整窗口大小的时候不刷新就能调整UI尺寸 1. 优化UI组建自适应,在调整窗口大小的时候不刷新就能调整UI尺寸
......
...@@ -124,6 +124,10 @@ class Menubar { ...@@ -124,6 +124,10 @@ class Menubar {
label: LANG['main']['language'], label: LANG['main']['language'],
accelerator: 'Shift+CmdOrCtrl+L', accelerator: 'Shift+CmdOrCtrl+L',
click: event.sender.send.bind(event.sender, 'menubar', 'settings-language') 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'], label: LANG['main']['update'],
accelerator: 'Shift+CmdOrCtrl+U', accelerator: 'Shift+CmdOrCtrl+U',
......
...@@ -17,6 +17,8 @@ class Request { ...@@ -17,6 +17,8 @@ class Request {
constructor(electron) { constructor(electron) {
// 监听请求 // 监听请求
const userAgent = 'antSword/1.1';
const timeout = 5000;
const ipcMain = electron.ipcMain; const ipcMain = electron.ipcMain;
// 代理测试 // 代理测试
...@@ -26,19 +28,19 @@ class Request { ...@@ -26,19 +28,19 @@ class Request {
logger.debug("[aProxy] Test Proxy - " + _aproxyuri + " - Connect to " + opts['url']); logger.debug("[aProxy] Test Proxy - " + _aproxyuri + " - Connect to " + opts['url']);
require('superagent-proxy')(superagent); require('superagent-proxy')(superagent);
_superagent _superagent
.get(opts['url']) .get(opts['url'])
.proxy(_aproxyuri) .set('User-Agent', userAgent)
.timeout(5000) .proxy(_aproxyuri)
.end((err, ret) => { .timeout(timeout)
if (err) { .end((err, ret) => {
logger.debug("[aProxy] Test Error"); if (err) {
return event.sender.send('aproxytest-error', err); logger.debug("[aProxy] Test Error");
}else{ return event.sender.send('aproxytest-error', err);
logger.debug("[aProxy] Test Success"); }else{
return event.sender.send('aproxytest-success', ret); logger.debug("[aProxy] Test Success");
} return event.sender.send('aproxytest-success', ret);
}); }
});
}); });
// 加载代理设置 // 加载代理设置
ipcMain.on('aproxy', (event, opts) => { ipcMain.on('aproxy', (event, opts) => {
...@@ -59,10 +61,10 @@ class Request { ...@@ -59,10 +61,10 @@ class Request {
logger.debug(opts['url'] + '\n', opts['data']); logger.debug(opts['url'] + '\n', opts['data']);
superagent superagent
.post(opts['url']) .post(opts['url'])
.set('User-Agent', 'antSword/1.0') .set('User-Agent', userAgent)
.proxy(aproxyuri) .proxy(aproxyuri)
.type('form') .type('form')
.timeout(5000) .timeout(timeout)
.send(opts['data']) .send(opts['data'])
.parse((res, callback) => { .parse((res, callback) => {
this.parse(opts['tag_s'], opts['tag_e'], (chunk) => { this.parse(opts['tag_s'], opts['tag_e'], (chunk) => {
......
{ {
"name": "antsword", "name": "antsword",
"version": "1.0.0", "version": "1.1.0",
"description": "中国蚁剑是一款跨平台的开源网站管理工具", "description": "中国蚁剑是一款跨平台的开源网站管理工具",
"main": "app.js", "main": "app.js",
"dependencies": { "dependencies": {
...@@ -30,5 +30,5 @@ ...@@ -30,5 +30,5 @@
"bugs": { "bugs": {
"url": "https://github.com/antoor/antSword/issues" "url": "https://github.com/antoor/antSword/issues"
}, },
"homepage": "https://github.com/antoor/antSword" "homepage": "http://uyu.us"
} }
...@@ -15,6 +15,7 @@ module.exports = { ...@@ -15,6 +15,7 @@ module.exports = {
plugin: 'Plugin center', plugin: 'Plugin center',
settings: 'System setting', settings: 'System setting',
language: 'Language setting', language: 'Language setting',
aproxy: 'Proxy setting',
update: 'Check update', update: 'Check update',
quit: 'Quit' quit: 'Quit'
}, },
...@@ -405,6 +406,39 @@ module.exports = { ...@@ -405,6 +406,39 @@ module.exports = {
toolbar: { toolbar: {
check: 'Check' 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: { aproxy: {
......
...@@ -16,6 +16,7 @@ module.exports = { ...@@ -16,6 +16,7 @@ module.exports = {
plugin: '插件中心', plugin: '插件中心',
settings: '系统设置', settings: '系统设置',
language: '语言设置', language: '语言设置',
aproxy: '代理设置',
update: '检查更新', update: '检查更新',
quit: '退出程序' quit: '退出程序'
}, },
......
...@@ -31,7 +31,7 @@ class AProxy { ...@@ -31,7 +31,7 @@ class AProxy {
// 表单 // 表单
const form = cell.attachForm([ 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: 'block', inputWidth: 'auto', offsetTop: 12, list: [
{ type: 'label', label: LANG['form']['label'] }, { type: 'label', label: LANG['form']['label'] },
......
...@@ -11,7 +11,7 @@ class Settings { ...@@ -11,7 +11,7 @@ class Settings {
constructor() { constructor() {
antSword['menubar'].reg('settings', this::this.open); antSword['menubar'].reg('settings', this::this.open);
['about', 'update', 'language'].map((_) => { ['about', 'update', 'language', 'aproxy'].map((_) => {
antSword['menubar'].reg(`settings-${_}`, this.setActive.bind(this, _)); antSword['menubar'].reg(`settings-${_}`, this.setActive.bind(this, _));
}); });
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment