mirror of
https://github.com/usual2970/certimate.git
synced 2025-06-17 09:59:51 +00:00
refactor: clean code
This commit is contained in:
parent
ee531dd186
commit
af3e20709d
@ -6,7 +6,7 @@ type DeployEditContext = {
|
|||||||
deploy: DeployConfig;
|
deploy: DeployConfig;
|
||||||
error: Record<string, string>;
|
error: Record<string, string>;
|
||||||
setDeploy: (deploy: DeployConfig) => void;
|
setDeploy: (deploy: DeployConfig) => void;
|
||||||
setError: (error: Record<string, string>) => void;
|
setError: (error: Record<string, string | undefined>) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const Context = createContext<DeployEditContext>({} as DeployEditContext);
|
export const Context = createContext<DeployEditContext>({} as DeployEditContext);
|
||||||
|
@ -12,6 +12,17 @@ const DeployToAliyunCDN = () => {
|
|||||||
|
|
||||||
const { deploy: data, setDeploy, error, setError } = useDeployEditContext();
|
const { deploy: data, setDeploy, error, setError } = useDeployEditContext();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!data.id) {
|
||||||
|
setDeploy({
|
||||||
|
...data,
|
||||||
|
config: {
|
||||||
|
domain: "",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setError({});
|
setError({});
|
||||||
}, []);
|
}, []);
|
||||||
|
@ -8,9 +8,22 @@ import { Label } from "@/components/ui/label";
|
|||||||
import { useDeployEditContext } from "./DeployEdit";
|
import { useDeployEditContext } from "./DeployEdit";
|
||||||
|
|
||||||
const DeployToAliyunOSS = () => {
|
const DeployToAliyunOSS = () => {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
const { deploy: data, setDeploy, error, setError } = useDeployEditContext();
|
const { deploy: data, setDeploy, error, setError } = useDeployEditContext();
|
||||||
|
|
||||||
const { t } = useTranslation();
|
useEffect(() => {
|
||||||
|
if (!data.id) {
|
||||||
|
setDeploy({
|
||||||
|
...data,
|
||||||
|
config: {
|
||||||
|
endpoint: "oss-cn-hangzhou.aliyuncs.com",
|
||||||
|
bucket: "",
|
||||||
|
domain: "",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setError({});
|
setError({});
|
||||||
@ -44,20 +57,7 @@ const DeployToAliyunOSS = () => {
|
|||||||
bucket: "",
|
bucket: "",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, []);
|
}, [data]);
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (!data.id) {
|
|
||||||
setDeploy({
|
|
||||||
...data,
|
|
||||||
config: {
|
|
||||||
endpoint: "oss-cn-hangzhou.aliyuncs.com",
|
|
||||||
bucket: "",
|
|
||||||
domain: "",
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const domainSchema = z.string().regex(/^(?:\*\.)?([a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}$/, {
|
const domainSchema = z.string().regex(/^(?:\*\.)?([a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}$/, {
|
||||||
message: t("common.errmsg.domain_invalid"),
|
message: t("common.errmsg.domain_invalid"),
|
||||||
|
@ -8,13 +8,8 @@ import { useDeployEditContext } from "./DeployEdit";
|
|||||||
|
|
||||||
const DeployToKubernetesSecret = () => {
|
const DeployToKubernetesSecret = () => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const { setError } = useDeployEditContext();
|
|
||||||
|
|
||||||
useEffect(() => {
|
const { deploy: data, setDeploy, setError } = useDeployEditContext();
|
||||||
setError({});
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const { deploy: data, setDeploy } = useDeployEditContext();
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!data.id) {
|
if (!data.id) {
|
||||||
@ -30,6 +25,10 @@ const DeployToKubernetesSecret = () => {
|
|||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setError({});
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="flex flex-col space-y-8">
|
<div className="flex flex-col space-y-8">
|
||||||
|
@ -12,6 +12,17 @@ const DeployToQiniuCDN = () => {
|
|||||||
|
|
||||||
const { deploy: data, setDeploy, error, setError } = useDeployEditContext();
|
const { deploy: data, setDeploy, error, setError } = useDeployEditContext();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!data.id) {
|
||||||
|
setDeploy({
|
||||||
|
...data,
|
||||||
|
config: {
|
||||||
|
domain: "",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setError({});
|
setError({});
|
||||||
}, []);
|
}, []);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user