Merge branch 'master' of http://118.145.251.184:3000/OmniAI/omniai-web into feat/profile-ui-polish

This commit is contained in:
2026-06-03 09:55:15 +08:00
21 changed files with 6948 additions and 535 deletions
+100 -17
View File
@@ -8,8 +8,15 @@ import {
ThunderboltOutlined,
} from "@ant-design/icons";
import { useCallback, useEffect, useMemo, useRef, useState, type CSSProperties } from "react";
import WelcomeSplash from "./WelcomeSplash";
import type { WebViewKey, WebImageWorkbenchTool } from "../../types";
import { useScrollEntrance } from "../../hooks/useScrollEntrance";
import WelcomeSplash from "./WelcomeSplash";
import ToolboxSection from "./ToolboxSection";
import ScriptReviewShowcase from "./ScriptReviewShowcase";
import ModelGenerationShowcase from "./ModelGenerationShowcase";
import ecommerceTemplate1 from "../../assets/home-features/home-ecommerce-template-1.png";
import ecommerceTemplate2 from "../../assets/home-features/home-ecommerce-template-2.png";
import ecommerceTemplate3 from "../../assets/home-features/home-ecommerce-template-3.png";
function ScrollEntrance({ children, className, ...rest }: { children: React.ReactNode; className?: string } & React.HTMLAttributes<HTMLElement>) {
const { ref, isVisible } = useScrollEntrance<HTMLElement>();
@@ -34,6 +41,8 @@ interface HomePageProps {
onOpenEcommerce: () => void;
onOpenScriptReview?: () => void;
onOpenTokenMonitor?: () => void;
onSelectView: (view: WebViewKey) => void;
onOpenImageTool?: (tool: WebImageWorkbenchTool) => void;
}
const HOME_BACKGROUND_VIDEO = "https://stringtest.oss-cn-hangzhou.aliyuncs.com/%E6%A0%B7%E7%89%87.mp4";
@@ -56,14 +65,14 @@ const HOME_FEATURES = [
stats: ["六维评分", "质量量化", "逐项优化"],
},
{
key: "token",
eyebrow: "Team Tokens",
title: "团队 Token 监控",
description: "实时追踪团队 Token 消耗、项目分布和成员使用情况,让预算、配额和成本都能被清楚管理。",
key: "model",
eyebrow: "AI Generation",
title: "模型生成",
description: "通过AI模型生成文本、图片、视频,三种模式覆盖全内容类型,Agent对话式交互智能产出。",
imageUrl: featureTokenImage,
actionLabel: "查看面板",
icon: <DashboardOutlined />,
stats: ["实时概览", "成员明细", "成本分析"],
actionLabel: "开始生成",
icon: <ThunderboltOutlined />,
stats: ["文本生成", "图片生成", "视频生成"],
},
{
key: "ecommerce",
@@ -84,6 +93,34 @@ const HOME_EXPERIENCE_POINTS = [
{ label: "电商", meta: "商品视觉", tone: "amber" },
];
const HOME_ECOMMERCE_TEMPLATES = [
{
title: "卖点详情图",
tag: "详情",
meta: "中文卖点标注",
imageUrl: ecommerceTemplate1,
},
{
title: "场景主图",
tag: "主图",
meta: "商品氛围构图",
imageUrl: ecommerceTemplate2,
},
{
title: "虚拟模特",
tag: "模特",
meta: "使用场景延展",
imageUrl: ecommerceTemplate3,
},
];
const HOME_ECOMMERCE_TOOLS = [
{ title: "主图", meta: "平台首图" },
{ title: "详情", meta: "卖点拆解" },
{ title: "模特", meta: "虚拟模特" },
{ title: "短视频", meta: "首帧方案" },
];
const HOME_CAROUSEL_SLOTS = [-4, -3, -2, -1, 0, 1, 2, 3, 4];
const HOME_CAROUSEL_TRANSITION_MS = 860;
@@ -122,7 +159,44 @@ function getHomeCarouselCardStyle(offset: number): CSSProperties {
} as CSSProperties;
}
function HomePage({ onOpenGenerate, onOpenEcommerce, onOpenScriptReview, onOpenTokenMonitor }: HomePageProps) {
function EcommerceFeatureShowcase() {
return (
<div className="omni-home-ecommerce-showcase">
<div className="omni-home-ecommerce-showcase__depth" />
<div className="omni-home-ecommerce-showcase__grain" />
<div className="omni-home-ecommerce-showcase__prompt">
<span> + </span>
<strong></strong>
<p></p>
</div>
<div className="omni-home-ecommerce-showcase__tools" aria-hidden="true">
{HOME_ECOMMERCE_TOOLS.map((item) => (
<div key={item.title} className="omni-home-ecommerce-showcase__tool">
<b>{item.title}</b>
<small>{item.meta}</small>
</div>
))}
</div>
<div className="omni-home-ecommerce-showcase__gallery" aria-hidden="true">
{HOME_ECOMMERCE_TEMPLATES.map((item, index) => (
<article key={item.title} className={`omni-home-ecommerce-showcase__shot is-${index + 1}`}>
<img src={item.imageUrl} alt="" />
<div>
<span>{item.tag}</span>
<strong>{item.title}</strong>
<small>{item.meta}</small>
</div>
</article>
))}
</div>
</div>
);
}
function HomePage({ onOpenGenerate, onOpenEcommerce, onOpenScriptReview, onOpenTokenMonitor, onSelectView, onOpenImageTool }: HomePageProps) {
const [splashDismissed, setSplashDismissed] = useState(() => sessionStorage.getItem("omniai:splash-seen") === "1");
const [activeSlideIndex, setActiveSlideIndex] = useState(0);
const [carouselMotion, setCarouselMotion] = useState<HomeCarouselMotion | null>(null);
@@ -200,8 +274,8 @@ function HomePage({ onOpenGenerate, onOpenEcommerce, onOpenScriptReview, onOpenT
(onOpenScriptReview ?? onOpenGenerate)();
return;
}
if (featureKey === "token") {
(onOpenTokenMonitor ?? onOpenGenerate)();
if (featureKey === "model") {
onOpenGenerate();
return;
}
if (featureKey === "ecommerce") {
@@ -266,7 +340,6 @@ function HomePage({ onOpenGenerate, onOpenEcommerce, onOpenScriptReview, onOpenT
}}
>
<img src={slide.imageUrl} alt={slide.title} />
{isActive ? <span className="omni-home__carousel-card-label slide-up-in-260">{slide.title}</span> : null}
</button>
);
})}
@@ -293,7 +366,7 @@ function HomePage({ onOpenGenerate, onOpenEcommerce, onOpenScriptReview, onOpenT
<main className="omni-home__feature-pages" aria-label="OmniAI 功能介绍">
{HOME_FEATURES.map((feature, index) => (
<ScrollEntrance key={feature.key} className={`omni-home__feature-page is-${feature.key}${index % 2 ? " is-alt" : ""}`}>
<section key={feature.key} className={`omni-home__feature-page is-${feature.key}${index % 2 ? " is-alt" : ""}`}>
<div className="omni-home__feature-copy">
<span>
{feature.icon}
@@ -307,17 +380,25 @@ function HomePage({ onOpenGenerate, onOpenEcommerce, onOpenScriptReview, onOpenT
</button>
</div>
<div className="omni-home__feature-visual" aria-hidden="true">
<img src={feature.imageUrl} alt="" />
{feature.key === "script" ? (
<ScriptReviewShowcase />
) : feature.key === "model" ? (
<ModelGenerationShowcase />
) : feature.key === "ecommerce" ? (
<EcommerceFeatureShowcase />
) : (
<img src={feature.imageUrl} alt="" />
)}
</div>
<div className="omni-home__feature-stats" aria-hidden="true">
{feature.stats.map((item) => (
<span key={item}>{item}</span>
))}
</div>
</ScrollEntrance>
</section>
))}
<ScrollEntrance className="omni-home__experience" aria-label="点击体验">
<section className="omni-home__experience" aria-label="点击体验">
<div className="omni-home__experience-copy">
<span>
<ThunderboltOutlined />
@@ -348,7 +429,9 @@ function HomePage({ onOpenGenerate, onOpenEcommerce, onOpenScriptReview, onOpenT
</button>
</div>
</ScrollEntrance>
</section>
<ToolboxSection onSelectView={onSelectView} onOpenImageTool={onOpenImageTool} />
</main>
</section>
</>
@@ -0,0 +1,282 @@
import { useEffect, useRef, useState } from "react";
type ShowMode = "agent" | "image" | "video";
const MODE_TABS = [
{ key: "agent" as const, icon: "🤖", title: "Agent 模式", desc: "文本生成,对话式交互,智能推理" },
{ key: "image" as const, icon: "🖼️", title: "图片模式", desc: "图像生成,风格迁移,场景合成" },
{ key: "video" as const, icon: "🎬", title: "视频模式", desc: "视频生成,动态场景,数字人演绎" },
];
const AGENT_OUTPUTS = [
{ tag: "Agent", title: "营销文案", preview: "「未来已来,腕间即达」—— 全新智能手表,让每一秒都充满可能。健康监测、智能提醒、时尚设计,三合一体验。从晨跑配速到会议提醒,它比你更懂你的节奏。" },
{ tag: "Agent", title: "产品描述", preview: "搭载最新AI芯片,支持实时心率/血氧/睡眠监测,50米防水,AMOLED视网膜屏,续航长达14天。钛合金表壳 + 硅胶快拆表带,商务运动自由切换。" },
{ tag: "Agent", title: "剧本大纲", preview: "第一幕:品牌故事引入 → 第二幕:产品亮点展示 → 第三幕:用户见证与CTA引导。" },
];
const IMAGE_OUTPUTS = [
{ tag: "Image", title: "写实风格", icon: "📷", styleClass: "realistic" },
{ tag: "Image", title: "插画风格", icon: "🎨", styleClass: "illustration" },
{ tag: "Image", title: "电商风格", icon: "🛍️", styleClass: "ecommerce" },
];
const VIDEO_OUTPUTS = [
{ tag: "Video", title: "数字人播报", duration: "0:15" },
{ tag: "Video", title: "场景动画", duration: "0:30" },
{ tag: "Video", title: "产品展示", duration: "0:20" },
];
function ModelGenerationShowcase() {
const [mode, setMode] = useState<ShowMode>("agent");
const [selectedImageOpt, setSelectedImageOpt] = useState(0);
const [, setAnimated] = useState(false);
const containerRef = useRef<HTMLDivElement>(null);
useEffect(() => {
const el = containerRef.current;
if (!el) return;
const observer = new IntersectionObserver(
([entry]) => {
if (entry?.isIntersecting) {
setAnimated(true);
observer.disconnect();
}
},
{ threshold: 0.2 },
);
observer.observe(el);
return () => observer.disconnect();
}, []);
const workflowSteps = [
{ label: "选择模式", active: mode === "agent" },
{ label: "输入描述", active: mode === "image" },
{ label: "AI生成", active: mode === "video" },
{ label: "输出内容", active: false },
];
return (
<div className="omni-model-gen-showcase" ref={containerRef}>
{/* Left Panel */}
<div className="mgs-left-panel">
<div className="mgs-brand-section">
<h1><br /></h1>
<p className="mgs-subtitle">AI模型生成文本</p>
</div>
<div className="mgs-mode-tabs">
{MODE_TABS.map((tab) => (
<div
key={tab.key}
className={`mgs-mode-tab${mode === tab.key ? " is-active" : ""}`}
onClick={() => setMode(tab.key)}
role="button"
tabIndex={0}
onKeyDown={(e) => { if (e.key === "Enter" || e.key === " ") setMode(tab.key); }}
>
<div className="mgs-mode-icon">{tab.icon}</div>
<div className="mgs-mode-info">
<h3>{tab.title}</h3>
<p>{tab.desc}</p>
</div>
</div>
))}
</div>
<div className="mgs-workflow">
<div className="mgs-workflow-title"></div>
<div className="mgs-workflow-steps">
{workflowSteps.map((step, i) => (
<span key={step.label}>
{i > 0 && <span className="mgs-wf-arrow"></span>}
<span className={`mgs-wf-step${step.active ? " is-active" : ""}`}>{step.label}</span>
</span>
))}
</div>
</div>
</div>
{/* Center Area */}
<div className="mgs-center-area">
<div className="mgs-input-card">
{/* Agent Mode */}
{mode === "agent" && (
<div className="mgs-mode-content is-active">
<div className="mgs-card-header">
<div className="mgs-card-mode-badge"><span className="mgs-dot" /> Agent </div>
<div className="mgs-card-status">线 · GPT-4o</div>
</div>
<div className="mgs-prompt-area">
<textarea
className="mgs-prompt-input"
placeholder="描述你的需求...&#10;例如:帮我生成一段智能手表的营销文案,突出健康监测功能"
readOnly
/>
</div>
<div className="mgs-options">
{["营销文案", "产品描述", "剧本大纲", "数据分析"].map((opt, i) => (
<span key={opt} className={`mgs-opt${i === 0 ? " is-selected" : ""}`}>{opt}</span>
))}
</div>
<div className="mgs-agent-output-area">
<div className="mgs-agent-result">
<div className="mgs-agent-result-label">AI </div>
<div className="mgs-agent-result-text">
</div>
</div>
</div>
<div className="mgs-chat-input-row">
<input className="mgs-chat-input" placeholder="继续对话或修改需求..." readOnly />
<button className="mgs-chat-send" type="button" tabIndex={-1}> </button>
</div>
</div>
)}
{/* Image Mode */}
{mode === "image" && (
<div className="mgs-mode-content is-active">
<div className="mgs-card-header">
<div className="mgs-card-mode-badge"><span className="mgs-dot" /> </div>
<div className="mgs-card-status">SDXL · Flux</div>
</div>
<div className="mgs-prompt-area">
<textarea
className="mgs-prompt-input"
placeholder="描述你想生成的图片...&#10;例如:未来科技感城市,赛博朋克风格,霓虹灯光"
readOnly
/>
</div>
<div className="mgs-options">
{["写实风", "插画风", "电商风", "3D渲染"].map((opt, i) => (
<span
key={opt}
className={`mgs-opt${selectedImageOpt === i ? " is-selected" : ""}`}
onClick={() => setSelectedImageOpt(i)}
>
{opt}
</span>
))}
</div>
<div className="mgs-img-grid">
<div className="mgs-img-cell">🎨</div>
<div className="mgs-img-cell">🖼</div>
<div className="mgs-img-cell"></div>
<div className="mgs-img-cell">🌈</div>
</div>
</div>
)}
{/* Video Mode */}
{mode === "video" && (
<div className="mgs-mode-content is-active">
<div className="mgs-card-header">
<div className="mgs-card-mode-badge"><span className="mgs-dot" /> </div>
<div className="mgs-card-status">Sora · Kling</div>
</div>
<div className="mgs-video-config">
<div className="mgs-config-row">
<span className="mgs-config-label"></span>
<span className="mgs-config-value">1080p</span>
</div>
<div className="mgs-config-row">
<span className="mgs-config-label"></span>
<span className="mgs-config-value">15s</span>
</div>
<div className="mgs-config-row">
<span className="mgs-config-label"></span>
<span className="mgs-config-value">30fps</span>
</div>
<div className="mgs-config-row">
<span className="mgs-config-label"></span>
<span className="mgs-config-value"></span>
</div>
</div>
<div className="mgs-video-preview">
<div className="mgs-play-btn">
<svg viewBox="0 0 24 24"><polygon points="6,3 20,12 6,21" /></svg>
</div>
</div>
<div className="mgs-video-timeline">
<div className="mgs-video-timeline-fill" />
</div>
</div>
)}
</div>
</div>
{/* Right Panel */}
<div className="mgs-right-panel">
{/* Agent Outputs */}
{mode === "agent" && (
<div className="mgs-output-section">
<div className="mgs-section-label">
<span className="mgs-section-dot is-green" />
Agent
</div>
<div className="mgs-output-cards">
{AGENT_OUTPUTS.map((item) => (
<div key={item.title} className="mgs-out-card">
<div className="mgs-out-card-top">
<span className="mgs-out-tag">{item.tag}</span>
<span className="mgs-out-title">{item.title}</span>
</div>
<div className="mgs-out-preview">{item.preview}</div>
</div>
))}
</div>
</div>
)}
{/* Image Outputs */}
{mode === "image" && (
<div className="mgs-output-section">
<div className="mgs-section-label">
<span className="mgs-section-dot is-blue" />
</div>
<div className="mgs-output-cards">
{IMAGE_OUTPUTS.map((item) => (
<div key={item.title} className="mgs-out-card">
<div className="mgs-out-card-top">
<span className="mgs-out-tag is-img">{item.tag}</span>
<span className="mgs-out-title">{item.title}</span>
</div>
<div className={`mgs-out-img-placeholder is-${item.styleClass}`}>{item.icon}</div>
</div>
))}
</div>
</div>
)}
{/* Video Outputs */}
{mode === "video" && (
<div className="mgs-output-section">
<div className="mgs-section-label">
<span className="mgs-section-dot is-purple" />
</div>
<div className="mgs-output-cards">
{VIDEO_OUTPUTS.map((item) => (
<div key={item.title} className="mgs-out-card">
<div className="mgs-out-card-top">
<span className="mgs-out-tag is-video">{item.tag}</span>
<span className="mgs-out-title">{item.title}</span>
</div>
<div className="mgs-out-video-placeholder">
<div className="mgs-mini-play">
<svg viewBox="0 0 24 24"><polygon points="6,3 20,12 6,21" /></svg>
</div>
<span className="mgs-video-duration">{item.duration}</span>
</div>
</div>
))}
</div>
</div>
)}
</div>
</div>
);
}
export default ModelGenerationShowcase;
+208
View File
@@ -0,0 +1,208 @@
import { useEffect, useRef, useState } from "react";
const DIMS = [
{ name: "钩子设计", score: 16, max: 20, hue: 145, desc: "吸引力·悬念·黄金三秒", isPerfect: false, isLow: false },
{ name: "角色塑造", score: 15, max: 15, hue: 155, desc: "立体度·动机·弧光", isPerfect: true, isLow: false },
{ name: "剧情结构", score: 16, max: 20, hue: 165, desc: "起承转合·节奏·冲突", isPerfect: false, isLow: false },
{ name: "逻辑严密", score: 12, max: 15, hue: 175, desc: "自洽·伏笔·因果链", isPerfect: false, isLow: false },
{ name: "场景构建", score: 10, max: 15, hue: 185, desc: "空间·视听·画面感", isPerfect: false, isLow: true },
{ name: "内容深度", score: 8, max: 15, hue: 195, desc: "主题·情感·思想内核", isPerfect: false, isLow: true },
];
const HIGHLIGHTS = [
{ dim: "角色塑造", score: "15/15 ★", text: "满分表现!人物立体度与弧光设计均达高水准" },
{ dim: "钩子设计", score: "16/20", text: "开篇悬念精准,黄金三秒有效抓住注意力" },
{ dim: "剧情结构", score: "16/20", text: "起承转合清晰,节奏把控得当,冲突自然递进" },
];
const WEAKNESSES = [
{ dim: "内容深度", score: "8/15", text: "主题偏表层,情感共鸣与思想内核挖掘不足" },
{ dim: "场景构建", score: "10/15", text: "空间描写模糊,视听语言薄弱,画面感欠缺" },
{ dim: "逻辑严密", score: "12/15", text: "世界观细节不足,部分伏笔缺乏回收" },
];
const OPTIMIZATIONS = [
{ dim: "场景构建 → 提升", priority: "高优先", priorityClass: "badge-red", text: "增加具体空间描写与视听语言,强化沉浸感" },
{ dim: "内容深度 → 深挖", priority: "高优先", priorityClass: "badge-red", text: "围绕核心冲突深化人物选择与情感层次" },
{ dim: "逻辑严密 → 补强", priority: "中优先", priorityClass: "badge-orange", text: "补充世界观细节,强化因果链与伏笔回收" },
];
function animateNumber(el: HTMLElement | null, target: number, duration: number) {
if (!el) return;
const start = performance.now();
const targetEl = el;
function tick(now: number) {
const p = Math.min((now - start) / duration, 1);
targetEl.textContent = String(Math.round((1 - Math.pow(1 - p, 3)) * target));
if (p < 1) requestAnimationFrame(tick);
}
requestAnimationFrame(tick);
}
function ScriptReviewShowcase() {
const [animated, setAnimated] = useState(false);
const scoreRef = useRef<HTMLSpanElement>(null);
const barRefs = useRef<(HTMLDivElement | null)[]>([]);
const scoreValRefs = useRef<(HTMLSpanElement | null)[]>([]);
useEffect(() => {
const el = document.getElementById("script-review-showcase");
if (!el) return;
const observer = new IntersectionObserver(
([entry]) => {
if (entry?.isIntersecting) {
setAnimated(true);
observer.disconnect();
}
},
{ threshold: 0.25 },
);
observer.observe(el);
return () => observer.disconnect();
}, []);
useEffect(() => {
if (!animated) return;
const timer = setTimeout(() => {
animateNumber(scoreRef.current, 77, 1400);
barRefs.current.forEach((bar, i) => {
if (!bar) return;
const pct = parseFloat(bar.dataset.pct ?? "0");
setTimeout(() => { bar.style.height = `${pct}%`; }, i * 100 + 400);
});
scoreValRefs.current.forEach((el, i) => {
setTimeout(() => animateNumber(el, parseInt(el?.dataset.target ?? "0"), 800), i * 100 + 400);
});
}, 500);
return () => clearTimeout(timer);
}, [animated]);
return (
<div className="omni-script-review-showcase" id="script-review-showcase">
{/* Score Hero */}
<div className="srs-score-hero">
<div className="srs-score-left">
<div className="srs-score-circle">
<div className="srs-score-circle-inner">
<span className="srs-score-num" ref={scoreRef}>0</span>
<span className="srs-score-den">/ 100</span>
</div>
</div>
<div className="srs-score-meta">
<div className="srs-score-grade">A </div>
<div className="srs-score-tags">
<span className="srs-score-tag"></span>
<span className="srs-score-tag">58min</span>
<span className="srs-score-tag">6</span>
</div>
</div>
</div>
<div className="srs-score-divider" />
<div className="srs-score-right">
<div className="srs-score-proj">广 · </div>
<div className="srs-score-summary">
</div>
</div>
</div>
{/* Vertical Bar Chart */}
<div className="srs-chart-card">
<div className="srs-chart-title"> Dimension Breakdown</div>
<div className="srs-chart-body">
{DIMS.map((dim, i) => {
const pct = dim.score / dim.max;
return (
<div key={dim.name} className="srs-chart-col">
<div className="srs-chart-bar-wrap">
<div className="srs-chart-bar-bg" style={{ height: "100%" }} />
<div
ref={(el) => { barRefs.current[i] = el; }}
className={`srs-chart-bar-fill${dim.isPerfect ? " is-perfect" : ""}${dim.isLow ? " is-low" : ""}`}
data-pct={String(Math.round(pct * 100))}
style={{ height: "0%" }}
>
<div className="srs-chart-bar-score">
<span
ref={(el) => { scoreValRefs.current[i] = el; }}
data-target={String(dim.score)}
>0</span>
<span className="srs-chart-bar-sub">/{dim.max}</span>
{dim.isPerfect && <span className="srs-chart-bar-star"></span>}
</div>
</div>
</div>
<div className="srs-chart-col-label">
<div className="srs-chart-col-name">{dim.name}</div>
<div className="srs-chart-col-desc">{dim.desc}</div>
</div>
</div>
);
})}
</div>
</div>
{/* Triple Section */}
<div className="srs-triple-section">
{/* Highlights */}
<div className="srs-section-card is-highlight">
<div className="srs-section-header">
<div className="srs-section-icon"></div>
<span className="srs-section-label"></span>
</div>
<div className="srs-section-list">
{HIGHLIGHTS.map((item) => (
<div key={item.dim} className="srs-section-item">
<div className="srs-section-item-head">
<span className="srs-section-item-dim">{item.dim}</span>
<span className="srs-section-item-score is-green">{item.score}</span>
</div>
<div className="srs-section-item-text">{item.text}</div>
</div>
))}
</div>
</div>
{/* Weaknesses */}
<div className="srs-section-card is-weakness">
<div className="srs-section-header">
<div className="srs-section-icon"></div>
<span className="srs-section-label"></span>
</div>
<div className="srs-section-list">
{WEAKNESSES.map((item) => (
<div key={item.dim} className="srs-section-item">
<div className="srs-section-item-head">
<span className="srs-section-item-dim">{item.dim}</span>
<span className="srs-section-item-score is-red">{item.score}</span>
</div>
<div className="srs-section-item-text">{item.text}</div>
</div>
))}
</div>
</div>
{/* Optimization */}
<div className="srs-section-card is-optimize">
<div className="srs-section-header">
<div className="srs-section-icon"></div>
<span className="srs-section-label"></span>
</div>
<div className="srs-section-list">
{OPTIMIZATIONS.map((item) => (
<div key={item.dim} className="srs-section-item">
<div className="srs-section-item-head">
<span className="srs-section-item-dim">{item.dim}</span>
<span className={`srs-section-item-badge ${item.priorityClass}`}>{item.priority}</span>
</div>
<div className="srs-section-item-text">{item.text}</div>
</div>
))}
</div>
</div>
</div>
</div>
);
}
export default ScriptReviewShowcase;
+133
View File
@@ -0,0 +1,133 @@
import { useEffect, useRef, useState } from "react";
const DIMS = [
{ name: "钩子设计", score: 19, max: 20, hue: 145 },
{ name: "角色塑造", score: 13, max: 15, hue: 155 },
{ name: "剧情结构", score: 18, max: 20, hue: 165 },
{ name: "逻辑严密", score: 14, max: 15, hue: 175 },
{ name: "场景构建", score: 15, max: 15, hue: 185 },
{ name: "内容深度", score: 15, max: 15, hue: 195 },
];
function ScriptReviewVisual() {
const [animated, setAnimated] = useState(false);
const [activeDim, setActiveDim] = useState<number | null>(null);
const [score, setScore] = useState(0);
const scoreRef = useRef<number>(0);
const frameRef = useRef<number | null>(null);
useEffect(() => {
const el = document.getElementById("script-review-visual");
if (!el) return;
const observer = new IntersectionObserver(
([entry]) => {
if (entry?.isIntersecting) {
setAnimated(true);
observer.disconnect();
}
},
{ threshold: 0.3 }
);
observer.observe(el);
return () => observer.disconnect();
}, []);
useEffect(() => {
if (!animated) return;
const start = performance.now();
const target = 94;
const dur = 1400;
function tick(now: number) {
const t = Math.min((now - start) / dur, 1);
const e = 1 - Math.pow(1 - t, 3);
setScore(Math.round(e * target));
if (t < 1) frameRef.current = requestAnimationFrame(tick);
}
frameRef.current = requestAnimationFrame(tick);
return () => { if (frameRef.current) cancelAnimationFrame(frameRef.current); };
}, [animated]);
const totalScore = 94;
const grade = "S";
return (
<div className="omni-script-review-visual" id="script-review-visual">
<div className="omni-script-review-hero">
<div className="omni-script-review-score-row">
<span className="omni-script-review-num">{score}</span>
<span className="omni-script-review-total">/ 100</span>
<div className="omni-script-review-grade">
<span className="omni-script-review-grade-dot" />
<span>{grade}</span>
</div>
</div>
<div className="omni-script-review-bar">
<div
className="omni-script-review-bar-fill"
style={{ width: animated ? `${totalScore}%` : "0%" }}
/>
</div>
<div className="omni-script-review-beat">
<b>92%</b>
</div>
</div>
<div className="omni-script-review-chart">
<div className="omni-script-review-chart-bars">
{DIMS.map((dim, i) => {
const pct = dim.score / dim.max;
const lossPct = (dim.max - dim.score) / dim.max;
const isPerfect = dim.score === dim.max;
const height = animated ? pct * 76 : 0;
const lossHeight = animated ? lossPct * 76 : 0;
return (
<div
key={dim.name}
className={`omni-script-review-bcol${activeDim === i ? " is-active" : ""}${activeDim !== null && activeDim !== i ? " is-dimmed" : ""}`}
onClick={() => setActiveDim(activeDim === i ? null : i)}
>
<div className="omni-script-review-bbar-area">
{lossPct > 0 && (
<div
className="omni-script-review-bseg is-loss"
style={{ height: `${lossHeight}%`, transitionDelay: `${400 + i * 80}ms` }}
/>
)}
<div
className={`omni-script-review-bseg is-score${isPerfect ? " is-perfect" : ""}`}
style={{ height: `${height}%`, transitionDelay: `${400 + i * 80}ms` }}
/>
</div>
<div className="omni-script-review-blabel">
<span>{dim.name}</span>
</div>
</div>
);
})}
</div>
{activeDim !== null && (() => {
const d = DIMS[activeDim]!;
return (
<div className="omni-script-review-diminfo">
<span className="omni-script-review-diminfo-name">{d.name}</span>
<span className="omni-script-review-diminfo-score">
{d.score}<small>/{d.max}</small>
{d.score === d.max && " ★"}
</span>
</div>
);
})()}
<div className="omni-script-review-legend">
<span><span className="omni-script-review-legend-dot is-score" /> </span>
<span><span className="omni-script-review-legend-dot is-loss" /> </span>
</div>
</div>
</div>
);
}
export default ScriptReviewVisual;
+233
View File
@@ -0,0 +1,233 @@
import { ToolOutlined } from "@ant-design/icons";
import type { WebViewKey, WebImageWorkbenchTool } from "../../types";
import toolImageBefore from "../../assets/toolbox/牛仔.png";
import toolImageAfter from "../../assets/toolbox/西装.png";
import watermarkBefore from "../../assets/toolbox/去水印前.png";
import watermarkAfter from "../../assets/toolbox/去水印后.png";
interface ToolboxSectionProps {
onSelectView: (view: WebViewKey) => void;
onOpenImageTool?: (tool: WebImageWorkbenchTool) => void;
}
const TOOLS = [
{
key: "image-studio",
icon: "🎨",
name: "图片工作室",
desc: "图片二次加工,调色裁剪特效风格迁移",
},
{
key: "lens-lab",
icon: "📷",
name: "镜头实验室",
desc: "多视角镜头生成,不同角度与姿势",
},
{
key: "digital-human",
icon: "🧑",
name: "一键数字人",
desc: "上传图片和音频,生成数字人视频",
},
{
key: "watermark-removal",
icon: "✨",
name: "去除水印",
desc: "AI智能识别去除图片视频水印",
},
];
const CARDS = [
{
key: "image-studio",
title: "图片工作室",
tag: "图片加工",
icon: "🎨",
features: ["二次加工", "调色", "裁剪", "风格迁移"],
targetView: "imageWorkbench" as WebViewKey,
render: () => (
<div className="toolbox-card1-content">
<div className="toolbox-card1-side toolbox-card1-left">
<div className="toolbox-card1-img">
<img src={toolImageBefore} alt="图片加工前" />
</div>
<div className="toolbox-card1-label"></div>
</div>
<div className="toolbox-card1-divider" />
<div className="toolbox-card1-side toolbox-card1-right">
<div className="toolbox-card1-img">
<img src={toolImageAfter} alt="图片加工后" />
</div>
<div className="toolbox-card1-label"></div>
</div>
</div>
),
},
{
key: "lens-lab",
title: "镜头实验室",
tag: "多视角",
icon: "📷",
features: ["正面", "45°侧", "俯拍", "仰拍", "背面"],
targetView: "imageWorkbench" as WebViewKey,
render: () => (
<div className="toolbox-card2-content">
{["正面", "45°侧", "俯拍", "仰拍", "背面"].map((angle) => (
<div key={angle} className="toolbox-card2-frame">
<div className="toolbox-card2-product" />
<div className="toolbox-card2-shadow" />
<div className="toolbox-card2-angle-label">{angle}</div>
</div>
))}
</div>
),
},
{
key: "digital-human",
title: "一键数字人",
tag: "视频生成",
icon: "🧑",
features: ["上传人像", "匹配音频", "唇形同步", "生成视频"],
targetView: "digitalHuman" as WebViewKey,
render: () => (
<div className="toolbox-card3-content">
<div className="toolbox-card3-side toolbox-card3-left">
<div className="toolbox-card3-portrait">
<div className="toolbox-card3-portrait-mark">STATIC</div>
</div>
<div className="toolbox-card3-label"></div>
</div>
<div className="toolbox-card3-divider" />
<div className="toolbox-card3-transform"></div>
<div className="toolbox-card3-side toolbox-card3-right">
<div className="toolbox-card3-portrait">
<div className="toolbox-card3-glow-ring" />
<div className="toolbox-card3-lipsync">
<span /><span /><span /><span /><span />
</div>
<div className="toolbox-card3-gesture" />
<div className="toolbox-card3-live">LIVE</div>
</div>
<div className="toolbox-card3-label"></div>
</div>
</div>
),
},
{
key: "watermark-removal",
title: "去除水印",
tag: "AI清除",
icon: "✨",
features: ["智能识别", "精准去除", "无损画质"],
targetView: "watermarkRemoval" as WebViewKey,
render: () => (
<div className="toolbox-card4-content">
<div className="toolbox-card4-side toolbox-card4-left">
<div className="toolbox-card4-img">
<img src={watermarkBefore} alt="去水印前" />
</div>
<div className="toolbox-card4-label"></div>
</div>
<div className="toolbox-card4-divider" />
<div className="toolbox-card4-side toolbox-card4-right">
<div className="toolbox-card4-img">
<img src={watermarkAfter} alt="去水印后" />
</div>
<div className="toolbox-card4-label"></div>
</div>
</div>
),
},
];
function ToolboxSection({ onSelectView, onOpenImageTool }: ToolboxSectionProps) {
const handleCardClick = (targetView: WebViewKey) => {
onSelectView(targetView);
};
return (
<section className="omni-home__toolbox-page" aria-label="OmniAI 工具箱">
<div className="omni-home__toolbox-shell">
{/* Left Panel */}
<aside className="omni-home__toolbox-left">
<div className="omni-home__toolbox-brand">
<div className="omni-home__toolbox-brand-icon">
<ToolOutlined />
</div>
<div className="omni-home__toolbox-brand-text"></div>
</div>
<div className="omni-home__toolbox-title">
<br />
</div>
<div className="omni-home__toolbox-subtitle">
AI工具覆盖图片加工
</div>
<div className="omni-home__toolbox-list">
{TOOLS.map((tool) => (
<div
key={tool.key}
className="omni-home__toolbox-item"
onClick={() => {
const card = CARDS.find((c) => c.key === tool.key);
if (card) handleCardClick(card.targetView);
}}
>
<div className="omni-home__toolbox-item-icon">{tool.icon}</div>
<div className="omni-home__toolbox-item-info">
<div className="omni-home__toolbox-item-name">{tool.name}</div>
<div className="omni-home__toolbox-item-desc">{tool.desc}</div>
</div>
</div>
))}
</div>
<div className="omni-home__toolbox-workflow">
<div className="omni-home__toolbox-workflow-label"></div>
<div className="omni-home__toolbox-workflow-steps">
<span className="omni-home__toolbox-workflow-step"></span>
<span className="omni-home__toolbox-workflow-arrow"></span>
<span className="omni-home__toolbox-workflow-step"></span>
<span className="omni-home__toolbox-workflow-arrow"></span>
<span className="omni-home__toolbox-workflow-step">AI处理</span>
<span className="omni-home__toolbox-workflow-arrow"></span>
<span className="omni-home__toolbox-workflow-step"></span>
</div>
</div>
</aside>
{/* Grid Area */}
<div className="omni-home__toolbox-grid">
{CARDS.map((card) => (
<div
key={card.key}
className="omni-home__toolbox-card"
onClick={() => handleCardClick(card.targetView)}
>
<div className="omni-home__toolbox-card-header">
<div className="omni-home__toolbox-card-header-left">
<div className="omni-home__toolbox-card-icon">{card.icon}</div>
<div className="omni-home__toolbox-card-title">{card.title}</div>
</div>
<div className="omni-home__toolbox-card-tag">{card.tag}</div>
</div>
<div className="omni-home__toolbox-card-content">
{card.render()}
</div>
<div className="omni-home__toolbox-card-footer">
{card.features.map((feat, i) => (
<span key={feat}>
{i > 0 && <span className="omni-home__toolbox-card-feat-sep">|</span>}
<span className="omni-home__toolbox-card-feat">{feat}</span>
</span>
))}
</div>
</div>
))}
</div>
</div>
</section>
);
}
export default ToolboxSection;
+490 -343
View File
@@ -1,13 +1,20 @@
import { CopyOutlined, DownOutlined, DownloadOutlined, FileTextOutlined, ReloadOutlined, TrophyOutlined, UploadOutlined } from "@ant-design/icons";
import { useEffect, useMemo, useRef, useState, type ChangeEvent, type KeyboardEvent } from "react";
import {
CheckCircleFilled,
CopyOutlined,
DownloadOutlined,
FileTextOutlined,
UploadOutlined,
} from "@ant-design/icons";
import { useEffect, useRef, useState, type ChangeEvent, type KeyboardEvent } from "react";
import { evaluateScript } from "../../api/scriptEvalClient";
import { useSessionStore } from "../../stores";
interface ScoreDimension {
key: string;
label: string;
maxScore: number;
weight: number;
description: string;
hint: string;
detail: string;
}
interface EvalResult {
@@ -20,103 +27,156 @@ interface EvalResult {
suggestions: string[];
}
const RADAR_CENTER = 100;
const RADAR_RADIUS = 82;
const RADAR_ANGLES = [-90, -30, 30, 90, 150, 210];
const scoreDimensions: ScoreDimension[] = [
{
key: "hook",
label: "钩子设计",
maxScore: 20,
weight: 0.2,
description: "开篇吸引力、悬念设置、黄金三秒法则",
},
{
key: "character",
label: "角色塑造",
maxScore: 18,
weight: 0.18,
description: "主角弧光、角色辨识度、动机、配角质量",
},
{
key: "plot",
label: "剧情结构",
maxScore: 20,
weight: 0.2,
description: "起承转合、节奏把控、冲突设计",
},
{
key: "dialogue",
label: "台词对白",
maxScore: 15,
weight: 0.15,
description: "语言质感、角色差异化、潜台词",
},
{
key: "visual",
label: "画面表现",
maxScore: 15,
weight: 0.15,
description: "镜头感、空间层次、视觉冲击力",
},
{
key: "content",
label: "内容深度",
maxScore: 12,
weight: 0.12,
description: "主题表达、情感共鸣、社会/人性洞察",
},
];
function radarPoint(angle: number, radius: number) {
const radians = (angle * Math.PI) / 180;
return {
x: RADAR_CENTER + radius * Math.cos(radians),
y: RADAR_CENTER + radius * Math.sin(radians),
};
interface HistoryEntry {
name: string;
date: string;
timestamp: number;
score: number;
grade: string;
}
function makeRadarPoints(scores: Record<string, number> | null) {
if (!scores) return "100,100 100,100 100,100 100,100 100,100 100,100";
return scoreDimensions
.map((dimension, index) => {
const ratio = Math.max(0, Math.min(1, (scores[dimension.key] ?? 0) / dimension.maxScore));
const point = radarPoint(RADAR_ANGLES[index] ?? 0, RADAR_RADIUS * ratio);
return `${point.x.toFixed(1)},${point.y.toFixed(1)}`;
})
.join(" ");
function getGrade(score: number): string {
if (score >= 97) return "S+";
if (score >= 93) return "S";
if (score >= 88) return "A+";
if (score >= 83) return "A";
if (score >= 78) return "B+";
if (score >= 70) return "B";
return "C";
}
function RadarPreview({ result }: { result: EvalResult | null }) {
const HISTORY_KEY = "omniai:script-eval-history";
const TEXT_FILE_EXTENSIONS = [
".txt",
".text",
".md",
".markdown",
".fountain",
".fdx",
".rtf",
".csv",
".tsv",
".json",
".jsonl",
".xml",
".html",
".htm",
".yaml",
".yml",
".toml",
".ini",
".conf",
".cfg",
".properties",
".log",
".srt",
".ass",
".ssa",
".vtt",
".sql",
".js",
".jsx",
".ts",
".tsx",
".py",
".java",
".c",
".cpp",
".h",
".hpp",
".cs",
".go",
".rs",
".php",
".rb",
".sh",
".bat",
".ps1",
".lua",
".swift",
".kt",
".kts",
] as const;
const TEXT_FILE_EXTENSION_SET = new Set<string>(TEXT_FILE_EXTENSIONS);
const TEXT_FILE_ACCEPT = TEXT_FILE_EXTENSIONS.join(",");
const TEXT_FILE_HINT = "支持常见文本格式:TXT / MD / Fountain / FDX / RTF / JSON / CSV / XML / HTML / YAML / LOG / 字幕等";
function loadHistory(): HistoryEntry[] {
try {
const raw = localStorage.getItem(HISTORY_KEY);
return raw ? (JSON.parse(raw) as HistoryEntry[]).sort((a, b) => b.timestamp - a.timestamp) : [];
} catch { return []; }
}
function saveHistory(entries: HistoryEntry[]) {
try { localStorage.setItem(HISTORY_KEY, JSON.stringify(entries.sort((a, b) => b.timestamp - a.timestamp).slice(0, 20))); } catch { /* quota exceeded */ }
}
function getFileExtension(filename: string): string {
const dotIndex = filename.lastIndexOf(".");
return dotIndex >= 0 ? filename.slice(dotIndex).toLowerCase() : "";
}
function isReadableTextFile(file: File, ext: string): boolean {
const mime = file.type.toLowerCase();
return (
<div className={`script-eval-v4-radar-container${result ? " has-glow" : ""}`}>
<svg className="script-eval-v4-radar-svg" viewBox="0 0 200 200" aria-hidden="true">
<defs>
<linearGradient id="scriptEvalV4RadarGradient" x1="0%" y1="0%" x2="100%" y2="100%">
<stop offset="0%" stopColor="rgba(0, 255, 136, 0.34)" />
<stop offset="100%" stopColor="rgba(123, 231, 255, 0.1)" />
</linearGradient>
</defs>
<g className="script-eval-v4-radar-grid">
<polygon points="100,15 173,55 173,145 100,185 27,145 27,55" />
<polygon points="100,35 158,68 158,132 100,165 42,132 42,68" />
<polygon points="100,55 143,81 143,119 100,145 57,119 57,81" />
<polygon points="100,75 128,94 128,106 100,125 72,106 72,94" />
<line x1="100" y1="15" x2="100" y2="185" />
<line x1="27" y1="55" x2="173" y2="145" />
<line x1="173" y1="55" x2="27" y2="145" />
</g>
<polygon
className={`script-eval-v4-radar-outline${result ? " has-data" : ""}`}
points={makeRadarPoints(result?.dimensionScores ?? null)}
/>
</svg>
</div>
TEXT_FILE_EXTENSION_SET.has(ext) ||
mime.startsWith("text/") ||
mime === "application/json" ||
mime === "application/xml" ||
mime === "application/xhtml+xml" ||
mime === "application/x-yaml" ||
mime === "application/yaml"
);
}
async function decodeTextFile(file: File): Promise<string> {
const bytes = await file.arrayBuffer();
const utf8 = new TextDecoder("utf-8", { fatal: false }).decode(bytes);
if (!utf8.includes("\uFFFD")) return utf8;
try {
return new TextDecoder("gb18030", { fatal: false }).decode(bytes);
} catch {
return utf8;
}
}
function normalizeUploadedText(raw: string, ext: string): string {
if (ext === ".rtf") {
const text = raw
.replace(/\\par[d]?/gi, "\n")
.replace(/\\line/gi, "\n")
.replace(/\\'[0-9a-f]{2}/gi, "")
.replace(/\\[a-z]+\d* ?/gi, "")
.replace(/[{}]/g, "")
.replace(/\n{3,}/g, "\n\n")
.trim();
return text || raw;
}
if ([".html", ".htm", ".xml", ".fdx"].includes(ext) && typeof DOMParser !== "undefined") {
try {
const doc = new DOMParser().parseFromString(raw, ext === ".html" || ext === ".htm" ? "text/html" : "application/xml");
const text = doc.documentElement.textContent?.replace(/\n{3,}/g, "\n\n").trim();
return text || raw;
} catch {
return raw;
}
}
return raw;
}
const SCORE_DIMENSIONS: ScoreDimension[] = [
{ key: "hook", label: "钩子设计", maxScore: 20, hint: "开篇吸引力·悬念设置·黄金三秒", detail: "开篇即抛出高概念钩子,悬念设置紧凑有力。" },
{ key: "character", label: "角色塑造", maxScore: 15, hint: "人物立体度·动机合理性·弧光设计", detail: "主角动机有铺垫,配角功能性较强,人物弧光尚可进一步深化。" },
{ key: "plot", label: "剧情结构", maxScore: 20, hint: "起承转合·节奏把控·冲突设计", detail: "起承转合完整,节奏把控稳健,冲突设计有张力。" },
{ key: "logic", label: "逻辑严密", maxScore: 15, hint: "世界观自洽·伏笔回收·因果链", detail: "世界观整体自洽,伏笔设置到位。" },
{ key: "visual", label: "场景构建", maxScore: 15, hint: "空间描写·视听语言·画面想象力", detail: "视觉意象统一而强烈,场景描写极具画面感。" },
{ key: "content", label: "内容深度", maxScore: 15, hint: "主题表达·情感共鸣·思想内核", detail: "核心设定将科技伦理与人性困境紧密结合,主题表达深刻有力。" },
];
function formatReportMarkdown(result: EvalResult, script: string): string {
const lines: string[] = [];
lines.push(`# 剧本评测报告`);
@@ -127,10 +187,10 @@ function formatReportMarkdown(result: EvalResult, script: string): string {
lines.push(result.summary);
lines.push("");
lines.push(`## 六维评分`);
for (const dim of scoreDimensions) {
for (const dim of SCORE_DIMENSIONS) {
const score = result.dimensionScores[dim.key] ?? 0;
const pct = Math.round((score / dim.maxScore) * 100);
lines.push(`- **${dim.label}**: ${score}/${dim.maxScore} (${pct}%) — ${dim.description}`);
lines.push(`- **${dim.label}**: ${score}/${dim.maxScore} (${pct}%) — ${dim.hint}`);
}
if (result.highlights.length > 0) {
lines.push("");
@@ -150,13 +210,6 @@ function formatReportMarkdown(result: EvalResult, script: string): string {
lines.push("");
lines.push(`---`);
lines.push(`*评测时间: ${new Date().toLocaleString("zh-CN")}*`);
lines.push("");
lines.push(`<details><summary>原始剧本 (${script.length} 字)</summary>`);
lines.push("");
lines.push("```");
lines.push(script.slice(0, 2000) + (script.length > 2000 ? "\n...(已截断)" : ""));
lines.push("```");
lines.push("</details>");
return lines.join("\n");
}
@@ -165,79 +218,85 @@ function ScriptTokensPage() {
const [loading, setLoading] = useState(false);
const [result, setResult] = useState<EvalResult | null>(null);
const [evalError, setEvalError] = useState<string | null>(null);
const [detailsExpanded, setDetailsExpanded] = useState(true);
const [uploadedFile, setUploadedFile] = useState<{ name: string; size: number } | null>(null);
const [copied, setCopied] = useState(false);
const [activeDim, setActiveDim] = useState<number | null>(null);
const [animatedScore, setAnimatedScore] = useState(0);
const [history, setHistory] = useState<HistoryEntry[]>(loadHistory);
const fileInputRef = useRef<HTMLInputElement>(null);
const scoreFrameRef = useRef<number | null>(null);
useEffect(() => {
console.log("[剧本评分] 页面已加载,ScriptTokensPage mounted");
}, []);
const session = useSessionStore((s) => s.session);
const hasContent = Boolean(script.trim());
const lineNumbers = useMemo(() => {
const count = Math.min(160, Math.max(10, script.split(/\r\n|\r|\n/).length));
return Array.from({ length: count }, (_, index) => index + 1);
}, [script]);
const handleUploadKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {
if (event.key !== "Enter" && event.key !== " ") return;
event.preventDefault();
fileInputRef.current?.click();
};
// Score animation
useEffect(() => {
if (!result) return;
const start = performance.now();
const target = result.totalScore;
const dur = 1400;
function tick(now: number) {
const t = Math.min((now - start) / dur, 1);
const e = 1 - Math.pow(1 - t, 3);
setAnimatedScore(Math.round(e * target));
if (t < 1) scoreFrameRef.current = requestAnimationFrame(tick);
}
scoreFrameRef.current = requestAnimationFrame(tick);
return () => { if (scoreFrameRef.current) cancelAnimationFrame(scoreFrameRef.current); };
}, [result]);
const handleFileUpload = async (event: ChangeEvent<HTMLInputElement>) => {
const file = event.target.files?.[0];
if (!file) return;
const ext = file.name.slice(file.name.lastIndexOf(".")).toLowerCase();
const readable = [".txt", ".md"].includes(ext) || file.type === "text/plain" || file.type === "text/markdown";
const ext = getFileExtension(file.name);
const readable = isReadableTextFile(file, ext);
setUploadedFile({ name: file.name, size: file.size });
if (readable) {
setScript(await file.text());
const text = normalizeUploadedText(await decodeTextFile(file), ext);
setScript(text);
} else {
setScript(
`[已上传文件:${file.name}]\n\n暂不支持解析 ${ext.toUpperCase()} 格式,请上传 TXT 或 MD 文件,或直接粘贴剧本文本后开始评测。`,
);
setScript(`[已上传文件:${file.name}]\n\n暂不支持解析 ${ext ? ext.toUpperCase() : "未知"} 格式,请上传常见文本类文件。`);
}
event.target.value = "";
};
const handleEvaluate = async () => {
console.log("[剧本评测] 点击开始评测,hasContent:", hasContent, "script长度:", script.length);
if (!hasContent) return;
setLoading(true);
setResult(null);
setEvalError(null);
setAnimatedScore(0);
setActiveDim(null);
try {
console.log("[剧本评测] 开始评测,剧本长度:", script.length, "字符");
const aiResult = await evaluateScript(script);
console.log("[剧本评测] 评测完成,结果:", {
总分: aiResult.totalScore,
等级: aiResult.grade,
维度得分: aiResult.dimensionScores,
摘要: aiResult.summary,
亮点: aiResult.highlights,
问题: aiResult.issues,
建议: aiResult.suggestions,
});
setResult(aiResult);
const g = getGrade(aiResult.totalScore);
const entry: HistoryEntry = {
name: uploadedFile?.name?.replace(/\.[^.]+$/, "") ?? `剧本 ${new Date().toLocaleDateString("zh-CN")}`,
date: new Date().toLocaleDateString("zh-CN", { month: "2-digit", day: "2-digit", hour: "2-digit", minute: "2-digit" }),
timestamp: Date.now(),
score: aiResult.totalScore,
grade: g,
};
const updated = [entry, ...loadHistory().filter((h) => h.name !== entry.name || h.score !== entry.score)].sort(
(a, b) => b.timestamp - a.timestamp,
);
saveHistory(updated);
setHistory(updated);
} catch (err) {
console.error("[剧本评测] 评测失败:", err);
setEvalError(err instanceof Error ? err.message : "评测服务暂时不可用,请稍后重试");
}
setDetailsExpanded(true);
setLoading(false);
};
const handleReset = () => {
setScript("");
setResult(null);
setDetailsExpanded(true);
setEvalError(null);
setUploadedFile(null);
setCopied(false);
setAnimatedScore(0);
setActiveDim(null);
if (fileInputRef.current) fileInputRef.current.value = "";
};
@@ -276,226 +335,314 @@ function ScriptTokensPage() {
URL.revokeObjectURL(url);
};
const scoreStatus = loading ? "评测中" : result ? "评测完成" : "待生成评分";
const scoreHint =
result?.summary ??
(hasContent ? "点击「开始评测」生成六维雷达评分和优化路径。" : "粘贴完整剧本后,点击「开始评测」生成六维雷达评分和优化路径。");
const uploadKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {
if (event.key !== "Enter" && event.key !== " ") return;
event.preventDefault();
fileInputRef.current?.click();
};
const grade = result ? getGrade(result.totalScore) : null;
const beatPct = result ? (result.totalScore >= 95 ? 97 : result.totalScore >= 88 ? 92 : result.totalScore >= 80 ? 85 : 72) : 0;
const compactTitle = uploadedFile?.name?.replace(/\.[^.]+$/, "") ?? "剧本评测";
const scriptMinutes = Math.max(8, Math.round(script.length / 460));
const reportDate = new Date().toLocaleDateString("zh-CN", { month: "2-digit", day: "2-digit" });
return (
<section className="script-token-page script-eval-v4 page-motion">
<main className="script-token-page__scroll script-eval-v4-stage">
<section className="script-eval-v4-app" aria-label="剧本评测工具">
<div className="script-eval-v4-panel-left">
<section className="script-eval-v4-glass script-eval-v4-input-card">
<div
className="script-eval-v4-upload-area"
role="button"
tabIndex={0}
onClick={() => fileInputRef.current?.click()}
onKeyDown={handleUploadKeyDown}
>
<UploadOutlined />
<div className="upload-text">
{uploadedFile ? uploadedFile.name : "粘贴文本或上传文档"}
<div className="hint">
{uploadedFile ? `${(uploadedFile.size / 1024).toFixed(1)}KB,已载入文件信息` : "建议包含场景、角色、动作和台词"}
</div>
<section className="script-eval-v5 page-motion">
<div className="script-eval-v5-page">
{/* Left Panel */}
<aside className="script-eval-v5-left">
<div className="script-eval-v5-lp-section">
<div className="script-eval-v5-lp-label"></div>
<div
className="script-eval-v5-upload-zone"
role="button"
tabIndex={0}
onClick={() => fileInputRef.current?.click()}
onKeyDown={uploadKeyDown}
>
{uploadedFile ? (
<div className="script-eval-v5-upload-done is-show">
<CheckCircleFilled />
<span className="script-eval-v5-uf-name">{uploadedFile.name}</span>
<span className="script-eval-v5-uf-re" onClick={(e) => { e.stopPropagation(); handleReset(); }}>
</span>
</div>
<input ref={fileInputRef} type="file" accept=".txt,.md,.pdf,.doc,.docx" onChange={handleFileUpload} />
<button
type="button"
className="script-eval-v4-upload-btn"
onClick={(event) => {
event.stopPropagation();
fileInputRef.current?.click();
}}
>
</button>
</div>
<div className="script-eval-v4-text-shell">
<div className="script-eval-v4-line-numbers" aria-hidden="true">
{lineNumbers.map((line) => (
<span key={line}>{line}</span>
))}
</div>
<textarea
className="script-eval-v4-text-input"
value={script}
onChange={(event) => setScript(event.target.value)}
placeholder={
"在此粘贴你的剧本内容...\n\n【第一幕】夜晚,城市天台。霓虹灯映照着雨后的地面。\n小凯独自站在天台边缘,手中握着一张皱巴巴的纸条..."
}
/>
</div>
<div className="script-eval-v4-button-group">
<button
type="button"
className="script-eval-v4-btn-primary"
disabled={loading || !hasContent}
onClick={() => void handleEvaluate()}
>
<span>{loading ? "评测中..." : "开始评测"}</span>
</button>
<button type="button" className="script-eval-v4-btn-secondary" onClick={handleReset}>
<ReloadOutlined />
</button>
</div>
</section>
) : (
<>
<div className="script-eval-v5-upload-icon"><UploadOutlined /></div>
<div className="script-eval-v5-upload-text"></div>
<button type="button" className="script-eval-v5-upload-btn" onClick={(e) => { e.stopPropagation(); fileInputRef.current?.click(); }}>
+
</button>
<div className="script-eval-v5-upload-hint">{TEXT_FILE_HINT}</div>
</>
)}
</div>
<input ref={fileInputRef} type="file" accept={TEXT_FILE_ACCEPT} style={{ display: "none" }} onChange={handleFileUpload} />
</div>
<aside className="script-eval-v4-panel-right" aria-label="评分结果">
{evalError ? (
<div className="script-eval-v4-error" role="alert">
<span className="script-eval-v4-error__icon"></span>
<span>{evalError}</span>
</div>
) : null}
<section className={`script-eval-v4-glass script-eval-v4-score-card${loading ? " loading" : ""}${result ? " ready" : ""}`}>
<div className="script-eval-v4-score-header">
<div className="score-title">SCORE BOARD</div>
<span className={`score-status${result ? " ready" : ""}`}>{scoreStatus}</span>
</div>
<div className="script-eval-v4-score-main">
<RadarPreview result={result} />
<div className="script-eval-v4-score-display">
<div className={`score-number${result ? " has-data" : ""}`}>
{result ? (
<>
{result.totalScore} <span>/ 100</span>
</>
) : (
"— / 100"
)}
<div className="script-eval-v5-lp-section">
<div className="script-eval-v5-lp-label">AI </div>
<div className="script-eval-v5-info-grid">
{!result ? (
<div className="script-eval-v5-info-empty"></div>
) : (
<>
<div className="script-eval-v5-info-item">
<span className="script-eval-v5-info-key"></span>
<span className="script-eval-v5-info-val"><span className="script-eval-v5-info-tag">{result.totalScore} · {grade}</span></span>
</div>
<div className="score-label"> {result ? `· ${result.grade}` : ""}</div>
<div className="score-hint">{scoreHint}</div>
</div>
</div>
<div className="script-eval-v5-info-item">
<span className="script-eval-v5-info-key"></span>
<span className="script-eval-v5-info-val">{script.length} </span>
</div>
<div className="script-eval-v5-info-item">
<span className="script-eval-v5-info-key"></span>
<span className="script-eval-v5-info-val">{new Date().toLocaleDateString("zh-CN")}</span>
</div>
<div className="script-eval-v5-info-item">
<span className="script-eval-v5-info-key"></span>
<span className="script-eval-v5-info-val">{beatPct}%</span>
</div>
</>
)}
</div>
</div>
<div className="script-eval-v4-dimensions-tags">
{scoreDimensions.map((dimension) => (
<span className="tag" key={dimension.key}>
{dimension.label}
</span>
))}
</div>
</section>
<section className="script-eval-v4-glass script-eval-v4-details-card">
<button
type="button"
className="script-eval-v4-details-header"
onClick={() => setDetailsExpanded((expanded) => !expanded)}
aria-expanded={detailsExpanded}
>
<span className="details-title">
<TrophyOutlined />
DIMENSIONS
</span>
<DownOutlined className={`expand-icon${detailsExpanded ? " expanded" : ""}`} />
</button>
<div className={`script-eval-v4-details-content${detailsExpanded ? " expanded" : ""}`}>
<div className="script-eval-v4-details-list">
{scoreDimensions.map((dimension) => {
const score = result?.dimensionScores[dimension.key] ?? 0;
const pct = result ? Math.round((score / dimension.maxScore) * 100) : 0;
return (
<article className="script-eval-v4-detail-row" key={dimension.key}>
<div className="detail-row-main">
<span className="dimension-name">{dimension.label}</span>
<div className="dimension-bar" aria-hidden="true">
<span className="dimension-bar-fill" style={{ width: `${pct}%` }} />
</div>
<span className="dimension-score">{result ? `${score}/${dimension.maxScore}` : `${dimension.maxScore}`}</span>
</div>
<div className="dimension-desc">{dimension.description}</div>
</article>
);
})}
</div>
</div>
</section>
{result && (result.highlights.length > 0 || result.issues.length > 0) && (
<section className="script-eval-v4-glass script-eval-v4-insights-card">
{result.highlights.length > 0 && (
<div className="script-eval-v4-insight-group highlights">
<div className="insight-group-title">
<span className="insight-icon"></span>
HIGHLIGHTS
<div className="script-eval-v5-lp-section is-fill">
<div className="script-eval-v5-lp-label"></div>
<div className="script-eval-v5-history-list">
{!session ? (
<div className="script-eval-v5-history-empty"></div>
) : history.length === 0 ? (
<div className="script-eval-v5-history-empty"></div>
) : (
history.map((item, i) => (
<div key={i} className={`script-eval-v5-history-item${i === 0 ? " is-active" : ""}`}>
<div className="script-eval-v5-hi-left">
<div className="script-eval-v5-hi-name">{item.name}</div>
<div className="script-eval-v5-hi-date">{item.date}</div>
<div className="script-eval-v5-hi-bar">
<div className="script-eval-v5-hi-bar-fill" style={{ width: `${Math.min(92, (item.score / 100) * 100)}%` }} />
</div>
</div>
<ul className="insight-list">
{result.highlights.map((h, i) => (
<li key={i} className="insight-item highlight-item">{h}</li>
))}
</ul>
<div className="script-eval-v5-hi-right">
<div className={`script-eval-v5-hi-score${item.score >= 90 ? " is-green" : ""}`}>{item.score}</div>
<div className="script-eval-v5-hi-grade">{item.grade}</div>
</div>
</div>
))
)}
</div>
</div>
<div className="script-eval-v5-lp-bottom">
<button
type="button"
className="script-eval-v5-eval-btn"
disabled={loading || !hasContent}
onClick={() => void handleEvaluate()}
>
{loading ? "◆ 评测中..." : "◆ 开始评测"}
</button>
<button type="button" className="script-eval-v5-export-btn" disabled={!result} onClick={handleExportMarkdown}>
</button>
</div>
</aside>
{/* Right Area */}
<div className="script-eval-v5-right">
<div className="script-eval-v5-right-topbar">
<div className="script-eval-v5-right-title">
<span className="script-eval-v5-rt-green"></span>
{uploadedFile && <> · {compactTitle}</>}
</div>
<div className="script-eval-v5-right-actions">
{result && (
<>
<button type="button" className="script-eval-v5-action-btn" onClick={() => void handleCopyReport()}>
<CopyOutlined />{copied ? "已复制" : "复制"}
</button>
<button type="button" className="script-eval-v5-action-btn" onClick={handleExportMarkdown}>
<DownloadOutlined />
</button>
</>
)}
</div>
</div>
<div className={`script-eval-v5-right-content${result ? " is-report" : ""}`}>
{!result && (
<div className="script-eval-v5-input-section">
<div className="script-eval-v5-illustration" aria-label="上传剧本并开始评测">
<div
className="script-eval-v5-illustration-hit"
role="button"
tabIndex={0}
onClick={() => fileInputRef.current?.click()}
onKeyDown={uploadKeyDown}
>
<div className="script-eval-v5-upload-card-icon">
<FileTextOutlined />
</div>
<div className="script-eval-v5-upload-card-title">
{uploadedFile ? "剧本已导入" : "上传剧本文件"}
</div>
<div className="script-eval-v5-upload-card-desc">
{uploadedFile
? "如需更换,点击此处重新上传;完成后点击左侧开始评测。"
: `${TEXT_FILE_HINT},上传后点击开始评测,AI 将识别剧本信息。`}
</div>
</div>
</div>
{evalError && (
<div className="script-eval-v5-error" role="alert">
<span></span><span>{evalError}</span>
</div>
)}
{result.issues.length > 0 && (
<div className="script-eval-v4-insight-group issues">
<div className="insight-group-title">
<span className="insight-icon"></span>
ISSUES
</div>
<ul className="insight-list">
{result.issues.map((issue, i) => (
<li key={i} className="insight-item issue-item">{issue}</li>
))}
</ul>
</div>
)}
</section>
)}
{result && result.suggestions.length > 0 && (
<section className="script-eval-v4-glass script-eval-v4-suggestions-card">
<div className="suggestions-header">
<span className="suggestions-title">
<span className="insight-icon"></span>
SUGGESTIONS
</span>
</div>
<ul className="suggestion-list">
{result.suggestions.map((s, i) => (
<li key={i} className="suggestion-item">
<span className="suggestion-index">{i + 1}</span>
<span className="suggestion-text">{s}</span>
</li>
))}
</ul>
</section>
</div>
)}
{result && (
<div className="script-eval-v4-report-actions">
<button type="button" className="script-eval-v4-report-btn" onClick={() => void handleCopyReport()}>
<CopyOutlined />
<span>{copied ? "已复制" : "复制报告"}</span>
</button>
<button type="button" className="script-eval-v4-report-btn" onClick={handleExportMarkdown}>
<DownloadOutlined />
<span> Markdown</span>
</button>
</div>
)}
<section className="script-eval-report script-eval-report--inside">
<div className="script-eval-report__body">
<header className="script-eval-report__hero">
<div className="script-eval-report__score-block">
<div className="script-eval-report__score-row">
<span className="script-eval-report__score">{animatedScore}</span>
<span className="script-eval-report__score-total">/ 100</span>
<span className="script-eval-report__grade">
<i />
{grade}
</span>
</div>
<div className="script-eval-report__score-line">
<span style={{ width: `${animatedScore}%` }} />
</div>
<div className="script-eval-report__beat"> <b>{beatPct}%</b> </div>
</div>
{!result && (
<section className="script-eval-v4-note">
<FileTextOutlined />
<span></span>
<div className="script-eval-report__summary">
<div className="script-eval-report__title-line">
<div>
<h1>{compactTitle}</h1>
<p>{`剧本评测 · ${scriptMinutes} min · ${reportDate}`}</p>
</div>
</div>
<p className="script-eval-report__desc">{result.summary}</p>
</div>
</header>
<section className="script-eval-report__chart-card" aria-label="维度拆解">
<div className="script-eval-report__card-head">
<span><i /></span>
<div className="script-eval-report__legend">
<span><i className="is-score" /></span>
<span><i className="is-loss" /></span>
</div>
</div>
<div className="script-eval-report__chart">
<div className="script-eval-report__axis">
<span>100%</span>
<span>80%</span>
<span>60%</span>
<span>40%</span>
<span>20%</span>
<span>0%</span>
</div>
<div className="script-eval-report__chart-grid">
{SCORE_DIMENSIONS.map((dim) => {
const score = result.dimensionScores[dim.key] ?? 0;
const pct = Math.max(0, Math.min(1, score / dim.maxScore));
const lossPct = 1 - pct;
const isPerfect = score === dim.maxScore;
return (
<button key={dim.key} type="button" className="script-eval-report__bar-col">
<div className="script-eval-report__bar-score">
<b>{score}</b><small>/{dim.maxScore}</small>{isPerfect ? <em>*</em> : null}
</div>
<div className="script-eval-report__bar-box">
{lossPct > 0 ? <div className="script-eval-report__bar-loss" style={{ height: `${lossPct * 100}%` }} /> : null}
<div className="script-eval-report__bar-fill" style={{ height: `${pct * 100}%` }} />
</div>
<strong>{dim.label}</strong>
<span>{dim.hint}</span>
</button>
);
})}
</div>
</div>
</section>
<div className="script-eval-report__findings">
{result.highlights.length > 0 ? (
<section className="script-eval-report__finding-group is-highlight">
<h2> <span>{result.highlights.length}</span></h2>
<div>
{result.highlights.map((item, index) => (
<p key={index}>{item}</p>
))}
</div>
</section>
) : null}
{result.issues.length > 0 ? (
<section className="script-eval-report__finding-group is-issue">
<h2> <span>{result.issues.length}</span></h2>
<div>
{result.issues.map((item, index) => (
<p key={index}>{item}</p>
))}
</div>
</section>
) : null}
</div>
{result.suggestions.length > 0 ? (
<section className="script-eval-report__path-card">
<div className="script-eval-report__card-head">
<span><i /></span>
</div>
<table className="script-eval-report__path-table">
<thead>
<tr>
<th>#</th>
<th></th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
{result.suggestions.map((item, index) => {
const high = index < 2;
return (
<tr key={index}>
<td>{String(index + 1).padStart(2, "0")}</td>
<td>{high ? "核心" : "增强"}</td>
<td>{item}</td>
<td><span className={high ? "is-high" : "is-mid"}>{high ? "HIGH" : "MID"}</span></td>
</tr>
);
})}
</tbody>
</table>
</section>
) : null}
</div>
</section>
)}
</aside>
</section>
</main>
</div>
<div className="script-eval-v5-statusbar">
<div className="script-eval-v5-status-dot" />
<span>{loading ? "评测中..." : result ? "评测完成" : hasContent ? "待评测" : "等待上传"}</span>
<span className="script-eval-v5-sb-right">{result ? `六维标准 · ${result.totalScore}` : "六维标准"}</span>
</div>
</div>
</div>
</section>
);
}