Commit 474dc45f authored by antoor's avatar antoor

更新优化代理设置

parent 60e309b2
......@@ -9,7 +9,7 @@
### /22
1. 数据分类重命名
2. 新增代理连接配置
2. 新增代理连接配置 // 感谢[@Medicean](https://github.com/Medicean)
### /21
1. 优化UI组建自适应,在调整窗口大小的时候不刷新就能调整UI尺寸
......
......@@ -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',
......
......@@ -17,6 +17,8 @@ class Request {
constructor(electron) {
// 监听请求
const userAgent = 'antSword/1.1';
const timeout = 5000;
const ipcMain = electron.ipcMain;
// 代理测试
......@@ -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) => {
......@@ -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) => {
......
{
"name": "antsword",
"version": "1.0.0",
"version": "1.1.0",
"description": "中国蚁剑是一款跨平台的开源网站管理工具",
"main": "app.js",
"dependencies": {
......@@ -30,5 +30,5 @@
"bugs": {
"url": "https://github.com/antoor/antSword/issues"
},
"homepage": "https://github.com/antoor/antSword"
"homepage": "http://uyu.us"
}
......@@ -15,6 +15,7 @@ module.exports = {
plugin: 'Plugin center',
settings: 'System setting',
language: 'Language setting',
aproxy: 'Proxy setting',
update: 'Check update',
quit: 'Quit'
},
......@@ -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: {
......
......@@ -16,6 +16,7 @@ module.exports = {
plugin: '插件中心',
settings: '系统设置',
language: '语言设置',
aproxy: '代理设置',
update: '检查更新',
quit: '退出程序'
},
......
......@@ -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'] },
......
......@@ -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, _));
});
}
......
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