新增代理功能

pull/96/head
lyswhut 2019-09-16 00:00:07 +08:00
parent 8bdbbc562c
commit b9aedc9165
6 changed files with 138 additions and 2 deletions

View File

@ -1,3 +1,7 @@
### 新增
- 新增代理功能
### 优化 ### 优化
- 优化从《梦里嫦娥》皮肤切换到其他皮肤时侧栏动画的切换效果 - 优化从《梦里嫦娥》皮肤切换到其他皮肤时侧栏动画的切换效果

View File

@ -35,7 +35,10 @@ export default {
isProd: process.env.NODE_ENV === 'production', isProd: process.env.NODE_ENV === 'production',
isLinux, isLinux,
globalObj: { globalObj: {
apiSource: 'messoer', apiSource: 'test',
proxy: {
},
}, },
updateTimeout: null, updateTimeout: null,
} }
@ -129,6 +132,7 @@ export default {
this.initData() this.initData()
this.globalObj.apiSource = this.setting.apiSource this.globalObj.apiSource = this.setting.apiSource
this.globalObj.proxy = this.setting.network.proxy
window.globalObj = this.globalObj window.globalObj = this.globalObj
}, },
enableIgnoreMouseEvents() { enableIgnoreMouseEvents() {

View File

@ -0,0 +1,86 @@
<template lang="pug">
input(:class="$style.input" :placeholder="placeholder" v-model.trim="text" :disabled="disabled"
@focus="$emit('focus', $event)" @blur="$emit('blur', $event)" @input="$emit('input', text)" @change="$emit('change', text)"
@keyup.enter="submit")
</template>
<script>
export default {
props: {
placeholder: {
type: String,
default: '',
},
disabled: {
type: Boolean,
default: false,
},
value: {
type: String,
default: '',
},
},
data() {
return {
text: '',
}
},
watch: {
value(n) {
this.text = n
},
},
methods: {
handleInput() {
},
},
}
</script>
<style lang="less" module>
@import '../../assets/styles/layout.less';
.input {
display: inline-block;
border: none;
border-radius: 3px;
padding: 7px 8px;
color: @color-btn;
outline: none;
transition: background-color 0.2s ease;
background-color: @color-btn-background;
&[disabled] {
opacity: .4;
}
&:hover, &:focus {
background-color: @color-theme_2-hover;
}
&:active {
background-color: @color-theme_2-active;
}
}
.min {
padding: 3px 8px;
font-size: 12px;
}
each(@themes, {
:global(#container.@{value}) {
.input {
color: ~'@{color-@{value}-btn}';
background-color: ~'@{color-@{value}-btn-background}';
&:hover, &:focus {
background-color: ~'@{color-@{value}-theme_2-hover}';
}
&:active {
background-color: ~'@{color-@{value}-theme_2-active}';
}
}
}
})
</style>

View File

@ -163,7 +163,7 @@ export const isChildren = (parent, children) => {
* @param {*} setting * @param {*} setting
*/ */
export const updateSetting = setting => { export const updateSetting = setting => {
const defaultVersion = '1.0.7' const defaultVersion = '1.0.8'
const defaultSetting = { const defaultSetting = {
version: defaultVersion, version: defaultVersion,
player: { player: {
@ -197,6 +197,15 @@ export const updateSetting = setting => {
odc: { odc: {
isAutoClearSearchInput: false, isAutoClearSearchInput: false,
}, },
network: {
proxy: {
enable: false,
host: '',
port: '',
username: '',
password: '',
},
},
themeId: 0, themeId: 0,
sourceId: 'kw', sourceId: 'kw',
apiSource: 'test', apiSource: 'test',

View File

@ -8,6 +8,8 @@ import { bHh } from './music/options'
const headers = { const headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36', 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36',
} }
// var proxyUrl = "http://" + user + ":" + password + "@" + host + ":" + port;
// var proxiedRequest = request.defaults({'proxy': proxyUrl});
/** /**
* promise 形式的请求方法 * promise 形式的请求方法
@ -215,6 +217,12 @@ export const http_jsonp = (url, options, callback) => {
}) })
} }
const getProxyInfo = () => {
return window.globalObj.proxy.enable
? `http://${window.globalObj.proxy.username}:${window.globalObj.proxy.password}@${window.globalObj.proxy.host}:${window.globalObj.proxy.port};`
: undefined
}
const fatchData = (url, method, options, callback) => { const fatchData = (url, method, options, callback) => {
// console.log(url, options) // console.log(url, options)
console.log('---start---', url) console.log('---start---', url)
@ -233,6 +241,7 @@ const fatchData = (url, method, options, callback) => {
form: options.form, form: options.form,
formData: options.formData, formData: options.formData,
timeout: options.timeout || 10000, timeout: options.timeout || 10000,
proxy: getProxyInfo(),
json: options.format === undefined || options.format === 'json', json: options.format === undefined || options.format === 'json',
}, (err, resp, body) => { }, (err, resp, body) => {
if (err) return callback(err, null) if (err) return callback(err, null)

View File

@ -62,6 +62,18 @@ div.scroll(:class="$style.setting")
h3 专辑栏 h3 专辑栏
div div
material-checkbox(id="setting_list_showalbum" v-model="current_setting.list.isShowAlbumName" label="是否显示专辑栏") material-checkbox(id="setting_list_showalbum" v-model="current_setting.list.isShowAlbumName" label="是否显示专辑栏")
dt 网络设置
dd
h3 代理设置
div
p
material-checkbox(id="setting_network_proxy_enable" v-model="current_setting.network.proxy.enable" @change="handleProxyChange('enabel')" label="是否启用")
p
material-input(:class="$style.gapLeft" v-model="current_setting.network.proxy.host" @change="handleProxyChange('host')" placeholder="主机")
material-input(:class="$style.gapLeft" v-model="current_setting.network.proxy.port" @change="handleProxyChange('port')" placeholder="端口")
p
material-input(:class="$style.gapLeft" v-model="current_setting.network.proxy.username" @change="handleProxyChange('username')" placeholder="用户名")
material-input(:class="$style.gapLeft" v-model="current_setting.network.proxy.password" @change="handleProxyChange('password')" placeholder="密码")
dt 强迫症设置 dt 强迫症设置
dd dd
h3 离开搜索界面时清空搜索框 h3 离开搜索界面时清空搜索框
@ -169,6 +181,15 @@ export default {
isDownloadLrc: false, isDownloadLrc: false,
isEmbedPic: true, isEmbedPic: true,
}, },
network: {
proxy: {
enable: false,
host: '',
port: '',
username: '',
password: '',
},
},
odc: { odc: {
isAutoClearSearchInput: false, isAutoClearSearchInput: false,
}, },
@ -416,6 +437,9 @@ export default {
clipboardWriteText(text) { clipboardWriteText(text) {
clipboardWriteText(text) clipboardWriteText(text)
}, },
handleProxyChange(key) {
window.globalObj.proxy[key] = this.current_setting.network.proxy[key]
},
openRewardModal() { openRewardModal() {
}, },