From 5ad9adeb4a3751f7c7cb52702bb59eb1a1d91fde Mon Sep 17 00:00:00 2001 From: huangqj Date: Fri, 8 Mar 2024 10:24:38 +0800 Subject: [PATCH] =?UTF-8?q?feat(ui):=E7=BB=86=E8=8A=82=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/composables/useCustomFormPopup.ts | 11 +++++-- .../vue-admin/src/composables/usePopup.ts | 2 +- .../src/views/ApiKey/ApiKeyContainer.vue | 6 ++-- .../vue-admin/src/views/ApiKey/ApiKeyForm.vue | 24 ++++++++++++++- .../views/ChatModel/ChatModelContainer.vue | 6 ++-- .../src/views/ChatModel/ChatModelForm.vue | 3 ++ .../vue-admin/src/views/DashboardView.vue | 29 +++++++++++++++---- .../src/views/Product/ProductContainer.vue | 6 ++-- .../src/views/Role/RoleContainer.vue | 13 +++++++-- .../src/views/User/UserContainer.vue | 10 +++++-- .../vue-admin/src/views/User/UserForm.vue | 16 ++++------ 11 files changed, 94 insertions(+), 32 deletions(-) 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 }) => {