1
0
mirror of synced 2026-03-23 11:18:36 +08:00

feat(vue-components,react-components): 增加点击事件,使用组件状态hook

This commit is contained in:
roymondchen
2025-03-06 20:29:38 +08:00
parent 8d0040da53
commit 0736646c63
60 changed files with 594 additions and 378 deletions

View File

@@ -1,5 +1,5 @@
{
"version": "0.0.2",
"version": "0.1.0",
"name": "@tmagic/react-page",
"type": "module",
"main": "src/index.ts",
@@ -14,17 +14,13 @@
"url": "https://github.com/Tencent/tmagic-editor.git"
},
"peerDependencies": {
"@tmagic/utils": "workspace:^",
"@tmagic/schema": "workspace:^",
"@tmagic/core": "workspace:^",
"@tmagic/react-runtime-help": "workspace:^",
"react": ">=18.3.1",
"react-dom": ">=18.3.1",
"typescript": "*"
},
"peerDependenciesMeta": {
"@tmagic/schema": {
"optional": true
},
"typescript": {
"optional": true
}

View File

@@ -18,8 +18,9 @@
import React from 'react';
import { useApp } from '@tmagic/react-runtime-help';
import type { MPage } from '@tmagic/schema';
import type { MPage } from '@tmagic/core';
import { IS_DSL_NODE_KEY } from '@tmagic/core';
import { useApp, useComponentStatus } from '@tmagic/react-runtime-help';
interface PageProps {
config: MPage;
@@ -27,7 +28,7 @@ interface PageProps {
const Page: React.FC<PageProps> = ({ config }) => {
const { app } = useApp({
config,
config: { ...config, [IS_DSL_NODE_KEY]: true },
methods: {
refresh: () => window.location.reload(),
},
@@ -37,12 +38,16 @@ const Page: React.FC<PageProps> = ({ config }) => {
const MagicUiComp = app.resolveComponent('container');
const classNames = ['magic-ui-page'];
if (config.className) {
classNames.push(config.className);
}
const { style, className } = useComponentStatus({ config });
return <MagicUiComp config={config} id={config.id} className={classNames.join(' ')}></MagicUiComp>;
return (
<MagicUiComp
config={{ ...config, [IS_DSL_NODE_KEY]: false }}
id={config.id}
className={className}
style={style}
></MagicUiComp>
);
};
Page.displayName = 'magic-ui-page';

View File

@@ -16,7 +16,7 @@
* limitations under the License.
*/
import { getElById } from '@tmagic/utils';
import { getElById } from '@tmagic/core';
export default [
{