From 3048bfa2e7b343ba4284256f955a2f8600df36db Mon Sep 17 00:00:00 2001 From: ZLY Date: Sun, 4 Jan 2026 21:08:18 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E9=87=8D=E6=9E=84=E5=BE=AE?= =?UTF-8?q?=E5=89=8D=E7=AB=AF=E7=9B=B8=E5=85=B3=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/label-app/src/index.tsx | 59 +------------------ .../data/views/marking/task-canvas.vue | 3 +- 2 files changed, 3 insertions(+), 59 deletions(-) diff --git a/apps/label-app/src/index.tsx b/apps/label-app/src/index.tsx index 672f75b..aecfbc7 100644 --- a/apps/label-app/src/index.tsx +++ b/apps/label-app/src/index.tsx @@ -12,61 +12,4 @@ window.React = React; // 是否是线上演示环境 window.IS_ONLINE = !!import.meta.env.VITE_IS_ONLINE; -// micro-app 类型声明 -declare global { - interface Window { - __MICRO_APP_NAME__?: string; - __MICRO_APP_ENVIRONMENT__?: boolean; - __MICRO_APP_BASE_ROUTE__?: string; - microApp?: { - addDataListener: (callback: (data: Record) => void, autoTrigger?: boolean) => void; - removeDataListener: (callback: (data: Record) => void) => void; - getData: () => Record; - dispatch: (data: Record) => void; - }; - } -} - -let root: ReactDOM.Root | null = null; - -// 渲染函数 -function render() { - const container = document.getElementById('root'); - if (container) { - root = ReactDOM.createRoot(container); - root.render(); - } -} - -// 卸载函数 -function unmount() { - if (root) { - root.unmount(); - root = null; - } -} - -// 判断是否在 micro-app 环境中 -if (window.__MICRO_APP_ENVIRONMENT__) { - console.log('[label-app] 运行在微前端环境中'); - // 监听主应用数据 - if (window.microApp) { - window.microApp.addDataListener((data) => { - console.log('[label-app] 收到主应用数据:', data); - }); - } -} else { - // 独立运行 - render(); -} - -// 导出生命周期函数 -export async function mount() { - console.log('[label-app] mount'); - render(); -} - -export async function unmountApp() { - console.log('[label-app] unmount'); - unmount(); -} +ReactDOM.createRoot(document.getElementById('root')!).render(); diff --git a/src/micro-app/data/views/marking/task-canvas.vue b/src/micro-app/data/views/marking/task-canvas.vue index 1c38293..9171738 100644 --- a/src/micro-app/data/views/marking/task-canvas.vue +++ b/src/micro-app/data/views/marking/task-canvas.vue @@ -1,5 +1,5 @@