Skip to content

Commit 1c9ae2a

Browse files
committed
feat: 支持 GitHub 加速代理(前端需 >= 2.15.58)
1 parent 22e39dc commit 1c9ae2a

3 files changed

Lines changed: 13 additions & 5 deletions

File tree

backend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sub-store",
3-
"version": "2.19.96",
3+
"version": "2.19.97",
44
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and Shadowrocket.",
55
"main": "src/main.js",
66
"scripts": {

backend/src/restful/settings.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ async function updateSettings(req, res) {
6161

6262
export async function updateAvatar() {
6363
const settings = $.read(SETTINGS_KEY);
64-
const { githubUser: username, syncPlatform } = settings;
64+
const { githubUser: username, syncPlatform, githubProxy } = settings;
6565
if (username) {
6666
if (syncPlatform === 'gitlab') {
6767
try {
@@ -92,7 +92,9 @@ export async function updateAvatar() {
9292
try {
9393
const data = await $.http
9494
.get({
95-
url: `https://api.github.com/users/${encodeURIComponent(
95+
url: `${
96+
githubProxy ? `${githubProxy}/` : ''
97+
}https://api.github.com/users/${encodeURIComponent(
9698
username,
9799
)}`,
98100
headers: {

backend/src/utils/gist.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ import { SETTINGS_KEY } from '@/constants';
99
export default class Gist {
1010
constructor({ token, key, syncPlatform }) {
1111
const { isStash, isLoon, isShadowRocket, isQX } = ENV();
12-
const { defaultProxy, defaultTimeout: timeout } = $.read(SETTINGS_KEY);
12+
const {
13+
defaultProxy,
14+
defaultTimeout: timeout,
15+
githubProxy,
16+
} = $.read(SETTINGS_KEY);
1317
let proxy = defaultProxy;
1418
if ($.env.isNode) {
1519
proxy =
@@ -63,7 +67,9 @@ export default class Gist {
6367
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.141 Safari/537.36',
6468
};
6569
this.http = HTTP({
66-
baseURL: 'https://api.github.com',
70+
baseURL: `${
71+
githubProxy ? `${githubProxy}/` : ''
72+
}https://api.github.com`,
6773
headers: {
6874
...this.headers,
6975
...(isStash && proxy

0 commit comments

Comments
 (0)