diff --git a/README.md b/README.md index d5bf470b..57cfe344 100644 --- a/README.md +++ b/README.md @@ -84,6 +84,8 @@ npm run pack:linux - `-dha` 禁用硬件加速启动(Disable Hardware Acceleration),窗口显示有问题时可以尝试添加此参数启动(v1.6.0起新增) - `-dt` 以非透明模式启动(Disable Transparent),对于未开启AERO效果的win7系统可加此参数启动以确保界面正常显示(注:该参数对桌面歌词无效),原来的`-nt`参数已重命名为`-dt`(v1.6.0起重命名) - `-dhmkh` 禁用硬件媒体密钥处理(Disable Hardware Media Key Handling),此选项将禁用Chromium的Hardware Media Key Handling特性(v1.9.0起新增) +- `-proxy-server` 设置代理服务器,代理应用的所有流量,例:`-proxy-server="127.0.0.1:1081"`(不支持设置账号密码,v1.17.0起新增)。注:应用内“设置-网络-代理设置”仅代理接口请求的流量,优先级更高 +- `-proxy-bypass-list` 以分号分隔的主机列表绕过代理服务器,例:`-proxy-bypass-list=";*.google.com;*foo.com;1.2.3.4:5678"`(与`-proxy-server`一起使用才有效,v1.17.0起新增)。注:此设置对应用内接口请求无效 - `-play` 启动时播放指定列表的音乐,参数说明: - `type`:播放类型,目前固定为`songList` - `source`:播放源,可用值为`kw/kg/tx/wy/mg/myList`,其中`kw/kg/tx/wy/mg`对应各源的在线列表,`myList`为本地列表 diff --git a/publish/changeLog.md b/publish/changeLog.md index 8072bfe6..ea36bef8 100644 --- a/publish/changeLog.md +++ b/publish/changeLog.md @@ -1,3 +1,7 @@ +### 新增 + +- 新增启动参数`-proxy-server`与`-proxy-bypass-list`,详细介绍看Readme.md文档的启动参数部分 + ### 优化 - 为可视化音频的频谱整体添加频谱均值加成,使频谱显示更有节奏感 diff --git a/src/main/index.js b/src/main/index.js index 2681c98f..67678277 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -37,6 +37,12 @@ if (process.platform == 'linux') app.commandLine.appendSwitch('use-gl', 'desktop // https://github.com/electron/electron/issues/22691 app.commandLine.appendSwitch('wm-window-animations-disabled') +// proxy +if (global.envParams.cmdParams['proxy-server']) { + app.commandLine.appendSwitch('proxy-server', global.envParams.cmdParams['proxy-server']) + app.commandLine.appendSwitch('proxy-bypass-list', global.envParams.cmdParams['proxy-bypass-list'] ?? '') +} +// if (global.envParams.cmdParams['proxy-pac-url']) app.commandLine.appendSwitch('proxy-pac-url', global.envParams.cmdParams['proxy-pac-url']) const { navigationUrlWhiteList, themes } = require('../common/config') const { getWindowSizeInfo, initSetting, updateSetting } = require('./utils') diff --git a/src/renderer/core/useApp/index.js b/src/renderer/core/useApp/index.js index 443c3de5..7a51f5c0 100644 --- a/src/renderer/core/useApp/index.js +++ b/src/renderer/core/useApp/index.js @@ -47,6 +47,15 @@ export default () => { getEnvParams().then(envParams => { + const envProxy = envParams['proxy-server'] + if (envProxy && typeof envProxy == 'string') { + const [host, port = ''] = envProxy.split(':') + proxy.envProxy = { + host, + port, + } + } + // 初始化我的列表、下载列表等数据 initData().then(() => { handleEnvParams(envParams) // 处理传入的启动参数 diff --git a/src/renderer/utils/index.js b/src/renderer/utils/index.js index 183292df..99fbc60e 100644 --- a/src/renderer/utils/index.js +++ b/src/renderer/utils/index.js @@ -387,9 +387,13 @@ export const clearCache = () => rendererInvoke(NAMES.mainWindow.clear_cache) export const setWindowSize = (width, height) => rendererSend(NAMES.mainWindow.set_window_size, { width, height }) -export const getProxyInfo = () => proxy.enable && proxy.host - ? `http://${proxy.username}:${proxy.password}@${proxy.host}:${proxy.port};` - : undefined +export const getProxyInfo = () => { + return proxy.enable && proxy.host + ? `http://${proxy.username}:${proxy.password}@${proxy.host}:${proxy.port};` + : proxy.envProxy + ? `http://${proxy.envProxy.host}:${proxy.envProxy.port};` + : undefined +} export const assertApiSupport = source => qualityList.value[source] != undefined diff --git a/src/renderer/views/setting/components/SettingNetwork.vue b/src/renderer/views/setting/components/SettingNetwork.vue index 1d57a4f9..25a9b6a0 100644 --- a/src/renderer/views/setting/components/SettingNetwork.vue +++ b/src/renderer/views/setting/components/SettingNetwork.vue @@ -6,8 +6,8 @@ dd p base-checkbox(id="setting_network_proxy_enable" v-model="currentStting.network.proxy.enable" :label="$t('setting__is_enable')") p - base-input.gap-left(v-model.trim="currentStting.network.proxy.host" :placeholder="$t('setting__network_proxy_host')") - base-input.gap-left(v-model.trim="currentStting.network.proxy.port" :placeholder="$t('setting__network_proxy_port')") + base-input.gap-left(v-model.trim="currentStting.network.proxy.host" :placeholder="proxy.envProxy ? proxy.envProxy.host : $t('setting__network_proxy_host')") + base-input.gap-left(v-model.trim="currentStting.network.proxy.port" :placeholder="proxy.envProxy ? proxy.envProxy.port : $t('setting__network_proxy_port')") p base-input.gap-left(v-model.trim="currentStting.network.proxy.username" :placeholder="$t('setting__network_proxy_username')") base-input.gap-left(v-model.trim="currentStting.network.proxy.password" type="password" :placeholder="$t('setting__network_proxy_password')") @@ -51,6 +51,7 @@ export default { return { currentStting, + proxy, } }, }