修复启用代理时,https请求可能被挂起或被转为http的问题
parent
2e5adeb50c
commit
f65213f8aa
File diff suppressed because it is too large
Load Diff
12
package.json
12
package.json
|
@ -178,7 +178,7 @@
|
|||
},
|
||||
"homepage": "https://github.com/lyswhut/lx-music-desktop#readme",
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.17.8",
|
||||
"@babel/core": "^7.17.9",
|
||||
"@babel/eslint-parser": "^7.17.0",
|
||||
"@babel/plugin-proposal-class-properties": "^7.16.7",
|
||||
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
||||
|
@ -201,17 +201,16 @@
|
|||
"electron-builder": "^23.0.3",
|
||||
"electron-debug": "^3.2.0",
|
||||
"electron-devtools-installer": "^3.2.0",
|
||||
"electron-to-chromium": "^1.4.103",
|
||||
"electron-to-chromium": "^1.4.105",
|
||||
"electron-updater": "^5.0.0",
|
||||
"eslint": "^8.12.0",
|
||||
"eslint-config-standard": "^16.0.3",
|
||||
"eslint-formatter-friendly": "git+https://github.com/lyswhut/eslint-friendly-formatter.git#2170d1320e2fad13615a9dcf229669f0bb473a53",
|
||||
"eslint-plugin-html": "^6.2.0",
|
||||
"eslint-plugin-import": "^2.25.4",
|
||||
"eslint-plugin-import": "^2.26.0",
|
||||
"eslint-plugin-node": "^11.1.0",
|
||||
"eslint-plugin-promise": "^6.0.0",
|
||||
"eslint-plugin-standard": "^4.1.0",
|
||||
"eslint-plugin-vue": "^8.5.0",
|
||||
"eslint-webpack-plugin": "^3.1.1",
|
||||
"file-loader": "^6.2.0",
|
||||
"html-webpack-plugin": "^5.5.0",
|
||||
|
@ -238,7 +237,7 @@
|
|||
"vue-template-compiler": "^2.6.14",
|
||||
"webpack": "^5.71.0",
|
||||
"webpack-cli": "^4.9.2",
|
||||
"webpack-dev-server": "^4.7.4",
|
||||
"webpack-dev-server": "^4.8.1",
|
||||
"webpack-hot-middleware": "git+https://github.com/lyswhut/webpack-hot-middleware#329c4375134b89d39da23a56a94db651247c74a1",
|
||||
"webpack-merge": "^5.8.0"
|
||||
},
|
||||
|
@ -259,9 +258,10 @@
|
|||
"request": "^2.88.2",
|
||||
"socket.io": "^4.4.1",
|
||||
"sortablejs": "^1.15.0",
|
||||
"tunnel": "^0.0.6",
|
||||
"utf-8-validate": "^5.0.9",
|
||||
"vue": "^3.2.31",
|
||||
"vue-i18n": "^9.2.0-beta.33",
|
||||
"vue-i18n": "^9.2.0-beta.34",
|
||||
"vue-router": "^4.0.14",
|
||||
"vuex": "^4.0.2"
|
||||
},
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
- 修复wy源搜索某些歌曲时第一页之后的歌曲无法加载的问题
|
||||
- 修复使用Scheme URL搜索歌曲时,不会自动关闭播放详情页(若处于打开状态)的问题
|
||||
- 修复换源失败时的处理问题
|
||||
- 修复启用代理时,https请求可能被挂起或被转为http的问题
|
||||
|
||||
### 变更
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import { shell, clipboard } from 'electron'
|
||||
import { httpOverHttp, httpsOverHttp } from 'tunnel'
|
||||
import crypto from 'crypto'
|
||||
import { rendererSend, rendererInvoke, NAMES } from '@common/ipc'
|
||||
import { log } from '@common/utils'
|
||||
|
@ -451,12 +452,33 @@ export const setWindowSize = (width, height) => rendererSend(NAMES.mainWindow.se
|
|||
|
||||
export const getProxyInfo = () => {
|
||||
return proxy.enable && proxy.host
|
||||
? `http://${proxy.username}:${proxy.password}@${proxy.host}:${proxy.port};`
|
||||
? `http://${proxy.username}:${proxy.password}@${proxy.host}:${proxy.port}`
|
||||
: proxy.envProxy
|
||||
? `http://${proxy.envProxy.host}:${proxy.envProxy.port};`
|
||||
? `http://${proxy.envProxy.host}:${proxy.envProxy.port}`
|
||||
: undefined
|
||||
}
|
||||
|
||||
const httpsRxp = /^https:/
|
||||
export const getRequestAgent = url => {
|
||||
let options
|
||||
if (proxy.enable && proxy.host) {
|
||||
options = {
|
||||
proxy: {
|
||||
host: proxy.host,
|
||||
port: proxy.port,
|
||||
},
|
||||
}
|
||||
} else if (proxy.envProxy) {
|
||||
options = {
|
||||
proxy: {
|
||||
host: proxy.envProxy.host,
|
||||
port: proxy.envProxy.port,
|
||||
},
|
||||
}
|
||||
}
|
||||
return options ? (httpsRxp.test(url) ? httpsOverHttp : httpOverHttp)(options) : undefined
|
||||
}
|
||||
|
||||
|
||||
export const assertApiSupport = source => qualityList.value[source] != undefined
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import { debugRequest } from './env'
|
|||
import { requestMsg } from './message'
|
||||
import { bHh } from './music/options'
|
||||
import { deflateRaw } from 'zlib'
|
||||
import { getProxyInfo } from './index'
|
||||
import { getRequestAgent } from './index'
|
||||
// import fs from 'fs'
|
||||
|
||||
const request = (url, options, callback) => {
|
||||
|
@ -277,7 +277,7 @@ const fetchData = async(url, method, {
|
|||
method,
|
||||
headers: Object.assign({}, defaultHeaders, headers),
|
||||
timeout,
|
||||
proxy: getProxyInfo(),
|
||||
agent: getRequestAgent(url),
|
||||
json: format === 'json',
|
||||
}, (err, resp, body) => {
|
||||
if (err) return callback(err, null)
|
||||
|
|
Loading…
Reference in New Issue