Skip to content

PRINTFILM: AI short-video marketing and AI short-drama creation platform

fix(drama): 统一工作区和分集生成状态提示

yi8793b12b701b
diff --git a/frontend/src/pages/drama/DramaStatusNotice.tsx b/frontend/src/pages/drama/DramaStatusNotice.tsx
new file mode 100644
index 0000000..a7becc9
--- /dev/null
+++ b/frontend/src/pages/drama/DramaStatusNotice.tsx
@@ -0,0 +1,66 @@
+import type { ReactNode } from 'react'
+import { AlertCircle, CheckCircle2, Info, LoaderCircle, TriangleAlert, WifiOff, X } from 'lucide-react'
+import BillingErrorNotice from '../../components/billing/BillingErrorNotice'
+import './dramaStatusNotice.css'
+
+type Props = {
+ tone?: 'info' | 'success' | 'warning' | 'error' | 'busy'
+ title: string
+ children?: ReactNode
+ icon?: ReactNode
+ className?: string
+ onDismiss?: () => void
+}
+
+const icons = {
+ info: Info,
+ success: CheckCircle2,
+ warning: TriangleAlert,
+ error: AlertCircle,
+ busy: LoaderCircle,
+}
+
+/** 大纲页共用状态条:保留内容层级,生成中的状态使用轻量动效。 */
+export default function DramaStatusNotice({ tone = 'info', title, children, icon, className = '', onDismiss }: Props) {
+ const Icon = icons[tone]
+ return (
+ <div className={`drama-status-notice is-${tone} ${className}`} role={tone === 'error' ? 'alert' : 'status'}>
+ <span className="drama-status-notice-icon" aria-hidden="true">
+ {icon || <Icon size={17} strokeWidth={1.8} className={tone === 'busy' ? 'drama-status-notice-spinner' : undefined} />}
+ </span>
+ <div className="drama-status-notice-content">
+ <strong className="drama-status-notice-title">{title}</strong>
+ {children ? <div className="drama-status-notice-description">{children}</div> : null}
+ </div>
+ {onDismiss ? (
+ <button type="button" className="drama-status-notice-close" onClick={onDismiss} aria-label="关闭提示">
+ <X size={16} aria-hidden="true" />
+ </button>
+ ) : null}
+ </div>
+ )
+}
+
+/** 网络异常使用中文说明,业务错误继续保留余额不足等操作入口。 */
+export function DramaErrorNotice({ message, className, onDismiss }: { message: string; className?: string; onDismiss?: () => void }) {
+ const networkError = /failed to fetch|networkerror|network request failed|load failed|connection reset|连接被重置/i.test(message)
+ return (
+ <DramaStatusNotice
+ tone={networkError ? 'warning' : 'error'}
+ title={networkError ? '暂时无法连接服务' : '操作未完成'}
+ icon={networkError ? <WifiOff size={17} strokeWidth={1.8} /> : undefined}
+ className={className}
+ onDismiss={onDismiss}
+ >
+ {networkError ? (
+ <>
+ <p>请检查网络连接后重试。如有生成任务进行中,可稍后查看任务状态。</p>
+ <details className="drama-status-notice-details">
+ <summary>查看错误详情</summary>
+ <p>{message}</p>
+ </details>
+ </>
+ ) : <BillingErrorNotice message={message} className="drama-status-notice-message" inline />}
+ </DramaStatusNotice>
+ )
+}
diff --git a/frontend/src/pages/drama/OutlineEpisodePanel.tsx b/frontend/src/pages/drama/OutlineEpisodePanel.tsx
index f43b7f0..4e8f965 100644
--- a/frontend/src/pages/drama/OutlineEpisodePanel.tsx
+++ b/frontend/src/pages/drama/OutlineEpisodePanel.tsx
@@ -33,9 +33,18 @@ import {
} from './dramaWorkspaceUtils'
import { sumFragmentContentDuration } from './dramaEpisodeEditUtils'
import { OutlineScriptParseModal, OutlineScriptPreview } from './outlineScriptPreview'
+import DramaStatusNotice, { DramaErrorNotice } from './DramaStatusNotice'
type SectionKey = 'creative' | 'summary' | 'body'
+const GENERATION_TITLES: Record<string, string> = {
+ creative: '正在生成本集创作思路',
+ summary: '正在生成本集梗概',
+ brief: '正在提取本集梗概',
+ body: '正在生成拍摄剧本',
+ full: '正在重新生成整集',
+}
+
/** 分集目录用的镜头合计文案 */
function formatOutlineShotDuration(sec: number): string {
if (sec <= 0) return '—'
@@ -856,41 +865,55 @@ export function OutlineEpisodePanel({
</div>
</header>
- {localError ? <p className="drama-error">{localError}</p> : null}
- {localNotice ? <p className="drama-outline-notice">{localNotice}</p> : null}
- {selectedShot?.scriptChanged ? (
- <p className="drama-outline-notice">剧本已修改,当前分镜仍为旧稿;进入后请重新分镜。</p>
- ) : null}
- {summaryGenerating ? (
- <p className="drama-loader">全剧摘要生成中…完成后抽取资产,再生成各集剧本</p>
- ) : null}
- {assetsSeeding ? (
- <p className="drama-loader">抽取资产中…角色/场景写入资产库后开始分集</p>
- ) : null}
- {episodeGenerating ? (
- <p className="drama-loader">
- {episodeProgress.total > 0
- ? `整剧进度 ${episodeProgress.done}/${episodeProgress.total} · 可先浏览已完成的集`
- : '全集剧本生成中,可先浏览已完成的集…'}
- </p>
- ) : null}
- {selectedGenerating ? (
- <p className="drama-loader">本集生成中({generatingMode})…</p>
- ) : anyEpisodeGenerating && generatingEpisodeNumber ? (
- <p className="drama-loader">
- 第 {generatingEpisodeNumber} 集生成中,可继续创作当前分集
- </p>
- ) : null}
- {selected && episodeShotStats[selected.episodeNumber || 0]?.planStatus === 'generating' ? (
- <p className="drama-loader">本集 AI 分镜中…</p>
- ) : null}
- {selected &&
- isSubstantialEpisodeBody(selected.body) &&
- !episodeShotStats[selected.episodeNumber || 0]?.planStatus &&
- !summaryGenerating &&
- !assetsSeeding ? (
- <p className="drama-loader">本集正文已就绪,正在准备 AI 分镜…</p>
- ) : null}
+ <div className="drama-outline-status-list">
+ {localError ? <DramaErrorNotice message={localError} onDismiss={() => setLocalError('')} /> : null}
+ {localNotice ? <DramaStatusNotice tone="success" title={localNotice} onDismiss={() => setLocalNotice('')} /> : null}
+ {selectedShot?.scriptChanged ? (
+ <DramaStatusNotice tone="warning" title="剧本已更新,分镜待同步">
+ 现有分镜仍为旧稿,进入分镜后请重新分镜。
+ </DramaStatusNotice>
+ ) : null}
+ {summaryGenerating ? (
+ <DramaStatusNotice tone="busy" title="正在生成全剧摘要">
+ 完成后将抽取角色与场景资产,再生成各集剧本。
+ </DramaStatusNotice>
+ ) : null}
+ {assetsSeeding ? (
+ <DramaStatusNotice tone="busy" title="正在抽取角色与场景资产">
+ 写入资产库后,将开始生成分集剧本。
+ </DramaStatusNotice>
+ ) : null}
+ {episodeGenerating ? (
+ <DramaStatusNotice tone="busy" title="正在生成分集剧本">
+ {episodeProgress.total > 0
+ ? `已完成 ${episodeProgress.done} / ${episodeProgress.total} 集,可先浏览已完成的内容。`
+ : '可先浏览已完成的分集内容。'}
+ </DramaStatusNotice>
+ ) : null}
+ {selectedGenerating ? (
+ <DramaStatusNotice tone="busy" title={GENERATION_TITLES[generatingMode || ''] || '正在生成本集内容'}>
+ 内容生成后将自动更新,请稍候。
+ </DramaStatusNotice>
+ ) : anyEpisodeGenerating && generatingEpisodeNumber ? (
+ <DramaStatusNotice tone="busy" title={`第 ${generatingEpisodeNumber} 集正在生成`}>
+ 可继续创作当前分集。
+ </DramaStatusNotice>
+ ) : null}
+ {selected && episodeShotStats[selected.episodeNumber || 0]?.planStatus === 'generating' ? (
+ <DramaStatusNotice tone="busy" title="正在生成本集 AI 分镜">
+ 分镜完成后,可进入查看与编辑。
+ </DramaStatusNotice>
+ ) : null}
+ {selected &&
+ isSubstantialEpisodeBody(selected.body) &&
+ !episodeShotStats[selected.episodeNumber || 0]?.planStatus &&
+ !selectedGenerating &&
+ !episodeGenerating &&
+ !summaryGenerating &&
+ !assetsSeeding ? (
+ <DramaStatusNotice tone="busy" title="本集剧本已就绪,正在准备 AI 分镜" />
+ ) : null}
+ </div>
<div className="drama-outline-sections">
<SectionCard
diff --git a/frontend/src/pages/drama/ProjectWorkspacePage.tsx b/frontend/src/pages/drama/ProjectWorkspacePage.tsx
index 0556c85..631211d 100644
--- a/frontend/src/pages/drama/ProjectWorkspacePage.tsx
+++ b/frontend/src/pages/drama/ProjectWorkspacePage.tsx
@@ -4,7 +4,7 @@ import { isRequestAborted } from '../../api/http'
import { useEffect, useRef, useState } from 'react'
import { useLocation, useNavigate, useParams } from 'react-router-dom'
import { Boxes, ChevronLeft } from 'lucide-react'
-import BillingErrorNotice from '../../components/billing/BillingErrorNotice'
+import { DramaErrorNotice } from './DramaStatusNotice'
import AppShell from '../../components/layout/AppShell'
import { dramaApi, type DramaProject } from '../../api/drama'
import {
@@ -236,7 +236,7 @@ function WorkspaceInner() {
</header>
{titleLock.error && <p role="alert" className="pf-team-alert">{titleLock.error}<button type="button" onClick={titleLock.retry}>重新取得编辑权</button></p>}
- {error ? <BillingErrorNotice message={error} className="drama-error drama-workspace-banner" /> : null}
+ {error ? <DramaErrorNotice message={error} className="drama-workspace-alert" onDismiss={() => setError('')} /> : null}
<main className="drama-workspace-main">
{assetsOpen ? <AssetsStep projectId={id} onError={setError} /> : null}
diff --git a/frontend/src/pages/drama/dramaStatusNotice.css b/frontend/src/pages/drama/dramaStatusNotice.css
new file mode 100644
index 0000000..40dace2
--- /dev/null
+++ b/frontend/src/pages/drama/dramaStatusNotice.css
@@ -0,0 +1,145 @@
+.drama-status-notice {
+ --notice-ink: #42627c;
+ --notice-bg: #f5f9fc;
+ --notice-line: #e0eaf2;
+ --notice-icon-bg: #e8f0f7;
+ display: flex;
+ align-items: flex-start;
+ gap: 11px;
+ min-width: 0;
+ padding: 13px 15px;
+ border: 1px solid var(--notice-line);
+ border-radius: 12px;
+ background: var(--notice-bg);
+ color: var(--notice-ink);
+ font-size: 13px;
+ line-height: 1.6;
+}
+
+.drama-status-notice.is-busy,
+.drama-status-notice.is-success {
+ --notice-ink: #167263;
+ --notice-bg: #f2faf7;
+ --notice-line: #d9eee5;
+ --notice-icon-bg: #e1f3eb;
+}
+
+.drama-status-notice.is-warning {
+ --notice-ink: #94621d;
+ --notice-bg: #fffbf2;
+ --notice-line: #f1e4c9;
+ --notice-icon-bg: #fbefda;
+}
+
+.drama-status-notice.is-error {
+ --notice-ink: #b04444;
+ --notice-bg: #fff7f7;
+ --notice-line: #f4dddd;
+ --notice-icon-bg: #fbe8e8;
+}
+
+.drama-status-notice-icon {
+ display: grid;
+ place-items: center;
+ flex: 0 0 30px;
+ height: 30px;
+ border-radius: 9px;
+ background: var(--notice-icon-bg);
+}
+
+.drama-status-notice-content {
+ flex: 1;
+ min-width: 0;
+ align-self: center;
+ overflow-wrap: anywhere;
+}
+
+.drama-status-notice-title {
+ display: block;
+ font-size: 13px;
+ font-weight: 600;
+ line-height: 1.6;
+}
+
+.drama-status-notice-description {
+ margin-top: 2px;
+ font-size: 12px;
+ color: var(--notice-ink);
+}
+
+.drama-status-notice-description p {
+ margin: 0;
+}
+
+.drama-status-notice-close {
+ display: grid;
+ place-items: center;
+ flex: 0 0 28px;
+ height: 28px;
+ padding: 0;
+ border: 0;
+ border-radius: 7px;
+ background: transparent;
+ color: inherit;
+ cursor: pointer;
+}
+
+.drama-status-notice-close:hover {
+ background: var(--notice-icon-bg);
+}
+
+.drama-status-notice-close:focus-visible,
+.drama-status-notice-details summary:focus-visible {
+ outline: 2px solid currentColor;
+ outline-offset: 3px;
+}
+
+.drama-status-notice-details {
+ margin-top: 5px;
+ font-size: 11px;
+}
+
+.drama-status-notice-details summary {
+ width: fit-content;
+ cursor: pointer;
+}
+
+.drama-status-notice-details p {
+ margin-top: 4px;
+ white-space: pre-wrap;
+}
+
+.drama-status-notice-spinner {
+ animation: drama-status-notice-spin 1s linear infinite;
+}
+
+@keyframes drama-status-notice-spin {
+ to { transform: rotate(360deg); }
+}
+
+.drama-workspace-alert {
+ margin: 12px 16px 0;
+}
+
+.drama-outline-status-list {
+ display: grid;
+ gap: 8px;
+ margin-bottom: 16px;
+}
+
+.drama-outline-status-list:empty {
+ display: none;
+}
+
+@media (max-width: 600px) {
+ .drama-status-notice {
+ gap: 9px;
+ padding: 11px 12px;
+ }
+}
+
+@media (prefers-reduced-motion: reduce) {
+ .drama-status-notice-spinner {
+ animation: none;
+ }
+}