Skip to content

Commit 92871e7

Browse files
committed
feat: 支持 GitHub 加速代理(后端需 >= 2.19.97)
1 parent e349148 commit 92871e7

File tree

7 files changed

+40
-2
lines changed

7 files changed

+40
-2
lines changed

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-front-end",
3-
"version": "2.15.57",
3+
"version": "2.15.59",
44
"private": true,
55
"scripts": {
66
"dev": "vite --host",

src/assets/icons/githubProxy.svg

Lines changed: 1 addition & 0 deletions
Loading

src/locales/en.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,12 +591,14 @@ export default {
591591
haveNotDownload: "Not download yet",
592592
githubUser: "Please input GitHub username",
593593
gistToken: "Please input Gist Token",
594+
githubProxy: "Please input GitHub Proxy",
594595
defaultUserAgent: "Please input Default User-Agent",
595596
defaultProxy: "Please input Default Proxy/Policy",
596597
defaultTimeout: "Default Timeout (in milliseconds, default: 8000)",
597598
cacheThreshold: "Cache Threshold (in KB, default: 1024)",
598599
noGithubUser: "Not set GitHub username",
599600
noGistToken: "Not set Gist Token",
601+
noGithubProxy: "Not set GitHub Proxy",
600602
noDefaultUserAgent: "Not set default user-agent",
601603
noDefaultProxy: "Not set default proxy/policy",
602604
noDefaultTimeout: "Not set default timeout",

src/locales/zh.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -586,12 +586,14 @@ export default {
586586
haveNotDownload: '暂无下载记录',
587587
githubUser: '请输入 GitHub 用户名',
588588
gistToken: '请输入 GitHub 令牌',
589+
githubProxy: '请输入 GitHub 加速代理',
589590
defaultUserAgent: '请输入默认 User-Agent',
590591
defaultProxy: '请输入默认代理/策略',
591592
defaultTimeout: '默认超时(单位: 毫秒, 默认: 8000)',
592593
cacheThreshold: '缓存阈值(单位: KB, 默认: 1024)',
593594
noGithubUser: '未配置 GitHub 用户名',
594595
noGistToken: '未配置 GitHub 令牌',
596+
noGithubProxy: '未配置 GitHub 加速代理',
595597
noDefaultUserAgent: '未配置默认 User-Agent',
596598
noDefaultProxy: '未配置默认代理/策略',
597599
noDefaultTimeout: '未配置默认超时',

src/store/settings.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export const useSettingsStore = defineStore("settingsStore", {
1515
return {
1616
syncPlatform: "",
1717
gistToken: "",
18+
githubProxy: "",
1819
githubUser: "",
1920
defaultUserAgent: "",
2021
defaultProxy: "",
@@ -58,6 +59,7 @@ export const useSettingsStore = defineStore("settingsStore", {
5859
if (res?.data?.status === "success" && res?.data?.data) {
5960
this.syncPlatform = res.data.data.syncPlatform || "";
6061
this.gistToken = res.data.data.gistToken || "";
62+
this.githubProxy = res.data.data.githubProxy || "";
6163
this.githubUser = res.data.data.githubUser || "";
6264
this.defaultProxy = res.data.data.defaultProxy || "";
6365
this.defaultUserAgent = res.data.data.defaultUserAgent || "";
@@ -100,6 +102,7 @@ export const useSettingsStore = defineStore("settingsStore", {
100102
if (res?.data?.status === "success" && res?.data?.data) {
101103
this.syncPlatform = res.data.data.syncPlatform || "";
102104
this.gistToken = res.data.data.gistToken || "";
105+
this.githubProxy = res.data.data.githubProxy || "";
103106
this.githubUser = res.data.data.githubUser || "";
104107
this.defaultProxy = res.data.data.defaultProxy || "";
105108
this.defaultUserAgent = res.data.data.defaultUserAgent || "";

src/types/store/settings.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ interface SettingsBase {
1111
interface SettingsPostData {
1212
syncPlatform?: string;
1313
gistToken?: string;
14+
githubProxy?: string;
1415
githubUser?: string;
1516
defaultProxy?: string;
1617
defaultUserAgent?: string;

src/views/My.vue

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,18 @@
173173
input-align="left"
174174
:left-icon="iconKey"
175175
/>
176+
<nut-input
177+
v-if="storageType !== 'manual'"
178+
class="input"
179+
v-model="githubProxyInput"
180+
:disabled="!isEditing"
181+
:placeholder="$t(`myPage.placeholder.githubProxy`)"
182+
type="text"
183+
input-align="left"
184+
:left-icon="icongithubProxy"
185+
right-icon="tips"
186+
@click-right-icon="githubProxyTips"
187+
/>
176188
<nut-input
177189
class="input"
178190
v-model="proxyInput"
@@ -275,6 +287,7 @@ import avatar from "@/assets/icons/avatar.svg?url";
275287
import iconKey from "@/assets/icons/key-solid.png";
276288
import iconUser from "@/assets/icons/user-solid.png";
277289
import iconProxy from "@/assets/icons/proxy.svg";
290+
import icongithubProxy from "@/assets/icons/githubProxy.svg";
278291
import iconUA from "@/assets/icons/user-agent.svg";
279292
import iconMax from "@/assets/icons/max.svg";
280293
import iconTimeout from "@/assets/icons/timeout.svg";
@@ -298,7 +311,7 @@ const router = useRouter();
298311
const { showNotify } = useAppNotifyStore();
299312
const { currentUrl: host } = useHostAPI();
300313
const settingsStore = useSettingsStore();
301-
const { githubUser, gistToken, syncTime, avatarUrl, defaultUserAgent, defaultProxy, defaultTimeout, cacheThreshold, syncPlatform } =
314+
const { githubUser, gistToken, syncTime, avatarUrl, defaultUserAgent, defaultProxy, defaultTimeout, cacheThreshold, syncPlatform, githubProxy } =
302315
storeToRefs(settingsStore);
303316
304317
const displayAvatar = computed(() => {
@@ -330,6 +343,7 @@ const onClickAbout = () => {
330343
const syncPlatformInput = ref("");
331344
const userInput = ref("");
332345
const tokenInput = ref("");
346+
const githubProxyInput = ref("");
333347
const uaInput = ref("");
334348
const proxyInput = ref("");
335349
const timeoutInput = ref("");
@@ -347,6 +361,7 @@ const toggleEditMode = async () => {
347361
syncPlatform: syncPlatformInput.value,
348362
githubUser: userInput.value,
349363
gistToken: tokenInput.value,
364+
githubProxy: githubProxyInput.value,
350365
defaultUserAgent: uaInput.value,
351366
defaultProxy: proxyInput.value,
352367
defaultTimeout: timeoutInput.value,
@@ -357,6 +372,7 @@ const toggleEditMode = async () => {
357372
syncPlatformInput.value = syncPlatform.value;
358373
userInput.value = githubUser.value;
359374
tokenInput.value = gistToken.value;
375+
githubProxyInput.value = githubProxy.value;
360376
uaInput.value = defaultUserAgent.value;
361377
proxyInput.value = defaultProxy.value;
362378
timeoutInput.value = defaultTimeout.value;
@@ -400,6 +416,7 @@ const toggleSyncPlatform = () => {
400416
const setDisplayInfo = () => {
401417
syncPlatformInput.value = syncPlatform.value || "";
402418
userInput.value = githubUser.value || "";
419+
githubProxyInput.value = githubProxy.value || "";
403420
tokenInput.value = gistToken.value
404421
? `${gistToken.value.slice(0, 6)}************`
405422
: "";
@@ -550,6 +567,18 @@ const downloadBtn = () => {
550567
lockScroll: false,
551568
});
552569
}
570+
const githubProxyTips = () => {
571+
Dialog({
572+
title: '请填写完整 GitHub 加速代理地址',
573+
content: '后端需 >= 2.19.97\n\n1. 仅用于上传/下载 Gist 和获取 GitHub 头像\n\n2. 请填写完整 如 https://a.com\n\n3. 需支持代理 https://api.github.com\n\n测试方式:\n浏览器打开\nhttps://a.com/https://api.github.com/users/xream\n有正常的响应\n\n3. 使用此方式时, 自行注意安全隐私问题',
574+
popClass: 'auto-dialog',
575+
textAlign: 'left',
576+
okText: 'OK',
577+
noCancelBtn: true,
578+
closeOnPopstate: true,
579+
lockScroll: false,
580+
});
581+
};
553582
const proxyTips = () => {
554583
Dialog({
555584
title: '通过代理/节点/策略进行下载',

0 commit comments

Comments
 (0)