diff --git a/runtime/react/package.json b/runtime/react/package.json index 83a31688..3a33b28e 100644 --- a/runtime/react/package.json +++ b/runtime/react/package.json @@ -20,7 +20,7 @@ }, "dependencies": { "@tmagic/core": "1.5.9", - "@tmagic/react-runtime-help": "0.0.4", + "@tmagic/react-runtime-help": "0.1.0", "@tmagic/stage": "1.5.9", "axios": "^0.25.0", "terser": "^5.31.6", diff --git a/runtime/react/playground/App.tsx b/runtime/react/playground/App.tsx index a3638d2d..bab21b07 100644 --- a/runtime/react/playground/App.tsx +++ b/runtime/react/playground/App.tsx @@ -16,7 +16,7 @@ * limitations under the License. */ -import React, { useContext } from 'react'; +import React, { useContext, useEffect } from 'react'; import type Core from '@tmagic/core'; import type { MPage } from '@tmagic/core'; @@ -31,7 +31,12 @@ function App() { const MagicUiPage = app.resolveComponent('page'); - return ; + useEffect(() => { + const page = document.querySelector(`div[data-tmagic-id=${app.page?.data.id}]`); + page && window.magic?.onPageElUpdate(page as HTMLElement); + }); + + return ; } export default App; diff --git a/runtime/react/playground/main.tsx b/runtime/react/playground/main.tsx index 98cf3d4f..5d2ffda3 100644 --- a/runtime/react/playground/main.tsx +++ b/runtime/react/playground/main.tsx @@ -63,11 +63,6 @@ const renderDom = () => { , ); - - setTimeout(() => { - // @ts-ignore - window.magic.onPageElUpdate(document.querySelector('.magic-ui-page')); - }); }; Object.keys(components).forEach((type: string) => app.registerComponent(type, components[type])); diff --git a/runtime/react/tsconfig.json b/runtime/react/tsconfig.json index cb593495..6a118e44 100644 --- a/runtime/react/tsconfig.json +++ b/runtime/react/tsconfig.json @@ -5,5 +5,10 @@ "jsx": "react", "forceConsistentCasingInFileNames": true, "types": ["node"], + "paths": { + // 内部模块都指向 src/index.ts, 会有更好的代码跳转体验. + "@tmagic/*": ["../../packages/*/src"], + "@tmagic/react-runtime-help": ["../react-runtime-help/src"], + }, }, } diff --git a/runtime/vue2/package.json b/runtime/vue2/package.json index 030bcb5b..bc5827e6 100644 --- a/runtime/vue2/package.json +++ b/runtime/vue2/package.json @@ -21,7 +21,7 @@ "dependencies": { "@tmagic/core": "1.5.9", "@tmagic/stage": "1.5.9", - "@tmagic/vue-runtime-help": "^1.0.0", + "@tmagic/vue-runtime-help": "^1.1.0", "axios": "^0.25.0", "terser": "^5.31.6", "vue": "^2.7.16" diff --git a/runtime/vue3/package.json b/runtime/vue3/package.json index d8e3b1f5..98cb26e3 100644 --- a/runtime/vue3/package.json +++ b/runtime/vue3/package.json @@ -21,7 +21,7 @@ "dependencies": { "@tmagic/core": "1.5.9", "@tmagic/stage": "1.5.9", - "@tmagic/vue-runtime-help": "^1.0.0", + "@tmagic/vue-runtime-help": "^1.1.0", "axios": "^0.25.0", "vue": "^3.5.0" },