Quellcode durchsuchen

feat: 插件新增依赖注入功能

Jin Mao vor 2 Monaten
Ursprung
Commit
6da3017dcf
2 geänderte Dateien mit 18 neuen und 17 gelöschten Zeilen
  1. 11 16
      playground/src/adapter/vxe-table.ts
  2. 7 1
      playground/src/bootstrap.ts

+ 11 - 16
playground/src/adapter/vxe-table.ts

@@ -1,24 +1,20 @@
-import type { VxeTableGridOptions } from '@vben/plugins/vxe-table';
-import type { Recordable } from '@vben/types';
+import type { VxeTableGridOptions } from "@vben/plugins/vxe-table";
+import { setupVbenVxeTable, useVbenVxeGrid as useGrid } from "@vben/plugins/vxe-table";
+import type { Recordable } from "@vben/types";
 
-import type { ComponentType } from './component';
+import type { ComponentType } from "./component";
 
-import { h } from 'vue';
+import { h } from "vue";
 
-import { IconifyIcon } from '@vben/icons';
-import { $te } from '@vben/locales';
-import {
-  setupVbenVxeTable,
-  useVbenVxeGrid as useGrid,
-} from '@vben/plugins/vxe-table';
-import { get, isFunction, isString } from '@vben/utils';
+import { IconifyIcon } from "@vben/icons";
+import { $te } from "@vben/locales";
+import { get, isFunction, isString } from "@vben/utils";
 
-import { objectOmit } from '@vueuse/core';
-import { Button, Image, Popconfirm, Switch, Tag } from 'ant-design-vue';
+import { objectOmit } from "@vueuse/core";
+import { Button, Image, Popconfirm, Switch, Tag } from "ant-design-vue";
 
-import { $t } from '#/locales';
 
-import { useVbenForm } from './form';
+import { $t } from "#/locales";
 
 setupVbenVxeTable({
   configVxeTable: (vxeUI) => {
@@ -281,7 +277,6 @@ setupVbenVxeTable({
     // 这里可以自行扩展 vxe-table 的全局配置,比如自定义格式化
     // vxeUI.formats.add
   },
-  useVbenForm,
 });
 
 export const useVbenVxeGrid = <T extends Record<string, any>>(

+ 7 - 1
playground/src/bootstrap.ts

@@ -2,6 +2,7 @@ import { createApp, watchEffect } from 'vue';
 
 import { registerAccessDirective } from '@vben/access';
 import { registerLoadingDirective } from '@vben/common-ui';
+import { providePluginsOptions } from '@vben/plugins';
 import { preferences } from '@vben/preferences';
 import { initStores } from '@vben/stores';
 import '@vben/styles';
@@ -13,7 +14,7 @@ import { $t, setupI18n } from '#/locales';
 import { router } from '#/router';
 
 import { initComponentAdapter } from './adapter/component';
-import { initSetupVbenForm } from './adapter/form';
+import { initSetupVbenForm, useVbenForm } from './adapter/form';
 import App from './app.vue';
 import { initTimezone } from './timezone-init';
 
@@ -24,6 +25,11 @@ async function bootstrap(namespace: string) {
   // 初始化表单组件
   await initSetupVbenForm();
 
+  // 注入插件全局配置
+  providePluginsOptions({
+    form: { useVbenForm },
+  });
+
   // 设置弹窗的默认配置
   // setDefaultModalProps({
   //   fullscreenButton: false,