@yl_lowcode/docs-theme 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/demo.vue CHANGED
@@ -1,5 +1,7 @@
1
1
  <script setup lang="ts">
2
2
  // @ts-nocheck
3
+ import React from "react";
4
+ import * as ReactDOMClient from "react-dom/client";
3
5
  import { ref, onMounted, onBeforeUnmount } from "vue";
4
6
  import { withBase } from 'vitepress'
5
7
 
@@ -17,11 +19,8 @@ let copyTimer: ReturnType<typeof setTimeout> | null = null;
17
19
 
18
20
  function mountPreview() {
19
21
  if (!previewRef.value) return;
20
- const React = (window as any).React;
21
- const ReactDOM = (window as any).ReactDOM;
22
- if (!React || !ReactDOM) return;
23
22
  previewRoot?.unmount();
24
- previewRoot = ReactDOM.createRoot(previewRef.value);
23
+ previewRoot = ReactDOMClient.createRoot(previewRef.value);
25
24
  previewRoot.render(React.createElement(props.component));
26
25
  }
27
26
  function openLive() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yl_lowcode/docs-theme",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "description": "共享 VitePress 文档主题(React Demo 支持)",
5
5
  "type": "module",
6
6
  "main": "index.ts",
package/playground.vue CHANGED
@@ -1,5 +1,7 @@
1
1
  <script setup lang="ts">
2
2
  // @ts-nocheck
3
+ import React from "react";
4
+ import * as ReactDOMClient from "react-dom/client";
3
5
  import { ref, inject, onMounted, onBeforeUnmount } from "vue";
4
6
  /**
5
7
  * 通用 Playground 组件
@@ -30,8 +32,6 @@ onMounted(async () => {
30
32
  if (!matchKey) return;
31
33
 
32
34
  const rawCode = (await config.codeGlobs[matchKey]()).raw as string;
33
- const React = (window as any).React;
34
- const ReactDOM = (window as any).ReactDOM;
35
35
  const { transform } = await import("sucrase");
36
36
  const userModules = await config.loadModules();
37
37
 
@@ -202,7 +202,7 @@ onMounted(async () => {
202
202
  );
203
203
  }
204
204
 
205
- reactRoot = ReactDOM.createRoot(containerRef.value);
205
+ reactRoot = ReactDOMClient.createRoot(containerRef.value);
206
206
  reactRoot.render(React.createElement(App));
207
207
  });
208
208