fix: 解决代理选项为空的问题 (#5300)

This commit is contained in:
ssongliu 2024-06-05 16:18:09 +08:00 committed by GitHub
parent 546bc53f28
commit dba5302d68
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 3 deletions

View file

@ -45,6 +45,7 @@ export const updateProxy = (params: Setting.ProxyUpdate) => {
if (request.proxyPasswd) {
request.proxyPasswd = Base64.encode(request.proxyPasswd);
}
request.proxyType = request.proxyType === 'close' ? '' : request.proxyType;
return http.post(`/settings/proxy/update`, request);
};

View file

@ -25,7 +25,7 @@
</el-alert>
<el-form-item :label="$t('setting.proxyType')" prop="proxyType">
<el-select v-model="form.proxyType" clearable>
<el-option value="" :label="$t('commons.button.close')" />
<el-option value="close" :label="$t('commons.button.close')" />
<el-option value="socks5" label="SOCKS5" />
<el-option value="http" label="HTTP" />
<el-option value="https" label="HTTPS" />
@ -80,6 +80,7 @@ const { isProductPro } = storeToRefs(globalStore);
const formRef = ref<FormInstance>();
const rules = reactive({
proxyType: [Rules.requiredSelect],
proxyUrl: [Rules.noSpace, Rules.requiredInput],
proxyPortItem: [Rules.port],
});
@ -107,7 +108,7 @@ interface DialogProps {
}
const acceptParams = (params: DialogProps): void => {
form.proxyUrl = params.url || '127.0.0.1';
form.proxyType = params.type;
form.proxyType = params.type || 'close';
form.proxyPortItem = params.port ? Number(params.port) : 7890;
form.proxyUser = params.user;
form.proxyPasswd = params.passwd;
@ -119,7 +120,7 @@ const submitChangePassword = async (formEl: FormInstance | undefined) => {
if (!formEl) return;
formEl.validate(async (valid) => {
if (!valid) return;
if (!form.proxyType) {
if (form.proxyType === '' || form.proxyType === 'close') {
form.proxyUrl = '';
form.proxyPort = '';
form.proxyUser = '';