fix(editor,ui,ui-vue2,ui-react): 页面配置更新后,蒙层无法显示

fix #472
This commit is contained in:
roymondchen 2023-03-06 16:29:46 +08:00
parent 449efcc56b
commit c025508cd7
5 changed files with 8 additions and 8 deletions

View File

@ -230,7 +230,7 @@ class Editor extends BaseService {
if (node?.id) { if (node?.id) {
this.get('stage') this.get('stage')
?.renderer.runtime?.getApp?.() ?.renderer.runtime?.getApp?.()
?.emit( .page?.emit(
'editor:select', 'editor:select',
{ {
node, node,

View File

@ -16,7 +16,7 @@
* limitations under the License. * limitations under the License.
*/ */
import React, { useContext, useEffect, useState } from 'react'; import React, { useContext, useState } from 'react';
import Core from '@tmagic/core'; import Core from '@tmagic/core';
import type { MComponent, MNode } from '@tmagic/schema'; import type { MComponent, MNode } from '@tmagic/schema';
@ -31,7 +31,7 @@ interface OverlayProps {
const Overlay: React.FC<OverlayProps> = ({ config }) => { const Overlay: React.FC<OverlayProps> = ({ config }) => {
const [visible, setVisible] = useState(false); const [visible, setVisible] = useState(false);
const app: Core = useContext(AppContent); const app: Core | undefined = useContext(AppContent);
const node = app?.page?.getNode(config.id); const node = app?.page?.getNode(config.id);
if (!app) return null; if (!app) return null;
@ -58,7 +58,7 @@ const Overlay: React.FC<OverlayProps> = ({ config }) => {
}, },
}); });
app?.on('editor:select', (info: any, path: MNode[]) => { app?.page?.on('editor:select', (info: any, path: MNode[]) => {
if (path.find((node: MNode) => node.id === config.id)) { if (path.find((node: MNode) => node.id === config.id)) {
openOverlay(); openOverlay();
} else { } else {

View File

@ -26,12 +26,12 @@ import AppContent from './AppContent';
interface UseAppOptions { interface UseAppOptions {
config: MComponent; config: MComponent;
methods?: { methods?: {
string: Function; [key: string]: Function;
}; };
} }
export default ({ config, methods }: UseAppOptions) => { export default ({ config, methods }: UseAppOptions) => {
const app: Core = useContext(AppContent); const app: Core | undefined = useContext(AppContent);
const node = app?.page?.getNode(config.id); const node = app?.page?.getNode(config.id);
const [created, setCreated] = useState(false); const [created, setCreated] = useState(false);

View File

@ -43,7 +43,7 @@ export default defineComponent({
} }
}; };
app?.on('editor:select', (info, path) => { app?.page?.on('editor:select', (info, path) => {
if (path.find((node: MNode) => node.id === props.config.id)) { if (path.find((node: MNode) => node.id === props.config.id)) {
openOverlay(); openOverlay();
} else { } else {

View File

@ -43,7 +43,7 @@ export default defineComponent({
} }
}; };
app?.on('editor:select', (info, path) => { app?.page?.on('editor:select', (info, path) => {
if (path.find((node: MNode) => node.id === props.config.id)) { if (path.find((node: MNode) => node.id === props.config.id)) {
openOverlay(); openOverlay();
} else { } else {