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
@@ -174,6 +174,8 @@ const withDefaultPlaceholder = <T extends Component>(
};
// 这里需要自行根据业务组件库进行适配,需要用到的组件都需要在这里类型说明
let initialized = false;
export type ComponentType =
| 'ApiSelect'
| 'ApiTreeSelect'
@@ -203,7 +205,11 @@ export type ComponentType =
| 'UserSelector'
| BaseFormComponentType;
async function initComponentAdapter() {
function initComponentAdapter() {
if (initialized) {
return;
}
const components: Partial<Record<ComponentType, Component>> = {
// 如果你的组件体积比较大,可以使用异步加载
// Button: () =>
@@ -349,6 +355,7 @@ async function initComponentAdapter() {
// 将组件注册到全局共享状态中
globalShareState.setComponents(components);
initialized = true;
// 定义全局共享状态中的消息提示
globalShareState.defineMessage({