Skip to content

Commit b151ff5

Browse files
fixed interactive comp playground
1 parent 73adc1a commit b151ff5

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

client/packages/lowcoder/src/comps/comps/remoteComp/loaders.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ async function npmLoader(
2323
? `${sdkConfig.baseURL}/${ASSETS_BASE_URL}`
2424
: NPM_PLUGIN_ASSETS_BASE_URL;
2525

26-
const entry = `${pluginBaseUrl}/${appId}/${packageName}@${localPackageVersion}/index.js`;
26+
const entry = `${pluginBaseUrl}/${appId || 'none'}/${packageName}@${localPackageVersion}/index.js`;
2727

2828
try {
2929
const module = await import(

client/packages/lowcoder/src/pages/ComponentPlayground/index.tsx

+16-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import { useParams } from "react-router-dom";
22
import styled from "styled-components";
33
import "comps";
4-
import { UICompType, UICompManifest, uiCompRegistry, UICompCategory } from "comps/uiCompRegistry";
4+
import { UICompType, UICompManifest, uiCompRegistry, UICompCategory, ExposingMultiCompConstructor } from "comps/uiCompRegistry";
55
import { CompPlayground } from "ide/CompPlayground";
66
import { Comp } from "lowcoder-core";
77
import { EditorContext, EditorState } from "comps/editorState";
88
import { RootComp } from "comps/comps/rootComp";
9+
import { useMemo } from "react";
10+
import { lazyLoadComp } from "@lowcoder-ee/comps/comps/lazyLoadComp/lazyLoadComp";
911

1012
type CompInfo = UICompManifest & { key: string };
1113
const groups: Partial<Record<UICompCategory, CompInfo[]>> = {};
@@ -56,13 +58,25 @@ export default function ComponentPlayground() {
5658
const dsl = JSON.parse(decodeURIComponent(params.dsl || ""));
5759
const compManifest = uiCompRegistry[params.name];
5860

61+
const comp = useMemo(() => {
62+
if (!compManifest.lazyLoad) {
63+
return compManifest.comp;
64+
}
65+
66+
return lazyLoadComp(
67+
compManifest.compName,
68+
compManifest.compPath,
69+
)
70+
}, [compManifest]);
71+
if (!comp) return null;
72+
5973
return (
6074
<Wrapper>
6175
<div className="content">
6276
<EditorContext.Provider value={editorState}>
6377
<CompPlayground
6478
initialValue={dsl}
65-
compFactory={compManifest.comp as unknown as Comp<any>}
79+
compFactory={comp as unknown as Comp<any>}
6680
layoutInfo={compManifest.layoutInfo || { h: 5, w: 5 }}
6781
/>
6882
</EditorContext.Provider>

0 commit comments

Comments
 (0)