Skip to content

Commit

Permalink
扩展支持自定义设置
Browse files Browse the repository at this point in the history
  • Loading branch information
monkeyWie committed Oct 31, 2018
1 parent 2e9cae0 commit 88d4153
Show file tree
Hide file tree
Showing 8 changed files with 230 additions and 18 deletions.
3 changes: 0 additions & 3 deletions front/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,4 @@ yarn-error.log*
*.sln
*.sw*

.vscode/*
!.vscode/settings.json

package-lock.json
29 changes: 28 additions & 1 deletion front/src/common/native.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,20 @@ export const toggleExtension = data => {
})
}

/**
* 保存指定扩展的设置
* @param {String} path 扩展路径
* @param {object} setting 扩展设置信息
*/
export const updateExtensionSetting = (path, setting) => {
return new Promise((resolve, reject) => {
client
.post('/native/updateExtensionSetting', { path, setting })
.then(response => resolve(response.data))
.catch(error => reject(error))
})
}

/**
* 打开浏览器并访问指定url
* @param {object} data
Expand All @@ -192,6 +206,19 @@ export const openUrl = url => {
}
}

/**
* 在解析任务时触发
* @param {object} request
*/
export const onResolve = request => {
return new Promise((resolve, reject) => {
clientNoSpin
.post('/native/onResolve', request)
.then(response => resolve(response.data))
.catch(error => reject(error))
})
}

/**
* 更新软件
* @param {string} path 更新包下载地址
Expand Down Expand Up @@ -265,4 +292,4 @@ export const copy = data => {
.then(response => resolve(response))
.catch(error => reject(error))
})
}
}
40 changes: 40 additions & 0 deletions front/src/components/ExtensionSetting.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<template>
<Form :label-width="70">
<FormItem v-for="(setting,index) in settings"
:key="index"
:label="setting.title"
:prop="setting.name">
<Switch v-if="setting.type==='Boolean'"
v-model="setting.value" />
<Select v-else-if="setting.options"
style="width:90%"
v-model="setting.value">
<Option v-for="(key,label) in setting.options"
:key="key"
:value="key">{{label}}</Option>
</Select>
<Input v-else
style="width:90%"
v-model="setting.value" />
<Tooltip class="item"
placement="right">
<Icon type="help-circled"
class="action-icon tip-icon" />
<div slot="content">
<p>{{ setting.description }}</p>
</div>
</Tooltip>
</FormItem>
</Form>
</template>

<script>
export default {
props: {
settings: {
type: Array
}
}
}
</script>

9 changes: 5 additions & 4 deletions front/src/i18n/en-US.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ export default {
},
extension: {
conditions: 'Notes',
conditionsContent: 'When using the extension for the first time, you must install a CA certificate randomly generated by Proxyee Down. Click Install below and follow the instructions. If a Proxyee Down CA certificate has been installed, you will be prompted to delete the old CA certificate.',
conditionsContent:
'When using the extension for the first time, you must install a CA certificate randomly generated by Proxyee Down. Click Install below and follow the instructions. If a Proxyee Down CA certificate has been installed, you will be prompted to delete the old CA certificate.',
install: 'Install',
globalProxy: 'Global Proxy',
proxyTip: 'View instructions',
Expand All @@ -70,7 +71,6 @@ export default {
actionInstall: 'Install',
uninstall: 'Uninstall',
uninstallTip: 'Do you want to uninstall this extension?',
switch: 'Switch',
actionDetail: 'Details',
switch: 'ON/OFF',
downloadingTip: 'Downloading...[servers(',
Expand Down Expand Up @@ -114,7 +114,8 @@ export default {
about: {
project: {
title: 'Project',
content: 'Proxyee-Down is an open source, free software based on the software\'s high-speed download kernel and extensions to easily and quickly download the required resources.',
content:
'Proxyee-Down is an open source, free software based on the software\'s high-speed download kernel and extensions to easily and quickly download the required resources.',
githubAddress: 'Project homepage: ',
official: 'Official website: ',
community: 'Official community: ',
Expand Down Expand Up @@ -168,4 +169,4 @@ export default {
4000: 'Params parse error'
}
}
}
}
62 changes: 57 additions & 5 deletions front/src/views/Extension.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
@on-change="changeProxyMode"></Switch>
<Tooltip placement="bottom">
<Icon type="help-circled"
@click="openUrl('https://github.com/proxyee-down-org/proxyee-down/tree/v3.0#%E6%89%A9%E5%B1%95%E6%A8%A1%E5%9D%97')"
@click="openUrl('https://github.com/proxyee-down-org/proxyee-down/wiki/%E5%AE%89%E8%A3%85%E6%89%A9%E5%B1%95')"
class="action-icon tip-icon" />
<div slot="content">
<p>{{ $t('extension.proxyTip') }}</p>
Expand Down Expand Up @@ -49,8 +49,22 @@
icon="social-buffer">
<Table :columns="localColumns"
:data="localAllList"></Table>
<Modal v-model="settingModal"
title="设置">
<ExtensionSetting :settings="settings" />
<span slot="footer">
<Button @click="settingModal = false">{{ $t('tip.cancel') }}</Button>
<Button type="primary"
@click="saveSetting()">{{ $t('tip.ok') }}</Button>
</span>
</Modal>
</TabPane>
</Tabs>
<Icon type="loop"
class="action-icon"
title="刷新"
style="position: absolute;top: 138px;left: 290px;"
@click="loadExtensions"></Icon>
<Spin fix
v-if="spinShow">
<Icon type="load-c"
Expand All @@ -61,6 +75,7 @@
</template>
<script>
import { Icon, Tag } from 'iview'
import ExtensionSetting from '../components/ExtensionSetting.vue'
import {
checkCert,
installCert,
Expand All @@ -74,11 +89,15 @@ import {
toggleExtension,
openUrl,
copy,
showDirChooser
showDirChooser,
updateExtensionSetting
} from '../common/native.js'
export default {
name: 'extension',
components: {
ExtensionSetting
},
data() {
return {
certStatus: false,
Expand All @@ -96,7 +115,10 @@ export default {
spinShow: false,
spinTip: '',
onlineColumns: this.buildCommonColumns(),
localColumns: this.buildCommonColumns(true)
localColumns: this.buildCommonColumns(true),
settingModal: false,
settingExt: null,
settings: []
}
},
methods: {
Expand Down Expand Up @@ -181,7 +203,25 @@ export default {
class="action-icon"
title={_this.$t('extension.uninstall')}
nativeOnClick={() => _this.uninstallExtension(params.row)}
/>
/>,
...(params.row.settings && params.row.settings.length
? [
<Icon
type="android-settings"
class="action-icon"
title="设置"
nativeOnClick={() => {
_this.settingModal = true
_this.settingExt = params.row
_this.settings = params.row.settings
const settingValues = params.row.meta.settings
if (settingValues) {
_this.settings.forEach(s => (s.value = settingValues[s.name] || s.value))
}
}}
/>
]
: [])
]
: [
<Icon
Expand Down Expand Up @@ -221,7 +261,7 @@ export default {
},
changeEnabled(enabled, row) {
toggleExtension({ path: row.meta.path, enabled: enabled }).then(() => {
toggleExtension({ path: row.meta.path, enabled: enabled, local: row.meta.local }).then(() => {
const localExt = this.localAllList.find(localExt => localExt.meta.path == row.meta.path)
localExt.meta.enabled = enabled
this.refreshExtensions()
Expand Down Expand Up @@ -381,6 +421,9 @@ export default {
'https://github.com/proxyee-down-org/proxyee-down-extension/blob/master' + row.meta.path + '/README.md'
openUrl(url)
},
openUrl(url) {
openUrl(url)
},
copyPac() {
const { protocol, host } = window.location
copy({
Expand All @@ -389,6 +432,15 @@ export default {
})
.then(() => this.$Message.success(this.$t('tip.copySucc')))
.catch(() => this.$Message.error(this.$t('tip.copyFail')))
},
saveSetting() {
const setting = {}
this.settingExt.settings.forEach(s => {
setting[s.name] = s.value
})
updateExtensionSetting(this.settingExt.meta.path, setting)
.then(() => this.$Message.success('保存成功'))
.catch(() => this.$Message.error('保存失败'))
}
},
created() {
Expand Down
4 changes: 2 additions & 2 deletions main/src/main/java/org/pdown/gui/http/EmbedHttpServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ public void start() {
}

public void start(GenericFutureListener startedListener) {
NioEventLoopGroup bossGroup = new NioEventLoopGroup(1);
NioEventLoopGroup workGroup = new NioEventLoopGroup(1);
NioEventLoopGroup bossGroup = new NioEventLoopGroup();
NioEventLoopGroup workGroup = new NioEventLoopGroup();
try {
ServerBootstrap bootstrap = new ServerBootstrap().group(bossGroup, workGroup)
.channel(NioServerSocketChannel.class)
Expand Down
Loading

0 comments on commit 88d4153

Please sign in to comment.