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.EqualsAndHashCode;
import java.io.Serial;
import java.io.Serializable;
@Data
@EqualsAndHashCode(callSuper = false)
public class UserLocalConfigUpdateRequest implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
@Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED)
@NotBlank(message = "{user_local_config.id.not_blank}")
private String id;
@Schema(description = "本地执行程序url", requiredMode = Schema.RequiredMode.REQUIRED)
@NotBlank(message = "{user_local_config.user_url.not_blank}")
@Size(min = 1, max = 50, message = "{user_local_config.user_url.length_range}")
@Schema(description = "本地执行程序url")
@Size( max = 50, message = "{user_local_config.user_url.length_range}")
private String userUrl;

View File

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

View File

@ -25,6 +25,7 @@
@press-enter="testApi"
></a-input>
<div class="config-card-footer">
<div>
<a-button
type="outline"
class="px-[8px]"
@ -35,6 +36,17 @@
>
{{ t('ms.personal.test') }}
</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="mr-[4px] text-[12px] leading-[16px] text-[var(--color-text-4)]">
{{ t('ms.personal.priorityLocalExec') }}
@ -42,7 +54,7 @@
<a-switch
v-model:model-value="apiConfig.enable"
size="small"
:disabled="apiConfig.id === '' || testApiLoading"
:disabled="apiConfig.id === '' || testApiLoading || apiConfig.userUrl.trim() === ''"
:before-change="(val) => handleApiPriorityBeforeChange(val)"
type="line"
/>
@ -155,6 +167,20 @@
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() {
if (apiConfig.value.userUrl.trim() === '') {
return;