Skip to content

Commit

Permalink
支持从本地加载扩展,支持卸载已安装的扩展
Browse files Browse the repository at this point in the history
  • Loading branch information
monkeyWie committed Sep 28, 2018
1 parent 22bb6fd commit a7da78e
Show file tree
Hide file tree
Showing 10 changed files with 437 additions and 181 deletions.
112 changes: 66 additions & 46 deletions front/src/common/native.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const clientNoSpin = axios.create()
/**
* 弹出原生文件选择框
*/
const showFileChooser = () => {
export const showFileChooser = () => {
return new Promise((resolve, reject) => {
client
.get('/native/fileChooser')
Expand All @@ -19,7 +19,7 @@ const showFileChooser = () => {
/**
* 弹出原生文件夹选择框
*/
const showDirChooser = () => {
export const showDirChooser = () => {
return new Promise((resolve, reject) => {
client
.get('/native/dirChooser')
Expand All @@ -31,7 +31,7 @@ const showDirChooser = () => {
/**
* 取应用初始化配置信息
*/
const getInitConfig = () => {
export const getInitConfig = () => {
return new Promise((resolve, reject) => {
client
.get('/native/getInitConfig')
Expand All @@ -44,10 +44,12 @@ const getInitConfig = () => {
* 弹出系统资源管理器并选中指定文件
* @param {string} path 文件路径
*/
const showFile = path => {
export const showFile = path => {
return new Promise((resolve, reject) => {
client
.post('/native/showFile', { path: path })
.post('/native/showFile', {
path: path
})
.then(response => resolve(response.data))
.catch(error => reject(error))
})
Expand All @@ -56,7 +58,7 @@ const showFile = path => {
/**
* 检查证书是否安装
*/
const checkCert = () => {
export const checkCert = () => {
return new Promise((resolve, reject) => {
clientNoSpin
.get('/native/checkCert')
Expand All @@ -68,7 +70,7 @@ const checkCert = () => {
/**
* 安装证书
*/
const installCert = () => {
export const installCert = () => {
return new Promise((resolve, reject) => {
client
.get('/native/installCert')
Expand All @@ -80,7 +82,7 @@ const installCert = () => {
/**
* 取设置的代理模式
*/
const getProxyMode = () => {
export const getProxyMode = () => {
return new Promise((resolve, reject) => {
clientNoSpin
.get('/native/getProxyMode')
Expand All @@ -93,10 +95,12 @@ const getProxyMode = () => {
* 修改代理模式
* @param {number} mode 0.不接管系统代理 1.接管系统代理
*/
const changeProxyMode = mode => {
export const changeProxyMode = mode => {
return new Promise((resolve, reject) => {
client
.post('/native/changeProxyMode', { mode: mode })
.post('/native/changeProxyMode', {
mode: mode
})
.then(response => resolve(response.data))
.catch(error => reject(error))
})
Expand All @@ -105,7 +109,7 @@ const changeProxyMode = mode => {
/**
* 取本地已安装的扩展列表
*/
const getExtensions = () => {
export const getExtensions = () => {
return new Promise((resolve, reject) => {
clientNoSpin
.get('/native/getExtensions')
Expand All @@ -118,7 +122,7 @@ const getExtensions = () => {
* 安装指定扩展
* @param {object} data 扩展相关信息
*/
const installExtension = data => {
export const installExtension = data => {
return new Promise((resolve, reject) => {
clientNoSpin
.post('/native/installExtension', data)
Expand All @@ -131,7 +135,7 @@ const installExtension = data => {
* 更新指定扩展
* @param {object} data 扩展相关信息
*/
const updateExtension = data => {
export const updateExtension = data => {
return new Promise((resolve, reject) => {
clientNoSpin
.post('/native/updateExtension', data)
Expand All @@ -140,11 +144,43 @@ const updateExtension = data => {
})
}

/**
* 安装本地扩展
* @param {string} path 扩展所在目录
*/
export const installLocalExtension = path => {
return new Promise((resolve, reject) => {
clientNoSpin
.post('/native/installLocalExtension', {
path: path
})
.then(response => resolve(response.data.data))
.catch(error => reject(error))
})
}

/**
* 卸载扩展
* @param {string} path 扩展所在目录
* @param {boolean} isLocal 是否本地加载的扩展
*/
export const uninstallExtension = (path, local) => {
return new Promise((resolve, reject) => {
client
.post('/native/uninstallExtension', {
path,
local
})
.then(response => resolve(response.data))
.catch(error => reject(error))
})
}

/**
* 启用或禁用扩展
* @param {object} data
*/
const toggleExtension = data => {
export const toggleExtension = data => {
return new Promise((resolve, reject) => {
client
.post('/native/toggleExtension', data)
Expand All @@ -157,9 +193,11 @@ const toggleExtension = data => {
* 打开浏览器并访问指定url
* @param {object} data
*/
const openUrl = url => {
export const openUrl = url => {
if (window.navigator.userAgent.indexOf('JavaFX') !== -1) {
clientNoSpin.post('/native/openUrl', { url: encodeURIComponent(url) })
clientNoSpin.post('/native/openUrl', {
url: encodeURIComponent(url)
})
} else {
window.open(url)
}
Expand All @@ -169,10 +207,12 @@ const openUrl = url => {
* 更新软件
* @param {string} path 更新包下载地址
*/
const doUpdate = path => {
export const doUpdate = path => {
return new Promise((resolve, reject) => {
clientNoSpin
.post('/native/doUpdate', { path: path })
.post('/native/doUpdate', {
path: path
})
.then(response => resolve(response.data))
.catch(error => reject(error))
})
Expand All @@ -181,7 +221,7 @@ const doUpdate = path => {
/**
* 更新软件进度获取
*/
const getUpdateProgress = () => {
export const getUpdateProgress = () => {
return new Promise((resolve, reject) => {
clientNoSpin
.get('/native/getUpdateProgress')
Expand All @@ -193,7 +233,7 @@ const getUpdateProgress = () => {
/**
* 重启软件
*/
const doRestart = () => {
export const doRestart = () => {
return new Promise((resolve, reject) => {
client
.get('/native/doRestart')
Expand All @@ -205,7 +245,7 @@ const doRestart = () => {
/**
* 取软件设置信息
*/
const getConfig = () => {
export const getConfig = () => {
return new Promise((resolve, reject) => {
clientNoSpin
.get('/native/getConfig')
Expand All @@ -218,10 +258,10 @@ const getConfig = () => {
* 保存软件设置
* @param {object} config
*/
const setConfig = config => {
export const setConfig = config => {
return new Promise((resolve, reject) => {
client
.put('/native/setConfig',config)
.put('/native/setConfig', config)
.then(response => resolve(response))
.catch(error => reject(error))
})
Expand All @@ -231,31 +271,11 @@ const setConfig = config => {
* 复制数据到系统剪贴板
* @param {object} data
*/
const copy = data => {
export const copy = data => {
return new Promise((resolve, reject) => {
clientNoSpin
.put('/native/copy',data)
.put('/native/copy', data)
.then(response => resolve(response))
.catch(error => reject(error))
})
}

export { showFileChooser }
export { showDirChooser }
export { openUrl }
export { doUpdate }
export { getUpdateProgress }
export { doRestart }
export { getInitConfig }
export { showFile }
export { checkCert }
export { installCert }
export { getProxyMode }
export { changeProxyMode }
export { getExtensions }
export { installExtension }
export { updateExtension }
export { toggleExtension }
export { getConfig }
export { setConfig }
export { copy }
}
2 changes: 1 addition & 1 deletion front/src/components/Table/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
width="400"
trigger="click">
<Icon type="ios-eye-outline"
style="padding-left: 0.625rem;"
style="padding-left: 0.625rem;padding-top: 0.1rem;"
class="action-icon"></Icon>
<div class="file-detail"
slot="content">
Expand Down
20 changes: 13 additions & 7 deletions front/src/i18n/en-US.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,14 @@ export default {
detail: 'Detail',
checkSameTask: 'Detected the same download task, did you choose to refresh the task?',
sameTaskList: 'Task List',
sameTaskPlaceholder: 'Please select the task to refresh'
sameTaskPlaceholder: 'Please select the task to refresh',
running: 'Downloading',
waiting: 'Waiting',
done: 'Done'
},
extension: {
conditions: 'Terms and Conditions',
conditionsContent:
'When using the expansion module for the first time, you must install a CA certificate randomly generated by Proxyee Down, click the install button below and press the system to confirm the installation. The program will detect whether the Proxyee Down CA certificate has been installed in the operating system before installation. (Tip:If it detects the installation, it will prompt to delete the corresponding old CA certificate)',
conditionsContent: 'When using the expansion module for the first time, you must install a CA certificate randomly generated by Proxyee Down, click the install button below and press the system to confirm the installation. The program will detect whether the Proxyee Down CA certificate has been installed in the operating system before installation. (Tip:If it detects the installation, it will prompt to delete the corresponding old CA certificate)',
install: 'Install',
globalProxy: 'Global Proxy',
proxyTip: 'Click to view instructions',
Expand All @@ -67,11 +69,16 @@ export default {
actionUpdate: 'Update',
actionInstall: 'Install',
actionDetail: 'Detail',
uninstall: 'Uninstall',
switch: 'Switch',
downloadingTip: 'Downloading...[servers(',
downloadOk: 'Download successful',
downloadErr: 'Download failed',
downloadErrTip: 'Automatically switch servers'
downloadErrTip: 'Automatically switch servers',
extCenter: 'Extension center',
installLocalExt: 'Install local extension',
installOk: 'Install successfully',
installErr: 'Install failed, please check the manifest.json file'
},
setting: {
downSetting: 'Down setting',
Expand Down Expand Up @@ -105,8 +112,7 @@ 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: ',
tutorial: 'Use Tutorial: ',
feedback: 'Feedback: ',
Expand Down Expand Up @@ -156,4 +162,4 @@ export default {
4000: 'Params parse error'
}
}
}
}
12 changes: 10 additions & 2 deletions front/src/i18n/zh-CN.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ export default {
detail: '下载详情',
checkSameTask: '检测到可能相同的下载任务,是否选择任务进行刷新?',
sameTaskList: '任务列表',
sameTaskPlaceholder: '请选择要刷新的任务'
sameTaskPlaceholder: '请选择要刷新的任务',
running: '进行中',
waiting: '等待中',
done: '已完成'
},
extension: {
conditions: '使用须知',
Expand All @@ -65,12 +68,17 @@ export default {
action: '操作',
actionUpdate: '更新',
actionInstall: '安装',
uninstall: '卸载',
actionDetail: '详情',
switch: '开关',
downloadingTip: '下载中...[服务器(',
downloadOk: '下载成功',
downloadErr: '下载失败',
downloadErrTip: '自动切换服务器'
downloadErrTip: '自动切换服务器',
extCenter: '扩展中心',
installLocalExt: '加载本地扩展',
installOk: '加载成功',
installErr: '加载失败,请检查manifest.json文件'
},
setting: {
downSetting: '下载设置',
Expand Down
12 changes: 10 additions & 2 deletions front/src/i18n/zh-TW.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ export default {
detail: '下載細節',
checkSameTask: '偵測到可能相同的下載任務,是否選擇任務進行更新?',
sameTaskList: '任務清單',
sameTaskPlaceholder: '請選擇要更新的任務'
sameTaskPlaceholder: '請選擇要更新的任務',
running: '進行中',
waiting: '等待中',
done: '已完成'
},
extension: {
conditions: '使用須知',
Expand All @@ -66,11 +69,16 @@ export default {
actionUpdate: '更新',
actionInstall: '安裝',
actionDetail: '細節',
uninstall: '卸載',
switch: '開關',
downloadingTip: '下載中...[伺服器(',
downloadOk: '下載成功',
downloadErr: '下載失敗',
downloadErrTip: '自動切換伺服器'
downloadErrTip: '自動切換伺服器',
extCenter: '擴充中心',
installLocalExt: '加載本地擴充',
installOk: '加載成功',
installErr: '加載失敗,請檢查manifest.json文件'
},
setting: {
downSetting: '下載設定',
Expand Down
Loading

0 comments on commit a7da78e

Please sign in to comment.