fix(个人中心): 本地执行支持清空URL
This commit is contained in:
parent
e2190b63c4
commit
f6d5b4c240
|
@ -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;
|
||||
|
||||
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -25,16 +25,28 @@
|
|||
@press-enter="testApi"
|
||||
></a-input>
|
||||
<div class="config-card-footer">
|
||||
<a-button
|
||||
type="outline"
|
||||
class="px-[8px]"
|
||||
size="mini"
|
||||
:disabled="apiConfig.userUrl.trim() === ''"
|
||||
:loading="testApiLoading"
|
||||
@click="testApi"
|
||||
>
|
||||
{{ t('ms.personal.test') }}
|
||||
</a-button>
|
||||
<div>
|
||||
<a-button
|
||||
type="outline"
|
||||
class="px-[8px]"
|
||||
size="mini"
|
||||
:disabled="apiConfig.userUrl.trim() === ''"
|
||||
:loading="testApiLoading"
|
||||
@click="testApi"
|
||||
>
|
||||
{{ 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;
|
||||
|
|
Loading…
Reference in New Issue