Files
qwenpaw/plugins/apps/qwenpaw-creator/ui/plugin-entry.js
T
agent-radar 1a3a4ccde1
Creator App Tests / PR Spam Gate (push) Skipped
Frontend Tests / PR Spam Gate (push) Skipped
NPM Format (website & console) / PR Spam Gate (push) Skipped
Pre-commit Checks / PR Spam Gate (push) Skipped
QwenPaw Creator Plugin Release / check-version (push) Canceled after 0s
QwenPaw Creator Plugin Release / upload-oss (push) Canceled after 0s
Tests / PR Spam Gate (push) Skipped
CodeQL / CodeQL (python) (push) Canceled after 0s
CodeQL / CodeQL (typescript) (push) Canceled after 0s
Creator App Tests / Creator Backend Tests (push) Canceled after 0s
Creator App Tests / Creator UI Build & Tests (push) Canceled after 0s
E2E Smoke Tests / Playwright UI Smoke (push) Canceled after 0s
Frontend Tests / Detect console changes (push) Canceled after 0s
NPM Format (website & console) / website format check (push) Canceled after 0s
NPM Format (website & console) / console format check (push) Canceled after 0s
Pre-commit Checks / Pre-commit (push) Canceled after 0s
QwenPaw Data Plugin Release / check-version (push) Canceled after 0s
Tests / Detect code changes (push) Canceled after 0s
Frontend Tests / Vitest Unit Tests (push) Canceled after 0s
Frontend Tests / Frontend Summary (push) Canceled after 0s
QwenPaw Data Plugin Release / upload-oss (push) Canceled after 0s
Tests / Maintainer Approval (push) Canceled after 0s
Tests / Unit Tests - py3.11 - macos-latest (push) Canceled after 0s
Tests / Unit Tests - py3.11 - ubuntu-latest (push) Canceled after 0s
Tests / Unit Tests - py3.13 - ubuntu-latest (push) Canceled after 0s
Tests / Unit Tests - py3.11 - windows-latest (push) Canceled after 0s
Tests / Contract Tests - py3.11 - macos-latest (push) Canceled after 0s
Tests / Contract Tests - py3.11 - ubuntu-latest (push) Canceled after 0s
Tests / Contract Tests - py3.13 - ubuntu-latest (push) Canceled after 0s
Tests / Contract Tests - py3.11 - windows-latest (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - macos-latest - p0 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - macos-latest - p1 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - macos-latest - p2 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - ubuntu-latest - fallback (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - ubuntu-latest - p0 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - ubuntu-latest - p1 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - ubuntu-latest - p2 (push) Canceled after 0s
Tests / Integrated Tests - py3.13 - ubuntu-latest - p0 (push) Canceled after 0s
Tests / Integrated Tests - py3.13 - ubuntu-latest - p1 (push) Canceled after 0s
Tests / Integrated Tests - py3.13 - ubuntu-latest - p2 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - windows-latest - p0 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - windows-latest - p1 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - windows-latest - p2 (push) Canceled after 0s
Tests / Coverage Report (push) Canceled after 0s
Tests / Test Summary (push) Canceled after 0s
源码快照 @ 2026-09-01 (source-only, 剔除非源码素材)
2026-09-01 20:01:50 +08:00

131 lines
4.2 KiB
JavaScript

(function () {
const pluginId = "qwenpaw-creator";
const QwenPaw = window.QwenPaw;
const host = QwenPaw && QwenPaw.host;
const React = host && host.React;
if (!QwenPaw || !React || !host.getApiUrl || !QwenPaw.registerRoutes) {
console.warn("[qwenpaw-creator] QwenPaw PawApp host API is unavailable.");
return;
}
const CREATOR_BG_COLOR = "#f9f8f4";
const CREATOR_BUILD_ID = "__CREATOR_BUILD_ID__";
const NAVIGATION_MESSAGE = "qwenpaw-creator:navigation";
const RESTORE_ROUTE_MESSAGE = "qwenpaw-creator:restore-route";
function normalizeCreatorRoute(path) {
if (
typeof path !== "string" ||
!path.startsWith("/") ||
path.startsWith("//") ||
path.includes("#")
) {
return null;
}
const parsed = new URL(path, "http://qwenpaw-creator.local");
return `${parsed.pathname}${parsed.search}`;
}
function creatorRouteFromHost() {
const route = window.location.hash.slice(1);
return normalizeCreatorRoute(route || "/") || "/";
}
function hostUrlForCreatorRoute(path) {
const route = normalizeCreatorRoute(path);
if (!route) return null;
return `${window.location.pathname}${window.location.search}#${route}`;
}
function CreatorFrame() {
const frameRef = React.useRef(null);
const initialSrcRef = React.useRef(null);
if (!initialSrcRef.current) {
const appUrl = host.getApiUrl(
"/frontend_plugin/qwenpaw-creator/files/ui/dist/app/index.html",
);
initialSrcRef.current = `${appUrl}?v=${encodeURIComponent(CREATOR_BUILD_ID)}#${creatorRouteFromHost()}`;
}
React.useEffect(() => {
const receiveCreatorRoute = (event) => {
if (
event.source !== frameRef.current?.contentWindow ||
event.data?.type !== NAVIGATION_MESSAGE
) {
return;
}
const nextUrl = hostUrlForCreatorRoute(event.data.path);
if (!nextUrl) return;
const currentUrl = `${window.location.pathname}${window.location.search}${window.location.hash}`;
if (nextUrl !== currentUrl) {
window.history.replaceState(window.history.state, "", nextUrl);
}
};
const restoreCreatorRoute = () => {
frameRef.current?.contentWindow?.postMessage(
{
type: RESTORE_ROUTE_MESSAGE,
path: creatorRouteFromHost(),
},
"*",
);
};
window.addEventListener("message", receiveCreatorRoute);
window.addEventListener("hashchange", restoreCreatorRoute);
window.addEventListener("popstate", restoreCreatorRoute);
return () => {
window.removeEventListener("message", receiveCreatorRoute);
window.removeEventListener("hashchange", restoreCreatorRoute);
window.removeEventListener("popstate", restoreCreatorRoute);
};
}, []);
// Fill the App Center embed frame (which is itself full-screen) instead
// of overlaying the whole viewport with a fixed-position layer.
return React.createElement(
"div",
{
className: "qwenpaw-creator-app-content",
style: {
width: "100%",
height: "100%",
overflow: "hidden",
background: CREATOR_BG_COLOR,
},
},
React.createElement("iframe", {
ref: frameRef,
title: "QwenPaw Creator",
src: initialSrcRef.current,
style: {
width: "100%",
height: "100%",
border: 0,
display: "block",
background: CREATOR_BG_COLOR,
},
allow:
"clipboard-read; clipboard-write; fullscreen; autoplay; picture-in-picture",
}),
);
}
// ── Self-register PawApp route ─────────────────────────────────────────
// Paths under `/apps/` register the route only — the app is reachable
// exclusively through the App Center (no sidebar menu entry).
QwenPaw.registerRoutes(pluginId, [
{
path: "/apps/qwenpaw-creator",
component: CreatorFrame,
label: "QwenPaw Creator",
icon: "🎬",
},
]);
console.info("[qwenpaw-creator] registered route /apps/qwenpaw-creator");
})();