Browse Source

NDS增加同步操作

main
dark 5 months ago
parent
commit
fbfc5ecdf3
  1. 13
      src/pages/websites/ssl/dns/DNSList.tsx
  2. 9
      src/service/websites.ts
  3. 13
      src/store/websites/dns.ts

13
src/pages/websites/ssl/dns/DNSList.tsx

@ -10,7 +10,7 @@ import {
dnsPageAtom,
DNSTypeEnum,
DNSTypes,
saveOrUpdateDNSAtom
saveOrUpdateDNSAtom, syncDNSAtom
} from '@/store/websites/dns.ts'
import { WebSite } from '@/types'
@ -154,6 +154,7 @@ const DNSList = () => {
const { data, isLoading, isFetching, refetch } = useAtomValue(dnsListAtom)
const { mutate: saveOrUpdate, isPending: isSubmitting, isSuccess } = useAtomValue(saveOrUpdateDNSAtom)
const { mutate: deleteDNS, isPending: isDeleting } = useAtomValue(deleteDNSAtom)
const { mutate: asyncDNS, isPending: isAsyncing } = useAtomValue(syncDNSAtom)
const [ open, setOpen ] = useState(false)
const columns = useMemo<ProColumns<WebSite.IDnsAccount>[]>(() => {
@ -206,13 +207,20 @@ const DNSList = () => {
return [
<Action key="edit"
as={'a'}
disabled={record.status === 2}
onClick={() => {
form.setFieldsValue(record)
setOpen(true)
}}>{t('actions.edit')}</Action>,
<Action key="sync"
as={'a'}
disabled={isAsyncing || record.status === 2}
onClick={() => {
asyncDNS(record)
}}>{t('actions.sync', '同步')}</Action>,
<Popconfirm
key={'del_confirm'}
disabled={isDeleting}
disabled={isDeleting || record.status === 2}
onConfirm={() => {
deleteDNS(record.id)
}}
@ -245,6 +253,7 @@ const DNSList = () => {
headerTitle={
<Button
onClick={() => {
form.resetFields()
form.setFieldsValue({
id: 0,
type: DNSTypeEnum.DnsPod,

9
src/service/websites.ts

@ -5,10 +5,10 @@ import request from '@/request.ts'
const websitesServ = {
ssl: {
...createCURD<any, WebSite.ISSL>('/website/ssl'),
upload: async(params: WebSite.SSLUploadDto)=>{
upload: async (params: WebSite.SSLUploadDto) => {
return request.post<any, WebSite.SSLUploadDto>('/website/ssl/upload', params)
},
download: async(params: any)=>{
download: async (params: any) => {
return request.download('/website/ssl/download', params)
},
},
@ -16,7 +16,10 @@ const websitesServ = {
...createCURD<any, WebSite.IAcmeAccount>('/website/acme')
},
dns: {
...createCURD<any, WebSite.IDnsAccount>('/website/dns_account')
...createCURD<any, WebSite.IDnsAccount>('/website/dns_account'),
sync: async (params: WebSite.IDnsAccount) => {
return request.post<any, WebSite.IDnsAccount>('/website/dns_account/sync', params)
}
},
ca: {
...createCURD<any, WebSite.ICA>('/website/ca'),

13
src/store/websites/dns.ts

@ -100,3 +100,16 @@ export const deleteDNSAtom = atomWithMutation<IApiResult, number>(get => ({
get(dnsListAtom).refetch()
}
}))
//sync
export const syncDNSAtom = atomWithMutation<IApiResult, number>(get => ({
mutationKey: [ 'syncDNS' ],
mutationFn: async (id) => {
return await websitesServ.dns.sync(id)
},
onSuccess: () => {
message.success(t('message.syncSuccess', '同步中'))
get(dnsListAtom).refetch()
}
}))
Loading…
Cancel
Save