PRINTFILM: AI short-video marketing and AI short-drama creation platform
fix(drama): 编辑权限检查期间保持工作区挂载,只刷新工作区
yid8c4ea2d97e1
diff --git a/frontend/src/features/teams/TeamEditingBoundary.tsx b/frontend/src/features/teams/TeamEditingBoundary.tsxindex 28a5fec..e3314d1 100644--- a/frontend/src/features/teams/TeamEditingBoundary.tsx+++ b/frontend/src/features/teams/TeamEditingBoundary.tsx@@ -1,4 +1,4 @@-import { useEffect, useState, type ReactNode } from 'react'+import { useEffect, useRef, useState, type ReactNode } from 'react'import { useParams } from 'react-router-dom'import AppShell from '../../components/layout/AppShell'import Button from '../../components/ui/Button'@@ -14,8 +14,8 @@ export function TeamEditingBoundary({ projectId, type, resourceId = 0, enabled =const lock = useTeamEditLock({ projectId, type, resourceId }, enabled, onAcquired)const { teams, activeTeamId } = useTeamPreview()const role = teams.find((team) => team.id === activeTeamId)?.myRole- if (lock.checking) return <p role="status">正在读取内容与编辑权限…</p>- return <TeamReadOnlyContext.Provider value={lock.readOnly}>{showReadOnlyNotice && <div role="status" className="pf-team-alert" style={{ display: lock.readOnly ? 'block' : 'none', marginBottom: 12 }}>{lock.error} · 当前只读 <Button size="sm" onClick={lock.retry}>重新尝试编辑</Button>{(role === 'owner' || role === 'admin') && <Button size="sm" onClick={lock.takeOver}>接管编辑</Button>}{readOnlyActions}</div>}{interactiveReadOnly ? children : <fieldset disabled={lock.readOnly} inert={lock.readOnly && !allowReadOnlyNavigation} style={{ border: 0, padding: 0, margin: 0, minWidth: 0 }}>{children}</fieldset>}</TeamReadOnlyContext.Provider>+ /* 检查占用期间保持工作区挂载(字段先禁用),不整页替换,避免内容反复重挂载。 */+ return <TeamReadOnlyContext.Provider value={lock.readOnly}>{showReadOnlyNotice && <div role="status" className="pf-team-alert" style={{ display: lock.readOnly && !lock.checking ? 'block' : 'none', marginBottom: 12 }}>{lock.error} · 当前只读 <Button size="sm" onClick={lock.retry}>重新尝试编辑</Button>{(role === 'owner' || role === 'admin') && <Button size="sm" onClick={lock.takeOver}>接管编辑</Button>}{readOnlyActions}</div>}{interactiveReadOnly ? children : <fieldset disabled={lock.readOnly} inert={lock.readOnly && !allowReadOnlyNavigation} style={{ border: 0, padding: 0, margin: 0, minWidth: 0 }}>{children}</fieldset>}</TeamReadOnlyContext.Provider>}/** 旧分镜编辑路由使用数据库分集 ID,先解析稳定集号再进入编辑界面。 */export function TeamEpisodeEditingBoundary({ children }: { children: ReactNode }) {@@ -23,13 +23,15 @@ export function TeamEpisodeEditingBoundary({ children }: { children: ReactNode }const [target, setTarget] = useState<EditTarget | null>(null)const [error, setError] = useState('')const [retry, setRetry] = useState(0)+ /* 首代解析完成前的空间事件来自本组件自身同步,忽略以免二次整页刷新。 */+ const settled = useRef(false)useEffect(() => {- let active = true; setTarget(null); setError('')- void syncProjectWorkspace(Number(projectId)).then(() => createJsonRequester()<{ project_id: number; params?: { episodeNumber?: number } }>(`/api/drama/episodes/${Number(episodeId)}`)).then((episode) => { if (episode.project_id !== Number(projectId)) throw new Error('分集不属于当前项目'); if (active) setTarget({ projectId: episode.project_id, type: 'episode', resourceId: Number(episode.params?.episodeNumber || episodeId) }) }).catch((cause) => { if (active) setError(cause instanceof Error ? cause.message : '分集加载失败') })- const unsubscribe = subscribeWorkspace(() => { if (active) { active = false; setRetry((n) => n + 1) } })+ let active = true; setError(''); settled.current = false+ void syncProjectWorkspace(Number(projectId)).then(() => createJsonRequester()<{ project_id: number; params?: { episodeNumber?: number } }>(`/api/drama/episodes/${Number(episodeId)}`)).then((episode) => { if (episode.project_id !== Number(projectId)) throw new Error('分集不属于当前项目'); if (!active) return; settled.current = true; setTarget({ projectId: episode.project_id, type: 'episode', resourceId: Number(episode.params?.episodeNumber || episodeId) }) }).catch((cause) => { if (active) setError(cause instanceof Error ? cause.message : '分集加载失败') })+ const unsubscribe = subscribeWorkspace(() => { if (active && settled.current) setRetry((n) => n + 1) })return () => { active = false; unsubscribe() }}, [projectId, episodeId, retry])- /* 加载与错误态也在 AppShell 内展示,避免整页只剩一行文字像白屏崩溃。 */+ /* 错误态在 AppShell 内展示;加载态仅首次进入出现,用壳内骨架屏过渡。 */if (error) return (<AppShell active="drama" flush><div role="alert" className="drama-workspace-status drama-error">{error}<Button onClick={() => setRetry((n) => n + 1)}>重试</Button></div>@@ -37,7 +39,7 @@ export function TeamEpisodeEditingBoundary({ children }: { children: ReactNode })if (!target) return (<AppShell active="drama" flush>- <div role="status" className="drama-workspace-status">正在读取分集与编辑权限…</div>+ <div role="status" aria-label="正在读取分集与编辑权限" className="drama-workspace-skeleton"><span /><span /><span /></div></AppShell>)return <TeamEditingBoundary {...target} interactiveReadOnly>{children}</TeamEditingBoundary>diff --git a/frontend/src/pages/drama/drama.css b/frontend/src/pages/drama/drama.cssindex 57ebe20..95102b6 100644--- a/frontend/src/pages/drama/drama.css+++ b/frontend/src/pages/drama/drama.css@@ -1357,13 +1357,6 @@font-weight: 600;}-.drama-asset-grid {- display: grid;- grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));- gap: 14px;- margin-top: 14px;-}-.drama-assets-page-meta {margin: 12px 0 0;font-size: 0.875rem;@@ -1373,76 +1366,6 @@margin-top: 20px;}-.drama-asset-card {- background: #fafafa;- border: 1px solid var(--drama-line);- border-radius: var(--drama-radius);- padding: 12px;- display: flex;- flex-direction: column;- gap: 8px;-}--.drama-asset-card-clickable {- cursor: pointer;- transition: border-color 0.15s ease, box-shadow 0.15s ease;-}--.drama-asset-card-clickable:hover {- border-color: color-mix(in srgb, var(--drama-lime) 55%, var(--drama-line));- box-shadow: 0 6px 18px rgba(0, 0, 0, 0.06);-}--.drama-asset-card-clickable:focus-visible {- outline: 2px solid var(--drama-lime);- outline-offset: 2px;-}--.drama-asset-thumb-btn {- display: block;- width: 100%;- padding: 0;- border: 0;- background: transparent;- cursor: zoom-in;- border-radius: 10px;- overflow: hidden;-}--.drama-asset-card img,-.drama-asset-placeholder {- width: 100%;- aspect-ratio: 1;- object-fit: cover;- border-radius: 10px;- background: #eee;-}--.drama-asset-placeholder {- display: grid;- place-items: center;- color: var(--drama-muted);- font-size: 12px;- text-transform: uppercase;-}--.drama-asset-card h3 {- margin: 0;- font-size: 14px;-}--.drama-asset-card p {- margin: 0;- font-size: 12px;- color: var(--drama-muted);-}--.drama-asset-card-actions {- display: flex;- flex-wrap: wrap;- gap: 6px;-}-.drama-asset-detail {display: flex;flex-direction: column;@@ -1463,9 +1386,7 @@.drama-asset-detail-media:disabled {cursor: default;}--.drama-asset-detail-media img,-.drama-asset-detail-media .drama-asset-placeholder {+.drama-asset-detail-media .pf-library-cover {aspect-ratio: 16 / 10;max-height: 240px;}@@ -1617,38 +1538,6 @@font-size: 18px;}-.drama-voice-list {- display: flex;- flex-direction: column;- gap: 8px;- margin: 14px 0;- max-height: 240px;- overflow: auto;-}--.drama-voice-option {- display: flex;- align-items: flex-start;- gap: 10px;- padding: 10px 12px;- border: 1px solid var(--drama-line);- border-radius: 10px;- cursor: pointer;- background: #fafafa;-}--.drama-voice-option span {- display: flex;- flex-direction: column;- gap: 2px;- font-size: 14px;-}--.drama-voice-option small {- color: var(--drama-muted);- font-size: 12px;-}-.drama-voice-audio {width: 100%;margin-bottom: 12px;@@ -1658,25 +1547,6 @@max-width: 560px;}-.drama-voice-mode-tabs {- display: flex;- gap: 8px;- margin: 12px 0;-}--.drama-voice-mode-tabs button {- border: 1px solid var(--drama-line);- background: #fff;- border-radius: 8px;- padding: 6px 12px;- cursor: pointer;-}--.drama-voice-mode-tabs button.active {- border-color: var(--drama-accent, #111);- background: #f5f5f5;-}-.drama-voice-create-form {display: flex;flex-direction: column;@@ -1707,213 +1577,6 @@resize: vertical;}-.drama-asset-grid.is-voice {- grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));- gap: 16px;-}--.drama-voice-card {- background: #fff;- border: 1px solid var(--drama-line);- border-radius: 16px;- display: flex;- flex-direction: column;- overflow: hidden;- transition:- border-color 0.18s ease,- box-shadow 0.18s ease;-}--.drama-voice-card:hover {- border-color: color-mix(in srgb, #6366f1 28%, var(--drama-line));- box-shadow: 0 10px 28px rgba(15, 23, 42, 0.08);-}--.drama-voice-card-head {- display: flex;- align-items: flex-start;- gap: 12px;- padding: 14px 14px 0;-}--.drama-voice-card-badge {- width: 42px;- height: 42px;- border-radius: 12px;- background: linear-gradient(145deg, #eef2ff 0%, #e0e7ff 100%);- color: #4f46e5;- display: grid;- place-items: center;- flex-shrink: 0;-}--.drama-voice-card-title {- flex: 1;- min-width: 0;-}--.drama-voice-card-title h3 {- margin: 0;- font-size: 15px;- font-weight: 700;- line-height: 1.35;- overflow: hidden;- text-overflow: ellipsis;- white-space: nowrap;-}--.drama-voice-card-status {- display: inline-block;- margin-top: 5px;- padding: 2px 8px;- border-radius: 999px;- font-size: 11px;- font-weight: 600;- line-height: 1.4;-}--.drama-voice-card-status.is-ready {- background: #ecfdf5;- color: #047857;-}--.drama-voice-card-status.is-pending {- background: #f1f5f9;- color: #64748b;-}--.drama-voice-card-delete {- display: grid;- place-items: center;- width: 32px;- height: 32px;- padding: 0;- border: none;- border-radius: 10px;- background: transparent;- color: #94a3b8;- cursor: pointer;- opacity: 0;- transition:- opacity 0.15s ease,- background 0.15s ease,- color 0.15s ease;-}--.drama-voice-card:hover .drama-voice-card-delete,-.drama-voice-card-delete:focus-visible {- opacity: 1;-}--.drama-voice-card-delete:hover:not(:disabled) {- background: #fef2f2;- color: #dc2626;-}--.drama-voice-card-delete:disabled {- cursor: not-allowed;- opacity: 0.35;-}--.drama-voice-card-body {- display: flex;- flex-direction: column;- gap: 12px;- padding: 12px 14px;- flex: 1;-}--.drama-voice-card-field {- display: flex;- flex-direction: column;- gap: 6px;-}--.drama-voice-card-field > span {- font-size: 11px;- font-weight: 600;- letter-spacing: 0.04em;- text-transform: uppercase;- color: #94a3b8;-}--.drama-voice-card-field textarea {- width: 100%;- min-height: 76px;- padding: 10px 12px;- border: 1px solid #e2e8f0;- border-radius: 10px;- background: #f8fafc;- font: inherit;- font-size: 13px;- line-height: 1.55;- resize: vertical;- transition:- border-color 0.15s ease,- background 0.15s ease,- box-shadow 0.15s ease;-}--.drama-voice-card-field textarea:focus {- outline: none;- border-color: #a5b4fc;- background: #fff;- box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);-}--.drama-voice-card-field textarea:disabled {- opacity: 0.72;- cursor: not-allowed;-}--.drama-voice-card-player {- display: flex;- align-items: center;- gap: 10px;- padding: 10px 12px;- border: 1px solid #e2e8f0;- border-radius: 12px;- background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);-}--.drama-voice-card-player.is-empty {- color: #94a3b8;- font-size: 13px;-}--.drama-voice-card-audio {- flex: 1;- min-width: 0;- height: 32px;-}--.drama-voice-card-player .drama-voice-preview-btn {- flex-shrink: 0;-}--.drama-voice-card-foot {- padding: 0 14px 14px;- margin-top: auto;-}--.drama-voice-card-synth {- width: 100%;- justify-content: center;-}--.drama-voice-card-icon {- width: 48px;- height: 48px;- border-radius: 10px;- background: #eef2ff;- color: #4338ca;- display: grid;- place-items: center;- font-size: 12px;- font-weight: 700;- margin-bottom: 8px;-}-.drama-modal-actions {display: flex;flex-wrap: wrap;@@ -1921,29 +1584,6 @@gap: 8px;}-.drama-asset-tabs {- display: flex;- flex-wrap: wrap;- gap: 6px;-}--.drama-asset-tabs button {- border: 1px solid var(--drama-line);- background: var(--drama-card);- border-radius: 999px;- padding: 7px 14px;- font: inherit;- cursor: pointer;- color: var(--drama-muted);-}--.drama-asset-tabs button.active {- background: var(--drama-lime);- border-color: var(--drama-lime);- color: var(--drama-ink);- font-weight: 600;-}-.drama-library-toolbar {display: flex;flex-wrap: wrap;@@ -2309,7 +1949,6 @@align-self: flex-start;}-.drama-assets-tips,.drama-episodes-tips {display: flex;align-items: center;@@ -2324,7 +1963,6 @@line-height: 1.45;}-.drama-assets-tips strong,.drama-episodes-tips strong {color: var(--drama-ink);font-weight: 600;@@ -3630,15 +3268,6 @@padding: 28px 20px 72px;}-.drama-assets-toolbar {- display: flex;- flex-wrap: wrap;- align-items: center;- justify-content: space-between;- gap: 12px;- margin-bottom: 12px;-}-.drama-episodes-hero-actions {display: flex;align-items: center;@@ -3712,6 +3341,33 @@}}+/* 分集编辑/画布页首屏骨架:外壳内占位,避免白屏与布局跳动 */+.drama-workspace-skeleton {+ display: grid;+ gap: 14px;+ align-content: start;+ min-height: 40vh;+ padding: 28px 4px;+}+.drama-workspace-skeleton > span {+ display: block;+ height: 16px;+ border-radius: 8px;+ background: linear-gradient(90deg, #f3f4f6 0%, #eceff3 50%, #f3f4f6 100%);+ background-size: 200% 100%;+ animation: drama-ep-skeleton 1.2s ease-in-out infinite;+}+.drama-workspace-skeleton > span:nth-child(1) {+ width: 42%;+ height: 26px;+}+.drama-workspace-skeleton > span:nth-child(2) {+ width: 78%;+}+.drama-workspace-skeleton > span:nth-child(3) {+ width: 64%;+}+.drama-ep-card-poster {position: relative;width: 88px;@@ -4321,28 +3977,6 @@color: #fff;}-.drama-ep-asset-tabs {- display: flex;- flex-wrap: wrap;- gap: 6px;- padding: 8px 12px;-}--.drama-ep-asset-tabs button {- border: none;- border-radius: 999px;- padding: 4px 10px;- font-size: 12px;- background: #fff;- color: #475569;- cursor: pointer;-}--.drama-ep-asset-tabs button.active {- background: #0f172a;- color: #fff;-}-.drama-ep-asset-actions {display: flex;gap: 6px;@@ -4375,102 +4009,7 @@background: #f8fafc;}-.drama-ep-asset-grid {- flex: 1;- min-height: 0;- overflow: auto;- padding: 0 12px 16px;- display: grid;- grid-template-columns: 1fr 1fr;- gap: 8px;- align-content: start;- grid-auto-rows: max-content;-}--.drama-ep-asset-card {- position: relative;- display: flex;- flex-direction: column;- align-items: stretch;- width: 100%;- min-width: 0;- border: none;- border-radius: 12px;- background: #fff;- padding: 0;- overflow: hidden;- cursor: pointer;- text-align: left;- transition: box-shadow 0.15s ease, outline-color 0.15s ease;-}--.drama-ep-asset-card:hover {- box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);-}--.drama-ep-asset-card.is-linked {- outline: 2px solid var(--drama-lime, #b7f34a);- outline-offset: -2px;-}--.drama-ep-asset-linked {- position: absolute;- top: 6px;- right: 6px;- z-index: 1;- font-size: 10px;- line-height: 1;- padding: 3px 5px;- border-radius: 999px;- background: rgba(17, 17, 17, 0.78);- color: #fff;-}--.drama-ep-asset-card.scene {- grid-column: 1 / -1;-}-/* 用 padding 占位保证缩略图高度:button + overflow 下 aspect-ratio 易塌成细条 */-.drama-ep-asset-thumb {- position: relative;- width: 100%;- height: 0;- padding-bottom: 133.333%; /* 3:4 */- background: var(--ep-soft);- overflow: hidden;- color: #cbd5e1;- font-weight: 700;- flex: none;-}--.drama-ep-asset-card.scene .drama-ep-asset-thumb {- padding-bottom: 75%; /* 4:3 */-}--.drama-ep-asset-thumb img,-.drama-ep-asset-thumb > span {- position: absolute;- inset: 0;- width: 100%;- height: 100%;- display: grid;- place-items: center;-}--.drama-ep-asset-thumb img {- object-fit: cover;-}--.drama-ep-asset-name {- display: block;- flex: none;- padding: 8px 52px 8px 6px;- font-size: 12px;- color: #475569;- white-space: nowrap;- overflow: hidden;- text-overflow: ellipsis;-}.drama-ep-empty {grid-column: 1 / -1;@@ -4857,44 +4396,6 @@min-width: 0;}-.drama-ep-asset-settings {- position: absolute;- bottom: 8px;- right: 6px;- z-index: 1;- font-size: 10px;- line-height: 1;- padding: 3px 7px;- border-radius: 999px;- background: rgba(17, 17, 17, 0.72);- color: #fff;-}--.drama-ep-asset-gen-badge {- position: absolute;- inset: 0;- display: flex;- align-items: center;- justify-content: center;- margin: 0;- font-style: normal;- font-size: 11px;- font-weight: 600;- color: #fff;- background: rgba(17, 17, 17, 0.55);-}--.drama-ep-asset-card.is-gen {- outline: 2px solid #94a3b8;- outline-offset: -2px;-}--.drama-ep-asset-ops {- display: flex;- flex-wrap: wrap;- gap: 4px;-}-.drama-ep-asset-op-btn {flex: 1;min-width: 0;@@ -4912,19 +4413,6 @@border-color: #d1d5db;}-.drama-ep-asset-voice {- position: absolute;- bottom: 28px;- left: 6px;- z-index: 1;- font-size: 9px;- line-height: 1;- padding: 2px 5px;- border-radius: 999px;- background: rgba(17, 17, 17, 0.78);- color: #b7f34a;-}-.drama-ep-asset-voice-btn {flex: 1;min-width: 0;@@ -6366,7 +5854,6 @@}}-/* Global image generation queue ? bottom-right FAB + half-height panel */.drama-gen-fab-root {position: fixed;@@ -6855,87 +6342,6 @@min-height: 280px;}-.drama-global-picker-lead {- margin: 0;-}--.drama-global-picker-tabs {- margin: 0;-}--.drama-global-picker-search {- margin: 0;- width: 100%;- box-sizing: border-box;-}--.drama-global-picker-grid {- display: grid;- grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));- gap: 10px;- overflow: auto;- max-height: min(42vh, 360px);- padding: 4px 2px 8px;-}--.drama-global-picker-card {- position: relative;- border: 1px solid var(--drama-line, #e5e7eb);- border-radius: 12px;- overflow: hidden;- background: #fafafa;- padding: 0;- cursor: pointer;- text-align: left;-}--.drama-global-picker-card.is-selected {- border-color: #111;- box-shadow: 0 0 0 2px rgba(182, 255, 0, 0.45);-}--.drama-global-picker-card img {- width: 100%;- aspect-ratio: 3 / 4;- object-fit: cover;- display: block;-}--.drama-global-picker-card-meta {- padding: 8px;- display: flex;- flex-direction: column;- gap: 2px;-}--.drama-global-picker-card-meta strong {- font-size: 12px;- font-weight: 600;- overflow: hidden;- text-overflow: ellipsis;- white-space: nowrap;-}--.drama-global-picker-card-meta span {- font-size: 11px;- color: var(--drama-muted, #6b7280);-}--.drama-global-picker-check {- position: absolute;- top: 8px;- right: 8px;- width: 22px;- height: 22px;- border-radius: 999px;- background: #111;- color: #b6ff00;- display: grid;- place-items: center;- font-size: 12px;- font-weight: 700;-}-.drama-btn-danger-text {color: #b91c1c;}