Merge branch 'l123wx-local_deployment_translate'

This commit is contained in:
yoan 2024-09-30 07:35:26 +08:00
commit 3375839a40
9 changed files with 51 additions and 46 deletions

File diff suppressed because one or more lines are too long

2
ui/dist/index.html vendored
View File

@ -5,7 +5,7 @@
<link rel="icon" type="image/svg+xml" href="/vite.svg" /> <link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Certimate - Your Trusted SSL Automation Partner</title> <title>Certimate - Your Trusted SSL Automation Partner</title>
<script type="module" crossorigin src="/assets/index-TzNEc_kS.js"></script> <script type="module" crossorigin src="/assets/index--un-5Tw_.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-I--T0qY3.css"> <link rel="stylesheet" crossorigin href="/assets/index-I--T0qY3.css">
</head> </head>
<body class="bg-background"> <body class="bg-background">

View File

@ -9,6 +9,7 @@ import { useConfig } from "@/providers/config";
import { zodResolver } from "@hookform/resolvers/zod"; import { zodResolver } from "@hookform/resolvers/zod";
import { useForm } from "react-hook-form"; import { useForm } from "react-hook-form";
import { z } from "zod"; import { z } from "zod";
import { useTranslation } from "react-i18next";
import { import {
Form, Form,
FormControl, FormControl,
@ -32,15 +33,16 @@ const AccessLocalForm = ({
onAfterReq: () => void; onAfterReq: () => void;
}) => { }) => {
const { addAccess, updateAccess, reloadAccessGroups } = useConfig(); const { addAccess, updateAccess, reloadAccessGroups } = useConfig();
const { t } = useTranslation();
const formSchema = z.object({ const formSchema = z.object({
id: z.string().optional(), id: z.string().optional(),
name: z.string().min(1).max(64), name: z.string().min(1, 'access.form.name.not.empty').max(64, t('zod.rule.string.max', { max: 64 })),
configType: accessFormType, configType: accessFormType,
command: z.string().min(1).max(2048), command: z.string().min(1, 'access.form.ssh.command.not.empty').max(2048, t('zod.rule.string.max', { max: 2048 })),
certPath: z.string().min(0).max(2048), certPath: z.string().min(0, 'access.form.ssh.cert.path.not.empty').max(2048, t('zod.rule.string.max', { max: 2048 })),
keyPath: z.string().min(0).max(2048), keyPath: z.string().min(0, 'access.form.ssh.key.path.not.empty').max(2048, t('zod.rule.string.max', { max: 2048 })),
}); });
let config: LocalConfig = { let config: LocalConfig = {
@ -54,7 +56,7 @@ const AccessLocalForm = ({
resolver: zodResolver(formSchema), resolver: zodResolver(formSchema),
defaultValues: { defaultValues: {
id: data?.id, id: data?.id,
name: data?.name, name: data?.name || '',
configType: "local", configType: "local",
certPath: config.certPath, certPath: config.certPath,
keyPath: config.keyPath, keyPath: config.keyPath,
@ -123,9 +125,9 @@ const AccessLocalForm = ({
name="name" name="name"
render={({ field }) => ( render={({ field }) => (
<FormItem> <FormItem>
<FormLabel></FormLabel> <FormLabel>{t('name')}</FormLabel>
<FormControl> <FormControl>
<Input placeholder="请输入授权名称" {...field} /> <Input placeholder={t('access.form.name.not.empty')} {...field} />
</FormControl> </FormControl>
<FormMessage /> <FormMessage />
@ -138,7 +140,7 @@ const AccessLocalForm = ({
name="id" name="id"
render={({ field }) => ( render={({ field }) => (
<FormItem className="hidden"> <FormItem className="hidden">
<FormLabel></FormLabel> <FormLabel>{t('access.form.config.field')}</FormLabel>
<FormControl> <FormControl>
<Input {...field} /> <Input {...field} />
</FormControl> </FormControl>
@ -153,7 +155,7 @@ const AccessLocalForm = ({
name="configType" name="configType"
render={({ field }) => ( render={({ field }) => (
<FormItem className="hidden"> <FormItem className="hidden">
<FormLabel></FormLabel> <FormLabel>{t('access.form.config.field')}</FormLabel>
<FormControl> <FormControl>
<Input {...field} /> <Input {...field} />
</FormControl> </FormControl>
@ -168,9 +170,9 @@ const AccessLocalForm = ({
name="certPath" name="certPath"
render={({ field }) => ( render={({ field }) => (
<FormItem> <FormItem>
<FormLabel></FormLabel> <FormLabel>{t('access.form.ssh.cert.path')}</FormLabel>
<FormControl> <FormControl>
<Input placeholder="请输入证书上传路径" {...field} /> <Input placeholder={t('access.form.ssh.cert.path.not.empty')} {...field} />
</FormControl> </FormControl>
<FormMessage /> <FormMessage />
@ -183,9 +185,9 @@ const AccessLocalForm = ({
name="keyPath" name="keyPath"
render={({ field }) => ( render={({ field }) => (
<FormItem> <FormItem>
<FormLabel></FormLabel> <FormLabel>{t('access.form.ssh.key.path')}</FormLabel>
<FormControl> <FormControl>
<Input placeholder="请输入私钥上传路径" {...field} /> <Input placeholder={t('access.form.ssh.key.path.not.empty')} {...field} />
</FormControl> </FormControl>
<FormMessage /> <FormMessage />
@ -198,9 +200,9 @@ const AccessLocalForm = ({
name="command" name="command"
render={({ field }) => ( render={({ field }) => (
<FormItem> <FormItem>
<FormLabel>Command</FormLabel> <FormLabel>{t('access.form.ssh.command')}</FormLabel>
<FormControl> <FormControl>
<Textarea placeholder="请输入要执行的命令" {...field} /> <Textarea placeholder={t('access.form.ssh.command.not.empty')} {...field} />
</FormControl> </FormControl>
<FormMessage /> <FormMessage />
@ -211,7 +213,7 @@ const AccessLocalForm = ({
<FormMessage /> <FormMessage />
<div className="flex justify-end"> <div className="flex justify-end">
<Button type="submit"></Button> <Button type="submit">{t('save')}</Button>
</div> </div>
</form> </form>
</Form> </Form>

View File

@ -81,7 +81,7 @@ const AccessSSHForm = ({
key: z.string().min(0, 'access.form.ssh.key.not.empty').max(20480, t('zod.rule.string.max', { max: 20480 })), key: z.string().min(0, 'access.form.ssh.key.not.empty').max(20480, t('zod.rule.string.max', { max: 20480 })),
keyFile: z.any().optional(), keyFile: z.any().optional(),
preCommand: z.string().min(0).max(2048).optional(), preCommand: z.string().min(0).max(2048, t('zod.rule.string.max', { max: 2048 })).optional(),
command: z.string().min(1, 'access.form.ssh.command.not.empty').max(2048, t('zod.rule.string.max', { max: 2048 })), command: z.string().min(1, 'access.form.ssh.command.not.empty').max(2048, t('zod.rule.string.max', { max: 2048 })),
certPath: z.string().min(0, 'access.form.ssh.cert.path.not.empty').max(2048, t('zod.rule.string.max', { max: 2048 })), certPath: z.string().min(0, 'access.form.ssh.cert.path.not.empty').max(2048, t('zod.rule.string.max', { max: 2048 })),
keyPath: z.string().min(0, 'access.form.ssh.key.path.not.empty').max(2048, t('zod.rule.string.max', { max: 2048 })), keyPath: z.string().min(0, 'access.form.ssh.key.path.not.empty').max(2048, t('zod.rule.string.max', { max: 2048 })),
@ -122,7 +122,6 @@ const AccessSSHForm = ({
}); });
const onSubmit = async (data: z.infer<typeof formSchema>) => { const onSubmit = async (data: z.infer<typeof formSchema>) => {
console.log(data);
let group = data.group; let group = data.group;
if (group == "emptyId") group = ""; if (group == "emptyId") group = "";
@ -480,9 +479,9 @@ const AccessSSHForm = ({
name="preCommand" name="preCommand"
render={({ field }) => ( render={({ field }) => (
<FormItem> <FormItem>
<FormLabel> Command</FormLabel> <FormLabel>{t('access.form.ssh.pre.command')}</FormLabel>
<FormControl> <FormControl>
<Textarea placeholder="请输入要在部署证书前执行的前置命令" {...field} /> <Textarea placeholder={t('access.form.ssh.pre.command.not.empty')} {...field} />
</FormControl> </FormControl>
<FormMessage /> <FormMessage />

View File

@ -9,7 +9,7 @@ export const accessTypeMap: Map<string, [string, string]> = new Map([
["qiniu", ["qiniu", "/imgs/providers/qiniu.svg"]], ["qiniu", ["qiniu", "/imgs/providers/qiniu.svg"]],
["ssh", ["ssh", "/imgs/providers/ssh.svg"]], ["ssh", ["ssh", "/imgs/providers/ssh.svg"]],
["webhook", ["webhook", "/imgs/providers/webhook.svg"]], ["webhook", ["webhook", "/imgs/providers/webhook.svg"]],
["local", ["local", "/imgs/providers/local.svg"]], ["local", ["local.deployment", "/imgs/providers/local.svg"]],
]); ]);
export const getProviderInfo = (t: string) => { export const getProviderInfo = (t: string) => {

View File

@ -47,7 +47,7 @@ export const targetTypeMap: Map<string, [string, string]> = new Map([
["ssh", ["ssh", "/imgs/providers/ssh.svg"]], ["ssh", ["ssh", "/imgs/providers/ssh.svg"]],
["qiniu-cdn", ["qiniu.cdn", "/imgs/providers/qiniu.svg"]], ["qiniu-cdn", ["qiniu.cdn", "/imgs/providers/qiniu.svg"]],
["webhook", ["webhook", "/imgs/providers/webhook.svg"]], ["webhook", ["webhook", "/imgs/providers/webhook.svg"]],
["local", ["local", "/imgs/providers/local.svg"]], ["local", ["local.deployment", "/imgs/providers/local.svg"]],
]); ]);
export const targetTypeKeys = Array.from(targetTypeMap.keys()); export const targetTypeKeys = Array.from(targetTypeMap.keys());

View File

@ -1 +1 @@
export const version = "Certimate v0.1.12"; export const version = "Certimate v0.1.14";

View File

@ -42,7 +42,7 @@
"ding.talk": "Ding Talk", "ding.talk": "Ding Talk",
"telegram": "Telegram", "telegram": "Telegram",
"webhook": "Webhook", "webhook": "Webhook",
"local": "Local Deployment", "local.deployment": "Local Deployment",
"tencent": "Tencent", "tencent": "Tencent",
"tencent.cdn": "Tencent-CDN", "tencent.cdn": "Tencent-CDN",
"aliyun": "Alibaba Cloud", "aliyun": "Alibaba Cloud",
@ -200,10 +200,12 @@
"access.form.ssh.key": "Key (Log in using certificate)", "access.form.ssh.key": "Key (Log in using certificate)",
"access.form.ssh.key.not.empty": "Please enter Key", "access.form.ssh.key.not.empty": "Please enter Key",
"access.form.ssh.key.file.not.empty": "Please select file", "access.form.ssh.key.file.not.empty": "Please select file",
"access.form.ssh.cert.path": "Certificate Upload Path", "access.form.ssh.cert.path": "Certificate Save Path",
"access.form.ssh.cert.path.not.empty": "Please enter certificate upload path", "access.form.ssh.cert.path.not.empty": "Please enter certificate save path",
"access.form.ssh.key.path": "Private Key Upload Path", "access.form.ssh.key.path": "Private Key Save Path",
"access.form.ssh.key.path.not.empty": "Please enter private key upload path", "access.form.ssh.key.path.not.empty": "Please enter private key save path",
"access.form.ssh.pre.command": "Pre-deployment Command",
"access.form.ssh.pre.command.not.empty": "Command to be executed before deploying the certificate",
"access.form.ssh.command": "Command", "access.form.ssh.command": "Command",
"access.form.ssh.command.not.empty": "Please enter command", "access.form.ssh.command.not.empty": "Please enter command",
"access.form.ding.access.token.placeholder": "Signature for signed addition" "access.form.ding.access.token.placeholder": "Signature for signed addition"

View File

@ -42,7 +42,7 @@
"ding.talk": "钉钉", "ding.talk": "钉钉",
"telegram": "Telegram", "telegram": "Telegram",
"webhook": "Webhook", "webhook": "Webhook",
"local": "本地部署", "local.deployment": "本地部署",
"tencent": "腾讯云", "tencent": "腾讯云",
"tencent.cdn": "腾讯云-CDN", "tencent.cdn": "腾讯云-CDN",
"aliyun": "阿里云", "aliyun": "阿里云",
@ -200,10 +200,12 @@
"access.form.ssh.key": "Key使用证书登录", "access.form.ssh.key": "Key使用证书登录",
"access.form.ssh.key.not.empty": "请输入 Key", "access.form.ssh.key.not.empty": "请输入 Key",
"access.form.ssh.key.file.not.empty": "请选择文件", "access.form.ssh.key.file.not.empty": "请选择文件",
"access.form.ssh.cert.path": "证书上传路径", "access.form.ssh.cert.path": "证书保存路径",
"access.form.ssh.cert.path.not.empty": "请输入证书上传路径", "access.form.ssh.cert.path.not.empty": "请输入证书保存路径",
"access.form.ssh.key.path": "私钥上传路径", "access.form.ssh.key.path": "私钥保存路径",
"access.form.ssh.key.path.not.empty": "请输入私钥上传路径", "access.form.ssh.key.path.not.empty": "请输入私钥保存路径",
"access.form.ssh.pre.command": "前置 Command",
"access.form.ssh.pre.command.not.empty": "在部署证书前执行的前置命令",
"access.form.ssh.command": "Command", "access.form.ssh.command": "Command",
"access.form.ssh.command.not.empty": "请输入要执行的命令", "access.form.ssh.command.not.empty": "请输入要执行的命令",
"access.form.ding.access.token.placeholder": "加签的签名" "access.form.ding.access.token.placeholder": "加签的签名"