Defer admin form runtime loading

This commit is contained in:
2026-06-09 19:10:03 +08:00
parent 0cf20cc1ea
commit fbd726ebdf
6 changed files with 46 additions and 7 deletions
+13 -1
View File
@@ -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 };