mirror of
https://github.com/qier222/YesPlayMusic.git
synced 2025-02-24 06:40:55 +08:00
fix: proxy issue
This commit is contained in:
parent
cc6b364b87
commit
5b6619d1de
@ -247,6 +247,14 @@ class Background {
|
||||
// init ipcMain
|
||||
initIpcMain(this.window, this.store);
|
||||
|
||||
// set proxy
|
||||
const proxyRules = this.store.get('proxy');
|
||||
if (proxyRules) {
|
||||
this.window.webContents.session.setProxy({ proxyRules }, result => {
|
||||
console.log('finished setProxy', result);
|
||||
});
|
||||
}
|
||||
|
||||
// check for updates
|
||||
this.checkForUpdates();
|
||||
|
||||
|
@ -105,8 +105,8 @@ export function initIpcMain(win, store) {
|
||||
});
|
||||
|
||||
ipcMain.on('setProxy', (event, config) => {
|
||||
console.log(config);
|
||||
const proxyRules = `${config.protocol}://${config.server}:${config.port}`;
|
||||
store.set('proxy', proxyRules);
|
||||
win.webContents.session.setProxy(
|
||||
{
|
||||
proxyRules,
|
||||
@ -120,5 +120,6 @@ export function initIpcMain(win, store) {
|
||||
ipcMain.on('removeProxy', (event, arg) => {
|
||||
console.log('removeProxy');
|
||||
win.webContents.session.setProxy({});
|
||||
store.set('proxy', '');
|
||||
});
|
||||
}
|
||||
|
@ -24,6 +24,12 @@ service.interceptors.request.use(function (config) {
|
||||
if (baseURL[0] !== '/' && !process.env.IS_ELECTRON) {
|
||||
config.params.cookie = `MUSIC_U=${Cookies.get('MUSIC_U')};`;
|
||||
}
|
||||
|
||||
const proxy = JSON.parse(localStorage.getItem('settings')).proxyConfig;
|
||||
if (['HTTP', 'HTTPS'].includes(proxy.protocol)) {
|
||||
config.params.proxy = `${proxy.protocol}://${proxy.server}:${proxy.port}`;
|
||||
}
|
||||
|
||||
return config;
|
||||
});
|
||||
|
||||
|
@ -362,7 +362,7 @@
|
||||
<option value="noProxy"> 关闭代理 </option>
|
||||
<option value="HTTP"> HTTP 代理 </option>
|
||||
<option value="HTTPS"> HTTPS 代理 </option>
|
||||
<option value="SOCKS"> SOCKS 代理 </option>
|
||||
<!-- <option value="SOCKS"> SOCKS 代理 </option> -->
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user