From 7138ab3df234dbca96de113d728940849d734675 Mon Sep 17 00:00:00 2001 From: AkiraFukushima Date: Wed, 23 Oct 2019 22:08:10 +0900 Subject: [PATCH] refs #982 Add authentication information in proxy form --- package-lock.json | 12 +++---- package.json | 2 +- .../locales/de/translation.missing.json | 2 ++ src/config/locales/en/translation.json | 2 ++ .../locales/fr/translation.missing.json | 2 ++ .../locales/it/translation.missing.json | 2 ++ src/config/locales/ja/translation.json | 2 ++ .../locales/ko/translation.missing.json | 2 ++ .../locales/pl/translation.missing.json | 2 ++ .../locales/zh_cn/translation.missing.json | 2 ++ src/main/preferences.ts | 4 ++- .../components/Preferences/Network.vue | 22 ++++++++++++ src/renderer/store/Preferences/Network.ts | 34 ++++++++++++++----- src/types/proxy.ts | 14 +++++--- 14 files changed, 82 insertions(+), 22 deletions(-) diff --git a/package-lock.json b/package-lock.json index 39bcbd5b..cc450531 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8166,9 +8166,9 @@ "dev": true }, "element-ui": { - "version": "2.4.11", - "resolved": "https://registry.npmjs.org/element-ui/-/element-ui-2.4.11.tgz", - "integrity": "sha512-RtgK0t840NAFTajGMWvylzZRSX1EkZ7V4YgAoBxhv4TtkeMscLuk/IdYOzPdlQq6IN0byx1YVBxCX+u4yYkGvw==", + "version": "2.12.0", + "resolved": "https://registry.npmjs.org/element-ui/-/element-ui-2.12.0.tgz", + "integrity": "sha512-DapyT0PW4i/1ETPHk8K8Qbe8B6hj10+dXsRTrOTFryV9wAs6e9mCxbV65awokyR2/v/KuIHJmqX+mH3wUa4rOQ==", "requires": { "async-validator": "~1.8.1", "babel-helper-vue-jsx-merge-props": "^2.0.0", @@ -17679,9 +17679,9 @@ "dev": true }, "resize-observer-polyfill": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/resize-observer-polyfill/-/resize-observer-polyfill-1.5.0.tgz", - "integrity": "sha512-M2AelyJDVR/oLnToJLtuDJRBBWUGUvvGigj1411hXhAdyFWqMaqHp7TixW3FpiLuVaikIcR1QL+zqoJoZlOgpg==" + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/resize-observer-polyfill/-/resize-observer-polyfill-1.5.1.tgz", + "integrity": "sha512-LwZrotdHOo12nQuZlHEmtuXdqGoOD0OhaxopaNFxWzInpEgaLWoVuAMbTzixuosCx2nEG58ngzW3vxdWoxIgdg==" }, "resolve": { "version": "1.8.1", diff --git a/package.json b/package.json index 5728059d..5884690b 100644 --- a/package.json +++ b/package.json @@ -171,7 +171,7 @@ "electron-json-storage": "^4.1.5", "electron-log": "^2.2.17", "electron-window-state": "^5.0.3", - "element-ui": "^2.4.11", + "element-ui": "^2.12.0", "emoji-mart-vue": "^2.6.6", "emojilib": "^2.4.0", "hawk": "^7.0.10", diff --git a/src/config/locales/de/translation.missing.json b/src/config/locales/de/translation.missing.json index d1187243..62bb40cb 100644 --- a/src/config/locales/de/translation.missing.json +++ b/src/config/locales/de/translation.missing.json @@ -61,6 +61,8 @@ "protocol": "Protocol", "host": "Proxy host", "port": "Proxy port", + "username": "Proxy username", + "password": "Proxy password", "protocol_list": { "http": "http", "https": "https", diff --git a/src/config/locales/en/translation.json b/src/config/locales/en/translation.json index 633222f2..4221d9b3 100644 --- a/src/config/locales/en/translation.json +++ b/src/config/locales/en/translation.json @@ -205,6 +205,8 @@ "protocol": "Protocol", "host": "Proxy host", "port": "Proxy port", + "username": "Proxy username", + "password": "Proxy password", "protocol_list": { "http": "http", "https": "https", diff --git a/src/config/locales/fr/translation.missing.json b/src/config/locales/fr/translation.missing.json index f12a95e5..daf9644a 100644 --- a/src/config/locales/fr/translation.missing.json +++ b/src/config/locales/fr/translation.missing.json @@ -21,6 +21,8 @@ "protocol": "Protocol", "host": "Proxy host", "port": "Proxy port", + "username": "Proxy username", + "password": "Proxy password", "protocol_list": { "http": "http", "https": "https", diff --git a/src/config/locales/it/translation.missing.json b/src/config/locales/it/translation.missing.json index 83a5edad..8e240a41 100644 --- a/src/config/locales/it/translation.missing.json +++ b/src/config/locales/it/translation.missing.json @@ -25,6 +25,8 @@ "protocol": "Protocol", "host": "Proxy host", "port": "Proxy port", + "username": "Proxy username", + "password": "Proxy password", "protocol_list": { "http": "http", "https": "https", diff --git a/src/config/locales/ja/translation.json b/src/config/locales/ja/translation.json index aa6acac2..5f4f622b 100644 --- a/src/config/locales/ja/translation.json +++ b/src/config/locales/ja/translation.json @@ -205,6 +205,8 @@ "protocol": "プロトコル", "host": "ホスト", "port": "ポート", + "username": "ユーザー名", + "password": "パスワード", "protocol_list": { "http": "http", "https": "https", diff --git a/src/config/locales/ko/translation.missing.json b/src/config/locales/ko/translation.missing.json index 4dc04d9c..28641219 100644 --- a/src/config/locales/ko/translation.missing.json +++ b/src/config/locales/ko/translation.missing.json @@ -26,6 +26,8 @@ "protocol": "Protocol", "host": "Proxy host", "port": "Proxy port", + "username": "Proxy username", + "password": "Proxy password", "protocol_list": { "http": "http", "https": "https", diff --git a/src/config/locales/pl/translation.missing.json b/src/config/locales/pl/translation.missing.json index 5ff1be60..bc3d8fcb 100644 --- a/src/config/locales/pl/translation.missing.json +++ b/src/config/locales/pl/translation.missing.json @@ -86,6 +86,8 @@ "protocol": "Protocol", "host": "Proxy host", "port": "Proxy port", + "username": "Proxy username", + "password": "Proxy password", "protocol_list": { "http": "http", "https": "https", diff --git a/src/config/locales/zh_cn/translation.missing.json b/src/config/locales/zh_cn/translation.missing.json index f12a95e5..daf9644a 100644 --- a/src/config/locales/zh_cn/translation.missing.json +++ b/src/config/locales/zh_cn/translation.missing.json @@ -21,6 +21,8 @@ "protocol": "Protocol", "host": "Proxy host", "port": "Proxy port", + "username": "Proxy username", + "password": "Proxy password", "protocol_list": { "http": "http", "https": "https", diff --git a/src/main/preferences.ts b/src/main/preferences.ts index c060b682..2fb8a62d 100644 --- a/src/main/preferences.ts +++ b/src/main/preferences.ts @@ -70,7 +70,9 @@ const proxy: Proxy = { manualProxyConfig: { protocol: '', host: '', - port: '' + port: '', + username: '', + password: '' } } diff --git a/src/renderer/components/Preferences/Network.vue b/src/renderer/components/Preferences/Network.vue index 42accba8..2c2a7b1c 100644 --- a/src/renderer/components/Preferences/Network.vue +++ b/src/renderer/components/Preferences/Network.vue @@ -27,6 +27,12 @@ + + + + + + {{ $t('preferences.network.save') }} @@ -72,6 +78,22 @@ export default { set(value) { this.$store.dispatch('Preferences/Network/updatePort', value) } + }, + proxyUsername: { + get() { + return this.$store.state.Preferences.Network.proxy.username + }, + set(value) { + this.$store.dispatch('Preferences/Network/updateUsername', value) + } + }, + proxyPassword: { + get() { + return this.$store.state.Preferences.Network.proxy.password + }, + set(value) { + this.$store.dispatch('Preferences/Network/updatePassword', value) + } } }, created() { diff --git a/src/renderer/store/Preferences/Network.ts b/src/renderer/store/Preferences/Network.ts index 33d193a6..0a4a0e9a 100644 --- a/src/renderer/store/Preferences/Network.ts +++ b/src/renderer/store/Preferences/Network.ts @@ -2,15 +2,11 @@ import { ipcRenderer } from 'electron' import { Module, MutationTree, ActionTree, GetterTree } from 'vuex' import { RootState } from '@/store' import { BaseConfig } from '~/src/types/preference' -import { Proxy, ProxySource, ProxyProtocol } from '~/src/types/proxy' +import { Proxy, ProxySource, ProxyProtocol, ManualProxy } from '~/src/types/proxy' export type NetworkState = { source: ProxySource - proxy: { - protocol: '' | ProxyProtocol - host: string - port: string - } + proxy: ManualProxy } const state = (): NetworkState => { @@ -19,7 +15,9 @@ const state = (): NetworkState => { proxy: { protocol: '', host: '', - port: '' + port: '', + username: '', + password: '' } } } @@ -29,7 +27,9 @@ export const MUTATION_TYPES = { CHANGE_SOURCE: 'changeSource', UPDATE_PROTOCOL: 'updateProtocol', UPDATE_HOST: 'updateHost', - UPDATE_PORT: 'updatePort' + UPDATE_PORT: 'updatePort', + UPDATE_USERNAME: 'updateUsername', + UPDATE_PASSWORD: 'updatePassword' } const mutations: MutationTree = { @@ -80,6 +80,12 @@ const mutations: MutationTree = { }, [MUTATION_TYPES.UPDATE_PORT]: (state, port: string) => { state.proxy.port = port + }, + [MUTATION_TYPES.UPDATE_USERNAME]: (state, username: string) => { + state.proxy.username = username + }, + [MUTATION_TYPES.UPDATE_PASSWORD]: (state, password: string) => { + state.proxy.password = password } } @@ -110,8 +116,18 @@ const actions: ActionTree = { updatePort: ({ commit }, port: string) => { commit(MUTATION_TYPES.UPDATE_PORT, port) }, + updateUsername: ({ commit }, username: string) => { + commit(MUTATION_TYPES.UPDATE_USERNAME, username) + }, + updatePassword: ({ commit }, password: string) => { + commit(MUTATION_TYPES.UPDATE_PASSWORD, password) + }, saveProxyConfig: ({ state }) => { - ipcRenderer.send('update-proxy-config', state) + const proxy: Proxy = { + source: state.source, + manualProxyConfig: state.proxy + } + ipcRenderer.send('update-proxy-config', proxy) } } diff --git a/src/types/proxy.ts b/src/types/proxy.ts index 86f1c74d..f71ba7c0 100644 --- a/src/types/proxy.ts +++ b/src/types/proxy.ts @@ -13,11 +13,15 @@ export enum ProxyProtocol { socks5h = 'socks5h' } +export type ManualProxy = { + protocol: '' | ProxyProtocol + host: string + port: string + username: string + password: string +} + export type Proxy = { source: ProxySource - manualProxyConfig: { - protocol: '' | ProxyProtocol - host: string - port: string - } + manualProxyConfig: ManualProxy }