Skip to content

Commit 8b08fb4

Browse files
committed
Fixed an issue(can not access TextComp before initialization)
1 parent 9704892 commit 8b08fb4

File tree

5 files changed

+46
-34
lines changed

5 files changed

+46
-34
lines changed

client/packages/lowcoder/src/appView/bootstrapAt.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1-
import { loadComps } from "bootstrap/admin";
21
import type { AppViewInstanceOptions } from "./AppViewInstance";
32
import { createRoot } from "react-dom/client";
4-
5-
loadComps();
3+
import {viewMode} from "@lowcoder-ee/util/editor";
64

75
export async function bootstrapAppAt<I>(
86
appId: string,
97
node: Element | null,
108
options: AppViewInstanceOptions<I> = {}
119
) {
10+
let loadComps: any;
11+
if(viewMode() !== "view") loadComps = await import("bootstrap/admin");
12+
else loadComps = await import("bootstrap/view");
13+
await loadComps();
1214
if (!node) {
1315
console.error("node must be not null.");
1416
return;

client/packages/lowcoder/src/bootstrap/admin/index.tsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import cnchar from "cnchar";
2-
import { trans } from "@lowcoder-ee/i18n";
2+
import { trans } from "../../i18n";
33
import { remoteComp } from "../../comps/comps/remoteComp/remoteComp";
44
import {
55
registerComp,
66
type UICompManifest,
77
type UICompType,
88
} from "../../comps/uiCompRegistry";
9-
import { RemoteCompInfo } from "@lowcoder-ee/types/remoteComp";
10-
import { MultiIcon } from "@lowcoder-ee/comps/comps/multiIconDisplay";
9+
import { RemoteCompInfo } from "../../types/remoteComp";
10+
import { MultiIcon } from "../../comps/comps/multiIconDisplay";
1111
import {
1212
AvatarCompIcon,
1313
AvatarGroupCompIcon,
@@ -113,13 +113,13 @@ import {
113113
KanbanCompIcon,
114114

115115
} from "lowcoder-design";
116-
import {TableComp} from "@lowcoder-ee/comps/comps/tableComp";
117-
import {TextComp} from "@lowcoder-ee/comps/comps/textComp";
118-
import {ModuleComp} from "@lowcoder-ee/comps/comps/moduleComp/moduleComp";
119-
import {InputComp} from "@lowcoder-ee/comps/comps/textInputComp/inputComp";
120-
import {TextAreaComp} from "@lowcoder-ee/comps/comps/textInputComp/textAreaComp";
121-
import {ButtonComp} from "@lowcoder-ee/comps/comps/buttonComp/buttonComp";
122-
import {ImageComp} from "@lowcoder-ee/comps/comps/imageComp";
116+
import {TableComp} from "../../comps/comps/tableComp";
117+
import {TextComp} from "../../comps/comps/textComp";
118+
import {ModuleComp} from "../../comps/comps/moduleComp/moduleComp";
119+
import {InputComp} from "../../comps/comps/textInputComp/inputComp";
120+
import {TextAreaComp} from "../../comps/comps/textInputComp/textAreaComp";
121+
import {ButtonComp} from "../../comps/comps/buttonComp/buttonComp";
122+
import {ImageComp} from "../../comps/comps/imageComp";
123123

124124
type Registry = {
125125
[key in UICompType]?: UICompManifest;

client/packages/lowcoder/src/bootstrap/view/index.tsx

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,15 @@ import {
44
type UICompType,
55
type UICompManifest
66
} from "../../comps/uiCompRegistry";
7-
import { RemoteCompInfo } from "@lowcoder-ee/types/remoteComp";
7+
import { RemoteCompInfo } from "../../types/remoteComp";
8+
9+
import {TableComp} from "../../comps/comps/tableComp";
10+
import {TextComp} from "../../comps/comps/textComp";
11+
import {ModuleComp} from "../../comps/comps/moduleComp/moduleComp";
12+
import {InputComp} from "../../comps/comps/textInputComp/inputComp";
13+
import {TextAreaComp} from "../../comps/comps/textInputComp/textAreaComp";
14+
import {ButtonComp} from "../../comps/comps/buttonComp/buttonComp";
15+
import {ImageComp} from "../../comps/comps/imageComp";
816

917
type Registry = {
1018
[key in UICompType]?: UICompManifest;
@@ -234,7 +242,8 @@ export var uiCompMap: Registry = {
234242
categories: ["dashboards"],
235243
icon: null,
236244
keywords: "",
237-
lazyLoad: true,
245+
lazyLoad: false,
246+
comp: TableComp,
238247
compName: "TableComp",
239248
compPath: "comps/tableComp/index",
240249
layoutInfo: {
@@ -818,8 +827,9 @@ export var uiCompMap: Registry = {
818827
categories: ["forms"],
819828
icon: null,
820829
keywords: "",
821-
lazyLoad: true,
830+
lazyLoad: false,
822831
compName: "InputComp",
832+
comp: InputComp,
823833
compPath: "comps/textInputComp/inputComp",
824834
layoutInfo: {
825835
w: 6,
@@ -863,8 +873,9 @@ export var uiCompMap: Registry = {
863873
categories: ["forms"],
864874
icon: null,
865875
keywords: "",
866-
lazyLoad: true,
876+
lazyLoad: false,
867877
compName: "TextAreaComp",
878+
comp: TextAreaComp,
868879
compPath: "comps/textInputComp/textAreaComp",
869880
layoutInfo: {
870881
w: 6,
@@ -1030,8 +1041,9 @@ export var uiCompMap: Registry = {
10301041
categories: ["forms"],
10311042
icon: null,
10321043
keywords: "",
1033-
lazyLoad: true,
1044+
lazyLoad: false,
10341045
compName: "ButtonComp",
1046+
comp: ButtonComp,
10351047
compPath: "comps/buttonComp/buttonComp",
10361048
layoutInfo: {
10371049
w: 6,
@@ -1270,8 +1282,9 @@ export var uiCompMap: Registry = {
12701282
categories: ["multimedia"],
12711283
icon: null,
12721284
keywords: "",
1273-
lazyLoad: true,
1285+
lazyLoad: false,
12741286
compName: "ImageComp",
1287+
comp: ImageComp,
12751288
compPath: "comps/imageComp",
12761289
layoutInfo: {
12771290
w: 12,
@@ -1594,8 +1607,9 @@ export var uiCompMap: Registry = {
15941607
description: "",
15951608
categories: [],
15961609
keywords: "",
1597-
lazyLoad: true,
1610+
lazyLoad: false,
15981611
compName: "ModuleComp",
1612+
comp: ModuleComp,
15991613
compPath: "comps/moduleComp/moduleComp",
16001614
layoutInfo: {
16011615
w: 12,
@@ -1613,7 +1627,8 @@ export var uiCompMap: Registry = {
16131627
icon: null,
16141628
keywords: "",
16151629
compName: "TextComp",
1616-
lazyLoad: true,
1630+
lazyLoad: false,
1631+
comp: TextComp,
16171632
compPath: "comps/textComp",
16181633
layoutInfo: {
16191634
w: 6,

client/packages/lowcoder/src/index.sdk.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export * from "util/context/ExternalEditorContext";
5959
export { CanvasContainerID } from "constants/domLocators";
6060

6161
// comps
62-
export * from "bootstrap/admin";
62+
// export * from "bootstrap/admin";
6363
export * from "comps/comps/rootComp";
6464

6565
// comp utils

client/packages/lowcoder/src/index.ts

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,13 @@ debug(`REACT_APP_ENV:, ${REACT_APP_ENV}`);
4242
debug(`REACT_APP_LOG_LEVEL:, ${REACT_APP_LOG_LEVEL}`);
4343
initTranslatorDesign().then(() => {
4444
initTranslator().then(async () => {
45-
try {
46-
if (!window.location.href.includes("view")) {
47-
const bootstrap = await import("./bootstrap/admin/app").then(module => module.bootstrap);
48-
bootstrap();
49-
} else {
50-
const bootstrap = await import("./bootstrap/view/app").then(module => module.bootstrap);
51-
console.log("view")
52-
bootstrap();
53-
}
54-
hideLoading();
55-
} catch (e) {
56-
log.error(e);
45+
if (!window.location.href.includes("view")) {
46+
const bootstrap = await import("./bootstrap/admin/app").then(module => module.bootstrap);
47+
bootstrap();
48+
} else {
49+
const bootstrap = await import("./bootstrap/view/app").then(module => module.bootstrap);
50+
bootstrap();
5751
}
52+
hideLoading();
5853
})
5954
})

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy