From 474dc45f04e247a235bdc80311858e5dd41df8e1 Mon Sep 17 00:00:00 2001 From: antoor Date: Wed, 23 Mar 2016 20:40:28 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=90=86=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 2 +- modules/menubar.js | 4 ++++ modules/request.js | 32 +++++++++++++++------------- package.json | 4 ++-- source/language/en.jsx | 34 ++++++++++++++++++++++++++++++ source/language/zh.jsx | 1 + source/modules/settings/aproxy.jsx | 2 +- source/modules/settings/index.jsx | 2 +- 8 files changed, 61 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6ac32180..87b14514 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ ### /22 1. 数据分类重命名 - 2. 新增代理连接配置 + 2. 新增代理连接配置 // 感谢[@Medicean](https://github.com/Medicean) ### /21 1. 优化UI组建自适应,在调整窗口大小的时候不刷新就能调整UI尺寸 diff --git a/modules/menubar.js b/modules/menubar.js index 68fb6f66..f9fb7844 100644 --- a/modules/menubar.js +++ b/modules/menubar.js @@ -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', diff --git a/modules/request.js b/modules/request.js index aeeb9e70..096958a4 100644 --- a/modules/request.js +++ b/modules/request.js @@ -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) => { diff --git a/package.json b/package.json index e5595602..a2a4c1a0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "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" } diff --git a/source/language/en.jsx b/source/language/en.jsx index 7c885596..9593ad6b 100644 --- a/source/language/en.jsx +++ b/source/language/en.jsx @@ -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: { diff --git a/source/language/zh.jsx b/source/language/zh.jsx index 32fe6861..f54a1082 100644 --- a/source/language/zh.jsx +++ b/source/language/zh.jsx @@ -16,6 +16,7 @@ module.exports = { plugin: '插件中心', settings: '系统设置', language: '语言设置', + aproxy: '代理设置', update: '检查更新', quit: '退出程序' }, diff --git a/source/modules/settings/aproxy.jsx b/source/modules/settings/aproxy.jsx index 9eccf569..59842f4d 100644 --- a/source/modules/settings/aproxy.jsx +++ b/source/modules/settings/aproxy.jsx @@ -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'] }, diff --git a/source/modules/settings/index.jsx b/source/modules/settings/index.jsx index a6b3c110..5343b8ac 100644 --- a/source/modules/settings/index.jsx +++ b/source/modules/settings/index.jsx @@ -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, _)); }); }