Browse Source

列表

main
chenyang 4 months ago
parent
commit
9d33024363
  1. 193
      src/pages/websites/account/index.tsx
  2. 26
      src/pages/websites/domain/index.tsx

193
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<WebSite.IDnsAccount>[] = []
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
},
{
title: t(`${i18nPrefix}.columns.authorization`, 'authorization'),
dataIndex: 'authorization',
formItemProps: {
rules: [
{ required: true, message: t('message.required', '请选择') }
]
},
{
title: t(`${i18nPrefix}.columns.status`, 'status'),
dataIndex: 'status',
},
{
title: t(`${i18nPrefix}.columns.remark`, 'remark'),
dataIndex: 'remark',
name: [ 'type' ],
valueType: 'dependency',
hideInSetting: true,
hideInTable: true,
columns: ({ type }) => {
return getKeyColumn(type, t)
}
},
{
title: t(`${i18nPrefix}.columns.tag`, 'tag'),
dataIndex: 'tag',
title: t(`${i18nPrefix}.columns.status`, '状态'),
dataIndex: 'status',
},
{
title: t(`${i18nPrefix}.columns.option`, '操作'),
key: 'option',
@ -88,11 +221,23 @@ const WebsiteDnsAccount = () => {
render: (_, record) => [
<Action key="edit"
as={'a'}
disabled={record.status === 2}
onClick={() => {
form.setFieldsValue(record)
setOpen(true)
}}>{t('actions.edit')}</Action>,
<Popconfirm
key={'sync_confirm'}
disabled={isAsyncing || record.status === 2}
onConfirm={() => {
asyncDNS(record)
}}
title={t('message.deleteConfirm')}>
<a key="del">
{t('actions.sync', '同步')}
</a>
</Popconfirm>,
<Popconfirm
key={'del_confirm'}
disabled={isDeleting}
onConfirm={() => {

26
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.created`, '创建时间'),
dataIndex: 'created',
},
{
title: t(`${i18nPrefix}.columns.remark`, 'remark'),
dataIndex: 'remark',
title: t(`${i18nPrefix}.columns.modified`, '修改时间'),
dataIndex: 'modified',
},
{
title: t(`${i18nPrefix}.columns.option`, '操作'),
key: 'option',

Loading…
Cancel
Save