Skip to content

Commit

Permalink
feat: 新增全局代理/策略设置, 后端 > 2.14.386
Browse files Browse the repository at this point in the history
  • Loading branch information
xream committed Oct 7, 2024
1 parent 78d25a2 commit ea05103
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sub-store-front-end",
"version": "2.14.265",
"version": "2.14.266",
"private": true,
"scripts": {
"dev": "vite --host",
Expand Down
1 change: 1 addition & 0 deletions src/assets/icons/proxy.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions src/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -473,11 +473,13 @@ export default {
githubUser: 'Please input GitHub username',
gistToken: 'Please input Gist Token',
defaultUserAgent: 'Please input Default User-Agent',
defaultProxy: 'Please input Default Proxy/Policy',
defaultTimeout: 'Please input Default Timeout (in milliseconds)',
cacheThreshold: 'Please input Cache Threshold (in KB)',
noGithubUser: 'Not set GitHub username',
noGistToken: 'Not set Gist Token',
noDefaultUserAgent: 'Not set default user-agent',
noDefaultProxy: 'Not set default proxy/policy',
noDefaultTimeout: 'Not set default timeout',
noCacheThreshold: 'Not set cache threshold',
},
Expand Down
4 changes: 3 additions & 1 deletion src/locales/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ export default {
},
proxy: {
label: '代理/策略',
placeholder: '通过代理/节点/策略获取订阅',
placeholder: '通过代理/节点/策略获取订阅,不填使用默认',
},
},
commonOptions: {
Expand Down Expand Up @@ -475,11 +475,13 @@ export default {
githubUser: '请输入 GitHub 用户名',
gistToken: '请输入 GitHub 令牌',
defaultUserAgent: '请输入默认 User-Agent',
defaultProxy: '请输入默认代理/策略',
defaultTimeout: '请输入默认超时(单位: 毫秒)',
cacheThreshold: '请输入缓存阈值(单位: KB)',
noGithubUser: '未配置 GitHub 用户名',
noGistToken: '未配置 GitHub 令牌',
noDefaultUserAgent: '未配置默认 User-Agent',
noDefaultProxy: '未配置默认代理/策略',
noDefaultTimeout: '未配置默认超时',
noCacheThreshold: '未配置缓存阈值',
},
Expand Down
3 changes: 3 additions & 0 deletions src/store/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const useSettingsStore = defineStore("settingsStore", {
gistToken: "",
githubUser: "",
defaultUserAgent: "",
defaultProxy: "",
defaultTimeout: "",
cacheThreshold: "",
syncTime: 0,
Expand Down Expand Up @@ -53,6 +54,7 @@ export const useSettingsStore = defineStore("settingsStore", {
this.syncPlatform = res.data.data.syncPlatform || "";
this.gistToken = res.data.data.gistToken || "";
this.githubUser = res.data.data.githubUser || "";
this.defaultProxy = res.data.data.defaultProxy || "";
this.defaultUserAgent = res.data.data.defaultUserAgent || "";
this.defaultTimeout = res.data.data.defaultTimeout || "";
this.cacheThreshold = res.data.data.cacheThreshold || "";
Expand Down Expand Up @@ -90,6 +92,7 @@ export const useSettingsStore = defineStore("settingsStore", {
this.syncPlatform = res.data.data.syncPlatform || "";
this.gistToken = res.data.data.gistToken || "";
this.githubUser = res.data.data.githubUser || "";
this.defaultProxy = res.data.data.defaultProxy || "";
this.defaultUserAgent = res.data.data.defaultUserAgent || "";
this.defaultTimeout = res.data.data.defaultTimeout || "";
this.cacheThreshold = res.data.data.cacheThreshold || "";
Expand Down
1 change: 1 addition & 0 deletions src/types/store/settings.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ interface SettingsPostData {
syncPlatform?: string;
gistToken?: string;
githubUser?: string;
defaultProxy?: string;
defaultUserAgent?: string;
defaultTimeout?: string;
cacheThreshold?: string;
Expand Down
30 changes: 29 additions & 1 deletion src/views/My.vue
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,17 @@
input-align="left"
:left-icon="iconKey"
/>
<nut-input
class="input"
v-model="proxyInput"
:disabled="!isEditing"
:placeholder="$t(`myPage.placeholder.defaultProxy`)"
type="text"
input-align="left"
:left-icon="iconProxy"
right-icon="tips"
@click-right-icon="proxyTips"
/>
<nut-input
class="input"
v-model="uaInput"
Expand Down Expand Up @@ -257,6 +268,7 @@ import { useSettingsApi } from "@/api/settings";
import avatar from "@/assets/icons/avatar.svg?url";
import iconKey from "@/assets/icons/key-solid.png";
import iconUser from "@/assets/icons/user-solid.png";
import iconProxy from "@/assets/icons/proxy.svg";
import iconUA from "@/assets/icons/user-agent.svg";
import iconMax from "@/assets/icons/max.svg";
import iconTimeout from "@/assets/icons/timeout.svg";
Expand All @@ -280,7 +292,7 @@ const router = useRouter();
const { showNotify } = useAppNotifyStore();
const { currentUrl: host } = useHostAPI();
const settingsStore = useSettingsStore();
const { githubUser, gistToken, syncTime, avatarUrl, defaultUserAgent, defaultTimeout, cacheThreshold, syncPlatform } =
const { githubUser, gistToken, syncTime, avatarUrl, defaultUserAgent, defaultProxy, defaultTimeout, cacheThreshold, syncPlatform } =
storeToRefs(settingsStore);
const displayAvatar = computed(() => {
Expand All @@ -306,6 +318,7 @@ const syncPlatformInput = ref("");
const userInput = ref("");
const tokenInput = ref("");
const uaInput = ref("");
const proxyInput = ref("");
const timeoutInput = ref("");
const cacheThresholdInput = ref("");
const isEditing = ref(false);
Expand All @@ -322,6 +335,7 @@ const toggleEditMode = async () => {
githubUser: userInput.value,
gistToken: tokenInput.value,
defaultUserAgent: uaInput.value,
defaultProxy: proxyInput.value,
defaultTimeout: timeoutInput.value,
cacheThreshold: cacheThresholdInput.value,
});
Expand All @@ -331,6 +345,7 @@ const toggleEditMode = async () => {
userInput.value = githubUser.value;
tokenInput.value = gistToken.value;
uaInput.value = defaultUserAgent.value;
proxyInput.value = defaultProxy.value;
timeoutInput.value = defaultTimeout.value;
cacheThresholdInput.value = cacheThreshold.value;
}
Expand Down Expand Up @@ -376,6 +391,7 @@ const setDisplayInfo = () => {
? gistToken.value.slice(0, 6) + "************"
: t(`myPage.placeholder.noGistToken`);
uaInput.value = defaultUserAgent.value || t(`myPage.placeholder.noDefaultUserAgent`);
proxyInput.value = defaultProxy.value || t(`myPage.placeholder.noDefaultProxy`);
timeoutInput.value = defaultTimeout.value || t(`myPage.placeholder.noDefaultTimeout`);
cacheThresholdInput.value = cacheThreshold.value || t(`myPage.placeholder.noCacheThreshold`);
};
Expand Down Expand Up @@ -478,6 +494,18 @@ const sync = async (query: "download" | "upload") => {
downloadIsLoading.value = false;
uploadIsLoading.value = false;
};
const proxyTips = () => {
Dialog({
title: '通过代理/节点/策略进行下载',
content: '1. Surge(参数 policy/policy-descriptor)\n\n可设置节点代理 例: Test = snell, 1.2.3.4, 80, psk=password, version=4\n\n或设置策略/节点 例: 国外加速\n\n2. Loon(参数 node)\n\nLoon 官方文档: \n\n指定该请求使用哪一个节点或者策略组(可以使节点名称、策略组名称,也可以说是一个Loon格式的节点描述,如:shadowsocksr,example.com,1070,chacha20-ietf,"password",protocol=auth_aes128_sha1,protocol-param=test,obfs=plain,obfs-param=edge.microsoft.com)\n\n3. Stash(参数 headers["X-Surge-Policy"])/Shadowrocket(参数 headers.X-Surge-Policy)/QX(参数 opts.policy)\n\n可设置策略/节点\n\n4. Node.js 版(模块 request 的 proxy 参数):\n\n例: http://127.0.0.1:8888',
popClass: 'auto-dialog',
textAlign: 'left',
okText: 'OK',
noCancelBtn: true,
closeOnPopstate: true,
lockScroll: false,
});
};
const uaTips = () => {
Dialog({
title: '默认为 clash.meta',
Expand Down
2 changes: 1 addition & 1 deletion src/views/SubEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,7 @@ const urlValidator = (val: string): Promise<boolean> => {
const proxyTips = () => {
Dialog({
title: '通过代理/节点/策略获取订阅',
content: '1. Surge(需使用 有 ability=http-client-policy 的模块, 参数 policy/policy-descriptor)\n\n可设置节点代理 例: Test = snell, 1.2.3.4, 80, psk=password, version=4\n\n或设置策略/节点 例: 国外加速\n\n2. Loon(参数 node)\n\nLoon 官方文档: \n\n指定该请求使用哪一个节点或者策略组(可以使节点名称、策略组名称,也可以说是一个Loon格式的节点描述,如:shadowsocksr,example.com,1070,chacha20-ietf,"password",protocol=auth_aes128_sha1,protocol-param=test,obfs=plain,obfs-param=edge.microsoft.com)\n\n3. Stash(参数 headers["X-Surge-Policy"])/Shadowrocket(参数 headers.X-Surge-Policy)/QX(参数 opts.policy)\n\n可设置策略/节点\n\n4. Node.js 版(模块 request 的 proxy 参数):\n\n例: http://127.0.0.1:8888',
content: '1. Surge(参数 policy/policy-descriptor)\n\n可设置节点代理 例: Test = snell, 1.2.3.4, 80, psk=password, version=4\n\n或设置策略/节点 例: 国外加速\n\n2. Loon(参数 node)\n\nLoon 官方文档: \n\n指定该请求使用哪一个节点或者策略组(可以使节点名称、策略组名称,也可以说是一个Loon格式的节点描述,如:shadowsocksr,example.com,1070,chacha20-ietf,"password",protocol=auth_aes128_sha1,protocol-param=test,obfs=plain,obfs-param=edge.microsoft.com)\n\n3. Stash(参数 headers["X-Surge-Policy"])/Shadowrocket(参数 headers.X-Surge-Policy)/QX(参数 opts.policy)\n\n可设置策略/节点\n\n4. Node.js 版(模块 request 的 proxy 参数):\n\n例: http://127.0.0.1:8888',
popClass: 'auto-dialog',
textAlign: 'left',
okText: 'OK',
Expand Down

0 comments on commit ea05103

Please sign in to comment.