feat: 支持 GitHub 加速代理(前端需 >= 2.15.58)

This commit is contained in:
xream
2025-07-28 14:31:39 +08:00
parent 22e39dc18f
commit 1c9ae2a079
3 changed files with 13 additions and 5 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "sub-store",
"version": "2.19.96",
"version": "2.19.97",
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and Shadowrocket.",
"main": "src/main.js",
"scripts": {

View File

@@ -61,7 +61,7 @@ async function updateSettings(req, res) {
export async function updateAvatar() {
const settings = $.read(SETTINGS_KEY);
const { githubUser: username, syncPlatform } = settings;
const { githubUser: username, syncPlatform, githubProxy } = settings;
if (username) {
if (syncPlatform === 'gitlab') {
try {
@@ -92,7 +92,9 @@ export async function updateAvatar() {
try {
const data = await $.http
.get({
url: `https://api.github.com/users/${encodeURIComponent(
url: `${
githubProxy ? `${githubProxy}/` : ''
}https://api.github.com/users/${encodeURIComponent(
username,
)}`,
headers: {

View File

@@ -9,7 +9,11 @@ import { SETTINGS_KEY } from '@/constants';
export default class Gist {
constructor({ token, key, syncPlatform }) {
const { isStash, isLoon, isShadowRocket, isQX } = ENV();
const { defaultProxy, defaultTimeout: timeout } = $.read(SETTINGS_KEY);
const {
defaultProxy,
defaultTimeout: timeout,
githubProxy,
} = $.read(SETTINGS_KEY);
let proxy = defaultProxy;
if ($.env.isNode) {
proxy =
@@ -63,7 +67,9 @@ export default class Gist {
'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',
};
this.http = HTTP({
baseURL: 'https://api.github.com',
baseURL: `${
githubProxy ? `${githubProxy}/` : ''
}https://api.github.com`,
headers: {
...this.headers,
...(isStash && proxy