fix(个人中心): 本地执行支持清空URL

This commit is contained in:
fit2-zhao 2024-03-20 17:26:59 +08:00 committed by Craftsman
parent e2190b63c4
commit f6d5b4c240
3 changed files with 41 additions and 18 deletions

View File

@ -6,21 +6,22 @@ import jakarta.validation.constraints.Size;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import java.io.Serial;
import java.io.Serializable; import java.io.Serializable;
@Data @Data
@EqualsAndHashCode(callSuper = false) @EqualsAndHashCode(callSuper = false)
public class UserLocalConfigUpdateRequest implements Serializable { public class UserLocalConfigUpdateRequest implements Serializable {
@Serial
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED) @Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED)
@NotBlank(message = "{user_local_config.id.not_blank}") @NotBlank(message = "{user_local_config.id.not_blank}")
private String id; private String id;
@Schema(description = "本地执行程序url", requiredMode = Schema.RequiredMode.REQUIRED) @Schema(description = "本地执行程序url")
@NotBlank(message = "{user_local_config.user_url.not_blank}") @Size( max = 50, message = "{user_local_config.user_url.length_range}")
@Size(min = 1, max = 50, message = "{user_local_config.user_url.length_range}")
private String userUrl; private String userUrl;

View File

@ -96,10 +96,6 @@ public class UserLocalConfigControllerTests extends BaseTest {
//不存在的 //不存在的
request.setId(UUID.randomUUID().toString()); request.setId(UUID.randomUUID().toString());
requestPost(UPDATE, request, status().is5xxServerError()); requestPost(UPDATE, request, status().is5xxServerError());
//url为空
request.setId(userLocalConfig.getId());
request.setUserUrl("");
requestPost(UPDATE, request, status().is4xxClientError());
//id为空 //id为空
request.setId(""); request.setId("");
request.setUserUrl("https://www.baidu.com"); request.setUserUrl("https://www.baidu.com");

View File

@ -25,6 +25,7 @@
@press-enter="testApi" @press-enter="testApi"
></a-input> ></a-input>
<div class="config-card-footer"> <div class="config-card-footer">
<div>
<a-button <a-button
type="outline" type="outline"
class="px-[8px]" class="px-[8px]"
@ -35,6 +36,17 @@
> >
{{ t('ms.personal.test') }} {{ t('ms.personal.test') }}
</a-button> </a-button>
<a-button
v-if="apiConfig.userUrl.trim()"
type="outline"
class="arco-btn-outline--secondary px-[8px]"
style="margin-left: 10px"
size="mini"
@click="clearApi"
>
{{ t('ms.transfer.clear') }}
</a-button>
</div>
<div class="flex items-center"> <div class="flex items-center">
<div class="mr-[4px] text-[12px] leading-[16px] text-[var(--color-text-4)]"> <div class="mr-[4px] text-[12px] leading-[16px] text-[var(--color-text-4)]">
{{ t('ms.personal.priorityLocalExec') }} {{ t('ms.personal.priorityLocalExec') }}
@ -42,7 +54,7 @@
<a-switch <a-switch
v-model:model-value="apiConfig.enable" v-model:model-value="apiConfig.enable"
size="small" size="small"
:disabled="apiConfig.id === '' || testApiLoading" :disabled="apiConfig.id === '' || testApiLoading || apiConfig.userUrl.trim() === ''"
:before-change="(val) => handleApiPriorityBeforeChange(val)" :before-change="(val) => handleApiPriorityBeforeChange(val)"
type="line" type="line"
/> />
@ -155,6 +167,20 @@
status: 0, status: 0,
}); });
function clearApi() {
apiConfig.value.userUrl = '';
if (apiConfig.value.id) {
//
updateLocalConfig({
id: apiConfig.value.id,
userUrl: apiConfig.value.userUrl.trim(),
});
disableLocalConfig(apiConfig.value.id);
apiConfig.value.enable = false;
Message.success(t('common.updateSuccess'));
}
}
async function testApi() { async function testApi() {
if (apiConfig.value.userUrl.trim() === '') { if (apiConfig.value.userUrl.trim() === '') {
return; return;