Browse Source

optimize: 检查更新和获取远程配置功能,避免被GFW拦截。

pull/333/head
王良 3 months ago
parent
commit
20b21843c4
  1. 7
      packages/core/src/config.js
  2. 2
      packages/gui/src/bridge/update/backend.js

7
packages/core/src/config.js

@ -59,7 +59,12 @@ const configApi = {
// eslint-disable-next-line handle-callback-err
return new Promise((resolve, reject) => {
log.info('开始下载远程配置:', remoteConfigUrl)
request(remoteConfigUrl, (error, response, body) => {
const headers = {}
if (remoteConfigUrl.startsWith('https://raw.githubusercontent.com/')) {
headers['Server-Name'] = 'baidu.com'
}
request(remoteConfigUrl, headers, (error, response, body) => {
if (error) {
log.error('下载远程配置失败, error:', error, ', response:', response, ', body:', body)
reject(error)

2
packages/gui/src/bridge/update/backend.js

@ -141,7 +141,7 @@ function updateHandle (app, api, win, beforeQuit, quit, log) {
// 检查更新
const releasesApiUrl = 'https://api.github.com/repos/docmirror/dev-sidecar/releases'
async function checkForUpdatesFromGitHub () {
request(releasesApiUrl, { headers: { 'User-Agent': 'DS/' + curVersion } }, (error, response, body) => {
request(releasesApiUrl, { headers: { 'User-Agent': 'DS/' + curVersion, 'Server-Name': 'baidu.com' } }, (error, response, body) => {
try {
if (error) {
log.error('检查更新失败:', error)

Loading…
Cancel
Save