wip: i18n
- Change locales json to one-dimensional format
This commit is contained in:
@@ -9,6 +9,7 @@ import { Access as AccessType, accessTypeMap } from "@/domain/access";
|
||||
import { convertZulu2Beijing } from "@/lib/time";
|
||||
import { useConfig } from "@/providers/config";
|
||||
import { remove } from "@/repository/access";
|
||||
import { t } from "i18next";
|
||||
import { Key } from "lucide-react";
|
||||
import { useLocation, useNavigate } from "react-router-dom";
|
||||
|
||||
@@ -46,11 +47,11 @@ const Access = () => {
|
||||
return (
|
||||
<div className="">
|
||||
<div className="flex justify-between items-center">
|
||||
<div className="text-muted-foreground">授权管理</div>
|
||||
<div className="text-muted-foreground">{t('access.management')}</div>
|
||||
{tab != "access_group" ? (
|
||||
<AccessEdit trigger={<Button>添加授权</Button>} op="add" />
|
||||
<AccessEdit trigger={<Button>{t('access.add')}</Button>} op="add" />
|
||||
) : (
|
||||
<AccessGroupEdit trigger={<Button>添加授权组</Button>} />
|
||||
<AccessGroupEdit trigger={<Button>{t('access.group.add')}</Button>} />
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -66,7 +67,7 @@ const Access = () => {
|
||||
handleTabItemClick("access");
|
||||
}}
|
||||
>
|
||||
授权管理
|
||||
{t('access.management')}
|
||||
</TabsTrigger>
|
||||
<TabsTrigger
|
||||
value="access_group"
|
||||
@@ -74,7 +75,7 @@ const Access = () => {
|
||||
handleTabItemClick("access_group");
|
||||
}}
|
||||
>
|
||||
授权组管理
|
||||
{t('access.group.management')}
|
||||
</TabsTrigger>
|
||||
</TabsList>
|
||||
<TabsContent value="access">
|
||||
@@ -85,10 +86,10 @@ const Access = () => {
|
||||
</span>
|
||||
|
||||
<div className="text-center text-sm text-muted-foreground mt-3">
|
||||
请添加授权开始部署证书吧。
|
||||
{t('access.empty')}
|
||||
</div>
|
||||
<AccessEdit
|
||||
trigger={<Button>添加授权</Button>}
|
||||
trigger={<Button>{t('access.add')}</Button>}
|
||||
op="add"
|
||||
className="mt-3"
|
||||
/>
|
||||
@@ -96,15 +97,15 @@ const Access = () => {
|
||||
) : (
|
||||
<>
|
||||
<div className="hidden sm:flex sm:flex-row text-muted-foreground text-sm border-b dark:border-stone-500 sm:p-2 mt-5">
|
||||
<div className="w-48">名称</div>
|
||||
<div className="w-48">服务商</div>
|
||||
<div className="w-48">{t('name')}</div>
|
||||
<div className="w-48">{t('access.type')}</div>
|
||||
|
||||
<div className="w-52">创建时间</div>
|
||||
<div className="w-52">更新时间</div>
|
||||
<div className="grow">操作</div>
|
||||
<div className="w-52">{t('create.time')}</div>
|
||||
<div className="w-52">{t('update.time')}</div>
|
||||
<div className="grow">{t('operation')}</div>
|
||||
</div>
|
||||
<div className="sm:hidden flex text-sm text-muted-foreground">
|
||||
授权列表
|
||||
{t('access.list')}
|
||||
</div>
|
||||
{accesses
|
||||
.filter((item) => {
|
||||
@@ -128,18 +129,18 @@ const Access = () => {
|
||||
</div>
|
||||
|
||||
<div className="sm:w-52 w-full pt-1 sm:pt-0 flex items-center">
|
||||
创建于{" "}
|
||||
{t('created.in')}{" "}
|
||||
{access.created && convertZulu2Beijing(access.created)}
|
||||
</div>
|
||||
<div className="sm:w-52 w-full pt-1 sm:pt-0 flex items-center">
|
||||
更新于{" "}
|
||||
{t('updated.in')}{" "}
|
||||
{access.updated && convertZulu2Beijing(access.updated)}
|
||||
</div>
|
||||
<div className="flex items-center grow justify-start pt-1 sm:pt-0">
|
||||
<AccessEdit
|
||||
trigger={
|
||||
<Button variant={"link"} className="p-0">
|
||||
编辑
|
||||
{t('edit')}
|
||||
</Button>
|
||||
}
|
||||
op="edit"
|
||||
@@ -153,7 +154,7 @@ const Access = () => {
|
||||
handleDelete(access);
|
||||
}}
|
||||
>
|
||||
删除
|
||||
{t('delete')}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -71,15 +71,15 @@ const Edit = () => {
|
||||
const formSchema = z.object({
|
||||
id: z.string().optional(),
|
||||
domain: z.string().regex(/^(?:\*\.)?([a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}$/, {
|
||||
message: t('domain.management.edit.domain.verify.tips'),
|
||||
message: 'domain.not.empty.verify.message',
|
||||
}),
|
||||
email: z.string().email().optional(),
|
||||
email: z.string().email('email.valid.message').optional(),
|
||||
access: z.string().regex(/^[a-zA-Z0-9]+$/, {
|
||||
message: t('domain.management.edit.dns.verify.tips'),
|
||||
message: 'domain.management.edit.dns.access.not.empty.message',
|
||||
}),
|
||||
targetAccess: z.string().optional(),
|
||||
targetType: z.string().regex(/^[a-zA-Z0-9-]+$/, {
|
||||
message: t('domain.management.edit.target.type.verify.tips'),
|
||||
message: 'domain.management.edit.target.type.not.empty.message',
|
||||
}),
|
||||
variables: z.string().optional(),
|
||||
group: z.string().optional(),
|
||||
@@ -140,11 +140,11 @@ const Edit = () => {
|
||||
if (group == "" && targetAccess == "") {
|
||||
form.setError("group", {
|
||||
type: "manual",
|
||||
message: "部署授权和部署授权组至少选一个",
|
||||
message: 'domain.management.edit.target.access.verify.msg',
|
||||
});
|
||||
form.setError("targetAccess", {
|
||||
type: "manual",
|
||||
message: "部署授权和部署授权组至少选一个",
|
||||
message: 'domain.management.edit.target.access.verify.msg',
|
||||
});
|
||||
return;
|
||||
}
|
||||
@@ -164,13 +164,13 @@ const Edit = () => {
|
||||
|
||||
try {
|
||||
await save(req);
|
||||
let description = "域名编辑成功";
|
||||
let description = t('domain.management.edit.succeed.tips');
|
||||
if (req.id == "") {
|
||||
description = "域名添加成功";
|
||||
description = t('domain.management.add.succeed.tips');
|
||||
}
|
||||
|
||||
toast({
|
||||
title: "成功",
|
||||
title: t('succeed'),
|
||||
description,
|
||||
});
|
||||
navigate("/domains");
|
||||
@@ -195,7 +195,7 @@ const Edit = () => {
|
||||
<div className="">
|
||||
<Toaster />
|
||||
<div className=" h-5 text-muted-foreground">
|
||||
{domain?.id ? "编辑" : "新增"}域名
|
||||
{domain?.id ? t('domain.edit') : t('domain.add')}
|
||||
</div>
|
||||
<div className="mt-5 flex w-full justify-center md:space-x-10 flex-col md:flex-row">
|
||||
<div className="w-full md:w-[200px] text-muted-foreground space-x-3 md:space-y-3 flex-row md:flex-col flex">
|
||||
@@ -208,7 +208,7 @@ const Edit = () => {
|
||||
setTab("base");
|
||||
}}
|
||||
>
|
||||
基础设置
|
||||
{t('basic.setting')}
|
||||
</div>
|
||||
<div
|
||||
className={cn(
|
||||
@@ -219,7 +219,7 @@ const Edit = () => {
|
||||
setTab("advance");
|
||||
}}
|
||||
>
|
||||
高级设置
|
||||
{t('advanced.setting')}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -234,9 +234,9 @@ const Edit = () => {
|
||||
name="domain"
|
||||
render={({ field }) => (
|
||||
<FormItem hidden={tab != "base"}>
|
||||
<FormLabel>域名</FormLabel>
|
||||
<FormLabel>{t('domain')}</FormLabel>
|
||||
<FormControl>
|
||||
<Input placeholder="请输入域名" {...field} />
|
||||
<Input placeholder={t('domain.not.empty.verify.message')} {...field} />
|
||||
</FormControl>
|
||||
|
||||
<FormMessage />
|
||||
@@ -249,12 +249,12 @@ const Edit = () => {
|
||||
render={({ field }) => (
|
||||
<FormItem hidden={tab != "base"}>
|
||||
<FormLabel className="flex w-full justify-between">
|
||||
<div>Email(申请证书需要提供邮箱)</div>
|
||||
<div>{t('email') + t('domain.management.edit.email.description')}</div>
|
||||
<EmailsEdit
|
||||
trigger={
|
||||
<div className="font-normal text-primary hover:underline cursor-pointer flex items-center">
|
||||
<Plus size={14} />
|
||||
新增
|
||||
{t('add')}
|
||||
</div>
|
||||
}
|
||||
/>
|
||||
@@ -268,11 +268,11 @@ const Edit = () => {
|
||||
}}
|
||||
>
|
||||
<SelectTrigger>
|
||||
<SelectValue placeholder="请选择邮箱" />
|
||||
<SelectValue placeholder={t('domain.management.edit.email.not.empty.message')} />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectGroup>
|
||||
<SelectLabel>邮箱列表</SelectLabel>
|
||||
<SelectLabel>{t('email.list')}</SelectLabel>
|
||||
{(emails.content as EmailsSetting).emails.map(
|
||||
(item) => (
|
||||
<SelectItem key={item} value={item}>
|
||||
@@ -295,12 +295,12 @@ const Edit = () => {
|
||||
render={({ field }) => (
|
||||
<FormItem hidden={tab != "base"}>
|
||||
<FormLabel className="flex w-full justify-between">
|
||||
<div>DNS 服务商授权配置</div>
|
||||
<div>{t('domain.management.edit.dns.access.label')}</div>
|
||||
<AccessEdit
|
||||
trigger={
|
||||
<div className="font-normal text-primary hover:underline cursor-pointer flex items-center">
|
||||
<Plus size={14} />
|
||||
新增
|
||||
{t('add')}
|
||||
</div>
|
||||
}
|
||||
op="add"
|
||||
@@ -315,11 +315,11 @@ const Edit = () => {
|
||||
}}
|
||||
>
|
||||
<SelectTrigger>
|
||||
<SelectValue placeholder="请选择授权配置" />
|
||||
<SelectValue placeholder={t('domain.management.edit.access.not.empty.message')} />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectGroup>
|
||||
<SelectLabel>服务商授权配置</SelectLabel>
|
||||
<SelectLabel>{t('domain.management.edit.access.label')}</SelectLabel>
|
||||
{accesses
|
||||
.filter((item) => item.usage != "deploy")
|
||||
.map((item) => (
|
||||
@@ -351,7 +351,7 @@ const Edit = () => {
|
||||
name="targetType"
|
||||
render={({ field }) => (
|
||||
<FormItem hidden={tab != "base"}>
|
||||
<FormLabel>部署服务类型</FormLabel>
|
||||
<FormLabel>{t('domain.management.edit.target.type')}</FormLabel>
|
||||
<FormControl>
|
||||
<Select
|
||||
{...field}
|
||||
@@ -361,11 +361,11 @@ const Edit = () => {
|
||||
}}
|
||||
>
|
||||
<SelectTrigger>
|
||||
<SelectValue placeholder="请选择部署服务类型" />
|
||||
<SelectValue placeholder={t('domain.management.edit.target.type.not.empty.message')} />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectGroup>
|
||||
<SelectLabel>部署服务类型</SelectLabel>
|
||||
<SelectLabel>{t('domain.management.edit.target.type')}</SelectLabel>
|
||||
{targetTypeKeys.map((key) => (
|
||||
<SelectItem key={key} value={key}>
|
||||
<div className="flex items-center space-x-2">
|
||||
@@ -392,12 +392,12 @@ const Edit = () => {
|
||||
render={({ field }) => (
|
||||
<FormItem hidden={tab != "base"}>
|
||||
<FormLabel className="w-full flex justify-between">
|
||||
<div>部署服务商授权配置</div>
|
||||
<div>{t('domain.management.edit.target.access')}</div>
|
||||
<AccessEdit
|
||||
trigger={
|
||||
<div className="font-normal text-primary hover:underline cursor-pointer flex items-center">
|
||||
<Plus size={14} />
|
||||
新增
|
||||
{t('add')}
|
||||
</div>
|
||||
}
|
||||
op="add"
|
||||
@@ -411,12 +411,12 @@ const Edit = () => {
|
||||
}}
|
||||
>
|
||||
<SelectTrigger>
|
||||
<SelectValue placeholder="请选择授权配置" />
|
||||
<SelectValue placeholder={t('domain.management.edit.target.access.not.empty.message')} />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectGroup>
|
||||
<SelectLabel>
|
||||
服务商授权配置{form.getValues().targetAccess}
|
||||
{t('domain.management.edit.target.access.content.label')} {form.getValues().targetAccess}
|
||||
</SelectLabel>
|
||||
<SelectItem value="emptyId">
|
||||
<div className="flex items-center space-x-2">
|
||||
@@ -453,7 +453,7 @@ const Edit = () => {
|
||||
<FormItem hidden={tab != "advance" || targetType != "ssh"}>
|
||||
<FormLabel className="w-full flex justify-between">
|
||||
<div>
|
||||
部署配置组(用于将一个域名证书部署到多个 ssh 主机)
|
||||
{t('domain.management.edit.group.label')}
|
||||
</div>
|
||||
</FormLabel>
|
||||
<FormControl>
|
||||
@@ -466,7 +466,7 @@ const Edit = () => {
|
||||
}}
|
||||
>
|
||||
<SelectTrigger>
|
||||
<SelectValue placeholder="请选择分组" />
|
||||
<SelectValue placeholder={t('domain.management.edit.group.not.empty.message')} />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="emptyId">
|
||||
@@ -511,10 +511,10 @@ const Edit = () => {
|
||||
name="variables"
|
||||
render={({ field }) => (
|
||||
<FormItem hidden={tab != "advance"}>
|
||||
<FormLabel>变量</FormLabel>
|
||||
<FormLabel>{t('variables')}</FormLabel>
|
||||
<FormControl>
|
||||
<Textarea
|
||||
placeholder={`可在SSH部署中使用,形如:\nkey=val;\nkey2=val2;`}
|
||||
placeholder={t('domain.management.edit.variables.placeholder')}
|
||||
{...field}
|
||||
className="placeholder:whitespace-pre-wrap"
|
||||
/>
|
||||
@@ -530,10 +530,10 @@ const Edit = () => {
|
||||
name="nameservers"
|
||||
render={({ field }) => (
|
||||
<FormItem hidden={tab != "advance"}>
|
||||
<FormLabel>域名服务器</FormLabel>
|
||||
<FormLabel>{t('dns')}</FormLabel>
|
||||
<FormControl>
|
||||
<Textarea
|
||||
placeholder={`自定义域名服务器,多个用分号隔开,如:\n8.8.8.8;\n8.8.4.4;`}
|
||||
placeholder={t('domain.management.edit.dns.placeholder')}
|
||||
{...field}
|
||||
className="placeholder:whitespace-pre-wrap"
|
||||
/>
|
||||
@@ -545,7 +545,7 @@ const Edit = () => {
|
||||
/>
|
||||
|
||||
<div className="flex justify-end">
|
||||
<Button type="submit">保存</Button>
|
||||
<Button type="submit">{t('save')}</Button>
|
||||
</div>
|
||||
</form>
|
||||
</Form>
|
||||
|
||||
Reference in New Issue
Block a user