Commit 9713e7ec authored by Medicean's avatar Medicean

(Enhance::Module::ViewSite) 新增浏览网站代理开关

parent 0d6dcfbe
...@@ -20,6 +20,10 @@ ...@@ -20,6 +20,10 @@
* 支持使用代理访问插件市场,当配置了代理之后,默认开启 * 支持使用代理访问插件市场,当配置了代理之后,默认开启
### 浏览网站
* 新增代理开关, 在配置了代理之后,可通过该开关控制是否使用代理浏览目标网站
### Other ### Other
* 调整 aproxy uri 初始化 URL 格式 * 调整 aproxy uri 初始化 URL 格式
......
...@@ -707,6 +707,7 @@ module.exports = { ...@@ -707,6 +707,7 @@ module.exports = {
}, },
viewsite: { viewsite: {
toolbar: { toolbar: {
useproxy: (s) => `Proxy: ${s?'ON':'OFF'}`,
save: 'Save', save: 'Save',
view: 'View' view: 'View'
}, },
......
...@@ -707,6 +707,7 @@ module.exports = { ...@@ -707,6 +707,7 @@ module.exports = {
}, },
viewsite: { viewsite: {
toolbar: { toolbar: {
useproxy: (s) => `代理: ${s?'开':'关'}`,
save: '保存', save: '保存',
view: '浏览' view: '浏览'
}, },
......
...@@ -24,7 +24,7 @@ class ViewSite { ...@@ -24,7 +24,7 @@ class ViewSite {
this.opts = opts; this.opts = opts;
this.cell = tabbar.cells(`tab_viewsite_${hash}`); this.cell = tabbar.cells(`tab_viewsite_${hash}`);
this.useproxy = antSword.aproxymode !== "noproxy";
// 初始化工具栏 // 初始化工具栏
this.toolbar = this._initToolbar(); this.toolbar = this._initToolbar();
...@@ -52,10 +52,21 @@ class ViewSite { ...@@ -52,10 +52,21 @@ class ViewSite {
const toolbar = this.cell.attachToolbar(); const toolbar = this.cell.attachToolbar();
toolbar.loadStruct([ toolbar.loadStruct([
{ id: 'url', width: 400, type: 'buttonInput', value: this.opts.url || 'loading..' }, { id: 'url', width: 400, type: 'buttonInput', value: this.opts.url || 'loading..' },
{ type: 'separator' },
{ id: 'useproxy', type: 'buttonTwoState', icon: 'paper-plane', text: LANG['toolbar'].useproxy(this.useproxy), pressed: this.useproxy, disabled: antSword.aproxymode === "noproxy"},
{ type: 'separator' },
{ id: 'view', type: 'button', icon: 'chrome', text: LANG['toolbar'].view }, { id: 'view', type: 'button', icon: 'chrome', text: LANG['toolbar'].view },
{ type: 'separator' }, { type: 'separator' },
{ id: 'save', type: 'button', icon: 'save', text: LANG['toolbar'].save }, { id: 'save', type: 'button', icon: 'save', text: LANG['toolbar'].save },
]); ]);
toolbar.attachEvent('onStateChange', (id, state) => {
switch(id) {
case 'useproxy':
this.useproxy = state;
toolbar.setItemText('useproxy', `<i class="fa fa-paper-plane"></i> ${LANG['toolbar'].useproxy(this.useproxy)}`);
break;
}
});
toolbar.attachEvent('onClick', (id) => { toolbar.attachEvent('onClick', (id) => {
switch(id) { switch(id) {
case 'save': case 'save':
...@@ -171,9 +182,19 @@ class ViewSite { ...@@ -171,9 +182,19 @@ class ViewSite {
}, },
title: url title: url
}); });
win.loadURL(url); win.on('close', () => {
win.show(); win = null;
win.openDevTools(); });
let ses = win.webContents.session;
let proxyuri = "";
if(this.useproxy && antSword.aproxymode != "noproxy") {
proxyuri = antSword.aproxyuri;
}
ses.setProxy({proxyRules: proxyuri}, ()=>{
win.loadURL(url);
win.show();
win.openDevTools();
});
} }
} }
......
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