1
This commit is contained in:
parent
6d25ac942f
commit
1d12668e9b
@ -6,7 +6,7 @@
|
|||||||
<title>AG Chart Service</title>
|
<title>AG Chart Service</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="zbChart"></div>
|
<div id="sbChart"></div>
|
||||||
<script type="module" src="/src/main.tsx"></script>
|
<script type="module" src="/src/main.tsx"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
23
src/main.tsx
23
src/main.tsx
@ -10,16 +10,29 @@ ModuleRegistry.registerModules([AllCommunityModule]);
|
|||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface Window {
|
interface Window {
|
||||||
__zbChartRoot?: ReturnType<typeof createRoot>;
|
__chartReactRoots?: WeakMap<Element, ReturnType<typeof createRoot>>;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const chartContainerId = 'sbChart';
|
||||||
|
|
||||||
|
const getRootRegistry = () => {
|
||||||
|
window.__chartReactRoots ??= new WeakMap<Element, ReturnType<typeof createRoot>>();
|
||||||
|
return window.__chartReactRoots;
|
||||||
|
};
|
||||||
|
|
||||||
const mount = () => {
|
const mount = () => {
|
||||||
const container = document.getElementById('zbChart');
|
const container = document.getElementById(chartContainerId);
|
||||||
if (!container) return false;
|
if (!container) return false;
|
||||||
|
|
||||||
window.__zbChartRoot ??= createRoot(container);
|
const roots = getRootRegistry();
|
||||||
window.__zbChartRoot.render(
|
let root = roots.get(container);
|
||||||
|
if (!root) {
|
||||||
|
root = createRoot(container);
|
||||||
|
roots.set(container, root);
|
||||||
|
}
|
||||||
|
|
||||||
|
root.render(
|
||||||
<StrictMode>
|
<StrictMode>
|
||||||
<App />
|
<App />
|
||||||
</StrictMode>,
|
</StrictMode>,
|
||||||
@ -34,7 +47,7 @@ if (!mount()) {
|
|||||||
if (mount() || retryCount >= 40) {
|
if (mount() || retryCount >= 40) {
|
||||||
window.clearInterval(timer);
|
window.clearInterval(timer);
|
||||||
if (retryCount >= 40) {
|
if (retryCount >= 40) {
|
||||||
console.warn('zbChart container was not found.');
|
console.warn(`${chartContainerId} container was not found.`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, 50);
|
}, 50);
|
||||||
|
|||||||
@ -2,7 +2,19 @@ import { defineConfig } from 'vite';
|
|||||||
import react from '@vitejs/plugin-react';
|
import react from '@vitejs/plugin-react';
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
plugins: [react()],
|
plugins: [
|
||||||
|
react(),
|
||||||
|
{
|
||||||
|
name: 'weaver-script-scope-wrapper',
|
||||||
|
renderChunk(code, chunk) {
|
||||||
|
if (!chunk.isEntry) return null;
|
||||||
|
return {
|
||||||
|
code: `;(() => {\n${code}\n})();\n`,
|
||||||
|
map: null,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
server: {
|
server: {
|
||||||
port: 5173,
|
port: 5173,
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user