Skip to content

Commit 844e4ca

Browse files
committed
fix: 增加透传请求的User-Agent开关的判断逻辑(透传时禁用自定义 UA)
1 parent 9f55029 commit 844e4ca

File tree

4 files changed

+28
-3
lines changed

4 files changed

+28
-3
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.79",
3+
"version": "2.15.80",
44
"private": true,
55
"scripts": {
66
"dev": "vite --host",

src/locales/en.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@ export default {
333333
ua: {
334334
label: "User-Agent",
335335
placeholder: "The User-Agent for downloading resource(s)",
336+
placeholderDisabled: 'Disable custom UA when passing through',
336337
},
337338
subUserinfo: {
338339
label: "Subscription-Userinfo",

src/locales/zh.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,7 @@ export default {
351351
ua: {
352352
label: 'User-Agent',
353353
placeholder: '下载时使用的 UA,不填使用默认',
354+
placeholderDisabled: '透传时禁用自定义 UA',
354355
},
355356
subUserinfo: {
356357
label: '订阅流量信息',

src/views/SubEditor.vue

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@
215215
v-if="form.source === 'remote'"
216216
>
217217
<div class="switch-wrapper">
218-
<nut-switch v-model="form.passThroughUA" />
218+
<nut-switch v-model="form.passThroughUA" @change="handlePassThroughUAChange"/>
219219
</div>
220220
</nut-form-item>
221221
<nut-form-item
@@ -227,10 +227,11 @@
227227
:border="false"
228228
class="nut-input-text"
229229
v-model.trim="form.ua"
230-
:placeholder="$t(`editorPage.subConfig.basic.ua.placeholder`)"
230+
:placeholder="userAgentPlaceholder"
231231
type="text"
232232
input-align="right"
233233
left-icon="tips"
234+
:readonly="passThroughUAOn"
234235
@click-left-icon="uaTips"
235236
/>
236237
</nut-form-item>
@@ -906,6 +907,28 @@ const compare = () => {
906907
});
907908
};
908909
910+
const passThroughUAOn = computed(() => {
911+
return form.source === "remote" && form.passThroughUA;
912+
});
913+
914+
const userAgentPlaceholder = computed(() => {
915+
return passThroughUAOn.value
916+
? t(`editorPage.subConfig.basic.ua.placeholderDisabled`)
917+
: t(`editorPage.subConfig.basic.ua.placeholder`);
918+
});
919+
920+
const handlePassThroughUAChange = (val) => {
921+
if (val) {
922+
form._savedUA = form.ua;
923+
form.ua = "";
924+
} else {
925+
if (form._savedUA !== undefined) {
926+
form.ua = form._savedUA;
927+
form._savedUA = undefined;
928+
}
929+
}
930+
};
931+
909932
const submit = () => {
910933
if (isget.value) {
911934
showNotify({

0 commit comments

Comments
 (0)