mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-24 03:19:18 +08:00
update: 升级vben5.5.9到5.7.0
This commit is contained in:
@@ -4,38 +4,22 @@ import { defineComponent, watch } from 'vue';
|
||||
|
||||
import { usePreferences } from '@vben/preferences';
|
||||
|
||||
import { useVbenForm } from '@vben-core/form-ui';
|
||||
|
||||
import {
|
||||
VxeButton,
|
||||
VxeCheckbox,
|
||||
|
||||
// VxeFormGather,
|
||||
// VxeForm,
|
||||
// VxeFormItem,
|
||||
VxeIcon,
|
||||
VxeInput,
|
||||
VxeLoading,
|
||||
VxeModal,
|
||||
VxeNumberInput,
|
||||
VxePager,
|
||||
// VxeList,
|
||||
// VxeModal,
|
||||
// VxeOptgroup,
|
||||
// VxeOption,
|
||||
// VxePulldown,
|
||||
// VxeRadio,
|
||||
// VxeRadioButton,
|
||||
VxeRadioGroup,
|
||||
VxeSelect,
|
||||
VxeTooltip,
|
||||
VxeUI,
|
||||
VxeUpload,
|
||||
// VxeSwitch,
|
||||
// VxeTextarea,
|
||||
} from 'vxe-pc-ui';
|
||||
import enUS from 'vxe-pc-ui/lib/language/en-US';
|
||||
// 导入默认的语言
|
||||
import enUS from 'vxe-pc-ui/lib/language/en-US'; // 导入默认的语言
|
||||
import zhCN from 'vxe-pc-ui/lib/language/zh-CN';
|
||||
import {
|
||||
VxeColgroup,
|
||||
@@ -45,13 +29,37 @@ import {
|
||||
VxeToolbar,
|
||||
} from 'vxe-table';
|
||||
|
||||
import { extendsDefaultFormatter } from './extends';
|
||||
import { injectPluginsOptions } from '../plugins-context';
|
||||
import { extendsDefaultFormatter } from './extends'; // 是否加载过
|
||||
|
||||
// 是否加载过
|
||||
let isInit = false;
|
||||
|
||||
// eslint-disable-next-line import/no-mutable-exports
|
||||
export let useTableForm: typeof useVbenForm;
|
||||
let tableFormFactory: ((...args: any[]) => any) | undefined;
|
||||
|
||||
function normalizeVxeLocale<T extends Record<string, any>>(localeModule: T) {
|
||||
return (
|
||||
localeModule &&
|
||||
typeof localeModule === 'object' &&
|
||||
'default' in localeModule
|
||||
? localeModule.default
|
||||
: localeModule
|
||||
) as T;
|
||||
}
|
||||
|
||||
export function useTableForm(...args: any[]) {
|
||||
const pluginsOptions = injectPluginsOptions();
|
||||
const contextFormFactory = pluginsOptions?.form?.useVbenForm;
|
||||
|
||||
const factory = tableFormFactory || contextFormFactory;
|
||||
if (!factory) {
|
||||
throw new Error(
|
||||
'useTableForm is not initialized. Please provide useVbenForm via setupVbenVxeTable() or providePluginsOptions()',
|
||||
);
|
||||
}
|
||||
|
||||
return factory(...args);
|
||||
}
|
||||
|
||||
// 部分组件,如果没注册,vxe-table 会报错,这里实际没用组件,只是为了不报错,同时可以减少打包体积
|
||||
const createVirtualComponent = (name = '') => {
|
||||
@@ -101,16 +109,19 @@ export function initVxeTable() {
|
||||
}
|
||||
|
||||
export function setupVbenVxeTable(setupOptions: SetupVxeTable) {
|
||||
const { configVxeTable, useVbenForm } = setupOptions;
|
||||
const { configVxeTable, useVbenForm: useVbenFormFromParam } = setupOptions;
|
||||
|
||||
initVxeTable();
|
||||
useTableForm = useVbenForm;
|
||||
|
||||
// 优先使用参数传入的 useVbenForm,否则清空让 context 注入生效
|
||||
if (useVbenFormFromParam) {
|
||||
tableFormFactory = useVbenFormFromParam;
|
||||
}
|
||||
const { isDark, locale } = usePreferences();
|
||||
|
||||
const localMap = {
|
||||
'zh-CN': zhCN,
|
||||
'en-US': enUS,
|
||||
'zh-CN': normalizeVxeLocale(zhCN),
|
||||
'en-US': normalizeVxeLocale(enUS),
|
||||
};
|
||||
|
||||
watch(
|
||||
|
||||
Reference in New Issue
Block a user