diff --git a/gpt-vue/projects/vue-admin/src/composables/useCustomFormPopup.ts b/gpt-vue/projects/vue-admin/src/composables/useCustomFormPopup.ts index 94c3ca33..41be9d81 100644 --- a/gpt-vue/projects/vue-admin/src/composables/useCustomFormPopup.ts +++ b/gpt-vue/projects/vue-admin/src/composables/useCustomFormPopup.ts @@ -1,4 +1,4 @@ -import usePopup from "./usePopup"; +import usePopup, { type Config } from "./usePopup"; import { Message } from "@arco-design/web-vue"; import type { Component } from "vue"; import type { BaseResponse } from "@gpt-vue/packages/type"; @@ -6,19 +6,23 @@ interface Arg { reload?: () => void; record?: Record; } + export default function ( node: Component, - api: (params?: any) => Promise> + api: (params?: any) => Promise>, + config?: Config ): (arg: Arg) => void { const nodeProps = (arg: Arg[]) => { return { data: arg[0].record || {}, + ...config.nodeProps?.(arg), }; }; const popupProps = (arg: Arg[], getExposed) => { return { - width: 800, + width: 750, + maskClosable: false, onBeforeOk: async () => { const exposed = getExposed(); const validateRes = await exposed?.formRef.value.validate(); @@ -32,6 +36,7 @@ export default function ( arg[0]?.reload?.(); return code === 0; }, + ...config.popupProps?.(arg, getExposed), }; }; diff --git a/gpt-vue/projects/vue-admin/src/composables/usePopup.ts b/gpt-vue/projects/vue-admin/src/composables/usePopup.ts index 282e1d3c..5a4fd6e3 100644 --- a/gpt-vue/projects/vue-admin/src/composables/usePopup.ts +++ b/gpt-vue/projects/vue-admin/src/composables/usePopup.ts @@ -4,7 +4,7 @@ import { Modal, Drawer } from "@arco-design/web-vue"; import type { ModalConfig, DrawerConfig } from "@arco-design/web-vue"; import app from "@/main"; -interface Config { +export interface Config { nodeProps?: (...arg: any) => Record; popupProps?: ( arg: any[], diff --git a/gpt-vue/projects/vue-admin/src/views/ApiKey/ApiKeyContainer.vue b/gpt-vue/projects/vue-admin/src/views/ApiKey/ApiKeyContainer.vue index 1b1dbac4..f3e04486 100644 --- a/gpt-vue/projects/vue-admin/src/views/ApiKey/ApiKeyContainer.vue +++ b/gpt-vue/projects/vue-admin/src/views/ApiKey/ApiKeyContainer.vue @@ -59,7 +59,9 @@ const getData = () => { getData(); // 新增编辑 -const popup = useCustomFormPopup(ApiKeyForm, save); +const popup = useCustomFormPopup(ApiKeyForm, save, { + popupProps: (arg) => ({ title: arg[0].record ? "编辑ApiKey" : "新增ApiKey" }), +}); // 删除 const handleDelete = ({ id }, reload) => { @@ -90,7 +92,7 @@ const handleStatusChange = ({ filed, value, record, reload }) => {