Defer admin form runtime loading
This commit is contained in:
@@ -8,7 +8,16 @@ import type { ComponentType } from './component';
|
||||
import { setupVbenForm, useVbenForm as useForm, z } from '@vben-core/form-ui';
|
||||
import { $t } from '@vben/locales';
|
||||
|
||||
async function initSetupVbenForm() {
|
||||
import { initComponentAdapter } from './component';
|
||||
|
||||
let initialized = false;
|
||||
|
||||
function initSetupVbenForm() {
|
||||
if (initialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
initComponentAdapter();
|
||||
setupVbenForm<ComponentType>({
|
||||
config: {
|
||||
modelPropNameMap: {
|
||||
@@ -31,8 +40,11 @@ async function initSetupVbenForm() {
|
||||
},
|
||||
},
|
||||
});
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
initSetupVbenForm();
|
||||
|
||||
const useVbenForm = useForm<ComponentType>;
|
||||
|
||||
export { initSetupVbenForm, useVbenForm, z };
|
||||
|
||||
Reference in New Issue
Block a user