refactor(frontend): 在工件与技能 hook 内嵌 iframe 消息常量
This commit is contained in:
parent
91e094066e
commit
49ff9411e9
|
|
@ -29,7 +29,6 @@ import { CodeEditor } from "@/components/workspace/code-editor";
|
||||||
import { useArtifactContent } from "@/core/artifacts/hooks";
|
import { useArtifactContent } from "@/core/artifacts/hooks";
|
||||||
import { urlOfArtifact } from "@/core/artifacts/utils";
|
import { urlOfArtifact } from "@/core/artifacts/utils";
|
||||||
import { useI18n } from "@/core/i18n/hooks";
|
import { useI18n } from "@/core/i18n/hooks";
|
||||||
import { POST_MESSAGE_TYPES, sendToParent } from "@/core/iframe-messages";
|
|
||||||
import { installSkill } from "@/core/skills/api";
|
import { installSkill } from "@/core/skills/api";
|
||||||
import { streamdownPlugins } from "@/core/streamdown";
|
import { streamdownPlugins } from "@/core/streamdown";
|
||||||
import { checkCodeFile, getFileName } from "@/core/utils/files";
|
import { checkCodeFile, getFileName } from "@/core/utils/files";
|
||||||
|
|
@ -40,6 +39,16 @@ import { CitationLink } from "../citations/citation-link";
|
||||||
|
|
||||||
import { useArtifacts } from "./context";
|
import { useArtifacts } from "./context";
|
||||||
|
|
||||||
|
const POST_MESSAGE_TYPES = {
|
||||||
|
FULLSCREEN: "fullscreen",
|
||||||
|
} as const;
|
||||||
|
|
||||||
|
function sendToParent(message: unknown): void {
|
||||||
|
if (window.parent !== window) {
|
||||||
|
window.parent.postMessage(message, "*");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export function ArtifactFileDetail({
|
export function ArtifactFileDetail({
|
||||||
className,
|
className,
|
||||||
filepath: filepathFromProps,
|
filepath: filepathFromProps,
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,26 @@
|
||||||
import { useSearchParams } from "next/navigation";
|
import { useSearchParams } from "next/navigation";
|
||||||
import { useState, useEffect, useCallback } from "react";
|
import { useState, useEffect, useCallback } from "react";
|
||||||
|
|
||||||
import {
|
const POST_MESSAGE_TYPES = {
|
||||||
POST_MESSAGE_TYPES,
|
SELECT_SKILL: "selectSkill",
|
||||||
RECEIVE_MESSAGE_TYPES,
|
OPEN_SKILL_DIALOG: "openSkillDialog",
|
||||||
sendToParent,
|
} as const;
|
||||||
type SelectedSkillMessage,
|
|
||||||
} from "@/core/iframe-messages";
|
const RECEIVE_MESSAGE_TYPES = {
|
||||||
|
SELECTED_SKILL: "selectedSkill",
|
||||||
|
} as const;
|
||||||
|
|
||||||
|
type SelectedSkillMessage = {
|
||||||
|
type: typeof RECEIVE_MESSAGE_TYPES.SELECTED_SKILL;
|
||||||
|
id: string | number;
|
||||||
|
title: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
function sendToParent(message: unknown): void {
|
||||||
|
if (window.parent !== window) {
|
||||||
|
window.parent.postMessage(message, "*");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Skill 数据类型
|
// Skill 数据类型
|
||||||
interface SkillData {
|
interface SkillData {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue