Skip to content

Commit

Permalink
💄 style: fix default plugins height unstabled when scrolling (lobehub…
Browse files Browse the repository at this point in the history
…#1142)

* ⚡️ perf: Add cache to render default plugins

* 🐛 fix: The debug panel cannot be closed
  • Loading branch information
mushan0x0 authored Jan 24, 2024
1 parent 0159a1a commit abed417
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/features/Conversation/Plugins/Inspector/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ const Inspector = memo<InspectorProps>(
label: t('debug.response'),
},
]}
style={{ maxWidth: 800 }}
style={{ display: 'grid', maxWidth: 800 }}
/>
)}
</Flexbox>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,23 @@ interface SystemJsRenderProps extends PluginRenderProps {
url: string;
}

const RenderCache: {
[url: string]: PluginRender;
} = {};

const SystemJsRender = memo<SystemJsRenderProps>(({ url, ...props }) => {
const [component, setComp] = useState<PluginRender | null>(null);
const [component, setComp] = useState<PluginRender | undefined>(RenderCache[url]);

useEffect(() => {
system
.import(url)
.then((module1) => {
setComp(module1.default);
RenderCache[url] = module1.default;
// 使用module1模块
})
.catch((error) => {
setComp(null);
setComp(undefined);
console.error(error);
});
}, [url]);
Expand Down

0 comments on commit abed417

Please sign in to comment.