From 91e094066ee46618b770bfae842d42ba9ea8b164 Mon Sep 17 00:00:00 2001 From: MT-Fire <798521692@qq.com> Date: Sun, 29 Mar 2026 00:57:40 +0800 Subject: [PATCH] =?UTF-8?q?refactor(frontend):=20=E5=86=85=E8=81=94=20ifra?= =?UTF-8?q?me=20=E6=B6=88=E6=81=AF=E8=BE=85=E5=8A=A9=E5=B9=B6=E7=A7=BB?= =?UTF-8?q?=E9=99=A4=E6=A0=B8=E5=BF=83=E6=97=A7=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/core/iframe-messages.ts | 59 ---------------------------- 1 file changed, 59 deletions(-) delete mode 100644 frontend/src/core/iframe-messages.ts diff --git a/frontend/src/core/iframe-messages.ts b/frontend/src/core/iframe-messages.ts deleted file mode 100644 index 9a28b2f1..00000000 --- a/frontend/src/core/iframe-messages.ts +++ /dev/null @@ -1,59 +0,0 @@ -/** - * iframe 与宿主页通信消息类型常量 - * - * 消息格式:{ type: MESSAGE_TYPE, ...其他字段 } - * 发送方式:window.parent.postMessage(message, "*") - */ - -// 发送给宿主页的消息类型 -export const POST_MESSAGE_TYPES = { - // 全屏切换 - FULLSCREEN: "fullscreen", - // 选择预定义 skill - SELECT_SKILL: "selectSkill", - // 打开 skill 选择对话框 - OPEN_SKILL_DIALOG: "openSkillDialog", -} as const; - -// 接收来自宿主页的消息类型 -export const RECEIVE_MESSAGE_TYPES = { - // 选中的 skill 数据 - SELECTED_SKILL: "selectedSkill", -} as const; - -// 消息类型 -export type PostMessageType = - (typeof POST_MESSAGE_TYPES)[keyof typeof POST_MESSAGE_TYPES]; -export type ReceiveMessageType = - (typeof RECEIVE_MESSAGE_TYPES)[keyof typeof RECEIVE_MESSAGE_TYPES]; - -// 消息数据类型 -export interface FullscreenMessage { - type: typeof POST_MESSAGE_TYPES.FULLSCREEN; - fullscreen: boolean; -} - -export interface SelectSkillMessage { - type: typeof POST_MESSAGE_TYPES.SELECT_SKILL; - skill_id: string; -} - -export interface OpenSkillDialogMessage { - type: typeof POST_MESSAGE_TYPES.OPEN_SKILL_DIALOG; - openSkillDialog: true; -} - -export interface SelectedSkillMessage { - type: typeof RECEIVE_MESSAGE_TYPES.SELECTED_SKILL; - id: string | number; - title: string; -} - -// 发送消息的辅助函数 -export function sendToParent( - message: FullscreenMessage | SelectSkillMessage | OpenSkillDialogMessage, -): void { - if (window.parent !== window) { - window.parent.postMessage(message, "*"); - } -}