From 9d3302436305ee50f613d8d31877116fa00cdd0b Mon Sep 17 00:00:00 2001 From: chenyang Date: Sat, 29 Jun 2024 22:42:29 +0700 Subject: [PATCH] =?UTF-8?q?=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/websites/account/index.tsx | 199 ++++++++++++++++++++++++++++++----- src/pages/websites/domain/index.tsx | 34 ++---- 2 files changed, 183 insertions(+), 50 deletions(-) diff --git a/src/pages/websites/account/index.tsx b/src/pages/websites/account/index.tsx index 235e1d8..5b3b491 100644 --- a/src/pages/websites/account/index.tsx +++ b/src/pages/websites/account/index.tsx @@ -17,9 +17,141 @@ import { useStyle } from './style.ts' import { FilterOutlined } from '@ant-design/icons' import { getValueCount } from '@/utils' import { Table as ProTable } from '@/components/table' +import {DNSTypeEnum, DNSTypes, syncDNSAtom} from "@/store/websites/dns.ts"; +import {WebSite} from "@/types"; const i18nPrefix = 'websiteDnsAccounts.list' +const getKeyColumn = (type: string, t) => { + const columns: ProColumns[] = [] + switch (type) { + case DNSTypeEnum.AliYun: { + columns.push(...[ + { + title: t('website.ssl.dns.columns.accessKey', 'Access Key'), + dataIndex: 'accessKey', + formItemProps: { + rules: [ { required: true, message: t('message.required') } ] + } + }, + { + title: t('website.ssl.dns.columns.secretKey', 'Secret Key'), + dataIndex: 'secretKey', + formItemProps: { + rules: [ { required: true, message: t('message.required') } ] + } + }, + ]) + } + break + case DNSTypeEnum.TencentCloud: { + columns.push(...[ + { + title: t('website.ssl.dns.columns.secretID', 'Secret ID'), + dataIndex: 'secretID', + formItemProps: { + rules: [ { required: true, message: t('message.required') } ] + } + }, { + title: t('website.ssl.dns.columns.secretKey', 'Secret Key'), + dataIndex: 'secretKey', + formItemProps: { + rules: [ { required: true, message: t('message.required') } ] + } + }, + ]) + break + } + case DNSTypeEnum.DnsPod: { + columns.push(...[ + { + title: t('website.ssl.dns.columns.apiId', 'ID'), + dataIndex: 'apiId', + formItemProps: { + rules: [ { required: true, message: t('message.required') } ] + } + }, { + title: t('website.ssl.dns.columns.token', 'Token'), + dataIndex: 'token', + formItemProps: { + rules: [ { required: true, message: t('message.required') } ] + } + }, + ]) + break + } + case DNSTypeEnum.CloudFlare: { + columns.push(...[ + { + title: t('website.ssl.dns.columns.email', 'Email'), + dataIndex: 'email', + formItemProps: { + rules: [ { required: true, message: t('message.required') } ] + } + }, { + title: t('website.ssl.dns.columns.apiKey', 'API ToKen'), + dataIndex: 'apiKey', + formItemProps: { + rules: [ { required: true, message: t('message.required') } ] + } + }, + ] + ) + break + } + case DNSTypeEnum.Godaddy: + case DNSTypeEnum.NameCheap: + case DNSTypeEnum.NameSilo: + columns.push({ + title: t('website.ssl.dns.columns.apiKey', 'API Key'), + dataIndex: 'apiKey', + formItemProps: { + rules: [ { required: true, message: t('message.required') } ] + } + }, + ) + if (type === DNSTypeEnum.NameCheap) { + columns.push({ + title: t('website.ssl.dns.columns.apiUser', 'API User'), + dataIndex: 'apiUser', + formItemProps: { + rules: [ { required: true, message: t('message.required') } ] + } + }) + } else if (type === DNSTypeEnum.Godaddy) { + columns.push({ + title: t('website.ssl.dns.columns.apiSecret', 'API Secret'), + dataIndex: 'apiSecret', + formItemProps: { + rules: [ { required: true, message: t('message.required') } ] + } + }) + } + break + case DNSTypeEnum.NameCom: { + columns.push( + { + title: t('website.ssl.dns.columns.apiUser', 'UserName'), + dataIndex: 'apiUser', + formItemProps: { + rules: [ { required: true, message: t('message.required') } ] + } + }, + { + title: t('website.ssl.dns.columns.token', 'Token'), + dataIndex: 'token', + formItemProps: { + rules: [ { required: true, message: t('message.required') } ] + } + } + ) + break + } + default: + break + } + return columns +} const WebsiteDnsAccount = () => { const { styles, cx } = useStyle() @@ -31,7 +163,7 @@ const WebsiteDnsAccount = () => { const [ currentWebsiteDnsAccount, setWebsiteDnsAccount ] = useAtom(websiteDnsAccountAtom) const { data, isFetching, isLoading, refetch } = useAtomValue(websiteDnsAccountsAtom) const { mutate: deleteWebsiteDnsAccount, isPending: isDeleting } = useAtomValue(deleteWebsiteDnsAccountAtom) - + const { mutate: asyncDNS, isPending: isAsyncing } = useAtomValue(syncDNSAtom) const [ open, setOpen ] = useState(false) const [ openFilter, setFilterOpen ] = useState(false) const [ searchKey, setSearchKey ] = useState(search?.title) @@ -46,40 +178,41 @@ const WebsiteDnsAccount = () => { formItemProps: { hidden: true } }, { - title: t(`${i18nPrefix}.columns.updated_at`, 'updated_at'), - dataIndex: 'updated_at', - }, - - { - title: t(`${i18nPrefix}.columns.name`, 'name'), + title: t(`${i18nPrefix}.columns.name`, '名称'), dataIndex: 'name', + valueType: 'text', + formItemProps: { + rules: [ + { required: true, message: t('message.required', '请输入') } + ] + } }, - { - title: t(`${i18nPrefix}.columns.type`, 'type'), + title: t(`${i18nPrefix}.columns.type`, '类型'), dataIndex: 'type', + valueType: 'select', + fieldProps: { + options: DNSTypes + }, + formItemProps: { + rules: [ + { required: true, message: t('message.required', '请选择') } + ] + }, }, - - { - title: t(`${i18nPrefix}.columns.authorization`, 'authorization'), - dataIndex: 'authorization', - }, - + { + name: [ 'type' ], + valueType: 'dependency', + hideInSetting: true, + hideInTable: true, + columns: ({ type }) => { + return getKeyColumn(type, t) + } + }, { - title: t(`${i18nPrefix}.columns.status`, 'status'), + title: t(`${i18nPrefix}.columns.status`, '状态'), dataIndex: 'status', }, - - { - title: t(`${i18nPrefix}.columns.remark`, 'remark'), - dataIndex: 'remark', - }, - - { - title: t(`${i18nPrefix}.columns.tag`, 'tag'), - dataIndex: 'tag', - }, - { title: t(`${i18nPrefix}.columns.option`, '操作'), key: 'option', @@ -88,11 +221,23 @@ const WebsiteDnsAccount = () => { render: (_, record) => [ { form.setFieldsValue(record) setOpen(true) }}>{t('actions.edit')}, { + asyncDNS(record) + }} + title={t('message.deleteConfirm')}> + + {t('actions.sync', '同步')} + + , + { diff --git a/src/pages/websites/domain/index.tsx b/src/pages/websites/domain/index.tsx index 181c1ae..8a4da42 100644 --- a/src/pages/websites/domain/index.tsx +++ b/src/pages/websites/domain/index.tsx @@ -46,42 +46,30 @@ const WebsiteDomain = () => { formItemProps: { hidden: true } }, { - title: t(`${i18nPrefix}.columns.name`, 'name'), + title: t(`${i18nPrefix}.columns.name`, '域名'), dataIndex: 'name', }, { - title: t(`${i18nPrefix}.columns.dns_account_id`, 'dns_account_id'), + title: t(`${i18nPrefix}.columns.dns_account_id`, 'DNS账号'), dataIndex: 'dns_account_id', }, { - title: t(`${i18nPrefix}.columns.status`, 'status'), + title: t(`${i18nPrefix}.columns.status`, '状态'), dataIndex: 'status', }, { - title: t(`${i18nPrefix}.columns.created`, 'created'), - dataIndex: 'created', - }, - { - title: t(`${i18nPrefix}.columns.modified`, 'modified'), - dataIndex: 'modified', - }, - - { title: t(`${i18nPrefix}.columns.nameservers`, 'nameservers'), dataIndex: 'nameservers', }, - - { - title: t(`${i18nPrefix}.columns.tag`, 'tag'), - dataIndex: 'tag', - }, - - { - title: t(`${i18nPrefix}.columns.remark`, 'remark'), - dataIndex: 'remark', - }, - + { + title: t(`${i18nPrefix}.columns.created`, '创建时间'), + dataIndex: 'created', + }, + { + title: t(`${i18nPrefix}.columns.modified`, '修改时间'), + dataIndex: 'modified', + }, { title: t(`${i18nPrefix}.columns.option`, '操作'), key: 'option',