refactor(ui): clean code

This commit is contained in:
Fu Diwei
2025-04-02 11:28:10 +08:00
parent 949660bc01
commit daa5b44f8e
6 changed files with 67 additions and 49 deletions

View File

@@ -10,7 +10,7 @@ type DeployNodeConfigFormAliyunCLBConfigFieldValues = Nullish<{
resourceType: string;
region: string;
loadbalancerId?: string;
listenerPort?: string | number;
listenerPort?: number;
domain?: string;
}>;
@@ -53,10 +53,13 @@ const DeployNodeConfigFormAliyunCLBConfig = ({
.min(1, t("workflow_node.deploy.form.aliyun_clb_loadbalancer_id.placeholder"))
.max(64, t("common.errmsg.string_max", { max: 64 }))
.trim(),
listenerPort: z
.union([z.number(), z.string()])
.refine((v) => fieldResourceType === RESOURCE_TYPE_LISTENER && validPortNumber(v), t("workflow_node.deploy.form.aliyun_clb_listener_port.placeholder"))
.nullish(),
listenerPort: z.preprocess(
(v) => (v == null || v === "" ? undefined : Number(v)),
z
.number()
.nullish()
.refine((v) => fieldResourceType === RESOURCE_TYPE_LISTENER && validPortNumber(v!), t("workflow_node.deploy.form.aliyun_clb_listener_port.placeholder"))
),
domain: z
.string()
.nullish()