mirror of
https://github.com/certd/certd.git
synced 2026-04-24 04:17:25 +08:00
perf: cname记录支持批量导入和导出
This commit is contained in:
@@ -60,7 +60,7 @@ export async function DeleteBatch(ids: any[]) {
|
||||
|
||||
export async function SyncSubmit(body: any) {
|
||||
return await request({
|
||||
url: apiPrefix + "/sync/submit",
|
||||
url: apiPrefix + "/sync/import",
|
||||
method: "post",
|
||||
data: body,
|
||||
});
|
||||
|
||||
@@ -157,6 +157,9 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
|
||||
expirationDate: {
|
||||
title: t("certd.domain.expirationDate"),
|
||||
type: "date",
|
||||
form: {
|
||||
show: false,
|
||||
},
|
||||
},
|
||||
challengeType: {
|
||||
title: t("certd.domain.challengeType"),
|
||||
|
||||
@@ -77,3 +77,11 @@ export async function ResetStatus(id: number) {
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export async function Import(form: { domainList: string; cnameProviderId: any }) {
|
||||
return await request({
|
||||
url: apiPrefix + "/import",
|
||||
method: "post",
|
||||
data: form,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -7,7 +7,9 @@ import { useUserStore } from "/@/store/user";
|
||||
import { useSettingStore } from "/@/store/settings";
|
||||
import { message, Modal } from "ant-design-vue";
|
||||
import CnameTip from "/@/components/plugins/cert/domains-verify-plan-editor/cname-tip.vue";
|
||||
import { useCnameImport } from "./use";
|
||||
export default function ({ crudExpose, context }: CreateCrudOptionsProps): CreateCrudOptionsRet {
|
||||
const crudBinding = crudExpose.crudBinding;
|
||||
const router = useRouter();
|
||||
const { t } = useI18n();
|
||||
const pageRequest = async (query: UserPageQuery): Promise<UserPageRes> => {
|
||||
@@ -27,10 +29,13 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
|
||||
return res;
|
||||
};
|
||||
|
||||
const openCnameImportDialog = useCnameImport();
|
||||
|
||||
const userStore = useUserStore();
|
||||
const settingStore = useSettingStore();
|
||||
const selectedRowKeys: Ref<any[]> = ref([]);
|
||||
context.selectedRowKeys = selectedRowKeys;
|
||||
|
||||
const dictRef = dict({
|
||||
data: [
|
||||
{ label: t("certd.pending_cname_setup"), value: "cname", color: "warning" },
|
||||
@@ -64,6 +69,32 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
|
||||
editRequest,
|
||||
delRequest,
|
||||
},
|
||||
actionbar: {
|
||||
buttons: {
|
||||
import: {
|
||||
title: "导入CNAME记录",
|
||||
type: "primary",
|
||||
text: "批量导入",
|
||||
click: () => {
|
||||
openCnameImportDialog({
|
||||
afterSubmit: () => {
|
||||
setTimeout(() => {
|
||||
crudExpose?.doRefresh();
|
||||
}, 2000);
|
||||
},
|
||||
});
|
||||
},
|
||||
},
|
||||
export: {
|
||||
title: "导出CNAME记录之后,可用于批量导入cname解析到域名注册商",
|
||||
type: "primary",
|
||||
text: "批量导出",
|
||||
click: () => {
|
||||
crudBinding.value.toolbar.buttons.export.click({});
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
tabs: {
|
||||
name: "status",
|
||||
show: true,
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
import { dict } from "@fast-crud/fast-crud";
|
||||
import { message } from "ant-design-vue";
|
||||
import * as api from "./api";
|
||||
import { useFormDialog } from "/@/use/use-dialog";
|
||||
|
||||
export const cnameProviderDict = dict({
|
||||
url: "/cname/provider/list",
|
||||
value: "id",
|
||||
label: "domain",
|
||||
});
|
||||
export function useCnameImport() {
|
||||
const { openFormDialog } = useFormDialog();
|
||||
|
||||
const columns = {
|
||||
domainList: {
|
||||
title: "域名列表",
|
||||
type: "text",
|
||||
form: {
|
||||
component: {
|
||||
name: "a-textarea",
|
||||
rows: 5,
|
||||
},
|
||||
col: {
|
||||
span: 24,
|
||||
},
|
||||
required: true,
|
||||
helper: "每个域名一行,批量导入\n泛域名请去掉*.\n已经存在的会自动跳过",
|
||||
},
|
||||
},
|
||||
cnameProviderId: {
|
||||
title: "CNAME服务",
|
||||
type: "dict-select",
|
||||
dict: cnameProviderDict,
|
||||
form: {
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
return function openCnameImportDialog(req: { afterSubmit?: () => void }) {
|
||||
openFormDialog({
|
||||
title: "导入CNAME记录",
|
||||
columns: columns,
|
||||
onSubmit: async (form: any) => {
|
||||
await api.Import({
|
||||
domainList: form.domainList,
|
||||
cnameProviderId: form.cnameProviderId,
|
||||
});
|
||||
message.success("导入任务已提交");
|
||||
if (req.afterSubmit) {
|
||||
req.afterSubmit();
|
||||
}
|
||||
},
|
||||
});
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user