Formerly KrillinAI, VideoTranslation and Dubbing Tool for 120+ Languages. Open-source AI workspace for creators, powered by Codex. Video downloader, video translation, create videos, images, audios, and edits with Agents in one place. For your Social Media like YouTube, TikTok, Instagram, etc.
TypeScript agent-skillscodex-clideskop-appdubbingimage-generationlocalizationskillsttsvideo-editingvideo-generationvideo-transcriptionvideo-translation
feat(web): refine account navigation and video translation workflow
Joshua Yin Junxi876e960c6381
diff --git a/apps/web/e2e/gateway-account.spec.ts b/apps/web/e2e/gateway-account.spec.tsindex 6a3c45fe..d2c7c680 100644--- a/apps/web/e2e/gateway-account.spec.ts+++ b/apps/web/e2e/gateway-account.spec.ts@@ -1,7 +1,7 @@import { test, expect } from './fixtures/runtime.js';import type { GatewayAccountState } from '@opencreator/protocol';-test('独立订阅页面支持游客选套餐、登录后继续购买并返回个人中心', async ({ page, runtime }, testInfo) => {+test('独立订阅页面支持游客选套餐、登录后继续购买并返回账户页面', async ({ page, runtime }, testInfo) => {const guest: GatewayAccountState = { source: 'manual', authState: 'signed_out', activationState: 'inactive', account: null, bindingVersion: null, models: [], activationError: null };let state = guest;let paid = false;@@ -36,9 +36,9 @@ test('独立订阅页面支持游客选套餐、登录后继续购买并返回const navigation = page.getByRole('navigation', { name: 'OpenCreator', exact: true });const openNavigation = page.getByRole('button', { name: '打开导航', exact: true });if (await openNavigation.isVisible()) await openNavigation.click();- await navigation.getByRole('button', { name: '个人中心', exact: true }).click();+ await navigation.getByRole('button', { name: '账户', exact: true }).click();if (await openNavigation.isVisible()) await expect(page.getByLabel('OpenCreator 导航', { exact: true })).toHaveCSS('visibility', 'hidden');- const center = page.getByRole('main', { name: '个人中心', exact: true });+ const center = page.getByRole('main', { name: '账户', exact: true });await expect(center.getByRole('button', { name: '登录 / 注册' })).toBeVisible();await expect(center.getByRole('heading', { name: '订阅套餐', exact: true })).toHaveCount(0);await page.screenshot({ path: testInfo.outputPath('personal-center.png'), fullPage: true });@@ -139,12 +139,12 @@ test('浏览器完成真实网关设备授权,缺少模型配置时保留登const navigation = page.getByRole('navigation', { name: 'OpenCreator', exact: true });const openNavigation = page.getByRole('button', { name: '打开导航', exact: true });if (await openNavigation.isVisible()) await openNavigation.click();- await navigation.getByRole('button', { name: '个人中心', exact: true }).click();+ await navigation.getByRole('button', { name: '账户', exact: true }).click();if (await openNavigation.isVisible()) await expect(page.getByLabel('OpenCreator 导航', { exact: true })).toHaveCSS('visibility', 'hidden');await expect(page).toHaveURL(/#\/account$/);- await expect(navigation.getByRole('button', { name: '个人中心', exact: true })).toHaveAttribute('aria-current', 'page');- await expect(navigation.getByRole('button', { name: '首页', exact: true })).not.toHaveAttribute('aria-current', 'page');- const center = page.getByRole('main', { name: '个人中心', exact: true });+ await expect(navigation.getByRole('button', { name: '账户', exact: true })).toHaveAttribute('aria-current', 'page');+ await expect(navigation.getByRole('button', { name: '模版', exact: true })).not.toHaveAttribute('aria-current', 'page');+ const center = page.getByRole('main', { name: '账户', exact: true });await expect(center.getByRole('heading', { name: '[email protected]', exact: true })).toBeVisible({ timeout: 20_000 });await expect(account.getByText('已登录', { exact: true })).toBeVisible();await expect(account.getByRole('group', { name: '使用模式' })).toHaveCount(0);diff --git a/apps/web/e2e/gateway-web-desktop-parity.spec.ts b/apps/web/e2e/gateway-web-desktop-parity.spec.tsindex c3d4d968..51aeb4c5 100644--- a/apps/web/e2e/gateway-web-desktop-parity.spec.ts+++ b/apps/web/e2e/gateway-web-desktop-parity.spec.ts@@ -15,7 +15,7 @@ test('账户入口在同尺寸 Browser/Desktop Bridge 下读取同一个 Daemon} });});try {- await runtime.openApp(page); await page.getByRole('button', { name: '个人中心', exact: true }).click();+ await runtime.openApp(page); await page.getByRole('button', { name: '账户', exact: true }).click();const account = page.getByRole('region', { name:'OpenCreator 账户' });await expect(account.getByRole('button', { name:'登录 / 注册' })).toBeVisible();await expect(account.getByRole('button', { name:'本地模式' })).toHaveCount(0);diff --git a/apps/web/e2e/video-translation-style-preview.spec.ts b/apps/web/e2e/video-translation-style-preview.spec.tsindex a00b2c1b..b9d93e9d 100644--- a/apps/web/e2e/video-translation-style-preview.spec.ts+++ b/apps/web/e2e/video-translation-style-preview.spec.ts@@ -31,6 +31,7 @@ test('字幕样式预览显示视频封面并按源比例或竖屏输出比例targetLanguage: 'zh_cn',currentStep: 2,furthestStep: 2,+ composeVideo: true,workspacePhase: 'configure'},creationKey: 'style-preview-ratio'@@ -59,6 +60,7 @@ test('字幕样式预览显示视频封面并按源比例或竖屏输出比例const sourceBox = await frame.boundingBox();expect(sourceBox).not.toBeNull();expect(sourceBox!.width / sourceBox!.height).toBeCloseTo(4 / 3, 1);+ await page.screenshot({ path: test.info().outputPath('video-subtitle-settings-wide.png'), fullPage: true });await page.setViewportSize({ width: 1100, height: 800 });expect(await settings.evaluate(element => {@@ -66,13 +68,11 @@ test('字幕样式预览显示视频封面并按源比例或竖屏输出比例return container !== null && element.getBoundingClientRect().width <= container.getBoundingClientRect().width;})).toBe(true);- await page.getByRole('button', { name: '继续' }).click();- await page.getByRole('switch', { name: '合成字幕视频' }).click();- await page.getByRole('radio', { name: /9:16/ }).click();- await page.getByRole('navigation', { name: '翻译流程' }).getByRole('button', { name: /字幕样式$/ }).click();+ await page.getByRole('combobox', { name: '输出画幅' }).selectOption('vertical');await expect(preview).toHaveAttribute('data-ratio', '9:16');await expect(preview).toHaveAttribute('data-converted', 'true');const verticalBox = await frame.boundingBox();expect(verticalBox).not.toBeNull();expect(verticalBox!.width / verticalBox!.height).toBeCloseTo(9 / 16, 1);+ await page.screenshot({ path: test.info().outputPath('video-subtitle-settings-narrow.png'), fullPage: true });});diff --git a/apps/web/e2e/web-desktop-parity.spec.ts b/apps/web/e2e/web-desktop-parity.spec.tsindex d378c97a..a4be1318 100644--- a/apps/web/e2e/web-desktop-parity.spec.ts+++ b/apps/web/e2e/web-desktop-parity.spec.ts@@ -29,7 +29,7 @@ test('项目管理资源不随通用项目页面提前加载且 Browser/DesktopheadingBox: await heading.boundingBox(),styles});- await page.getByRole('button', { name: '首页', exact: true }).click();+ await page.getByRole('button', { name: '模版', exact: true }).click();await expect(page.getByRole('tab', { name: '推荐', exact: true })).toBeVisible();expect(resources).toHaveLength(0);} finally { await context.close(); }diff --git a/apps/web/package.json b/apps/web/package.jsonindex 806d1efb..6525f320 100644--- a/apps/web/package.json+++ b/apps/web/package.json@@ -32,6 +32,7 @@"fuse.js": "^7.1.0","lucide-react": "^0.468.0","react": "^18.3.1",+ "react-colorful": "^5.6.1","react-dom": "^18.3.1","react-router-dom": "^6.30.1","react-virtuoso": "4.18.10",diff --git a/apps/web/src/app/App.test.tsx b/apps/web/src/app/App.test.tsxindex 17fb378b..87f2d7df 100644--- a/apps/web/src/app/App.test.tsx+++ b/apps/web/src/app/App.test.tsx@@ -222,7 +222,7 @@ describe('App', () => {}if (activationState === 'blocked') {expect(screen.getByText('已登录,模型服务暂不可用。')).toBeInTheDocument();- await user.click(within(screen.getByText('已登录,模型服务暂不可用。').parentElement!).getByRole('button', { name: '个人中心' }));+ await user.click(within(screen.getByText('已登录,模型服务暂不可用。').parentElement!).getByRole('button', { name: '账户' }));await waitFor(() => expect(window.location.hash).toBe('#/account'));}});@@ -927,7 +927,7 @@ describe('App', () => {.toHaveAttribute('aria-selected', 'true');expect(screen.getByRole('tab', { name: '视频创作' })).toBeInTheDocument();expect(screen.getByRole('tab', { name: '图像设计' })).toBeInTheDocument();- expect(screen.getByRole('button', { name: '首页' })).toHaveAttribute('aria-current', 'page');+ expect(screen.getByRole('button', { name: '模版' })).toHaveAttribute('aria-current', 'page');expect(screen.getByRole('button', { name: '工作台' })).not.toHaveAttribute('aria-current');expect(screen.queryByRole('button', { name: '空白视频翻译' })).not.toBeInTheDocument();});@@ -1455,7 +1455,6 @@ describe('App', () => {);await user.click(screen.getByRole('button', { name: '继续' }));await user.click(screen.getByRole('button', { name: '继续' }));- await user.click(screen.getByRole('button', { name: '继续' }));await user.click(within(screen.getByRole('region', { name: '视频翻译操作区' })).getByRole('button', { name: '开始翻译' }));@@ -1511,7 +1510,6 @@ describe('App', () => {await user.upload(screen.getByLabelText('Upload a local video'), file);await user.click(screen.getByRole('button', { name: 'Continue' }));await user.click(screen.getByRole('button', { name: 'Continue' }));- await user.click(screen.getByRole('button', { name: 'Continue' }));await user.click(within(screen.getByRole('region', { name: 'Video translation workspace' })).getByRole('button', { name: 'Start translation' }));diff --git a/apps/web/src/app/AppController.tsx b/apps/web/src/app/AppController.tsxindex 2c2a0dd2..4b7aaf73 100644--- a/apps/web/src/app/AppController.tsx+++ b/apps/web/src/app/AppController.tsx@@ -4218,7 +4218,7 @@ export function AppController(props: AppControllerProps) {const composerDisabledReason = connectionState.status !== 'connected'? t('conversation.connectingRuntime'): agentSetup === 'skipped'- ? gatewayAccountState?.source === 'gateway' ? l('请在个人中心连接模型服务', 'Connect model services from your personal center') : l('请先配置 Agent 模型服务', 'Configure the Agent model service first')+ ? gatewayAccountState?.source === 'gateway' ? l('请在账户页面连接模型服务', 'Connect model services from your account') : l('请先配置 Agent 模型服务', 'Configure the Agent model service first'): projectLoadError !== undefined? t('conversation.checkingTask'): conversationNeedsProject && currentProject === undefined@@ -4527,7 +4527,7 @@ export function AppController(props: AppControllerProps) {: l('请登录 OpenCreator 后继续创作。', 'Sign in to OpenCreator to continue creating.'): l('Agent 尚未配置,暂时无法发送任务。', 'Agent is not configured; you cannot send tasks yet.')}<button type="button" onClick={() => gatewayAccountState?.source === 'gateway' ? openPrimaryView('account') : setAgentSetup('needed')}>- {gatewayAccountState?.source === 'gateway' ? l('个人中心', 'Personal center') : l('配置 Agent', 'Set up Agent')}+ {gatewayAccountState?.source === 'gateway' ? l('账户', 'Account') : l('配置 Agent', 'Set up Agent')}</button></div>) : null}diff --git a/apps/web/src/features/account/PersonalCenterPage.tsx b/apps/web/src/features/account/PersonalCenterPage.tsxindex 40b11aba..6cf7e8d2 100644--- a/apps/web/src/features/account/PersonalCenterPage.tsx+++ b/apps/web/src/features/account/PersonalCenterPage.tsx@@ -22,7 +22,7 @@ export default function PersonalCenterPage(props: {useEffect(() => { setState(props.accountState); }, [props.accountState]);const email = state?.authState === 'signed_in' ? state.account?.email : undefined;const subscriptionPage = props.view === 'subscription';- const title = subscriptionPage ? l('积分与充值', 'Credits & Recharge') : l('个人中心', 'Personal center');+ const title = subscriptionPage ? l('积分与充值', 'Credits') : l('账户', 'Account');return <main className="opencreator-scroll-page personal-center" aria-label={title}><div className="personal-center__content">diff --git a/apps/web/src/features/dashboard/CreatorCollaborationPanel.test.tsx b/apps/web/src/features/dashboard/CreatorCollaborationPanel.test.tsxindex ac2a565b..873ab28d 100644--- a/apps/web/src/features/dashboard/CreatorCollaborationPanel.test.tsx+++ b/apps/web/src/features/dashboard/CreatorCollaborationPanel.test.tsx@@ -169,6 +169,23 @@ describe('Short video script panel', () => {});describe('CreatorCollaborationPanel', () => {+ it('places a supplied summary above the timeline and preserves current issues', () => {+ const panel = (currentIssue?: string) => <LanguageProvider initialPreference="zh-CN">+ <CreatorSessionProvider initialJob={videoGenerationJob()} service={{ applyAction: vi.fn(), runAgentTurn: vi.fn() } as never}>+ <CreatorCollaborationPanel adapter={videoGenerationPanelAdapter} stepLabel="生成视频"+ contextSummary="Veo" taskSummary={<aside aria-label="任务摘要">任务参数</aside>} currentIssue={currentIssue} />+ </CreatorSessionProvider>+ </LanguageProvider>;+ const view = render(panel());+ const summary = screen.getByLabelText('任务摘要');+ const timeline = screen.getByRole('log', { name: '协作时间线' });+ expect(summary.compareDocumentPosition(timeline) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();+ expect(screen.queryByText('当前任务')).not.toBeInTheDocument();+ view.rerender(panel('请检查服务设置'));+ expect(screen.getByText('请检查服务设置')).toBeVisible();+ expect(screen.getByLabelText('任务摘要')).toBeVisible();+ });+it('shows a pre-job failure once and forwards questions to the real Agent without creating a job', () => {const issue = normalizePageIssue('creator-launch',diff --git a/apps/web/src/features/dashboard/CreatorCollaborationPanel.tsx b/apps/web/src/features/dashboard/CreatorCollaborationPanel.tsxindex 6384f90a..c080b93f 100644--- a/apps/web/src/features/dashboard/CreatorCollaborationPanel.tsx+++ b/apps/web/src/features/dashboard/CreatorCollaborationPanel.tsx@@ -19,7 +19,7 @@ import {Square,XCircle} from 'lucide-react';-import { useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';+import { useEffect, useLayoutEffect, useMemo, useRef, useState, type ReactNode } from 'react';import OpenCreatorMark from '../../components/brand/OpenCreatorMark.js';import { MarkdownRenderer } from '../../components/markdown/MarkdownRenderer.js';import { useLocalizedCopy } from '../../i18n/useLocalizedCopy.js';@@ -98,6 +98,7 @@ export default function CreatorCollaborationPanel(props: {adapter: CreatorPanelAdapter;stepLabel: string;contextSummary: string;+ taskSummary?: ReactNode;promptHint?: string;currentIssue?: string;quickActions?: CreatorPanelQuickAction[];@@ -237,13 +238,15 @@ export default function CreatorCollaborationPanel(props: {) : null}</header>- <div className="creator-collaboration-context">+ {props.taskSummary ? <div className="creator-collaboration-task-summary">{props.taskSummary}</div> : null}++ {!props.taskSummary || props.currentIssue ? <div className="creator-collaboration-context"><Sparkles size={14} strokeWidth={1.8} aria-hidden="true" /><span><small>{l('当前任务', 'Current task')}</small><strong>{props.currentIssue ?? props.contextSummary}</strong></span>- </div>+ </div> : null}{session?.preflight !== null && session?.preflight !== undefined ? (<section className="creator-collaboration-preflight" aria-label={l('启动前体检', 'Preflight check')}>diff --git a/apps/web/src/features/dashboard/CreatorResultVersionMenu.tsx b/apps/web/src/features/dashboard/CreatorResultVersionMenu.tsxindex ac9d2760..e2055cff 100644--- a/apps/web/src/features/dashboard/CreatorResultVersionMenu.tsx+++ b/apps/web/src/features/dashboard/CreatorResultVersionMenu.tsx@@ -10,6 +10,7 @@ export type CreatorResultVersionItem = {};export default function CreatorResultVersionMenu(props: {+ showCompletion?: boolean;version: number;versions: CreatorResultVersionItem[];onVersionChange(version: number): void;@@ -66,7 +67,7 @@ export default function CreatorResultVersionMenu(props: {aria-controls={menuId}onClick={() => setHistoryOpen(open => !open)}>- {!stale ? <CircleCheck size={15} strokeWidth={2} aria-hidden="true" /> : null}+ {!stale && props.showCompletion !== false ? <CircleCheck size={15} strokeWidth={2} aria-hidden="true" /> : null}<span>{l(`项目 V${props.version}`, `Project V${props.version}`)}</span><ChevronDown className="video-result-version-chevron" size={15} strokeWidth={1.8} aria-hidden="true" /></button>diff --git a/apps/web/src/features/dashboard/CreatorTaskSummary.test.tsx b/apps/web/src/features/dashboard/CreatorTaskSummary.test.tsxindex d6c04d0c..6ac46f42 100644--- a/apps/web/src/features/dashboard/CreatorTaskSummary.test.tsx+++ b/apps/web/src/features/dashboard/CreatorTaskSummary.test.tsx@@ -1,4 +1,4 @@-import { render, screen } from '@testing-library/react';+import { fireEvent, render, screen } from '@testing-library/react';import type { CreatorJob } from '@opencreator/protocol';import { FileVideo } from 'lucide-react';import { describe, expect, it, vi } from 'vitest';@@ -7,6 +7,24 @@ import CreatorTaskSummary from './CreatorTaskSummary.js';import { CreatorSessionProvider } from './creator-session-store.js';describe('CreatorTaskSummary', () => {+ it('starts compact, expands the details, and preserves expansion when settings change', () => {+ const summary = (value: string) => <LanguageProvider initialPreference="zh-CN">+ <CreatorTaskSummary sourceIcon={FileVideo} sourceLabel="源视频" sourceValue="demo.mp4"+ compactSummary={`English → 简体中文 · ${value}`} items={[{ label: '输出', value }]} />+ </LanguageProvider>;+ const view = render(summary('16:9 横屏'));+ const details = screen.getByLabelText('任务摘要').querySelector('details');+ expect(details).not.toHaveAttribute('open');+ expect(screen.getByText('demo.mp4')).not.toBeVisible();+ fireEvent.click(screen.getByText('任务摘要'));+ expect(details).toHaveAttribute('open');+ expect(screen.getByText('demo.mp4')).toBeVisible();+ view.rerender(summary('9:16 竖屏'));+ expect(details).toHaveAttribute('open');+ expect(screen.getByText('English → 简体中文 · 9:16 竖屏')).toBeVisible();+ expect(screen.getByText('9:16 竖屏')).toBeVisible();+ });+it('shows the preset origin shared by every Creator workspace', () => {const createdAt = '2026-09-08T00:00:00.000Z';const job: CreatorJob = {diff --git a/apps/web/src/features/dashboard/CreatorTaskSummary.tsx b/apps/web/src/features/dashboard/CreatorTaskSummary.tsxindex 1fdebc31..9a52dbea 100644--- a/apps/web/src/features/dashboard/CreatorTaskSummary.tsx+++ b/apps/web/src/features/dashboard/CreatorTaskSummary.tsx@@ -1,4 +1,4 @@-import { Sparkles, type LucideIcon } from 'lucide-react';+import { ChevronDown, Sparkles, type LucideIcon } from 'lucide-react';import { useLocalizedCopy } from '../../i18n/useLocalizedCopy.js';import { useOptionalCreatorSession } from './creator-session-store.js';@@ -14,22 +14,22 @@ export default function CreatorTaskSummary(props: {items: SummaryItem[];note?: string;noteIcon?: LucideIcon;+ compactSummary?: string;}) {const l = useLocalizedCopy();const session = useOptionalCreatorSession();const SourceIcon = props.sourceIcon;const NoteIcon = props.noteIcon;const presetTitle = session?.job.presetOrigin?.title.trim();-- return (- <aside- className="video-translation-summary creator-task-summary"- aria-label={l('任务摘要', 'Task summary')}- >- <div className="video-translation-summary-heading">- <span><Sparkles size={16} strokeWidth={1.8} aria-hidden="true" /></span>- <h2>{l('任务摘要', 'Task summary')}</h2>- </div>+ const heading = (+ <div className="video-translation-summary-heading">+ <span><Sparkles size={16} strokeWidth={1.8} aria-hidden="true" /></span>+ <h2>{l('任务摘要', 'Task summary')}</h2>+ {props.compactSummary !== undefined ? <ChevronDown size={15} strokeWidth={1.8} aria-hidden="true" /> : null}+ </div>+ );+ const content = (+ <><div className="video-translation-source-summary"><SourceIcon size={16} strokeWidth={1.7} aria-hidden="true" /><span>@@ -52,6 +52,23 @@ export default function CreatorTaskSummary(props: {))}</dl>{props.note ? <p>{NoteIcon ? <NoteIcon size={14} strokeWidth={1.8} aria-hidden="true" /> : null}{props.note}</p> : null}+ </>+ );++ return (+ <aside+ className={`video-translation-summary creator-task-summary${props.compactSummary !== undefined ? ' creator-task-summary-compact' : ''}`}+ aria-label={l('任务摘要', 'Task summary')}+ >+ {props.compactSummary !== undefined ? (+ <details>+ <summary>+ {heading}+ <p className="creator-task-summary-overview">{props.compactSummary}</p>+ </summary>+ <div className="creator-task-summary-details">{content}</div>+ </details>+ ) : <>{heading}{content}</>}</aside>);}diff --git a/apps/web/src/features/dashboard/DashboardPage.test.tsx b/apps/web/src/features/dashboard/DashboardPage.test.tsxindex b24f1006..fbd8b1d4 100644--- a/apps/web/src/features/dashboard/DashboardPage.test.tsx+++ b/apps/web/src/features/dashboard/DashboardPage.test.tsx@@ -772,7 +772,7 @@ describe('DashboardPage', () => {expect(screen.getByRole('tab', { name: 'Video Editing' })).toBeInTheDocument();expect(screen.getByRole('searchbox', { name: 'Search apps' })).toBeInTheDocument();expect(screen.getByText('Translate & Dub Video')).toBeInTheDocument();- expect(screen.getAllByText('Thumbnail Generator')).toHaveLength(2);+ expect(screen.getAllByText('Thumbnail Generator')).toHaveLength(1);expect(screen.getAllByText('Image Generation')).toHaveLength(2);expect(screen.queryByText('Digital Avatar')).not.toBeInTheDocument();});@@ -855,33 +855,25 @@ describe('DashboardPage', () => {const videoTranslationCard = screen.getByRole('button', { name: /^视频翻译/ });expect(within(videoTranslationCard).getByText('HOT')).toBeInTheDocument();const appCards = Array.from(container.querySelectorAll('.dashboard-app-card'));- expect(appCards).toHaveLength(11);+ expect(appCards).toHaveLength(4);expect(appCards.map(card => card.querySelector('strong')?.textContent)).toEqual(['视频下载','视频翻译','视频生成',- '图像生成',- '文章写作',- '火柴人动画',- '视频切片',- '封面生成',- '小红书帖子',- '短视频脚本',- '智能配音'+ '图像生成']);- expect(screen.getByRole('button', { name: /^火柴人动画 角色、分镜与完整动画/ }))- .toBeInTheDocument();+ expect(screen.queryByRole('button', { name: /^火柴人动画 角色、分镜与完整动画/ }))+ .not.toBeInTheDocument();expect(screen.queryByRole('button', { name: /^自动剪辑/ })).not.toBeInTheDocument();- expect(screen.getByRole('button', { name: /^智能配音/ })).toBeInTheDocument();+ expect(screen.queryByRole('button', { name: /^智能配音/ })).not.toBeInTheDocument();expect(screen.getByRole('button', { name: /^视频生成/ })).toBeInTheDocument();- const articleCard = screen.getByRole('button', { name: /^文章写作/ });- expect(within(articleCard).getByText('公众号、X 等平台文章')).toBeInTheDocument();- expect(within(articleCard).getByText('NEW')).toBeInTheDocument();+ expect(screen.queryByRole('button', { name: /^文章写作/ })).not.toBeInTheDocument();expect(screen.queryByRole('button', { name: /^数字人口播/ })).not.toBeInTheDocument();});it('opens the WeChat article writer from the app directory', () => {const { container } = render(<DashboardPage onSelectPrompt={vi.fn()} />);+ fireEvent.click(screen.getByRole('tab', { name: '文案创作' }));fireEvent.click(screen.getByRole('button', { name: /^文章写作/ }));expect(screen.getByRole('heading', { name: '文章写作' })).toBeInTheDocument();expect(screen.getByText('公众号、X 等平台文章')).toBeInTheDocument();@@ -989,20 +981,25 @@ describe('DashboardPage', () => {expect(screen.getByRole('combobox', { name: '源语言' })).toHaveValue('en');expect(screen.getByRole('combobox', { name: '翻译为' })).toHaveValue('zh_cn');fireEvent.click(screen.getByRole('button', { name: '继续' }));- expect(screen.getByRole('heading', { name: '设置字幕样式' })).toBeInTheDocument();+ expect(screen.getByRole('heading', { name: '视频与字幕' })).toBeInTheDocument();+ expect(screen.queryByRole('combobox', { name: '字幕字体' })).not.toBeInTheDocument();+ fireEvent.click(screen.getByRole('switch', { name: '合成字幕视频' }));fireEvent.change(screen.getByRole('combobox', { name: '字幕字体' }), { target: { value: 'rounded' } });- fireEvent.click(screen.getByRole('radio', { name: '大' }));+ fireEvent.change(screen.getByRole('combobox', { name: '字幕大小' }), { target: { value: 'large' } });+ fireEvent.click(screen.getByRole('button', { name: '选择译文颜色' }));fireEvent.click(screen.getByRole('button', { name: '#FFE45C' }));+ fireEvent.keyDown(screen.getByRole('button', { name: '#FFE45C' }), { key: 'Escape' });const subtitlePreview = screen.getByRole('region', { name: '字幕样式预览' });expect(subtitlePreview).toHaveTextContent('这是一段译文字幕');expect(subtitlePreview).toHaveTextContent('这是一段原文字幕');expect(subtitlePreview.querySelectorAll('[data-subtitle-kind]')[0]).toHaveAttribute('data-subtitle-kind', 'translation');expect(subtitlePreview.querySelector(':scope > div')).toHaveStyle({ '--subtitle-preview-font-size': '18px' });- fireEvent.click(screen.getByRole('button', { name: '继续' }));expect(screen.getByLabelText('任务摘要')).toHaveTextContent('English → 简体中文');expect(screen.getByLabelText('任务摘要')).toHaveTextContent('圆体 · 粗体 · 大 · #FFE45C');expect(screen.getByLabelText('任务摘要')).toHaveClass('video-translation-summary', 'creator-task-summary');- expect(screen.getByLabelText('任务摘要').parentElement).toHaveClass('video-translation-final-grid');+ expect(screen.getByLabelText('任务摘要').parentElement).toHaveClass('creator-collaboration-task-summary');+ expect(screen.getByRole('region', { name: '视频翻译操作区' })).not.toContainElement(screen.getByLabelText('任务摘要'));+ expect(screen.getByRole('complementary', { name: 'OpenCreator' })).toContainElement(screen.getByLabelText('任务摘要'));await startVideoTranslation();expect(onSelectPrompt).not.toHaveBeenCalled();@@ -1012,7 +1009,7 @@ describe('DashboardPage', () => {fireEvent.click(screen.getByRole('tab', { name: '字幕' }));expect(screen.getByRole('button', { name: '保存横屏字幕' })).toBeDisabled();fireEvent.click(screen.getByRole('tab', { name: '任务设置' }));- expect(screen.getByText('圆体 · 粗体 · 大 · #FFE45C')).toBeInTheDocument();+ expect(within(screen.getByRole('region', { name: '视频翻译操作区' })).getByText('圆体 · 粗体 · 大 · #FFE45C')).toBeInTheDocument();expect(screen.queryByText(/之前的版本仍可查看/)).not.toBeInTheDocument();expect(screen.queryByRole('region', { name: '生成新版本' })).not.toBeInTheDocument();expect(screen.queryByRole('button', { name: '生成新版本' })).not.toBeInTheDocument();@@ -1025,8 +1022,8 @@ describe('DashboardPage', () => {const steps = screen.getByRole('navigation', { name: '翻译流程' });expect(within(steps).getByRole('button', { name: '1 添加视频' })).toHaveAttribute('aria-current', 'step');expect(within(steps).getByRole('button', { name: '2 翻译设置' })).toBeDisabled();- expect(within(steps).getByRole('button', { name: '3 字幕样式' })).toBeDisabled();- expect(within(steps).getByRole('button', { name: '4 配音与输出' })).toBeDisabled();+ expect(within(steps).getByRole('button', { name: '3 视频与字幕' })).toBeDisabled();+ expect(within(steps).getAllByRole('button')).toHaveLength(3);fireEvent.change(screen.getByRole('textbox', { name: '视频链接' }), {target: { value: 'https://www.youtube.com/watch?v=steps-test' }@@ -1035,28 +1032,67 @@ describe('DashboardPage', () => {expect(within(steps).getByRole('button', { name: /翻译设置$/ })).toHaveAttribute('aria-current', 'step');fireEvent.click(screen.getByRole('button', { name: '在下' }));fireEvent.click(screen.getByRole('button', { name: '继续' }));- expect(within(steps).getByRole('button', { name: /字幕样式$/ })).toHaveAttribute('aria-current', 'step');- expect(screen.queryByLabelText('任务摘要')).not.toBeInTheDocument();+ expect(within(steps).getByRole('button', { name: /视频与字幕$/ })).toHaveAttribute('aria-current', 'step');+ expect(screen.getByLabelText('任务摘要')).toBeInTheDocument();+ expect(within(screen.getByRole('region', { name: '视频翻译操作区' })).getByRole('button', { name: '开始翻译' })).toBeInTheDocument();+ fireEvent.click(screen.getByRole('switch', { name: '合成字幕视频' }));const bottomTranslationPreview = screen.getByRole('region', { name: '字幕样式预览' });expect(bottomTranslationPreview.querySelectorAll('[data-subtitle-kind]')[0]).toHaveAttribute('data-subtitle-kind', 'original');expect(bottomTranslationPreview.querySelectorAll('[data-subtitle-kind]')[1]).toHaveAttribute('data-subtitle-kind', 'translation');+ expect(screen.getByRole('button', { name: '选择原文颜色' })).toBeInTheDocument();fireEvent.click(within(steps).getByRole('button', { name: /翻译设置$/ }));fireEvent.click(screen.getByRole('switch', { name: '双语字幕' }));- fireEvent.click(within(steps).getByRole('button', { name: /字幕样式$/ }));+ fireEvent.click(within(steps).getByRole('button', { name: /视频与字幕$/ }));const translationOnlyPreview = screen.getByRole('region', { name: '字幕样式预览' });expect(translationOnlyPreview.querySelector('[data-subtitle-kind="original"]')).not.toBeInTheDocument();expect(translationOnlyPreview.querySelector('[data-subtitle-kind="translation"]')).toBeInTheDocument();- fireEvent.click(screen.getByRole('button', { name: '继续' }));- expect(within(steps).getByRole('button', { name: /配音与输出$/ })).toHaveAttribute('aria-current', 'step');+ expect(screen.queryByRole('button', { name: '选择原文颜色' })).not.toBeInTheDocument();+ expect(screen.getByRole('button', { name: '选择译文颜色' })).toBeInTheDocument();expect(screen.getByLabelText('任务摘要')).toBeInTheDocument();fireEvent.click(within(steps).getByRole('button', { name: /翻译设置$/ }));expect(screen.getByRole('heading', { name: '设置翻译语言' })).toBeInTheDocument();- fireEvent.click(within(steps).getByRole('button', { name: /字幕样式$/ }));- expect(screen.getByRole('heading', { name: '设置字幕样式' })).toBeInTheDocument();- fireEvent.click(within(steps).getByRole('button', { name: /配音与输出$/ }));- expect(screen.getByRole('heading', { name: '选择输出内容' })).toBeInTheDocument();+ fireEvent.click(screen.getByRole('switch', { name: '双语字幕' }));+ fireEvent.click(within(steps).getByRole('button', { name: /视频与字幕$/ }));+ expect(screen.getByRole('heading', { name: '视频与字幕' })).toBeInTheDocument();+ expect(screen.getByRole('button', { name: '选择原文颜色' })).toBeInTheDocument();+ });++ it('reveals video settings together and preserves them when rendering is toggled off', () => {+ render(<DashboardPage onSelectPrompt={vi.fn()} />);+ openBlankWorkspace('视频翻译', '空白视频翻译');+ fireEvent.change(screen.getByRole('textbox', { name: '视频链接' }), {+ target: { value: 'https://www.youtube.com/watch?v=conditional-video-settings' }+ });+ fireEvent.click(screen.getByRole('button', { name: '继续' }));+ fireEvent.click(screen.getByRole('button', { name: '继续' }));++ const rendering = screen.getByRole('switch', { name: '合成字幕视频' });+ expect(rendering).toHaveAttribute('aria-checked', 'false');+ expect(screen.queryByRole('combobox', { name: '输出画幅' })).not.toBeInTheDocument();+ expect(screen.queryByRole('combobox', { name: '字幕字体' })).not.toBeInTheDocument();+ expect(screen.queryByRole('region', { name: '字幕样式预览' })).not.toBeInTheDocument();+ expect(screen.queryByRole('switch', { name: '生成目标语言配音' })).not.toBeInTheDocument();+ fireEvent.click(rendering);+ expect(screen.getByRole('combobox', { name: '输出画幅' }).closest('.video-translation-option-block')).toBeNull();+ fireEvent.change(screen.getByRole('combobox', { name: '字幕字体' }), { target: { value: 'rounded' } });+ fireEvent.change(screen.getByRole('combobox', { name: '输出画幅' }), { target: { value: 'vertical' } });+ fireEvent.change(screen.getByRole('textbox', { name: /竖屏主标题/ }), { target: { value: '保留标题' } });+ expect(screen.getByRole('region', { name: '字幕样式预览' })).toHaveAttribute('data-ratio', '9:16');++ fireEvent.click(rendering);+ expect(screen.queryByRole('combobox', { name: '输出画幅' })).not.toBeInTheDocument();+ expect(screen.queryByRole('combobox', { name: '字幕字体' })).not.toBeInTheDocument();+ expect(screen.queryByRole('region', { name: '字幕样式预览' })).not.toBeInTheDocument();+ expect(screen.getByLabelText('任务摘要')).not.toHaveTextContent('字幕样式');+ expect(screen.getByLabelText('任务摘要')).not.toHaveTextContent('配音');+ fireEvent.click(screen.getByRole('switch', { name: '合成字幕视频' }));+ expect(screen.getByRole('combobox', { name: '字幕字体' })).toHaveValue('rounded');+ expect(screen.getByRole('combobox', { name: '输出画幅' })).toHaveValue('vertical');+ expect(screen.getByRole('textbox', { name: /竖屏主标题/ })).toHaveValue('保留标题');+ expect(screen.getByLabelText('任务摘要')).toHaveTextContent('字幕样式');+ expect(screen.getByLabelText('任务摘要')).toHaveTextContent('圆体');});it('uses the selected vertical output ratio for the subtitle preview', () => {@@ -1066,13 +1102,12 @@ describe('DashboardPage', () => {target: { value: 'https://www.youtube.com/watch?v=vertical-preview' }});- fireEvent.click(screen.getByRole('button', { name: '继续' }));fireEvent.click(screen.getByRole('button', { name: '继续' }));fireEvent.click(screen.getByRole('button', { name: '继续' }));fireEvent.click(screen.getByRole('switch', { name: '合成字幕视频' }));- fireEvent.click(screen.getByRole('radio', { name: /9:16/ }));+ fireEvent.change(screen.getByRole('combobox', { name: '输出画幅' }), { target: { value: 'vertical' } });fireEvent.click(within(screen.getByRole('navigation', { name: '翻译流程' })).getByRole('button', {- name: /字幕样式$/+ name: /视频与字幕$/}));expect(screen.getByRole('region', { name: '字幕样式预览' })).toHaveAttribute('data-ratio', '9:16');@@ -1102,6 +1137,7 @@ describe('DashboardPage', () => {/>);+ fireEvent.click(screen.getByRole('tab', { name: '视频创作' }));fireEvent.click(screen.getByRole('button', { name: /^火柴人动画/ }));expect(screen.getByRole('heading', { name: '火柴人动画' })).toBeInTheDocument();expect(screen.getByRole('navigation', { name: '火柴人视频制作步骤' })).toBeInTheDocument();@@ -1200,6 +1236,7 @@ describe('DashboardPage', () => {it('opens the three-step cover workflow and configures the output count', () => {render(<DashboardPage onSelectPrompt={vi.fn()} />);+ fireEvent.click(screen.getByRole('tab', { name: '图像创作' }));openBlankWorkspace('封面生成', '空白封面生成');expect(screen.getByRole('heading', { name: '封面生成' })).toBeInTheDocument();@@ -1230,6 +1267,7 @@ describe('DashboardPage', () => {/>);+ fireEvent.click(screen.getByRole('tab', { name: '图像创作' }));openBlankWorkspace('封面生成', '空白封面生成');fireEvent.change(screen.getByRole('textbox', { name: '内容与补充要求' }), {target: { value: '验证空白封面使用当前模板版本' }@@ -1251,7 +1289,6 @@ describe('DashboardPage', () => {});fireEvent.click(screen.getByRole('button', { name: '继续' }));fireEvent.click(screen.getByRole('button', { name: '继续' }));- fireEvent.click(screen.getByRole('button', { name: '继续' }));await startVideoTranslation();fireEvent.click(screen.getByRole('tab', { name: '字幕' }));@@ -1280,7 +1317,6 @@ describe('DashboardPage', () => {});fireEvent.click(screen.getByRole('button', { name: '继续' }));fireEvent.click(screen.getByRole('button', { name: '继续' }));- fireEvent.click(screen.getByRole('button', { name: '继续' }));await startVideoTranslation();fireEvent.click(screen.getByRole('tab', { name: '字幕' }));@@ -1311,7 +1347,6 @@ describe('DashboardPage', () => {});fireEvent.click(screen.getByRole('button', { name: '继续' }));fireEvent.click(screen.getByRole('button', { name: '继续' }));- fireEvent.click(screen.getByRole('button', { name: '继续' }));await startVideoTranslation();fireEvent.click(screen.getByRole('tab', { name: '字幕' }));@@ -1348,13 +1383,12 @@ describe('DashboardPage', () => {});fireEvent.click(screen.getByRole('button', { name: '继续' }));fireEvent.click(screen.getByRole('button', { name: '继续' }));- fireEvent.click(screen.getByRole('button', { name: '继续' }));await startVideoTranslation();fireEvent.click(screen.getByRole('tab', { name: '配音' }));fireEvent.click(screen.getByRole('button', { name: '开启配音并生成新版本' }));fireEvent.click(screen.getByRole('button', { name: '继续' }));- fireEvent.click(screen.getByRole('button', { name: '继续' }));+ fireEvent.click(screen.getByRole('switch', { name: '合成字幕视频' }));fireEvent.click(screen.getByRole('switch', { name: '生成目标语言配音' }));fireEvent.click(screen.getByRole('button', { name: '返回 V1 成品' }));const regenerationRegion = screen.getByRole('region', { name: '生成新版本' });@@ -1385,7 +1419,6 @@ describe('DashboardPage', () => {});fireEvent.click(screen.getByRole('button', { name: '继续' }));fireEvent.click(screen.getByRole('button', { name: '继续' }));- fireEvent.click(screen.getByRole('button', { name: '继续' }));await startVideoTranslation();fireEvent.click(screen.getByRole('tab', { name: '任务设置' }));@@ -1416,7 +1449,6 @@ describe('DashboardPage', () => {fireEvent.click(screen.getByRole('button', { name: '继续' }));expect(screen.getByRole('combobox', { name: '翻译为' })).toHaveValue('ja');fireEvent.click(screen.getByRole('button', { name: '继续' }));- fireEvent.click(screen.getByRole('button', { name: '继续' }));fireEvent.click(screen.getByRole('button', { name: '生成 V2' }));expect(await screen.findByRole('button', { name: '项目 V2' })).toBeInTheDocument();@@ -1461,13 +1493,11 @@ describe('DashboardPage', () => {});fireEvent.click(screen.getByRole('button', { name: '继续' }));fireEvent.click(screen.getByRole('button', { name: '继续' }));- fireEvent.click(screen.getByRole('button', { name: '继续' }));await startVideoTranslation();fireEvent.click(screen.getByRole('tab', { name: '任务设置' }));fireEvent.click(screen.getByRole('button', { name: '调整设置' }));fireEvent.click(screen.getByRole('button', { name: '继续' }));- fireEvent.click(screen.getByRole('button', { name: '继续' }));fireEvent.click(screen.getByRole('switch', { name: '合成字幕视频' }));fireEvent.click(screen.getByRole('button', { name: '生成 V2' }));@@ -1508,7 +1538,6 @@ describe('DashboardPage', () => {});fireEvent.click(screen.getByRole('button', { name: '继续' }));fireEvent.click(screen.getByRole('button', { name: '继续' }));- fireEvent.click(screen.getByRole('button', { name: '继续' }));await startVideoTranslation();fireEvent.click(screen.getByRole('tab', { name: '任务设置' }));@@ -1520,7 +1549,6 @@ describe('DashboardPage', () => {});fireEvent.click(screen.getByRole('button', { name: '继续' }));fireEvent.click(screen.getByRole('button', { name: '继续' }));- fireEvent.click(screen.getByRole('button', { name: '继续' }));fireEvent.click(screen.getByRole('button', { name: '生成 V2' }));await waitFor(() => {@@ -1552,14 +1580,12 @@ describe('DashboardPage', () => {});fireEvent.click(screen.getByRole('button', { name: '继续' }));fireEvent.click(screen.getByRole('button', { name: '继续' }));- fireEvent.click(screen.getByRole('button', { name: '继续' }));fireEvent.click(screen.getByRole('switch', { name: '合成字幕视频' }));await startVideoTranslation();fireEvent.click(screen.getByRole('tab', { name: '任务设置' }));fireEvent.click(screen.getByRole('button', { name: '调整设置' }));fireEvent.click(screen.getByRole('button', { name: '继续' }));- fireEvent.click(screen.getByRole('button', { name: '继续' }));fireEvent.click(screen.getByRole('switch', { name: '合成字幕视频' }));fireEvent.click(screen.getByRole('button', { name: '生成 V2' }));@@ -1591,7 +1617,6 @@ describe('DashboardPage', () => {});fireEvent.click(screen.getByRole('button', { name: '继续' }));fireEvent.click(screen.getByRole('button', { name: '继续' }));- fireEvent.click(screen.getByRole('button', { name: '继续' }));fireEvent.click(screen.getByRole('switch', { name: '合成字幕视频' }));await startVideoTranslation();@@ -1691,17 +1716,17 @@ describe('DashboardPage', () => {fireEvent.click(screen.getByRole('button', { name: '继续' }));expect(screen.getByRole('switch', { name: '优先使用平台字幕' })).toBeDisabled();fireEvent.click(screen.getByRole('button', { name: '继续' }));- fireEvent.click(screen.getByRole('button', { name: '继续' }));- fireEvent.click(screen.getByRole('switch', { name: '生成目标语言配音' }));fireEvent.click(screen.getByRole('switch', { name: '合成字幕视频' }));- expect(screen.getByRole('radio', { name: /16:9/ })).toBeEnabled();- expect(screen.getByRole('radio', { name: /双画幅/ })).toBeEnabled();- fireEvent.click(screen.getByRole('radio', { name: /9:16/ }));+ expect(screen.getByRole('option', { name: /16:9/ })).toBeEnabled();+ expect(screen.getByRole('option', { name: /双画幅/ })).toBeEnabled();+ fireEvent.change(screen.getByRole('combobox', { name: '输出画幅' }), { target: { value: 'vertical' } });+ expect(screen.getByRole('textbox', { name: /竖屏主标题/ })).toBeInTheDocument();+ fireEvent.click(screen.getByRole('switch', { name: '生成目标语言配音' }));expect(screen.getByText('demo.mp4')).toBeInTheDocument();expect(await screen.findByRole('combobox', { name: '配音音色' })).toHaveValue('marin');expect(tts.getTtsVoices).toHaveBeenCalledWith('openai', 'gpt-4o-mini-tts');- expect(screen.getByRole('textbox', { name: /竖屏主标题/ })).toBeInTheDocument();+ expect(screen.getByRole('switch', { name: '合成字幕视频' })).toHaveAttribute('aria-checked', 'true');});it('only allows portrait output after detecting a portrait source video', async () => {@@ -1725,15 +1750,14 @@ describe('DashboardPage', () => {});fireEvent.loadedMetadata(preview);- fireEvent.click(screen.getByRole('button', { name: '继续' }));fireEvent.click(screen.getByRole('button', { name: '继续' }));fireEvent.click(screen.getByRole('button', { name: '继续' }));fireEvent.click(screen.getByRole('switch', { name: '合成字幕视频' }));- expect(screen.getByRole('radio', { name: /16:9/ })).toBeDisabled();- expect(screen.getByRole('radio', { name: /双画幅/ })).toBeDisabled();- expect(screen.getByRole('radio', { name: /9:16/ })).toBeEnabled();- expect(screen.getByRole('radio', { name: /9:16/ })).toHaveAttribute('aria-checked', 'true');+ expect(screen.getByRole('option', { name: /16:9/ })).toBeDisabled();+ expect(screen.getByRole('option', { name: /双画幅/ })).toBeDisabled();+ expect(screen.getByRole('option', { name: /9:16/ })).toBeEnabled();+ expect(screen.getByRole('combobox', { name: '输出画幅' })).toHaveValue('vertical');});it('requires a video before advancing to translation settings', () => {@@ -1866,6 +1890,8 @@ describe('DashboardPage', () => {expect(screen.getByText('没有找到相关应用')).toBeInTheDocument();fireEvent.click(screen.getByRole('button', { name: '查看全部应用' }));expect(screen.getByRole('tab', { name: '全部' })).toHaveAttribute('aria-selected', 'true');+ expect(directory.querySelectorAll('.dashboard-app-card')).toHaveLength(4);+ expect(within(directory).queryByRole('button', { name: /^封面生成/ })).not.toBeInTheDocument();fireEvent.click(screen.getByRole('tab', { name: '音频处理' }));expect(within(directory).getByRole('button', { name: /^智能配音/ })).toBeInTheDocument();diff --git a/apps/web/src/features/dashboard/DashboardPage.tsx b/apps/web/src/features/dashboard/DashboardPage.tsxindex f45b72a5..4085c329 100644--- a/apps/web/src/features/dashboard/DashboardPage.tsx+++ b/apps/web/src/features/dashboard/DashboardPage.tsx@@ -204,6 +204,12 @@ const creatorTools: DashboardEntry[] = [const categories = ['全部', '视频创作', '视频编辑', '图像创作', '文案创作', '音频处理'] as const;type CategoryFilter = typeof categories[number];+const allTabWorkspaces = new Set<CreatorWorkspace>([+ 'video-download',+ 'video-translation',+ 'video-generation',+ 'image-generation'+]);const CREATOR_JOB_CREATE_ATTEMPT_TIMEOUT_MS = 4_000;const CREATOR_JOB_CREATE_ATTEMPTS = 3;@@ -255,7 +261,9 @@ export default function DashboardPage(props: {: value;const visibleTools = useMemo(() => creatorTools.filter(tool => {if (tool.workspace === undefined || !isVisibleCreatorWorkspace(tool.workspace)) return false;- const matchesCategory = category === '全部' || tool.category === category;+ const matchesCategory = category === '全部'+ ? allTabWorkspaces.has(tool.workspace)+ : tool.category === category;const matchesQuery = normalizedQuery.length === 0|| `${localize(tool.title)} ${localize(tool.description)} ${localize(tool.category)}`.toLocaleLowerCase()diff --git a/apps/web/src/features/dashboard/ImageGenerationWorkspace.tsx b/apps/web/src/features/dashboard/ImageGenerationWorkspace.tsxindex 6c8ef0e9..0541aacf 100644--- a/apps/web/src/features/dashboard/ImageGenerationWorkspace.tsx+++ b/apps/web/src/features/dashboard/ImageGenerationWorkspace.tsx@@ -372,7 +372,7 @@ export default function ImageGenerationWorkspace(props: {async function generate() {if (generating) return;- if (official.official && !official.ready) { setError(l('官方图片服务暂不可用,请在个人中心检查连接状态', 'Official image service is unavailable. Check the connection in your personal center.')); return; }+ if (official.official && !official.ready) { setError(l('官方图片服务暂不可用,请在账户页面检查连接状态', 'Official image service is unavailable. Check the connection in your account.')); return; }if (session === null) {setError(l('图像生成服务暂不可用,请检查 Runtime 连接',diff --git a/apps/web/src/features/dashboard/LocalTranscriptionNotice.tsx b/apps/web/src/features/dashboard/LocalTranscriptionNotice.tsxindex 72b561e8..22097fb5 100644--- a/apps/web/src/features/dashboard/LocalTranscriptionNotice.tsx+++ b/apps/web/src/features/dashboard/LocalTranscriptionNotice.tsx@@ -1,38 +1,22 @@import { useEffect } from 'react';import type { RuntimeDependenciesController } from '../../app/use-runtime-dependencies.js';import { useLocalizedCopy } from '../../i18n/useLocalizedCopy.js';-import { componentProgressText } from '../settings/RuntimeManagedComponents.js';-import { OriginalErrorDetails } from '../issues/OriginalErrorDetails.js';-export function LocalTranscriptionNotice({ controller, platformCaptions, importedSubtitle, beforeNavigate }: {+export function LocalTranscriptionNotice({ controller, importedSubtitle, beforeNavigate }: {controller?: RuntimeDependenciesController;- platformCaptions: boolean;importedSubtitle: boolean;beforeNavigate(): void;}) {const localize = useLocalizedCopy();useEffect(() => { void controller?.refreshComponents?.(); }, [controller?.refreshComponents]);- if (!controller) return null;+ if (!controller || importedSubtitle) return null;const status = controller.componentsStatus;- if (!status) return controller.componentError ? <aside className="local-transcription-notice" role="status">{localize('无法读取本地转录组件状态', 'Cannot read local transcription component status')} <button type="button" onClick={() => void controller.refreshComponents?.()}>{localize('重试', 'Retry')}</button></aside> : null;+ if (!status) return null;const component = status.components.find(candidate => candidate.id === status.selectedProvider);- if (!component) return null;- const busy = ['downloading', 'verifying', 'extracting'].includes(component.state);- const ready = component.state === 'ready';- const query = new URLSearchParams({ tab: 'local-components', component: component.id, from: 'video-translation', returnPath: window.location.hash });- const settingsQuery = new URLSearchParams(query);- settingsQuery.set('tab', 'ai-services');- settingsQuery.set('section', 'transcription');+ if (!component || status.selectedModel?.trim()) return null;+ const settingsQuery = new URLSearchParams({ tab: 'ai-services', section: 'transcription', component: component.id, from: 'video-translation', returnPath: window.location.hash });return <aside className="local-transcription-notice" data-state={component.state} role="status">- <div>- <strong>{!component.available ? localize('当前平台不支持此本地转录组件', 'This local transcription component is unavailable on this platform') : busy ? localize('正在准备本地转录组件', 'Preparing local transcription components') : ready ? localize('本地转录已就绪', 'Local transcription ready') : component.state === 'failed' ? localize('本地转录组件下载失败', 'Local transcription component download failed') : localize('本地转录组件尚未就绪', 'Local transcription components are not ready')}</strong>- <small>{component.name} · {status.selectedModel}</small>- {!ready || importedSubtitle ? <p>{importedSubtitle ? localize('当前任务使用导入字幕,无需本地语音转录。', 'This task uses imported subtitles and does not need transcription.') : platformCaptions ? localize('将优先使用视频原始字幕;没有可用字幕时才需要本地转录。可提前下载组件,避免任务中等待。', 'Original video captions are used first. Local transcription is needed only when captions are unavailable; prepare components now to avoid waiting during the task.') : localize('此任务需要本地语音转录。模型文件较大,首次执行会自动下载,也可提前准备;下载并校验完成后任务会自动继续。', 'This task requires local transcription. Large models are downloaded automatically when needed, or can be prepared in advance. The task continues automatically after verification.')}</p> : null}- {busy ? <p>{component.item} {component.state === 'downloading' ? componentProgressText(component) : localize('正在校验或安装,请稍候', 'Verifying or installing; please wait')}</p> : null}- {component.error ? <OriginalErrorDetails detail={component.error} /> : null}- </div><div className="local-transcription-notice-actions">- {component.available ? <a href={`#/settings?${query}`} onClick={beforeNavigate}>{ready ? localize('管理组件', 'Manage components') : busy ? localize('查看下载进度', 'View download progress') : component.state === 'failed' ? localize('前往重试', 'Retry download') : localize('前往组件下载', 'Go to component downloads')}</a> : null}<a href={`#/settings?${settingsQuery}`} onClick={beforeNavigate}>{localize('调整转录设置', 'Change transcription settings')}</a></div></aside>;diff --git a/apps/web/src/features/dashboard/SmartDubbingWorkspace.tsx b/apps/web/src/features/dashboard/SmartDubbingWorkspace.tsxindex 4eaba7e6..cddd3091 100644--- a/apps/web/src/features/dashboard/SmartDubbingWorkspace.tsx+++ b/apps/web/src/features/dashboard/SmartDubbingWorkspace.tsx@@ -228,7 +228,7 @@ export default function SmartDubbingWorkspace(props: {}async function generate() {- if (official.official && !official.ready) { setError(l('官方语音服务暂不可用,请在个人中心检查连接状态', 'Official speech service is unavailable. Check your personal center.')); return; }+ if (official.official && !official.ready) { setError(l('官方语音服务暂不可用,请在账户页面检查连接状态', 'Official speech service is unavailable. Check your account.')); return; }if (generating) return;if (session === null) {setError(l('智能配音服务暂不可用,请检查 Runtime 连接', 'Smart dubbing is unavailable. Check the Runtime connection.'));diff --git a/apps/web/src/features/dashboard/VideoGenerationWorkspace.tsx b/apps/web/src/features/dashboard/VideoGenerationWorkspace.tsxindex ad57bdd6..0cd0775f 100644--- a/apps/web/src/features/dashboard/VideoGenerationWorkspace.tsx+++ b/apps/web/src/features/dashboard/VideoGenerationWorkspace.tsx@@ -435,7 +435,7 @@ export default function VideoGenerationWorkspace(props: {async function generate() {if (generating) return;- if (!serviceReady) { setError(l('官方视频服务暂不可用,请在个人中心检查连接状态', 'Official video service is unavailable. Check the connection in your personal center.')); return; }+ if (!serviceReady) { setError(l('官方视频服务暂不可用,请在账户页面检查连接状态', 'Official video service is unavailable. Check the connection in your account.')); return; }if (session === null) {setError(l('视频生成服务暂不可用,请检查 Runtime 连接',diff --git a/apps/web/src/features/dashboard/VideoTranslationAgentPanel.tsx b/apps/web/src/features/dashboard/VideoTranslationAgentPanel.tsxindex b58a2a58..a3b7b580 100644--- a/apps/web/src/features/dashboard/VideoTranslationAgentPanel.tsx+++ b/apps/web/src/features/dashboard/VideoTranslationAgentPanel.tsx@@ -1,3 +1,4 @@+import type { ReactNode } from 'react';import CreatorCollaborationPanel, {type CreatorPanelQuickAction} from './CreatorCollaborationPanel.js';@@ -8,6 +9,7 @@ export type VideoTranslationAgentQuickAction = CreatorPanelQuickAction;export default function VideoTranslationAgentPanel(props: {stepLabel: string;contextSummary: string;+ taskSummary?: ReactNode;promptHint?: string;currentIssue?: string;quickActions?: VideoTranslationAgentQuickAction[];diff --git a/apps/web/src/features/dashboard/VideoTranslationResultWorkspace.test.tsx b/apps/web/src/features/dashboard/VideoTranslationResultWorkspace.test.tsxindex 60333a99..16e4de95 100644--- a/apps/web/src/features/dashboard/VideoTranslationResultWorkspace.test.tsx+++ b/apps/web/src/features/dashboard/VideoTranslationResultWorkspace.test.tsx@@ -41,6 +41,65 @@ const baseProps = {};describe('VideoTranslationResultWorkspace', () => {+ it.each([+ ['queued', 'Translation is queued'],+ ['running', 'Translation in progress'],+ ['needs_input', 'Translation needs your attention'],+ ['failed', 'Translation failed'],+ ['canceled', 'Translation stopped'],+ ['interrupted', 'Translation interrupted']+ ] as const)('shows the %s task state before any outputs exist', (status, title) => {+ render(<LanguageProvider initialPreference="en-US"><VideoTranslationResultWorkspace+ {...baseProps} activeTab="video" subtitleOutputs={[]}+ execution={{ status, stageLabel: 'Subtitle translation' }}+ /></LanguageProvider>);+ expect(screen.getByText(title)).toBeVisible();+ expect(screen.queryByText('This project version has no works')).not.toBeInTheDocument();+ expect(screen.queryByText('No outputs available for this version')).not.toBeInTheDocument();+ expect(screen.getByRole('tab', { name: 'Outputs' })).toBeVisible();+ expect(screen.getByRole('button', { name: 'Project V1' }).querySelector('.lucide-circle-check')).toBeNull();+ });++ it('distinguishes subtitles still processing from an empty generated subtitle file', () => {+ const view = render(<LanguageProvider initialPreference="en-US"><VideoTranslationResultWorkspace+ {...baseProps} activeTab="subtitles" subtitleOutputs={[]}+ execution={{ status: 'running', stageLabel: 'Subtitle translation' }}+ /></LanguageProvider>);+ expect(screen.getByText('Subtitles are not ready yet')).toBeVisible();+ view.rerender(<LanguageProvider initialPreference="en-US"><VideoTranslationResultWorkspace+ {...baseProps} activeTab="subtitles" subtitleOutputs={[{ ...baseProps.subtitleOutputs[0]!, cues: [] }]}+ /></LanguageProvider>);+ expect(screen.getByText('The subtitle file contains no cues')).toBeVisible();+ expect(screen.queryByText('Subtitles are not ready yet')).not.toBeInTheDocument();+ });++ it('keeps generated files visible while later stages are running', () => {+ render(<LanguageProvider initialPreference="en-US"><VideoTranslationResultWorkspace+ {...baseProps} activeTab="video" execution={{ status: 'running', stageLabel: 'Dubbing' }}+ /></LanguageProvider>);+ expect(screen.getByText('horizontal.srt')).toBeVisible();+ expect(screen.getByText('Translation in progress · Current stage: Dubbing')).toBeVisible();+ expect(screen.getByRole('button', { name: 'Project V1' })).toBeVisible();+ });++ it('distinguishes pending dubbing from disabled dubbing and does not invite duplicate generation', () => {+ const view = render(<LanguageProvider initialPreference="en-US"><VideoTranslationResultWorkspace+ {...baseProps} activeTab="voice" dubbing execution={{ status: 'running', stageLabel: 'Subtitle translation' }}+ /></LanguageProvider>);+ expect(screen.getByText('Dubbing is not ready yet')).toBeVisible();+ expect(screen.queryByRole('button', { name: 'Enable dubbing and generate a new version' })).not.toBeInTheDocument();+ view.rerender(<LanguageProvider initialPreference="en-US"><VideoTranslationResultWorkspace+ {...baseProps} activeTab="voice" execution={{ status: 'running', stageLabel: 'Subtitle translation' }}+ /></LanguageProvider>);+ expect(screen.getByText('Dubbing is disabled for this version')).toBeVisible();+ expect(screen.queryByText('Dubbing is not ready yet')).not.toBeInTheDocument();+ view.rerender(<LanguageProvider initialPreference="en-US"><VideoTranslationResultWorkspace+ {...baseProps} activeTab="voice" dubbing+ /></LanguageProvider>);+ expect(screen.getByRole('button', { name: 'Adjust dubbing settings' })).toBeVisible();+ expect(screen.queryByRole('button', { name: 'Enable dubbing and generate a new version' })).not.toBeInTheDocument();+ });+it('localizes preview loading failures without modifying subtitles or automatically retrying', () => {const raw = '后台原文:原视频读取失败';const onPrepareSourceVideo = vi.fn();@@ -110,8 +169,9 @@ describe('VideoTranslationResultWorkspace', () => {);expect(screen.getByRole('tab', { name: '作品' })).toHaveAttribute('aria-selected', 'true');- expect(screen.getByRole('heading', { name: '作品' })).toBeInTheDocument();- expect(screen.getByText('项目 V1 · 1 个文件')).toBeInTheDocument();+ expect(screen.queryByRole('heading', { name: '作品' })).not.toBeInTheDocument();+ expect(screen.queryByText('项目 V1 · 1 个文件')).not.toBeInTheDocument();+ expect(screen.getByRole('button', { name: '项目 V1' })).toBeInTheDocument();expect(screen.getByText('horizontal.srt')).toBeInTheDocument();fireEvent.click(screen.getByRole('button', { name: '下载横屏字幕' }));expect(onExport).toHaveBeenCalledWith('subtitles', 'subtitle-horizontal-v1');@@ -136,7 +196,8 @@ describe('VideoTranslationResultWorkspace', () => {);expect(screen.getByText('translated-horizontal.mp4')).toBeInTheDocument();- expect(screen.getByText('子项 V1 · 项目 V1')).toBeInTheDocument();+ expect(screen.queryByText('子项 V1 · 项目 V1')).not.toBeInTheDocument();+ expect(screen.getByText('横屏 16:9')).toBeInTheDocument();expect(screen.getByLabelText('横屏成片预览')).toHaveAttribute('src','blob:http://localhost/translated-video'@@ -173,8 +234,8 @@ describe('VideoTranslationResultWorkspace', () => {/>);- expect(screen.getByRole('heading', { name: '横屏成片' })).toBeInTheDocument();- expect(screen.getByRole('heading', { name: '竖屏成片' })).toBeInTheDocument();+ expect(screen.getByRole('region', { name: '横屏成片' })).toBeInTheDocument();+ expect(screen.getByRole('region', { name: '竖屏成片' })).toBeInTheDocument();expect(screen.getByLabelText('横屏成片预览').parentElement).toHaveAttribute('data-ratio', '16:9');expect(screen.getByLabelText('竖屏成片预览').parentElement).toHaveAttribute('data-ratio', '9:16');expect(screen.queryByRole('radiogroup', { name: '成片画幅' })).not.toBeInTheDocument();diff --git a/apps/web/src/features/dashboard/VideoTranslationResultWorkspace.tsx b/apps/web/src/features/dashboard/VideoTranslationResultWorkspace.tsxindex b3e937d1..064fa607 100644--- a/apps/web/src/features/dashboard/VideoTranslationResultWorkspace.tsx+++ b/apps/web/src/features/dashboard/VideoTranslationResultWorkspace.tsx@@ -22,6 +22,11 @@ export type VideoTranslationResultTab = 'video' | 'subtitles' | 'voice' | 'settiexport type VideoResultVariant = 'horizontal' | 'vertical' | 'dubbed';export type SubtitleResultVariant = 'horizontal' | 'vertical';+export type VideoTranslationResultExecution = {+ status: 'queued' | 'running' | 'needs_input' | 'failed' | 'canceled' | 'interrupted';+ stageLabel: string;+};+export type SubtitleCue = {id: number;start: string;@@ -104,6 +109,7 @@ export default function VideoTranslationResultWorkspace(props: {affectedArtifacts: string[];hasPendingChanges: boolean;regenerationPending: boolean;+ execution?: VideoTranslationResultExecution;notice?: string;onTabChange(tab: VideoTranslationResultTab): void;onVersionChange(version: number): void;@@ -150,6 +156,19 @@ export default function VideoTranslationResultWorkspace(props: {const generatedArtifactCount = props.videoOutputs.length+ props.subtitleOutputs.length+ (props.voiceOutput === undefined ? 0 : 1);+ const outputEmptyTitle = emptyResultTitle('video', props.execution?.status, l);+ const subtitleEmptyTitle = emptyResultTitle('subtitles', props.execution?.status, l);+ const voiceEmptyTitle = props.dubbing+ ? emptyResultTitle('voice', props.execution?.status, l)+ : l('此版本未开启配音', 'Dubbing is disabled for this version');+ const executionDetail = props.execution === undefined ? undefined+ : props.execution.status === 'failed'+ ? l('查看任务面板中的错误详情后重试。', 'Check the error in the task panel and retry.')+ : props.execution.status === 'needs_input'+ ? l('请先处理任务面板中的待办事项。', 'Resolve the pending action in the task panel to continue.')+ : props.execution.status === 'canceled' || props.execution.status === 'interrupted'+ ? l('可在任务面板中继续任务。', 'Resume the task from the task panel.')+ : l(`当前阶段:${props.execution.stageLabel}`, `Current stage: ${props.execution.stageLabel}`);useEffect(() => {setSelectedSubtitleVariant(availableSubtitleVariants.includes('horizontal')@@ -198,6 +217,7 @@ export default function VideoTranslationResultWorkspace(props: {</div><CreatorResultVersionMenu+ showCompletion={props.execution === undefined && generatedArtifactCount > 0}version={props.version}versions={props.versions}onVersionChange={props.onVersionChange}@@ -208,31 +228,18 @@ export default function VideoTranslationResultWorkspace(props: {{props.activeTab === 'video' ? (<div className="video-result-pane">- <header className="video-result-pane-heading">- <div>- <h2>{l('作品', 'Works')}</h2>- <p>{l(- `项目 V${props.version} · ${generatedArtifactCount} 个文件`,- `Project V${props.version} · ${generatedArtifactCount} file(s)`- )}</p>- </div>- </header>+ {generatedArtifactCount > 0 && props.execution ? (+ <p className="video-result-notice" role="status">{outputEmptyTitle} · {executionDetail}</p>+ ) : null}{generatedArtifactCount > 0 ? (<div className="video-result-generated-sections">{props.videoOutputs.length > 0 ? (- <section className="video-result-generated-section">- <h3>{l('成片', 'Videos')}</h3>+ <section className="video-result-generated-section" aria-label={l('成片', 'Videos')}><div className="video-result-video-grid">{props.videoOutputs.map(output => {const artifactLabel = videoVariantArtifactLabel(output.variant, l);return (- <section className="video-result-output-column" data-variant={output.variant} key={output.artifactId}>- <div className="video-result-output-heading">- <div>- <h3>{artifactLabel}</h3>- <small>{videoVariantFormatLabel(output.variant, l)} · {l('子项', 'Item')} V{output.artifactVersion}</small>- </div>- </div>+ <section className="video-result-output-column" aria-label={artifactLabel} data-variant={output.variant} key={output.artifactId}><div className="video-result-player-frame" data-ratio={output.variant === 'vertical' ? '9:16' : '16:9'}>{output.src !== undefined ? (<video@@ -253,11 +260,8 @@ export default function VideoTranslationResultWorkspace(props: {<div className="video-result-file-row"><span aria-hidden="true"><FileVideo size={19} strokeWidth={1.7} /></span><div>- <strong>{output.fileName ?? `${artifactLabel}-${props.targetLanguage}-V${props.version}.mp4`}</strong>- <small>- {l('子项', 'Item')} V{output.artifactVersion}- {' · '}{l('项目', 'Project')} V{props.version}- </small>+ <strong title={output.fileName}>{output.fileName ?? `${artifactLabel}-${props.targetLanguage}-V${props.version}.mp4`}</strong>+ <small>{videoVariantFormatLabel(output.variant, l)}</small></div><buttontype="button"@@ -285,10 +289,8 @@ export default function VideoTranslationResultWorkspace(props: {<div className="video-result-file-row" key={output.artifactId}><span aria-hidden="true"><Captions size={19} strokeWidth={1.7} /></span><div>- <strong>{output.fileName ?? `${variantLabel}-V${props.version}.srt`}</strong>- <small>- {variantLabel} · {l('子项', 'Item')} V{output.artifactVersion}- </small>+ <strong title={output.fileName}>{output.fileName ?? `${variantLabel}-V${props.version}.srt`}</strong>+ <small>{variantLabel}</small></div><buttontype="button"@@ -312,11 +314,7 @@ export default function VideoTranslationResultWorkspace(props: {<div className="video-result-file-row"><span aria-hidden="true"><FileAudio size={19} strokeWidth={1.7} /></span><div>- <strong>{props.voiceOutput.fileName ?? `${l('目标语言配音', 'Target-language-dubbing')}-V${props.version}.wav`}</strong>- <small>- {l('配音', 'Dubbing')} V{props.voiceOutput.artifactVersion}- {' · '}{l('项目', 'Project')} V{props.version}- </small>+ <strong title={props.voiceOutput.fileName}>{props.voiceOutput.fileName ?? `${l('目标语言配音', 'Target-language-dubbing')}-V${props.version}.wav`}</strong></div><buttontype="button"@@ -332,9 +330,10 @@ export default function VideoTranslationResultWorkspace(props: {) : null}</div>) : (- <div className="video-result-empty">+ <div className="video-result-empty" role="status"><PackageOpen size={26} strokeWidth={1.5} aria-hidden="true" />- <strong>{l('当前项目版本没有作品', 'This project version has no works')}</strong>+ <strong>{outputEmptyTitle}</strong>+ {executionDetail ? <p>{executionDetail}</p> : null}</div>)}</div>@@ -546,12 +545,15 @@ export default function VideoTranslationResultWorkspace(props: {})}</div>) : (- <div className="video-result-subtitle-empty">{l('当前版本没有可展示的字幕', 'No subtitle cues to display')}</div>+ <div className="video-result-subtitle-empty" role="status">{l('字幕文件中没有可显示的内容', 'The subtitle file contains no cues')}</div>)}</section></div>) : (- <div className="video-result-subtitle-empty">{l('当前版本没有可展示的字幕', 'No subtitles to display for this version')}</div>+ <div className="video-result-subtitle-empty" role="status">+ <strong>{subtitleEmptyTitle}</strong>+ {executionDetail ? <p>{executionDetail}</p> : null}+ </div>)}</div>) : null}@@ -561,7 +563,7 @@ export default function VideoTranslationResultWorkspace(props: {<header className="video-result-pane-heading"><div><h2>{l('目标语言配音', 'Target-language dubbing')}</h2>- <p>{props.hasVoiceArtifact ? l('配音文件已生成', 'Dubbing file generated') : l('当前版本未生成配音', 'No dubbing was generated for this version')}</p>+ {props.hasVoiceArtifact ? <p>{l('配音文件已生成', 'Dubbing file generated')}</p> : null}</div></header>{props.hasVoiceArtifact && props.voiceOutput !== undefined ? (@@ -610,10 +612,15 @@ export default function VideoTranslationResultWorkspace(props: {</div></div>) : (- <div className="video-result-empty">+ <div className="video-result-empty" role="status"><FileAudio size={26} strokeWidth={1.5} aria-hidden="true" />- <strong>{l('这个版本没有配音文件', 'This version has no dubbing file')}</strong>- <button type="button" onClick={props.onAdjustSettings}>{l('开启配音并生成新版本', 'Enable dubbing and generate a new version')}</button>+ <strong>{voiceEmptyTitle}</strong>+ {props.dubbing && executionDetail ? <p>{executionDetail}</p> : null}+ {props.execution === undefined ? (+ <button type="button" onClick={props.onAdjustSettings}>{props.dubbing+ ? l('调整配音设置', 'Adjust dubbing settings')+ : l('开启配音并生成新版本', 'Enable dubbing and generate a new version')}</button>+ ) : null}</div>)}</div>@@ -708,7 +715,7 @@ function subtitleCueDisplayText(function localizeResultTab(label: string, l: LocalizeCopy): string {const labels: Record<string, string> = {- '作品': 'Works',+ '作品': 'Outputs','字幕': 'Subtitles','配音': 'Dubbing','任务设置': 'Task settings'@@ -716,6 +723,32 @@ function localizeResultTab(label: string, l: LocalizeCopy): string {return l(label, labels[label] ?? label);}+function emptyResultTitle(+ tab: 'video' | 'subtitles' | 'voice',+ status: VideoTranslationResultExecution['status'] | undefined,+ l: LocalizeCopy+): string {+ if (status === 'failed') return l('翻译任务失败', 'Translation failed');+ if (status === 'needs_input') return l('翻译任务等待处理', 'Translation needs your attention');+ if (status === 'canceled') return l('翻译任务已终止', 'Translation stopped');+ if (status === 'interrupted') return l('翻译任务已中断', 'Translation interrupted');+ if (status === 'queued') return ({+ video: l('翻译任务等待执行', 'Translation is queued'),+ subtitles: l('字幕等待生成', 'Subtitles are pending'),+ voice: l('配音等待生成', 'Dubbing is pending')+ })[tab];+ if (status === 'running') return ({+ video: l('翻译进行中', 'Translation in progress'),+ subtitles: l('字幕尚未就绪', 'Subtitles are not ready yet'),+ voice: l('配音尚未就绪', 'Dubbing is not ready yet')+ })[tab];+ return ({+ video: l('此版本暂无生成结果', 'No outputs available for this version'),+ subtitles: l('此版本尚未生成字幕', 'Subtitles have not been generated for this version'),+ voice: l('此版本尚未生成配音', 'Dubbing has not been generated for this version')+ })[tab];+}+function subtitleTimestampSeconds(value: string): number {const match = /^(\d+):(\d{2}):(\d{2})(?:[,.](\d{1,3}))?$/.exec(value.trim());if (match === null) return Number.NaN;diff --git a/apps/web/src/features/dashboard/VideoTranslationWorkspace.control.test.tsx b/apps/web/src/features/dashboard/VideoTranslationWorkspace.control.test.tsxindex 7c327fb7..9d649a74 100644--- a/apps/web/src/features/dashboard/VideoTranslationWorkspace.control.test.tsx+++ b/apps/web/src/features/dashboard/VideoTranslationWorkspace.control.test.tsx@@ -13,6 +13,44 @@ import VideoTranslationWorkspace from './VideoTranslationWorkspace.js';import { LanguageSwitchControls } from '../../test/LanguageSwitchControls.js';describe('VideoTranslationWorkspace task controls', () => {+ it.each([+ ['running', 'queued', '翻译任务等待执行'],+ ['running', 'running', '翻译进行中'],+ ['running', 'succeeded', '翻译进行中'],+ ['needs_input', 'failed', '翻译任务等待处理'],+ ['failed', 'failed', '翻译任务失败'],+ ['canceled', 'canceled', '翻译任务已终止'],+ ['failed', 'interrupted', '翻译任务已中断']+ ] as const)('restores a %s/%s translation before artifacts arrive', (jobStatus, stageStatus, title) => {+ render(<LanguageProvider initialPreference="zh-CN"><CreatorSessionProvider+ initialJob={job({ status: jobStatus, revision: 1, stages: [stage({+ id: 'generation', status: stageStatus, dispatchStatus: stageStatus === 'queued' ? 'queued' : 'claimed',+ progress: { workflow: true }+ })] })}+ service={{ applyAction: vi.fn(), runAgentTurn: vi.fn() } as never}+ ><VideoTranslationWorkspace onBack={vi.fn()} /></CreatorSessionProvider></LanguageProvider>);+ const workspace = screen.getByRole('region', { name: '视频翻译操作区' });+ expect(within(workspace).getByText(title)).toBeVisible();+ expect(workspace.querySelector('.video-translation-header p')).toHaveTextContent('https://www.youtube.com/watch?v=job-control');+ expect(within(workspace).queryByText('当前项目版本没有作品')).not.toBeInTheDocument();+ });++ it.each(['subtitle', 'prepare-source-video'])('does not label existing outputs as generating when %s targets another result or only prepares a preview', stageId => {+ render(<LanguageProvider initialPreference="zh-CN"><CreatorSessionProvider+ initialJob={job({ status: 'running', revision: 1, artifacts: [subtitleArtifact(1, '已完成字幕')],+ state: { dubbing: true, composeVideo: true },+ stages: [{ ...stage({ id: 'other-operation', status: 'running', dispatchStatus: 'claimed',+ progress: stageId === 'subtitle' ? { targetResultVersion: 2 } : { inputResultVersion: 1 }+ }), stageId }]+ })}+ service={{ applyAction: vi.fn(), runAgentTurn: vi.fn() } as never}+ ><VideoTranslationWorkspace onBack={vi.fn()} /></CreatorSessionProvider></LanguageProvider>);+ const workspace = screen.getByRole('region', { name: '视频翻译操作区' });+ fireEvent.click(within(workspace).getByRole('tab', { name: '配音' }));+ expect(within(workspace).getByText('此版本尚未生成配音')).toBeVisible();+ expect(within(workspace).queryByText('配音尚未就绪')).not.toBeInTheDocument();+ });+it('downloads and previews a draft Douyin source without entering results and clears playback when the source changes', async () => {const objectUrlDescriptor = Object.getOwnPropertyDescriptor(URL, 'createObjectURL');const revokeDescriptor = Object.getOwnPropertyDescriptor(URL, 'revokeObjectURL');@@ -230,11 +268,56 @@ describe('VideoTranslationWorkspace task controls', () => {expect(screen.getByLabelText('UTF-8 SRT file')).toHaveAttribute('type', 'file');fireEvent.click(screen.getByRole('button', { name: 'Continue' }));- fireEvent.click(screen.getByRole('button', { name: 'Continue' }));- expect(screen.getByRole('radio', { name: '16:9 + 9:16 Both' })).toBeInTheDocument();+ expect(screen.getByRole('switch', { name: 'Render subtitled video' })).toHaveAttribute('aria-checked', 'true');+ expect(screen.getByRole('combobox', { name: 'Output format' })).toHaveValue('horizontal');+ expect(screen.getByRole('option', { name: '16:9 + 9:16 Both' })).toBeInTheDocument();expect(screen.queryByText('双画幅')).not.toBeInTheDocument();});+ it('restores an old fourth-step draft on the final step of the three-step workflow', () => {+ render(<LanguageProvider initialPreference="zh-CN"><CreatorSessionProvider+ initialJob={job({ status: 'draft', revision: 0, stages: [], state: {+ currentStep: 3, furthestStep: 3, composeVideo: true, dubbing: true, voiceCode: 'marin', voiceName: 'Marin'+ } })}+ service={{ applyAction: vi.fn(), runAgentTurn: vi.fn() } as never}+ ><VideoTranslationWorkspace onBack={vi.fn()} /></CreatorSessionProvider></LanguageProvider>);++ const steps = screen.getByRole('navigation', { name: '翻译流程' });+ expect(within(steps).getAllByRole('button')).toHaveLength(3);+ expect(within(steps).getByRole('button', { name: '3 视频与字幕' })).toHaveAttribute('aria-current', 'step');+ expect(screen.getByRole('switch', { name: '生成目标语言配音' })).toHaveAttribute('aria-checked', 'true');+ expect(screen.getByLabelText('任务摘要')).toHaveTextContent('marin');+ expect(screen.queryByRole('button', { name: '继续' })).not.toBeInTheDocument();+ expect(within(screen.getByRole('region', { name: '视频翻译操作区' })).getByRole('button', { name: '开始翻译' })).toBeInTheDocument();+ });++ it('preserves the selected voice but submits without dubbing when video composition is disabled', async () => {+ let current = job({ status: 'draft', revision: 0, stages: [], state: {+ currentStep: 2, furthestStep: 2, composeVideo: true, dubbing: true, voiceCode: 'marin', voiceName: 'Marin'+ } });+ const stageSettings: CreatorJob['state'][] = [];+ const applyAction = vi.fn(async (_id: string, request: { action: string; input: Record<string, CreatorJson> }) => {+ if (request.action === 'run-stage') stageSettings.push({ ...current.state });+ current = { ...current, revision: current.revision + 1, state: { ...current.state, ...request.input.patch as object } };+ return { job: current };+ });+ render(<LanguageProvider initialPreference="zh-CN"><CreatorSessionProvider initialJob={current}+ service={{ applyAction, runAgentTurn: vi.fn() } as never}+ ><VideoTranslationWorkspace onBack={vi.fn()} /></CreatorSessionProvider></LanguageProvider>);++ fireEvent.click(screen.getByRole('switch', { name: '合成字幕视频' }));+ expect(screen.queryByRole('switch', { name: '生成目标语言配音' })).not.toBeInTheDocument();+ expect(screen.getByLabelText('任务摘要')).not.toHaveTextContent('配音');+ await waitFor(() => expect(current.state).toMatchObject({ composeVideo: false, dubbing: false, voiceCode: 'marin' }));++ fireEvent.click(screen.getByRole('switch', { name: '合成字幕视频' }));+ fireEvent.click(screen.getByRole('switch', { name: '生成目标语言配音' }));+ expect(screen.getByLabelText('任务摘要')).toHaveTextContent('marin');+ fireEvent.click(screen.getByRole('switch', { name: '合成字幕视频' }));+ fireEvent.click(within(screen.getByRole('region', { name: '视频翻译操作区' })).getByRole('button', { name: '开始翻译' }));+ await waitFor(() => expect(stageSettings).toEqual([expect.objectContaining({ composeVideo: false, dubbing: false, voiceCode: 'marin' })]));+ });+it('keeps an imported translation in configuration and shows its persisted metadata', async () => {let current = job({ status: 'draft', revision: 0, stages: [], state: { currentStep: 1, furthestStep: 1 } });const applyAction = vi.fn(async (_id: string, request: { action: string; input: Record<string, CreatorJson> }) => {@@ -256,7 +339,6 @@ describe('VideoTranslationWorkspace task controls', () => {expect(await screen.findByText('本地导入 · translated.srt · zh_cn · 1 条字幕 · v1')).toBeInTheDocument();expect(screen.getByRole('heading', { name: '设置翻译语言' })).toBeInTheDocument();fireEvent.click(screen.getByRole('button', { name: '继续' }));- fireEvent.click(screen.getByRole('button', { name: '继续' }));fireEvent.click(within(screen.getByRole('region', { name: '视频翻译操作区' })).getByRole('button', { name: '开始翻译' }));await waitFor(() => expect(applyAction).toHaveBeenCalledWith('job_control', expect.objectContaining({ action: 'run-stage', input: { stageId: 'subtitle', workflow: true } })));});@@ -293,6 +375,7 @@ describe('VideoTranslationWorkspace task controls', () => {state: {currentStep: 2,furthestStep: 2,+ composeVideo: true,subtitleFont: 'serif',subtitleSize: 'large',subtitleColor: '#7EE7FF'@@ -306,15 +389,44 @@ describe('VideoTranslationWorkspace task controls', () => {);expect(screen.getByRole('combobox', { name: '字幕字体' })).toHaveValue('serif');- expect(screen.getByRole('radio', { name: '大' })).toHaveAttribute('aria-checked', 'true');+ expect(screen.getByRole('combobox', { name: '字幕大小' })).toHaveValue('large');+ expect(screen.getByRole('button', { name: '选择译文颜色' })).toHaveTextContent('#7EE7FF');+ fireEvent.click(screen.getByRole('button', { name: '选择译文颜色' }));expect(screen.getByRole('button', { name: '#7EE7FF' })).toHaveAttribute('aria-pressed', 'true');});+ it('validates HEX colors, updates the preview, and closes the palette with Escape or an outside click', () => {+ render(<LanguageProvider initialPreference="zh-CN">+ <CreatorSessionProvider initialJob={job({ status: 'draft', revision: 0, stages: [], state: {+ currentStep: 2, furthestStep: 2, composeVideo: true+ } })} service={{ applyAction: vi.fn(), runAgentTurn: vi.fn() } as never}>+ <VideoTranslationWorkspace onBack={vi.fn()} />+ </CreatorSessionProvider>+ </LanguageProvider>);+ const trigger = screen.getByRole('button', { name: '选择译文颜色' });+ expect(screen.queryByRole('dialog', { name: '译文颜色色板' })).not.toBeInTheDocument();+ fireEvent.click(trigger);+ const hex = screen.getByRole('textbox', { name: '译文颜色 HEX' });+ const frame = screen.getByRole('region', { name: '字幕样式预览' }).querySelector(':scope > div');+ fireEvent.change(hex, { target: { value: '#12' } });+ expect(frame).toHaveStyle({ '--subtitle-preview-color': '#FFFFFF' });+ fireEvent.change(hex, { target: { value: '123abc' } });+ expect(frame).toHaveStyle({ '--subtitle-preview-color': '#123ABC' });+ expect(trigger).toHaveTextContent('#123ABC');+ fireEvent.keyDown(hex, { key: 'Escape' });+ expect(trigger).toHaveFocus();+ expect(trigger).toHaveAttribute('aria-expanded', 'false');+ fireEvent.click(trigger);+ expect(screen.getByRole('textbox', { name: '译文颜色 HEX' })).toHaveValue('#123ABC');+ fireEvent.pointerDown(screen.getByRole('combobox', { name: '输出画幅' }));+ expect(screen.queryByRole('dialog', { name: '译文颜色色板' })).not.toBeInTheDocument();+ });+it('uses the same preset and custom color controls for original, outline, and shadow', () => {render(<LanguageProvider initialPreference="zh-CN"><CreatorSessionProvider- initialJob={job({ status: 'draft', revision: 0, stages: [], state: { currentStep: 2, furthestStep: 2 } })}+ initialJob={job({ status: 'draft', revision: 0, stages: [], state: { currentStep: 2, furthestStep: 2, composeVideo: true } })}service={{ applyAction: vi.fn(), runAgentTurn: vi.fn() } as never}><VideoTranslationWorkspace onBack={vi.fn()} />@@ -322,13 +434,16 @@ describe('VideoTranslationWorkspace task controls', () => {</LanguageProvider>);+ fireEvent.click(screen.getByText('更多样式'));for (const label of ['原文颜色', '描边颜色', '阴影颜色']) {+ fireEvent.click(screen.getByRole('button', { name: `选择${label}` }));const preset = screen.getByRole('button', { name: `${label} #7EE7FF` });fireEvent.click(preset);expect(preset).toHaveAttribute('aria-pressed', 'true');- expect(screen.getByLabelText(label)).toHaveValue('#7ee7ff');+ expect(screen.getByRole('textbox', { name: `${label} HEX` })).toHaveValue('#7EE7FF');}- expect(screen.getAllByText('自定义')).toHaveLength(4);+ expect(screen.getAllByRole('slider')).toHaveLength(2);+ expect(screen.queryByText('自定义')).not.toBeInTheDocument();});it('uses the platform poster and actual dimensions when metadata provides them', async () => {@@ -344,7 +459,7 @@ describe('VideoTranslationWorkspace task controls', () => {<CreatorSessionProviderinitialJob={job({status: 'draft', revision: 0, stages: [],- state: { currentStep: 2, furthestStep: 2, sourceUrl: 'https://www.bilibili.com/video/BV1abc' }+ state: { currentStep: 2, furthestStep: 2, composeVideo: true, sourceUrl: 'https://www.bilibili.com/video/BV1abc' }})}service={{ applyAction: vi.fn(), runAgentTurn: vi.fn() } as never}>@@ -368,7 +483,7 @@ describe('VideoTranslationWorkspace task controls', () => {<CreatorSessionProviderinitialJob={job({status: 'draft', revision: 0, stages: [],- state: { currentStep: 2, furthestStep: 2, sourceUrl: 'https://www.youtube.com/shorts/portrait123' }+ state: { currentStep: 2, furthestStep: 2, composeVideo: true, sourceUrl: 'https://www.youtube.com/shorts/portrait123' }})}service={{ applyAction: vi.fn(), runAgentTurn: vi.fn() } as never}>@@ -390,7 +505,7 @@ describe('VideoTranslationWorkspace task controls', () => {<CreatorSessionProviderinitialJob={job({status: 'draft', revision: 0, stages: [],- state: { currentStep: 2, furthestStep: 2, sourceUrl: 'https://video.example.test/source.mp4' }+ state: { currentStep: 2, furthestStep: 2, composeVideo: true, sourceUrl: 'https://video.example.test/source.mp4' }})}service={{ applyAction: vi.fn(), runAgentTurn: vi.fn() } as never}>@@ -415,16 +530,51 @@ describe('VideoTranslationWorkspace task controls', () => {expect(preview).toHaveAttribute('data-ratio', '4:3');expect(preview.querySelector(':scope > div')).toHaveStyle({ '--subtitle-preview-aspect-ratio': '1440 / 1080' });- fireEvent.click(screen.getByRole('button', { name: '继续' }));- fireEvent.click(screen.getByRole('switch', { name: '合成字幕视频' }));- fireEvent.click(screen.getByRole('radio', { name: /9:16/ }));- fireEvent.click(within(screen.getByRole('navigation', { name: '翻译流程' })).getByRole('button', {- name: /字幕样式$/- }));+ fireEvent.change(screen.getByRole('combobox', { name: '输出画幅' }), { target: { value: 'vertical' } });expect(screen.getByRole('region', { name: '字幕样式预览' })).toHaveAttribute('data-ratio', '9:16');expect(screen.getByRole('region', { name: '字幕样式预览' })).toHaveAttribute('data-converted', 'true');});+ it('previews vertical titles live for portrait and dual output and hides them for landscape output', () => {+ render(+ <LanguageProvider initialPreference="zh-CN">+ <CreatorSessionProvider+ initialJob={job({+ status: 'draft', revision: 0, stages: [],+ state: { currentStep: 2, furthestStep: 2, composeVideo: true }+ })}+ service={{ applyAction: vi.fn(), runAgentTurn: vi.fn() } as never}+ >+ <VideoTranslationWorkspace onBack={vi.fn()} />+ </CreatorSessionProvider>+ </LanguageProvider>+ );++ const format = screen.getByRole('combobox', { name: '输出画幅' });+ const preview = screen.getByRole('region', { name: '字幕样式预览' });+ fireEvent.change(format, { target: { value: 'vertical' } });+ fireEvent.change(screen.getByRole('textbox', { name: /竖屏主标题/ }), { target: { value: '1111' } });+ fireEvent.change(screen.getByRole('textbox', { name: /竖屏副标题/ }), { target: { value: '2222' } });+ expect(within(preview).getByText('1111')).toBeVisible();+ expect(within(preview).getByText('2222')).toBeVisible();+ fireEvent.change(screen.getByRole('textbox', { name: /竖屏主标题/ }), { target: { value: '更新标题' } });+ expect(within(preview).queryByText('1111')).not.toBeInTheDocument();+ expect(within(preview).getByText('更新标题')).toBeVisible();++ fireEvent.change(format, { target: { value: 'all' } });+ expect(preview).toHaveAttribute('data-ratio', '9:16');+ expect(within(preview).getByText('更新标题')).toBeVisible();+ expect(within(preview).getByText('2222')).toBeVisible();++ fireEvent.change(format, { target: { value: 'horizontal' } });+ expect(within(preview).queryByText('更新标题')).not.toBeInTheDocument();+ expect(within(preview).queryByText('2222')).not.toBeInTheDocument();+ fireEvent.change(format, { target: { value: 'vertical' } });+ fireEvent.change(screen.getByRole('textbox', { name: /竖屏主标题/ }), { target: { value: '' } });+ expect(within(preview).queryByText('更新标题')).not.toBeInTheDocument();+ expect(within(preview).getByText('2222')).toBeVisible();+ });+it('uses a local video still and preserves its portrait 3:4 ratio', () => {const createObjectUrlDescriptor = Object.getOwnPropertyDescriptor(URL, 'createObjectURL');const revokeObjectUrlDescriptor = Object.getOwnPropertyDescriptor(URL, 'revokeObjectURL');@@ -457,6 +607,7 @@ describe('VideoTranslationWorkspace task controls', () => {fireEvent.loadedMetadata(sourceVideo);fireEvent.click(screen.getByRole('button', { name: '继续' }));fireEvent.click(screen.getByRole('button', { name: '继续' }));+ fireEvent.click(screen.getByRole('switch', { name: '合成字幕视频' }));const preview = screen.getByRole('region', { name: '字幕样式预览' });expect(preview).toHaveAttribute('data-ratio', '3:4');@@ -488,6 +639,7 @@ describe('VideoTranslationWorkspace task controls', () => {state: {currentStep: 2,furthestStep: 2,+ composeVideo: true,sourceType: 'file',sourceUrl: '',sourceFileName: 'saved.mp4',@@ -523,6 +675,7 @@ describe('VideoTranslationWorkspace task controls', () => {state: {currentStep: 2,furthestStep: 2,+ composeVideo: true,subtitleStyle: {fontPreset: 'sans',fontWeight: 'bold',@@ -581,22 +734,34 @@ describe('VideoTranslationWorkspace task controls', () => {fireEvent.change(screen.getByRole('combobox', { name: '字幕字体' }), {target: { value: 'rounded' }});- fireEvent.click(screen.getByRole('radio', { name: '常规' }));- fireEvent.click(screen.getByRole('radio', { name: '小' }));- fireEvent.change(screen.getByLabelText('自定义译文颜色'), {+ fireEvent.change(screen.getByRole('combobox', { name: '字幕字重' }), {+ target: { value: 'regular' }+ });+ fireEvent.change(screen.getByRole('combobox', { name: '字幕大小' }), {+ target: { value: 'small' }+ });+ fireEvent.click(screen.getByRole('button', { name: '选择译文颜色' }));+ fireEvent.change(screen.getByRole('textbox', { name: '译文颜色 HEX' }), {target: { value: '#123456' }});- fireEvent.change(screen.getByLabelText('原文颜色'), {+ fireEvent.click(screen.getByRole('button', { name: '选择原文颜色' }));+ fireEvent.change(screen.getByRole('textbox', { name: '原文颜色 HEX' }), {target: { value: '#654321' }});- fireEvent.change(screen.getByLabelText('描边颜色'), {+ const advancedStyles = screen.getByText('更多样式').closest('details');+ expect(advancedStyles).not.toHaveAttribute('open');+ fireEvent.click(screen.getByText('更多样式'));+ expect(advancedStyles).toHaveAttribute('open');+ fireEvent.click(screen.getByRole('button', { name: '选择描边颜色' }));+ fireEvent.change(screen.getByRole('textbox', { name: '描边颜色 HEX' }), {target: { value: '#111111' }});fireEvent.change(screen.getByRole('spinbutton', { name: '描边宽度' }), {target: { value: '3.5' }});fireEvent.click(screen.getByRole('switch', { name: '字幕阴影' }));- fireEvent.change(screen.getByLabelText('阴影颜色'), {+ fireEvent.click(screen.getByRole('button', { name: '选择阴影颜色' }));+ fireEvent.change(screen.getByRole('textbox', { name: '阴影颜色 HEX' }), {target: { value: '#222222' }});fireEvent.change(screen.getByRole('spinbutton', { name: '不透明度' }), {@@ -1305,8 +1470,16 @@ describe('VideoTranslationWorkspace task controls', () => {expect(screen.queryByText('任务状态刚刚发生变化,请重试一次。你的设置没有丢失。')).not.toBeInTheDocument();});expect(screen.getByText('翻译任务已开始,进度会实时同步到创作动态')).toBeInTheDocument();+ expect(within(workspace).getByText('翻译进行中')).toBeVisible();+ expect(within(workspace).queryByText('当前项目版本没有作品')).not.toBeInTheDocument();expect(within(workspace).getByRole('button', { name: '终止任务' })).toBeInTheDocument();expect(applyAction.mock.calls.filter(([, request]) => request.action === 'run-stage')).toHaveLength(1);+ act(() => currentSession!.applyRemoteSnapshot(job({+ status: 'completed', revision: 4, artifacts: [subtitleArtifact(1, '翻译完成')],+ stages: [stage({ id: 'stage_subtitle_started', status: 'succeeded', dispatchStatus: 'finished', progress: { resultVersion: 1 } })]+ })));+ expect(within(workspace).queryByText('翻译进行中')).not.toBeInTheDocument();+ expect(within(workspace).queryByText('翻译任务已开始,进度会实时同步到创作动态')).not.toBeInTheDocument();});});diff --git a/apps/web/src/features/dashboard/VideoTranslationWorkspace.tsx b/apps/web/src/features/dashboard/VideoTranslationWorkspace.tsxindex 24df5dd0..2f6cba90 100644--- a/apps/web/src/features/dashboard/VideoTranslationWorkspace.tsx+++ b/apps/web/src/features/dashboard/VideoTranslationWorkspace.tsx@@ -1,14 +1,17 @@import {useEffect,+ useId,+ useLayoutEffect,useMemo,useRef,useState,type CSSProperties} from 'react';+import { createPortal } from 'react-dom';+import { HexColorPicker } from 'react-colorful';import {ArrowLeft,ArrowRight,- Captions,Check,ChevronDown,FileVideo,@@ -18,7 +21,8 @@ import {MonitorPlay,Play,Sparkles,- Square+ Square,+ X} from 'lucide-react';import { TtsVoicePicker } from '../../components/tts/TtsVoicePicker.js';import { OfficialModelField, useOfficialServices } from './official-services.js';@@ -67,7 +71,7 @@ type SubtitleWeight = 'regular' | 'medium' | 'bold';type SubtitleSize = 'small' | 'medium' | 'large';type VideoFormat = 'horizontal' | 'vertical' | 'all';type VideoOrientation = 'landscape' | 'portrait';-type WizardStep = 0 | 1 | 2 | 3;+type WizardStep = 0 | 1 | 2;type WorkspacePhase = 'configure' | 'result';type ResultProposal = 'regenerate';type AgentFocus = 'language' | 'subtitles' | 'dubbing' | 'output';@@ -152,9 +156,9 @@ type LanguageOption = {label: string;};-const steps = ['添加视频', '翻译设置', '字幕样式', '配音与输出'] as const;+const steps = ['添加视频', '翻译设置', '视频与字幕'] as const;let componentNavigationDraft: { jobId: string | null; settings: TranslationSettingsSnapshot; source: TranslationSourceSnapshot; currentStep: WizardStep; furthestStep: WizardStep; workspacePhase: WorkspacePhase } | undefined;-const subtitleColors = ['#FFFFFF', '#FFE45C', '#7EE7FF', '#A7F3D0'] as const;+const subtitleColors = ['#FFFFFF', '#FFE45C', '#7EE7FF', '#A7F3D0', '#000000'] as const;const defaultSubtitleStyle: SubtitleStyleSettings = {subtitleFont: 'sans',subtitleWeight: 'bold',@@ -1451,38 +1455,155 @@ function SubtitlePreviewVideo(props: {function SubtitleColorControl(props: {label: string;- inputLabel: string;- customLabel: string;value: string;onChange(value: string): void;prefixPresetLabel?: boolean;}) {+ const l = useLocalizedCopy();+ const id = useId();+ const triggerRef = useRef<HTMLButtonElement>(null);+ const paletteRef = useRef<HTMLDivElement>(null);+ const [open, setOpen] = useState(false);+ const [hex, setHex] = useState(props.value.toUpperCase());+ const [position, setPosition] = useState<{ left: number; top: number; width: number; maxHeight: number; above: boolean }>();+ useEffect(() => { setHex(props.value.toUpperCase()); }, [props.value]);++ useLayoutEffect(() => {+ if (!open) return;+ const place = () => {+ const rect = triggerRef.current?.getBoundingClientRect();+ if (!rect) return;+ const viewport = window.visualViewport;+ const leftEdge = viewport?.offsetLeft ?? 0;+ const topEdge = viewport?.offsetTop ?? 0;+ const viewportWidth = viewport?.width ?? window.innerWidth;+ const bottomEdge = topEdge + (viewport?.height ?? window.innerHeight);+ const below = bottomEdge - rect.bottom - 14;+ const above = rect.top - topEdge - 14;+ const opensAbove = below < 360 && above > below;+ const width = Math.min(240, viewportWidth - 16);+ setPosition({+ left: Math.max(leftEdge + 8, Math.min(rect.left, leftEdge + viewportWidth - width - 8)),+ top: opensAbove ? rect.top - 6 : rect.bottom + 6,+ width,+ maxHeight: Math.max(0, Math.min(400, opensAbove ? above : below)),+ above: opensAbove+ });+ };+ place();+ window.addEventListener('resize', place);+ window.addEventListener('scroll', place, true);+ window.visualViewport?.addEventListener('resize', place);+ window.visualViewport?.addEventListener('scroll', place);+ return () => {+ window.removeEventListener('resize', place);+ window.removeEventListener('scroll', place, true);+ window.visualViewport?.removeEventListener('resize', place);+ window.visualViewport?.removeEventListener('scroll', place);+ };+ }, [open]);++ useEffect(() => {+ if (!open || !position) return;+ (paletteRef.current?.querySelector<HTMLButtonElement>('[aria-pressed="true"]')+ ?? paletteRef.current?.querySelector<HTMLButtonElement>('.video-translation-color-options > button'))?.focus();+ const onOutside = (event: Event) => {+ if (!triggerRef.current?.contains(event.target as Node) && !paletteRef.current?.contains(event.target as Node)) setOpen(false);+ };+ const onEscape = (event: KeyboardEvent) => {+ if (event.key !== 'Escape') return;+ event.preventDefault();+ event.stopPropagation();+ setOpen(false);+ triggerRef.current?.focus();+ };+ document.addEventListener('pointerdown', onOutside);+ document.addEventListener('focusin', onOutside);+ document.addEventListener('keydown', onEscape);+ return () => {+ document.removeEventListener('pointerdown', onOutside);+ document.removeEventListener('focusin', onOutside);+ document.removeEventListener('keydown', onEscape);+ };+ }, [open, position !== undefined]);++ function close() {+ setOpen(false);+ triggerRef.current?.focus();+ }+return (<div className="video-translation-style-control"><span>{props.label}</span>- <div className="video-translation-color-options">- {subtitleColors.map(color => (- <button- type="button"- aria-label={props.prefixPresetLabel ? `${props.label} ${color}` : color}- aria-pressed={props.value.toUpperCase() === color}- key={color}- style={{ '--subtitle-swatch-color': color } as CSSProperties}- onClick={() => props.onChange(color)}- >- {props.value.toUpperCase() === color ? <Check size={13} strokeWidth={2.4} aria-hidden="true" /> : null}+ <button+ type="button"+ className="video-translation-color-trigger"+ ref={triggerRef}+ aria-label={l(`选择${props.label}`, `Choose ${props.label.toLowerCase()}`)}+ title={props.label}+ aria-haspopup="dialog"+ aria-expanded={open}+ aria-controls={open ? id : undefined}+ onClick={() => { setHex(props.value.toUpperCase()); setOpen(value => !value); }}+ >+ <span className="video-translation-current-color" style={{ '--subtitle-swatch-color': props.value } as CSSProperties} />+ <span>{props.value.toUpperCase()}</span>+ <ChevronDown size={14} aria-hidden="true" />+ </button>+ {open && position ? createPortal(<div+ id={id}+ ref={paletteRef}+ className="video-translation-color-palette"+ role="dialog"+ aria-label={l(`${props.label}色板`, `${props.label} palette`)}+ style={{ left: position.left, top: position.top, width: position.width, maxHeight: position.maxHeight, transform: position.above ? 'translateY(-100%)' : undefined }}+ >+ <div className="video-translation-color-palette-heading">+ <strong>{props.label}</strong>+ <button type="button" aria-label={l('关闭色板', 'Close palette')} title={l('关闭色板', 'Close palette')} onClick={close}>+ <X size={14} aria-hidden="true" /></button>- ))}- <label className="video-translation-custom-color" title={props.customLabel}>+ </div>+ <HexColorPicker+ className="video-translation-color-picker"+ color={props.value}+ onChange={value => props.onChange(value.toUpperCase())}+ aria-label={l(`选择${props.label}`, `Choose ${props.label.toLowerCase()}`)}+ />+ <div className="video-translation-color-options">+ {subtitleColors.map(color => (+ <button+ type="button"+ aria-label={props.prefixPresetLabel ? `${props.label} ${color}` : color}+ title={color}+ aria-pressed={props.value.toUpperCase() === color}+ key={color}+ style={{ '--subtitle-swatch-color': color, '--subtitle-swatch-ink': color === '#000000' ? '#FFFFFF' : '#17191d' } as CSSProperties}+ onClick={() => props.onChange(color)}+ >+ {props.value.toUpperCase() === color ? <Check size={13} strokeWidth={2.4} aria-hidden="true" /> : null}+ </button>+ ))}+ </div>+ <div className="video-translation-custom-color-fields">+ <span className="video-translation-current-color" style={{ '--subtitle-swatch-color': props.value } as CSSProperties} /><input- type="color"- aria-label={props.inputLabel}- value={props.value}- onChange={event => props.onChange(event.target.value.toUpperCase())}+ className="video-translation-color-hex"+ type="text"+ aria-label={`${props.label} HEX`}+ placeholder="#RRGGBB"+ maxLength={7}+ spellCheck={false}+ value={hex}+ onChange={event => {+ const value = event.target.value;+ setHex(value);+ if (/^#?[0-9a-f]{6}$/i.test(value)) props.onChange(`#${value.replace(/^#/, '').toUpperCase()}`);+ }}+ onBlur={() => setHex(props.value.toUpperCase())}/>- <span>{props.customLabel}</span>- </label>- </div>+ </div>+ </div>, document.body) : null}</div>);}@@ -1495,6 +1616,10 @@ export default function VideoTranslationWorkspace(props: {runtimeDependencies?: RuntimeDependenciesController;}) {const l = useLocalizedCopy();+ const translationStartedNotice = l(+ '翻译任务已开始,进度会实时同步到创作动态',+ 'Translation started. Progress will appear in creation activity.'+ );const creatorSession = useOptionalCreatorSession();const officialSpeech = useOfficialServices('speech');const mediaPreviewContextRef = useRef({ session: creatorSession, localize: l });@@ -1542,12 +1667,13 @@ export default function VideoTranslationWorkspace(props: {const [subtitleShadowOffsetX, setSubtitleShadowOffsetX] = useState(defaultSubtitleStyle.subtitleShadowOffsetX);const [subtitleShadowOffsetY, setSubtitleShadowOffsetY] = useState(defaultSubtitleStyle.subtitleShadowOffsetY);const [subtitleShadowBlur, setSubtitleShadowBlur] = useState(defaultSubtitleStyle.subtitleShadowBlur);- const [dubbing, setDubbing] = useState(false);+ const [dubbingRequested, setDubbing] = useState(false);const [ttsProvider, setTtsProvider] = useState<CreatorTtsProvider>('openai');const [ttsModel, setTtsModel] = useState('gpt-4o-mini-tts');const [voiceCode, setVoiceCode] = useState('');const [voiceName, setVoiceName] = useState('');const [composeVideo, setComposeVideo] = useState(false);+ const dubbing = composeVideo && dubbingRequested;const [videoFormat, setVideoFormat] = useState<VideoFormat>('horizontal');const [sourceOrientation, setSourceOrientation] = useState<VideoOrientation>(() => (creatorSession?.state.sourceOrientation === 'portrait' ? 'portrait' : 'landscape'@@ -1577,7 +1703,7 @@ export default function VideoTranslationWorkspace(props: {&& ((currentUrlMetadata.parts?.length ?? 0) < 2 || currentUrlMetadata.selectedPart !== undefined))));useEffect(() => {- if (workspacePhase !== 'configure' || currentStep !== 2 || sourceType !== 'file'+ if (workspacePhase !== 'configure' || currentStep !== 2 || !composeVideo || sourceType !== 'file'|| videoFile === null || !videoFile.type.startsWith('video/')|| typeof URL.createObjectURL !== 'function') {setLocalPreviewUrl(undefined);@@ -1586,7 +1712,7 @@ export default function VideoTranslationWorkspace(props: {const url = URL.createObjectURL(videoFile);setLocalPreviewUrl({ file: videoFile, url });return () => URL.revokeObjectURL(url);- }, [workspacePhase, currentStep, sourceType, videoFile]);+ }, [workspacePhase, currentStep, composeVideo, sourceType, videoFile]);useEffect(() => {if (sourceType !== 'url' || !isValidVideoUrl(videoUrl)@@ -1681,10 +1807,10 @@ export default function VideoTranslationWorkspace(props: {if (typeof persisted.verticalTitle === 'string') setVerticalTitle(persisted.verticalTitle);if (typeof persisted.verticalSubtitle === 'string') setVerticalSubtitle(persisted.verticalSubtitle);if (persisted.currentStep === 0 || persisted.currentStep === 1 || persisted.currentStep === 2 || persisted.currentStep === 3) {- setCurrentStep(persisted.currentStep);+ setCurrentStep(persisted.currentStep === 3 ? 2 : persisted.currentStep);}if (persisted.furthestStep === 0 || persisted.furthestStep === 1 || persisted.furthestStep === 2 || persisted.furthestStep === 3) {- setFurthestStep(persisted.furthestStep);+ setFurthestStep(persisted.furthestStep === 3 ? 2 : persisted.furthestStep);}const artifactVersions = resultVersionsFromArtifacts(creatorSession.job.artifacts, persisted);const latest = artifactVersions.at(-1);@@ -1708,19 +1834,22 @@ export default function VideoTranslationWorkspace(props: {}if (latest !== undefined) {if (!shouldRestoreLatestResult) return;- setCurrentStep(3);- setFurthestStep(3);+ setCurrentStep(2);+ setFurthestStep(2);setResultVersion(persistedVersion?.value ?? latest.value);setDraftBaseVersion(latest.value);setResultTab('video');setWorkspacePhase('result');} else if (shouldRestoreLatestResult) {setDraftBaseVersion(undefined);- setWorkspacePhase('configure');+ setWorkspacePhase(creatorSession.job.status !== 'draft'+ && creatorSession.job.stages.some(stage => ['subtitle', 'tts', 'render-horizontal', 'render-vertical'].includes(stage.stageId))+ ? 'result' : 'configure');}}, [creatorSession?.job.id, creatorSession?.job.revision]);useEffect(() => {+ if (!composeVideo) return;if (officialSpeech.official) {setTtsProvider('openai'); setTtsModel(officialSpeech.model?.id ?? '');const voices = officialSpeech.model?.voices ?? [];@@ -1766,7 +1895,7 @@ export default function VideoTranslationWorkspace(props: {return () => {active = false;};- }, [creatorSession?.job.id, props.creatorServicesService, officialSpeech.official, officialSpeech.model?.id]);+ }, [composeVideo, creatorSession?.job.id, props.creatorServicesService, officialSpeech.official, officialSpeech.model?.id]);useEffect(() => {if (creatorSession === null) return;@@ -1975,7 +2104,7 @@ export default function VideoTranslationWorkspace(props: {const [artifactPreviewUrl, setArtifactPreviewUrl] = useState<{ artifactId: string; url: string }>();useEffect(() => {const { session, localize } = mediaPreviewContextRef.current;- if (workspacePhase !== 'configure' || currentStep !== 2 || sourceType !== 'file'+ if (workspacePhase !== 'configure' || currentStep !== 2 || !composeVideo || sourceType !== 'file'|| videoFile !== null || registeredSourceArtifact === undefined|| session === null || !canOpenMediaPreview) {setArtifactPreviewUrl(undefined);@@ -2000,7 +2129,7 @@ export default function VideoTranslationWorkspace(props: {canceled = true;if (objectUrl !== undefined) URL.revokeObjectURL(objectUrl);};- }, [workspacePhase, currentStep, sourceType, videoFile, registeredSourceArtifact?.id,+ }, [workspacePhase, currentStep, composeVideo, sourceType, videoFile, registeredSourceArtifact?.id,canOpenMediaPreview, mediaPreviewJobId]);const previewVideoSrc = sourceType === 'file'@@ -2025,7 +2154,8 @@ export default function VideoTranslationWorkspace(props: {const sourceIsPortrait = shortVideo || (knownDimensions === undefined? sourceOrientation === 'portrait': knownDimensions.height > knownDimensions.width);- const convertedToVertical = videoFormat === 'vertical' && !sourceIsPortrait;+ const previewVerticalOutput = videoFormat === 'vertical' || videoFormat === 'all';+ const convertedToVertical = previewVerticalOutput && !sourceIsPortrait;const previewWidth = convertedToVertical ? 9 : knownDimensions?.width ?? (sourceIsPortrait ? 9 : 16);const previewHeight = convertedToVertical ? 16 : knownDimensions?.height ?? (sourceIsPortrait ? 16 : 9);const selectedFileRegistered = videoFile !== null@@ -2083,14 +2213,11 @@ export default function VideoTranslationWorkspace(props: {}setWorkspacePhase('result');setDraftBaseVersion(undefined);- setResultNotice(l(- '翻译任务已开始,进度会实时同步到创作动态',- 'Translation started. Progress will appear in creation activity.'- ));+ setResultNotice(translationStartedNotice);}, [activeStage,creatorSession,- l,+ translationStartedNotice,startRevisionConflict]);const sourceName = sourceType === 'url'@@ -2104,12 +2231,31 @@ export default function VideoTranslationWorkspace(props: {const summaryItems = useMemo(() => [{ label: l('翻译语言', 'Languages'), value: `${languageLabel(sourceLanguages, sourceLanguage)} → ${languageLabel(targetLanguages, targetLanguage)}` },{ label: l('字幕', 'Subtitles'), value: bilingual ? l(`双语 · 译文在${subtitlePosition === 'top' ? '上' : '下'}`, `Bilingual · translation ${subtitlePosition === 'top' ? 'above' : 'below'}`) : l('仅译文', 'Translation only') },- { label: l('字幕样式', 'Subtitle style'), value: subtitleStyleLabel },- { label: l('配音', 'Dubbing'), value: dubbing ? (voiceName.trim() || voiceCode.trim() || l('自动匹配音色', 'Auto-match voice')) : l('关闭', 'Off') },+ ...(composeVideo ? [{ label: l('字幕样式', 'Subtitle style'), value: subtitleStyleLabel }] : []),+ ...(composeVideo ? [{ label: l('配音', 'Dubbing'), value: dubbing ? (voiceName.trim() || voiceCode.trim() || l('自动匹配音色', 'Auto-match voice')) : l('关闭', 'Off') }] : []),{ label: l('输出', 'Output'), value: outputLabel }- ], [bilingual, dubbing, l, outputLabel, sourceLanguage, subtitlePosition, subtitleStyleLabel, targetLanguage, voiceCode, voiceName]);+ ], [bilingual, composeVideo, dubbing, l, outputLabel, sourceLanguage, subtitlePosition, subtitleStyleLabel, targetLanguage, voiceCode, voiceName]);const targetLanguageLabel = languageLabel(targetLanguages, targetLanguage);const selectedResult = resultVersions.find(version => version.value === resultVersion);+ const generationStage = [...(creatorSession?.job.stages ?? [])].reverse().find(stage => (+ ['subtitle', 'tts', 'render-horizontal', 'render-vertical'].includes(stage.stageId)+ ));+ const generationVersion = generationStage === undefined ? undefined+ : readPositiveResultVersion(generationStage.progress.targetResultVersion)+ ?? readPositiveResultVersion(generationStage.progress.resultVersion)+ ?? (typeof generationStage.progress.baseResultVersion === 'number'+ ? (resultVersions.at(-1)?.value ?? 0) + 1+ : selectedResult === undefined ? resultVersion : undefined);+ const generationStatus = creatorSession?.job.status === 'needs_input'+ ? 'needs_input' as const+ : creatorSession?.job.status === 'running' && generationStage?.status === 'succeeded' && activeStage === undefined+ ? 'running' as const : generationStage?.status;+ const resultExecution = generationVersion === resultVersion && generationStage !== undefined+ && generationStatus !== undefined && generationStatus !== 'succeeded'+ ? { status: generationStatus, stageLabel: generationStage.status === 'succeeded' && generationStatus === 'running'+ ? l('准备下一阶段', 'Preparing the next stage')+ : translationStageLabel(generationStage.stageId, l) }+ : undefined;const selectedResultSettings = selectedResult?.settings;const selectedVideoArtifacts = videoArtifactsForResultVersion(jobArtifacts,@@ -2360,7 +2506,7 @@ export default function VideoTranslationWorkspace(props: {const selectedSubtitleStyleLabel = selectedResultSettings? `${subtitleFontLabel(selectedResultSettings.subtitleFont, l)} · ${subtitleWeightLabel(selectedResultSettings.subtitleWeight, l)} · ${subtitleSizeLabel(selectedResultSettings.subtitleSize, l)} · ${selectedResultSettings.subtitleColor.toUpperCase()}`: subtitleStyleLabel;- const selectedSourceName = selectedResultSource?.sourceType === 'url'+ const selectedSourceName = selectedResultSource === undefined ? sourceName : selectedResultSource.sourceType === 'url'? (selectedResultSource.videoUrl.trim() || l('等待填写链接', 'Waiting for a link')): (selectedResultSource?.videoFile?.name?? selectedResultSource?.videoFileName@@ -2381,7 +2527,10 @@ export default function VideoTranslationWorkspace(props: {return artifact === undefined ? [] : [artifact.kind];}));- const visibleResultNotice = resultNotice || (selectedHasStaleArtifacts+ const currentResultNotice = resultNotice === translationStartedNotice+ && resultExecution?.status !== 'running' && resultExecution?.status !== 'queued'+ ? '' : resultNotice;+ const visibleResultNotice = currentResultNotice || (selectedHasStaleArtifacts? l('当前项目版本中的部分配音或成片基于较早内容,可继续使用;重新生成后会更新引用。','Some dubbing or video outputs in this project version are based on earlier content. They remain usable until regenerated.'@@ -2403,9 +2552,9 @@ export default function VideoTranslationWorkspace(props: {? sourceName: currentStep === 1? `${languageLabel(sourceLanguages, sourceLanguage)} → ${targetLanguageLabel}`- : currentStep === 2- ? subtitleStyleLabel- : `${dubbing ? l('配音开启', 'Dubbing on') : l('无配音', 'No dubbing')}, ${outputLabel}`;+ : composeVideo+ ? `${outputLabel} · ${subtitleStyleLabel} · ${dubbing ? l('配音开启', 'Dubbing on') : l('无配音', 'No dubbing')}`+ : outputLabel;function openWizardStep(step: WizardStep) {if (step > 0 && !sourceSelectionReady) {setCurrentStep(0);@@ -2511,7 +2660,7 @@ export default function VideoTranslationWorkspace(props: {}, 1800);}- function openAgentConfiguration(step: Extract<WizardStep, 1 | 3>, focus: AgentFocus) {+ function openAgentConfiguration(step: Extract<WizardStep, 1 | 2>, focus: AgentFocus) {if (workspacePhase === 'result' && selectedResult) {if (draftBaseVersion !== selectedResult.value) {applySourceSnapshot(selectedResult.source);@@ -2802,10 +2951,7 @@ export default function VideoTranslationWorkspace(props: {`新版本已从“${translationStageLabel(stageId, l)}”开始,已有前置产物会直接复用`,`The new version started from "${translationStageLabel(stageId, l)}" and will reuse existing upstream outputs.`)- : l(- '翻译任务已开始,进度会实时同步到创作动态',- 'Translation started. Progress will appear in creation activity.'- ));+ : translationStartedNotice);} catch (cause) {if ((cause as { code?: unknown })?.code === 'creator_revision_conflict') {setStartRevisionConflict(true);@@ -3000,7 +3146,7 @@ export default function VideoTranslationWorkspace(props: {setDraftBaseVersion(selectedResult.value);setWorkspacePhase('configure');setCurrentStep(1);- setFurthestStep(3);+ setFurthestStep(2);setResultProposal(undefined);setResultNotice('');}@@ -3086,7 +3232,6 @@ export default function VideoTranslationWorkspace(props: {{workspacePhase === 'configure' ? (<div className="video-translation-configure-top"><LocalTranscriptionNotice controller={props.runtimeDependencies}- platformCaptions={sourceType === 'url' && (videoUrl.trim() === '' || parseVideoSource(videoUrl).kind === 'youtube') && preferPlatformCaptions}importedSubtitle={typeof creatorSession?.state.importedSourceSubtitleId === 'string' || typeof creatorSession?.state.importedTargetSubtitleId === 'string'}beforeNavigate={preserveComponentNavigationDraft} />{draftBaseVersion !== undefined ? (@@ -3135,7 +3280,7 @@ export default function VideoTranslationWorkspace(props: {targetLanguage={selectedTargetLanguageLabel}outputLabel={selectedOutputLabel}subtitleStyleLabel={selectedSubtitleStyleLabel}- dubbing={selectedResultSettings?.dubbing ?? false}+ dubbing={selectedResultSettings?.dubbing ?? (composeVideo && dubbing)}hasVoiceArtifact={hasVoiceArtifact}videoOutputs={videoOutputs}subtitleOutputs={subtitleOutputs}@@ -3150,6 +3295,7 @@ export default function VideoTranslationWorkspace(props: {affectedArtifacts={regenerationArtifacts}hasPendingChanges={hasPendingChanges}regenerationPending={resultProposal === 'regenerate'}+ execution={resultExecution}notice={visibleResultNotice}onTabChange={tab => {setResultTab(tab);@@ -3282,330 +3428,324 @@ export default function VideoTranslationWorkspace(props: {) : null}{workspacePhase === 'configure' && currentStep === 2 ? (- <section className="video-translation-step-panel video-translation-subtitle-style" aria-labelledby="subtitle-style-title">- <div className="video-translation-step-heading">- <h2 id="subtitle-style-title">{l('设置字幕样式', 'Set subtitle style')}</h2>- <p>{l('调整字幕字体、大小和颜色,并实时预览显示效果', 'Choose the subtitle font, size, and color with a live preview')}</p>- </div>-- <div className="video-translation-subtitle-style-layout">- <div className="video-translation-subtitle-controls">- <label className="video-translation-field">- <span>{l('字幕字体', 'Subtitle font')}</span>- <div className="video-translation-select-wrap">- <select- aria-label={l('字幕字体', 'Subtitle font')}- value={subtitleFont}- onChange={event => setSubtitleFont(event.target.value as SubtitleFont)}- >- <option value="system">{l('系统默认', 'System default')}</option>- <option value="sans">{l('无衬线', 'Sans serif')}</option>- <option value="serif">{l('衬线', 'Serif')}</option>- <option value="rounded">{l('圆体', 'Rounded')}</option>- </select>- <ChevronDown size={15} strokeWidth={1.8} aria-hidden="true" />- </div>- </label>-- <div className="video-translation-style-control">- <span>{l('字重', 'Font weight')}</span>- <div className="video-translation-size-options" role="radiogroup" aria-label={l('字幕字重', 'Subtitle font weight')}>- {(['regular', 'medium', 'bold'] as const).map(weight => (- <button- type="button"- role="radio"- aria-checked={subtitleWeight === weight}- key={weight}- onClick={() => setSubtitleWeight(weight)}- >- {subtitleWeightLabel(weight, l)}- </button>- ))}- </div>- </div>-- <div className="video-translation-style-control">- <span>{l('字幕大小', 'Subtitle size')}</span>- <div className="video-translation-size-options" role="radiogroup" aria-label={l('字幕大小', 'Subtitle size')}>- {(['small', 'medium', 'large'] as const).map(size => (- <button- type="button"- role="radio"- aria-checked={subtitleSize === size}- key={size}- onClick={() => setSubtitleSize(size)}- >- {subtitleSizeLabel(size, l)}- </button>- ))}- </div>- </div>+ <div className="video-translation-output-settings">+ <section className="video-translation-step-panel video-translation-subtitle-style" aria-labelledby="subtitle-style-title">+ <div className="video-translation-step-heading">+ <h2 id="subtitle-style-title">{l('视频与字幕', 'Video & subtitles')}</h2>+ </div>- <SubtitleColorControl- label={l('译文颜色', 'Translation color')}- inputLabel={l('自定义译文颜色', 'Custom translation color')}- customLabel={l('自定义', 'Custom')}- value={subtitleColor}- onChange={setSubtitleColor}- />-- <SubtitleColorControl- label={l('原文颜色', 'Original color')}- inputLabel={l('原文颜色', 'Original color')}- customLabel={l('自定义', 'Custom')}- value={subtitleSecondaryColor}- onChange={setSubtitleSecondaryColor}- prefixPresetLabel- />-- <div className="video-translation-outline-fields">- <SubtitleColorControl- label={l('描边颜色', 'Outline color')}- inputLabel={l('描边颜色', 'Outline color')}- customLabel={l('自定义', 'Custom')}- value={subtitleOutlineColor}- onChange={setSubtitleOutlineColor}- prefixPresetLabel+ <div className="video-translation-option-block" data-agent-focus={agentFocus === 'output'}>+ <div className="video-translation-option-title">+ <span className="video-translation-option-icon"><MonitorPlay size={17} strokeWidth={1.8} /></span>+ <Switch+ checked={composeVideo}+ label={l('合成字幕视频', 'Render subtitled video')}+ description={l('将字幕直接嵌入成片', 'Embed subtitles directly in the final video')}+ onChange={setComposeVideo}/>+ </div>+ </div>+ {composeVideo ? (+ <div className="video-translation-output-format-settings"><label className="video-translation-field">- <span>{l('描边宽度', 'Outline width')}</span>- <input- type="number"- min="0"- max="8"- step="0.5"- value={subtitleOutlineWidth}- onChange={event => setSubtitleOutlineWidth(Number(event.target.value))}- />+ <span>{l('输出画幅', 'Output format')}</span>+ <div className="video-translation-select-wrap">+ <select+ aria-label={l('输出画幅', 'Output format')}+ value={videoFormat}+ onChange={event => setVideoFormat(event.target.value as VideoFormat)}+ >+ {([+ ['horizontal', '16:9', '横屏'],+ ['vertical', '9:16', '竖屏'],+ ['all', '双画幅', '全部']+ ] as const).map(([value, ratio, label]) => (+ <option+ value={value}+ disabled={sourceOrientation === 'portrait' && value !== 'vertical'}+ title={sourceOrientation === 'portrait' && value !== 'vertical'+ ? l('竖屏源视频仅支持竖屏输出', 'Portrait source videos only support portrait output')+ : undefined}+ key={value}+ >+ {value === 'all' ? l('双画幅', '16:9 + 9:16') : ratio} {localizeFormatLabel(label, l)}+ </option>+ ))}+ </select>+ <ChevronDown size={15} strokeWidth={1.8} aria-hidden="true" />+ </div></label>+ {videoFormat === 'vertical' || videoFormat === 'all' ? (+ <div className="video-translation-title-fields">+ <label className="video-translation-field">+ <span>{l('竖屏主标题', 'Vertical video title')} <small>{l('选填', 'Optional')}</small></span>+ <input value={verticalTitle} onChange={event => setVerticalTitle(event.target.value)} placeholder={l('留空将自动生成', 'Leave blank to generate automatically')} />+ </label>+ <label className="video-translation-field">+ <span>{l('竖屏副标题', 'Vertical video subtitle')} <small>{l('选填', 'Optional')}</small></span>+ <input value={verticalSubtitle} onChange={event => setVerticalSubtitle(event.target.value)} placeholder={l('留空将自动生成', 'Leave blank to generate automatically')} />+ </label>+ </div>+ ) : null}</div>+ ) : null}- <div className="video-translation-shadow-settings">- <Switch- checked={subtitleShadowEnabled}- label={l('字幕阴影', 'Subtitle shadow')}- description={l('为字幕增加可控阴影,提高复杂画面上的可读性', 'Add a controlled shadow for readability on detailed footage')}- onChange={setSubtitleShadowEnabled}- />- {subtitleShadowEnabled ? (- <>- <SubtitleColorControl- label={l('阴影颜色', 'Shadow color')}- inputLabel={l('阴影颜色', 'Shadow color')}- customLabel={l('自定义', 'Custom')}- value={subtitleShadowColor}- onChange={setSubtitleShadowColor}- prefixPresetLabel- />- <div className="video-translation-style-fields">- <label className="video-translation-field">- <span>{l('不透明度', 'Opacity')}</span>- <input- type="number"- min="0"- max="1"- step="0.05"- value={subtitleShadowOpacity}- onChange={event => setSubtitleShadowOpacity(Number(event.target.value))}+ {composeVideo ? (+ <>+ <div className="video-translation-subtitle-style-layout">+ <div+ className="video-translation-subtitle-preview"+ data-ratio={aspectRatioLabel(previewWidth, previewHeight)}+ data-orientation={previewHeight > previewWidth ? 'portrait' : 'landscape'}+ data-converted={convertedToVertical}+ role="region"+ aria-label={l('字幕样式预览', 'Subtitle style preview')}+ >+ <span>{l('字幕样式预览', 'Subtitle style preview')}</span>+ <div+ style={{+ '--subtitle-preview-aspect-ratio': `${previewWidth} / ${previewHeight}`,+ '--subtitle-preview-color': subtitleColor,+ '--subtitle-preview-secondary-color': subtitleSecondaryColor,+ '--subtitle-preview-outline-color': subtitleOutlineColor,+ '--subtitle-preview-outline-width': `${subtitleOutlineWidth}px`,+ '--subtitle-preview-shadow': subtitleShadowEnabled+ ? `${subtitleShadowOffsetX}px ${subtitleShadowOffsetY}px ${subtitleShadowBlur}px color-mix(in srgb, ${subtitleShadowColor} ${Math.round(subtitleShadowOpacity * 100)}%, transparent)`+ : 'none',+ '--subtitle-preview-font-size': ({ small: '14px', medium: '16px', large: '18px' } as const)[subtitleSize],+ '--subtitle-preview-font-family': subtitleFontFamily(subtitleFont, subtitleWeight),+ '--subtitle-preview-font-weight': ({ regular: 400, medium: 500, bold: 700 } as const)[subtitleWeight]+ } as CSSProperties}+ >+ {previewPosterUrl ? (+ <img+ className="video-translation-subtitle-preview-media"+ src={previewPosterUrl}+ alt=""+ aria-hidden="true"+ onError={event => { event.currentTarget.hidden = true; }}/>- </label>+ ) : null}+ {previewVideoSrc ? (+ <SubtitlePreviewVideo key={previewVideoSrc} src={previewVideoSrc} onDimensions={updateSourceOrientation} />+ ) : null}+ {previewVerticalOutput && (verticalTitle.trim() || verticalSubtitle.trim()) ? (+ <div className="video-translation-subtitle-preview-titles">+ {verticalTitle.trim() ? <div data-title-kind="major">{verticalTitle}</div> : null}+ {verticalSubtitle.trim() ? <div data-title-kind="minor">{verticalSubtitle}</div> : null}+ </div>+ ) : null}+ <div className="video-translation-subtitle-preview-cues">+ {bilingual && subtitlePosition === 'bottom' ? (+ <small data-subtitle-kind="original">{l('这是一段原文字幕', 'This is an original subtitle')}</small>+ ) : null}+ <strong data-subtitle-kind="translation">{l('这是一段译文字幕', 'This is a translated subtitle')}</strong>+ {bilingual && subtitlePosition === 'top' ? (+ <small data-subtitle-kind="original">{l('这是一段原文字幕', 'This is an original subtitle')}</small>+ ) : null}+ </div>+ </div>+ </div>+ <div className="video-translation-subtitle-controls">+ <h3 className="video-translation-subtitle-style-title">{l('字幕样式', 'Subtitle style')}</h3>+ <div className="video-translation-typography-fields"><label className="video-translation-field">- <span>{l('水平偏移', 'Horizontal offset')}</span>- <input- type="number"- min="-20"- max="20"- step="1"- value={subtitleShadowOffsetX}- onChange={event => setSubtitleShadowOffsetX(Number(event.target.value))}- />+ <span>{l('字幕字体', 'Subtitle font')}</span>+ <div className="video-translation-select-wrap">+ <select+ aria-label={l('字幕字体', 'Subtitle font')}+ value={subtitleFont}+ onChange={event => setSubtitleFont(event.target.value as SubtitleFont)}+ >+ <option value="system">{l('系统默认', 'System default')}</option>+ <option value="sans">{l('无衬线', 'Sans serif')}</option>+ <option value="serif">{l('衬线', 'Serif')}</option>+ <option value="rounded">{l('圆体', 'Rounded')}</option>+ </select>+ <ChevronDown size={15} strokeWidth={1.8} aria-hidden="true" />+ </div></label>+<label className="video-translation-field">- <span>{l('垂直偏移', 'Vertical offset')}</span>- <input- type="number"- min="-20"- max="20"- step="1"- value={subtitleShadowOffsetY}- onChange={event => setSubtitleShadowOffsetY(Number(event.target.value))}- />+ <span>{l('字重', 'Font weight')}</span>+ <div className="video-translation-select-wrap">+ <select+ aria-label={l('字幕字重', 'Subtitle font weight')}+ value={subtitleWeight}+ onChange={event => setSubtitleWeight(event.target.value as SubtitleWeight)}+ >+ {(['regular', 'medium', 'bold'] as const).map(weight => (+ <option key={weight} value={weight}>{subtitleWeightLabel(weight, l)}</option>+ ))}+ </select>+ <ChevronDown size={15} strokeWidth={1.8} aria-hidden="true" />+ </div></label>+<label className="video-translation-field">- <span>{l('模糊', 'Blur')}</span>- <input- type="number"- min="0"- max="10"- step="0.5"- value={subtitleShadowBlur}- onChange={event => setSubtitleShadowBlur(Number(event.target.value))}- />+ <span>{l('字幕大小', 'Subtitle size')}</span>+ <div className="video-translation-select-wrap">+ <select+ aria-label={l('字幕大小', 'Subtitle size')}+ value={subtitleSize}+ onChange={event => setSubtitleSize(event.target.value as SubtitleSize)}+ >+ {(['small', 'medium', 'large'] as const).map(size => (+ <option key={size} value={size}>{subtitleSizeLabel(size, l)}</option>+ ))}+ </select>+ <ChevronDown size={15} strokeWidth={1.8} aria-hidden="true" />+ </div></label></div>- </>- ) : null}- </div>- </div>-- <div- className="video-translation-subtitle-preview"- data-ratio={aspectRatioLabel(previewWidth, previewHeight)}- data-orientation={previewHeight > previewWidth ? 'portrait' : 'landscape'}- data-converted={convertedToVertical}- role="region"- aria-label={l('字幕样式预览', 'Subtitle style preview')}- >- <span>{l('字幕样式预览', 'Subtitle style preview')}</span>- <div- style={{- '--subtitle-preview-aspect-ratio': `${previewWidth} / ${previewHeight}`,- '--subtitle-preview-color': subtitleColor,- '--subtitle-preview-secondary-color': subtitleSecondaryColor,- '--subtitle-preview-outline-color': subtitleOutlineColor,- '--subtitle-preview-outline-width': `${subtitleOutlineWidth}px`,- '--subtitle-preview-shadow': subtitleShadowEnabled- ? `${subtitleShadowOffsetX}px ${subtitleShadowOffsetY}px ${subtitleShadowBlur}px color-mix(in srgb, ${subtitleShadowColor} ${Math.round(subtitleShadowOpacity * 100)}%, transparent)`- : 'none',- '--subtitle-preview-font-size': ({ small: '14px', medium: '16px', large: '18px' } as const)[subtitleSize],- '--subtitle-preview-font-family': subtitleFontFamily(subtitleFont, subtitleWeight),- '--subtitle-preview-font-weight': ({ regular: 400, medium: 500, bold: 700 } as const)[subtitleWeight]- } as CSSProperties}- >- {previewPosterUrl ? (- <img- className="video-translation-subtitle-preview-media"- src={previewPosterUrl}- alt=""- aria-hidden="true"- onError={event => { event.currentTarget.hidden = true; }}- />- ) : null}- {previewVideoSrc ? (- <SubtitlePreviewVideo key={previewVideoSrc} src={previewVideoSrc} onDimensions={updateSourceOrientation} />- ) : null}- <div className="video-translation-subtitle-preview-cues">- {bilingual && subtitlePosition === 'bottom' ? (- <small data-subtitle-kind="original">{l('这是一段原文字幕', 'This is an original subtitle')}</small>- ) : null}- <strong data-subtitle-kind="translation">{l('这是一段译文字幕', 'This is a translated subtitle')}</strong>- {bilingual && subtitlePosition === 'top' ? (- <small data-subtitle-kind="original">{l('这是一段原文字幕', 'This is an original subtitle')}</small>- ) : null}- </div>- </div>- </div>- </div>- </section>- ) : null}- {workspacePhase === 'configure' && currentStep === 3 ? (- <div className="video-translation-final-grid">- <section className="video-translation-step-panel video-translation-final-settings" aria-labelledby="output-settings-title">- <div className="video-translation-step-heading">- <h2 id="output-settings-title">{l('选择输出内容', 'Choose output')}</h2>- <p>{l('按需生成配音和多画幅成片', 'Generate dubbing and videos in the formats you need')}</p>- </div>+ <div className="video-translation-style-fields">+ <SubtitleColorControl+ label={l('译文颜色', 'Translation color')}+ value={subtitleColor}+ onChange={setSubtitleColor}+ />++ {bilingual ? <SubtitleColorControl+ label={l('原文颜色', 'Original color')}+ value={subtitleSecondaryColor}+ onChange={setSubtitleSecondaryColor}+ prefixPresetLabel+ /> : null}+ </div>- <div className="video-translation-option-block" data-agent-focus={agentFocus === 'dubbing'}>- <div className="video-translation-option-title">- <span className="video-translation-option-icon"><Mic2 size={17} strokeWidth={1.8} /></span>- <Switch- checked={dubbing}- label={l('生成目标语言配音', 'Generate target-language dubbing')}- description={l('匹配翻译后的语速与停顿', 'Match the translated pacing and pauses')}- onChange={value => {- setDubbing(value);- }}- />- </div>- {dubbing ? (- <div className="video-translation-option-content">- {officialSpeech.official ? <OfficialModelField label={l('语音合成模型', 'Speech model')} service={officialSpeech} /> : <div className="video-translation-voice-source">- <strong>{ttsProviderLabel(ttsProvider, l)}</strong>- <small>{ttsModel || l('本地语音服务', 'Local speech service')}</small>- </div>}- <TtsVoicePicker- id="video-translation-voice"- provider={ttsProvider}- model={ttsModel}- value={voiceCode}- service={props.creatorServicesService ?? null}- label={l('配音音色', 'Dubbing voice')}- onChange={(voiceId, voice) => {- setVoiceCode(voiceId);- setVoiceName(voice?.name ?? voiceId);- }}- onVoiceResolved={voice => setVoiceName(voice.name)}- />+ <details className="video-translation-advanced-style">+ <summary>+ {l('更多样式', 'More styles')}+ <ChevronDown size={15} strokeWidth={1.8} aria-hidden="true" />+ </summary>+ <div className="video-translation-advanced-style-content">+ <div className="video-translation-outline-fields">+ <SubtitleColorControl+ label={l('描边颜色', 'Outline color')}+ value={subtitleOutlineColor}+ onChange={setSubtitleOutlineColor}+ prefixPresetLabel+ />+ <label className="video-translation-field">+ <span>{l('描边宽度', 'Outline width')}</span>+ <input+ type="number"+ min="0"+ max="8"+ step="0.5"+ value={subtitleOutlineWidth}+ onChange={event => setSubtitleOutlineWidth(Number(event.target.value))}+ />+ </label>+ </div>++ <div className="video-translation-shadow-settings">+ <Switch+ checked={subtitleShadowEnabled}+ label={l('字幕阴影', 'Subtitle shadow')}+ description={l('为字幕增加可控阴影,提高复杂画面上的可读性', 'Add a controlled shadow for readability on detailed footage')}+ onChange={setSubtitleShadowEnabled}+ />+ {subtitleShadowEnabled ? (+ <>+ <SubtitleColorControl+ label={l('阴影颜色', 'Shadow color')}+ value={subtitleShadowColor}+ onChange={setSubtitleShadowColor}+ prefixPresetLabel+ />+ <div className="video-translation-style-fields">+ <label className="video-translation-field">+ <span>{l('不透明度', 'Opacity')}</span>+ <input+ type="number"+ min="0"+ max="1"+ step="0.05"+ value={subtitleShadowOpacity}+ onChange={event => setSubtitleShadowOpacity(Number(event.target.value))}+ />+ </label>+ <label className="video-translation-field">+ <span>{l('水平偏移', 'Horizontal offset')}</span>+ <input+ type="number"+ min="-20"+ max="20"+ step="1"+ value={subtitleShadowOffsetX}+ onChange={event => setSubtitleShadowOffsetX(Number(event.target.value))}+ />+ </label>+ <label className="video-translation-field">+ <span>{l('垂直偏移', 'Vertical offset')}</span>+ <input+ type="number"+ min="-20"+ max="20"+ step="1"+ value={subtitleShadowOffsetY}+ onChange={event => setSubtitleShadowOffsetY(Number(event.target.value))}+ />+ </label>+ <label className="video-translation-field">+ <span>{l('模糊', 'Blur')}</span>+ <input+ type="number"+ min="0"+ max="10"+ step="0.5"+ value={subtitleShadowBlur}+ onChange={event => setSubtitleShadowBlur(Number(event.target.value))}+ />+ </label>+ </div>+ </>+ ) : null}+ </div>+ </div>+ </details>+ </div></div>- ) : null}- </div>-- <div className="video-translation-option-block" data-agent-focus={agentFocus === 'output'}>- <div className="video-translation-option-title">- <span className="video-translation-option-icon"><MonitorPlay size={17} strokeWidth={1.8} /></span>- <Switch- checked={composeVideo}- label={l('合成字幕视频', 'Render subtitled video')}- description={l('将字幕直接嵌入成片', 'Embed subtitles directly in the final video')}- onChange={value => {- setComposeVideo(value);- }}- />- </div>- {composeVideo ? (- <div className="video-translation-option-content">- <div className="video-translation-format" role="radiogroup" aria-label={l('输出画幅', 'Output format')}>- {([- ['horizontal', '16:9', '横屏'],- ['vertical', '9:16', '竖屏'],- ['all', '双画幅', '全部']- ] as const).map(([value, ratio, label]) => (- <button- type="button"- role="radio"- aria-checked={videoFormat === value}- disabled={sourceOrientation === 'portrait' && value !== 'vertical'}- title={sourceOrientation === 'portrait' && value !== 'vertical'- ? l('竖屏源视频仅支持竖屏输出', 'Portrait source videos only support portrait output')- : undefined}- key={value}- onClick={() => {- setVideoFormat(value);- }}- >- <span>{value === 'all' ? l('双画幅', '16:9 + 9:16') : ratio}</span>- <small>{localizeFormatLabel(label, l)}</small>- {videoFormat === value ? <Check size={14} strokeWidth={2} aria-hidden="true" /> : null}- </button>- ))}+ <div className="video-translation-option-block video-translation-dubbing-settings" data-agent-focus={agentFocus === 'dubbing'}>+ <div className="video-translation-option-title">+ <span className="video-translation-option-icon"><Mic2 size={17} strokeWidth={1.8} /></span>+ <Switch+ checked={dubbing}+ label={l('生成目标语言配音', 'Generate target-language dubbing')}+ description={l('匹配翻译后的语速与停顿', 'Match the translated pacing and pauses')}+ onChange={value => {+ setDubbing(value);+ }}+ /></div>- {videoFormat === 'vertical' || videoFormat === 'all' ? (- <div className="video-translation-title-fields">- <label className="video-translation-field">- <span>{l('竖屏主标题', 'Vertical video title')} <small>{l('选填', 'Optional')}</small></span>- <input value={verticalTitle} onChange={event => setVerticalTitle(event.target.value)} placeholder={l('留空将自动生成', 'Leave blank to generate automatically')} />- </label>- <label className="video-translation-field">- <span>{l('竖屏副标题', 'Vertical video subtitle')} <small>{l('选填', 'Optional')}</small></span>- <input value={verticalSubtitle} onChange={event => setVerticalSubtitle(event.target.value)} placeholder={l('留空将自动生成', 'Leave blank to generate automatically')} />- </label>+ {dubbing ? (+ <div className="video-translation-option-content">+ {officialSpeech.official ? <OfficialModelField label={l('语音合成模型', 'Speech model')} service={officialSpeech} /> : <div className="video-translation-voice-source">+ <strong>{ttsProviderLabel(ttsProvider, l)}</strong>+ <small>{ttsModel || l('本地语音服务', 'Local speech service')}</small>+ </div>}+ <TtsVoicePicker+ id="video-translation-voice"+ provider={ttsProvider}+ model={ttsModel}+ value={voiceCode}+ service={props.creatorServicesService ?? null}+ label={l('配音音色', 'Dubbing voice')}+ onChange={(voiceId, voice) => {+ setVoiceCode(voiceId);+ setVoiceName(voice?.name ?? voiceId);+ }}+ onVoiceResolved={voice => setVoiceName(voice.name)}+ /></div>) : null}</div>- ) : null}- </div>+ </>+ ) : null}</section>- <CreatorTaskSummary- sourceIcon={FileVideo}- sourceLabel={l('视频来源', 'Video source')}- sourceValue={sourceName}- items={summaryItems}- note={l('配置将带入 Home 对话继续创建', 'These settings will carry into the Home conversation')}- noteIcon={Captions}- /></div>) : null}</div>@@ -3634,7 +3774,7 @@ export default function VideoTranslationWorkspace(props: {<ArrowRight size={16} strokeWidth={1.8} aria-hidden="true" /></button></div>- ) : currentStep < 3 ? (+ ) : currentStep < 2 ? (<button className="video-translation-primary-action" type="button" onClick={() => openWizardStep((currentStep + 1) as WizardStep)}>{l('继续', 'Continue')}<ArrowRight size={16} strokeWidth={1.8} aria-hidden="true" />@@ -3667,6 +3807,13 @@ export default function VideoTranslationWorkspace(props: {agentPanel={<VideoTranslationAgentPanelstepLabel={workspacePhase === 'result' ? l('项目结果', 'Project results') : localizeStep(steps[currentStep], l)}contextSummary={agentContextSummary}+ taskSummary={<CreatorTaskSummary+ sourceIcon={FileVideo}+ sourceLabel={l('视频来源', 'Video source')}+ sourceValue={sourceName}+ items={summaryItems}+ compactSummary={`${languageLabel(sourceLanguages, sourceLanguage)} → ${targetLanguageLabel} · ${outputLabel}`}+ />}promptHint={props.promptHint}currentIssue={runIssueMessage || undefined}quickActions={[@@ -3949,8 +4096,7 @@ function creatorServicesSettingsHref(...codes: Array<string | null | undefined>)function localizeStep(step: typeof steps[number], l: LocalizeCopy): string {if (step === '添加视频') return l(step, 'Add video');if (step === '翻译设置') return l(step, 'Translation');- if (step === '字幕样式') return l(step, 'Subtitle style');- return l(step, 'Dubbing & output');+ return l(step, 'Video & subtitles');}function localizeFormatLabel(label: '横屏' | '竖屏' | '全部', l: LocalizeCopy): string {diff --git a/apps/web/src/features/dashboard/dashboard-css.test.ts b/apps/web/src/features/dashboard/dashboard-css.test.tsindex 4d466a79..c116e3c0 100644--- a/apps/web/src/features/dashboard/dashboard-css.test.ts+++ b/apps/web/src/features/dashboard/dashboard-css.test.ts@@ -136,10 +136,9 @@ describe('dashboard CSS contracts', () => {const verticalPreview = cssBlocks('.video-translation-subtitle-preview[data-orientation="portrait"] > div');expect(layout[0]).toContain('align-items: start;');- expect(layout[0]).toContain('minmax(350px, 1.2fr) minmax(260px, 1fr)');+ expect(layout[0]).toContain('grid-template-columns: minmax(0, 1fr) 280px;');expect(outlineFields[0]).toContain('grid-template-columns: minmax(0, 1fr) 88px;');expect(colorOptions[0]).toContain('flex-wrap: wrap;');- expect(dashboardCss).toMatch(/@container video-translation-workspace \(max-width: 760px\) \{\s*\.video-translation-subtitle-style-layout/);expect(preview[0]).toContain('grid-template-rows: auto auto;');expect(preview[0]).toContain('align-content: start;');expect(player[0]).toContain('aspect-ratio: var(--subtitle-preview-aspect-ratio, 16 / 9);');@@ -149,21 +148,23 @@ describe('dashboard CSS contracts', () => {expect(cues[0]).toContain('position: absolute;');expect(cues[0]).toContain('z-index: 2;');expect(verticalPreview).toHaveLength(1);- expect(verticalPreview[0]).toContain('width: min(236px, 100%);');+ expect(verticalPreview[0]).toContain('width: min(158px, 100%);');});- it('widens the translation settings consistently and keeps smaller color swatches', () => {+ it('fills the available translation workspace width and keeps smaller color swatches', () => {for (const selector of ['.video-translation-source-step',+ '.video-translation-bilibili-parts',+ '.video-translation-source-step .video-translation-url-field','.video-translation-configure-top','.video-translation-wizard-main .video-translation-wizard-body','.video-translation-wizard-main .video-translation-wizard-actions','.video-translation-run-notice']) {- expect(cssBlocks(selector)[0]).toContain('width: min(960px, 100%);');+ expect(cssBlocks(selector)[0]).toContain('width: 100%;');}expect(cssBlocks('.video-translation-color-options > button')[0]).toContain('width: 26px;');- expect(cssBlocks('.video-translation-custom-color input')[0]).toContain('width: 26px;');+ expect(cssBlocks('.video-translation-color-palette .video-translation-color-picker')[0]).toContain('height: 150px;');});it('matches video download settings width to translation and centers labeled platforms', () => {@@ -248,9 +249,9 @@ describe('dashboard CSS contracts', () => {);expect(resultHeader).toHaveLength(1);- expect(resultHeader[0]).toContain('width: min(1080px, 100%);');+ expect(resultHeader[0]).toContain('width: 100%;');expect(resultBody).toHaveLength(1);- expect(resultBody[0]).toContain('width: min(1080px, 100%);');+ expect(resultBody[0]).toContain('width: 100%;');});it('keeps media generation steps vertically scrollable inside the fixed workspace', () => {diff --git a/apps/web/src/features/dashboard/dashboard.css b/apps/web/src/features/dashboard/dashboard.cssindex 457ffb19..28d29958 100644--- a/apps/web/src/features/dashboard/dashboard.css+++ b/apps/web/src/features/dashboard/dashboard.css@@ -1102,17 +1102,56 @@gap: 10px;}+.video-translation-output-format-settings {+ display: grid;+ gap: 12px;+ margin-top: 16px;+}++.video-translation-subtitle-style-title {+ margin: 0;+ font-size: 14px;+ font-weight: 650;+}++.video-translation-output-settings {+ display: grid;+ grid-template-columns: minmax(0, 1fr);+ align-items: start;+ gap: 16px;+}++.video-translation-output-settings > .video-translation-step-panel {+ min-width: 0;+ container-type: inline-size;+ container-name: video-translation-output-controls;+}++.video-translation-dubbing-settings {+ margin-top: 16px;+}++.video-translation-dubbing-settings .tts-voice-picker > label:first-child {+ grid-template-columns: auto minmax(0, 1fr);+ align-items: center;+ gap: 12px;+}+.video-translation-subtitle-style-layout {display: grid;- grid-template-columns: minmax(350px, 1.2fr) minmax(260px, 1fr);+ grid-template-columns: minmax(0, 1fr) 280px;align-items: start;gap: 22px;+ margin-top: 16px;}.video-translation-subtitle-controls {+ min-width: 0;+ grid-column: 1;+ grid-row: 1;display: grid;align-content: start;- gap: 16px;+ gap: 12px;}.video-translation-style-control {@@ -1127,29 +1166,179 @@font-weight: 550;}-.video-translation-size-options {+.video-translation-typography-fields {display: grid;- grid-template-columns: repeat(3, minmax(0, 1fr));- gap: 4px;- padding: 3px;- border-radius: 7px;- background: var(--surface-2);+ grid-template-columns: minmax(0, 1.4fr) repeat(2, minmax(0, 1fr));+ gap: 10px;}-.video-translation-size-options button {- height: 34px;+.video-translation-advanced-style {+ border-top: 1px solid var(--border-hairline);+}++.video-translation-advanced-style > summary {+ display: flex;+ align-items: center;+ justify-content: space-between;+ gap: 8px;+ min-height: 40px;+ padding: 8px 0;+ box-sizing: border-box;+ color: var(--muted);+ font-size: 12px;+ font-weight: 550;+ cursor: pointer;+ list-style: none;+}++.video-translation-advanced-style > summary::-webkit-details-marker {+ display: none;+}++.video-translation-advanced-style > summary:hover {+ color: var(--text);+}++.video-translation-advanced-style > summary:focus-visible {+ outline: 2px solid var(--accent);+ outline-offset: 2px;+}++.video-translation-advanced-style[open] > summary svg {+ transform: rotate(180deg);+}++.video-translation-advanced-style-content {+ display: grid;+ gap: 12px;+}++.video-translation-color-trigger {+ width: 100%;+ min-width: 0;+ height: 38px;+ display: flex;+ align-items: center;+ gap: 8px;padding: 0 10px;+ border: 1px solid var(--border);+ border-radius: 6px;+ background: var(--surface);+ color: var(--text);+ cursor: pointer;+ font-size: 12px;+}++.video-translation-current-color {+ width: 20px;+ height: 20px;+ flex: 0 0 auto;+ border: 1px solid var(--border);+ border-radius: 4px;+ background: var(--subtitle-swatch-color);+}++.video-translation-color-trigger > svg {+ flex: 0 0 auto;+ margin-left: auto;+ color: var(--muted);+}++.video-translation-color-trigger:hover,+.video-translation-color-trigger[aria-expanded="true"] {+ border-color: var(--border-strong);+}++.video-translation-color-palette {+ position: fixed;+ z-index: 160;+ display: grid;+ gap: 12px;+ overflow-y: auto;+ padding: 14px;+ border: 1px solid var(--border-strong);+ border-radius: 8px;+ background: var(--surface);+ color: var(--text);+ box-shadow: 0 8px 24px color-mix(in srgb, var(--text) 12%, transparent);+}++.video-translation-color-palette-heading {+ display: flex;+ align-items: center;+ justify-content: space-between;+ gap: 8px;+ font-size: 12px;+}++.video-translation-color-palette-heading > button {+ width: 24px;+ height: 24px;+ display: grid;+ place-items: center;+ padding: 0;border: 0;- border-radius: 5px;+ border-radius: 4px;background: transparent;color: var(--muted);- font-size: 12px;+ cursor: pointer;}-.video-translation-size-options button[aria-checked="true"] {- background: var(--surface);+.video-translation-color-palette-heading > button:hover {+ background: var(--surface-2);color: var(--text);- box-shadow: 0 1px 3px color-mix(in srgb, var(--text) 10%, transparent);+}++.video-translation-color-trigger:focus-visible,+.video-translation-color-palette button:focus-visible,+.video-translation-color-palette input:focus-visible {+ outline: 2px solid var(--accent);+ outline-offset: 2px;+}++.video-translation-custom-color-fields {+ display: grid;+ grid-template-columns: auto minmax(0, 1fr);+ align-items: center;+ gap: 12px;+}++.video-translation-color-palette .video-translation-color-picker {+ width: 100%;+ height: 150px;+}++.video-translation-color-palette .react-colorful__saturation {+ border-radius: 4px;+ border-bottom: 0;+}++.video-translation-color-palette .react-colorful__hue {+ height: 14px;+ margin-top: 12px;+ border-radius: 4px;+}++.video-translation-color-palette .react-colorful__pointer {+ width: 18px;+ height: 18px;+}++.video-translation-color-palette .react-colorful__interactive:focus-visible {+ outline: 2px solid var(--accent);+ outline-offset: 2px;+}++.video-translation-color-hex {+ width: 100%;+ min-width: 0;+ height: 32px;+ padding: 0 8px;+ border: 1px solid var(--border);+ border-radius: 4px;+ background: var(--surface-2);+ color: var(--text);+ font-size: 12px;}.video-translation-color-options {@@ -1171,7 +1360,7 @@border-radius: 50%;outline: 1px solid var(--border);background: var(--subtitle-swatch-color);- color: #17191d;+ color: var(--subtitle-swatch-ink, #17191d);}.video-translation-color-options > button[aria-pressed="true"] {@@ -1179,36 +1368,6 @@outline-offset: 2px;}-.video-translation-custom-color {- min-width: 0;- display: inline-flex;- align-items: center;- gap: 7px;- color: var(--muted);- cursor: pointer;- font-size: 11px;-}--.video-translation-custom-color input {- width: 26px;- height: 26px;- flex: 0 0 auto;- padding: 2px;- border: 1px solid var(--border);- border-radius: 50%;- background: var(--surface);- cursor: pointer;-}--.video-translation-custom-color input::-webkit-color-swatch-wrapper {- padding: 0;-}--.video-translation-custom-color input::-webkit-color-swatch {- border: 0;- border-radius: 50%;-}-.video-translation-style-fields {display: grid;grid-template-columns: repeat(2, minmax(0, 1fr));@@ -1231,6 +1390,10 @@.video-translation-subtitle-preview {min-width: 0;+ width: min(280px, 100%);+ grid-column: 2;+ grid-row: 1;+ justify-self: end;display: grid;grid-template-rows: auto auto;align-content: start;@@ -1289,10 +1452,46 @@}.video-translation-subtitle-preview[data-orientation="portrait"] > div {- width: min(236px, 100%);+ width: min(158px, 100%);justify-self: center;}+.video-translation-subtitle-preview-titles {+ position: absolute;+ z-index: 2;+ inset: 0 0 auto;+ height: 19.53125%;+ display: flex;+ flex-direction: column;+ justify-content: center;+ gap: 3px;+ padding: 0 8px;+ box-sizing: border-box;+ overflow: hidden;+ background: #000;+ color: #ffff00;+ font-family: "OpenCreator Sans Bold", system-ui, sans-serif;+ line-height: 1.2;+}++.video-translation-subtitle-preview-titles > div {+ display: -webkit-box;+ -webkit-box-orient: vertical;+ -webkit-line-clamp: 2;+ overflow: hidden;+ overflow-wrap: anywhere;+}++.video-translation-subtitle-preview-titles [data-title-kind="major"] {+ font-size: 11px;+ font-weight: 700;+}++.video-translation-subtitle-preview-titles [data-title-kind="minor"] {+ font-size: 9px;+ font-weight: 400;+}+.video-translation-subtitle-preview small,.video-translation-subtitle-preview strong {max-width: 100%;@@ -11402,14 +11601,14 @@}.video-translation-source-step {- width: min(960px, 100%);+ width: 100%;margin: 0 auto;padding: 24px;box-sizing: border-box;}.video-translation-bilibili-parts {- width: min(960px, 100%);+ width: 100%;margin: 0 auto;padding: 0 24px 24px;box-sizing: border-box;@@ -11846,7 +12045,7 @@}.video-translation-source-step .video-translation-url-field {- width: min(592px, 100%);+ width: 100%;margin-right: auto;margin-left: auto;}@@ -11942,7 +12141,7 @@}.video-translation-run-notice {- width: min(960px, 100%);+ width: 100%;min-height: 40px;display: flex;align-items: center;@@ -12066,14 +12265,30 @@}.video-translation-wizard-main .video-translation-header {- margin-bottom: 18px;+ margin-bottom: 12px;+}++.video-translation-wizard-main[data-phase="configure"] .video-translation-step-panel {+ padding: 20px 24px;+}++.video-translation-wizard-main[data-phase="configure"] .video-translation-step-heading {+ margin-bottom: 16px;+}++.video-translation-wizard-main .video-translation-option-title {+ padding-block: 4px;+}++.video-translation-wizard-main .video-translation-option-title .video-translation-toggle-row {+ min-height: 44px;}.video-translation-configure-top {- width: min(960px, 100%);+ width: 100%;display: grid;gap: 14px;- margin: 0 auto 20px;+ margin: 0 auto 16px;}.video-translation-steps {@@ -12236,7 +12451,7 @@}.video-translation-wizard-main .video-translation-wizard-body {- width: min(960px, 100%);+ width: 100%;min-height: 0;margin: 0 auto;overflow-y: auto;@@ -12246,7 +12461,7 @@}.video-translation-wizard-main .video-translation-wizard-actions {- width: min(960px, 100%);+ width: 100%;margin-right: auto;margin-left: auto;}@@ -12264,19 +12479,78 @@background: var(--surface);}-@container video-translation-workspace (max-width: 760px) {+@container video-translation-output-controls (max-width: 560px) {.video-translation-subtitle-style-layout {grid-template-columns: minmax(0, 1fr);}++ .video-translation-subtitle-preview {+ grid-column: 1;+ }++ .video-translation-subtitle-controls {+ grid-row: 2;+ }+}++@container video-translation-output-controls (max-width: 360px) {+ .video-translation-typography-fields {+ grid-template-columns: repeat(2, minmax(0, 1fr));+ }++ .video-translation-typography-fields > :first-child {+ grid-column: 1 / -1;+ }++ .video-translation-outline-fields,+ .video-translation-title-fields {+ grid-template-columns: minmax(0, 1fr);+ }+}++@container video-translation-output-controls (max-width: 480px) {+ .video-translation-dubbing-settings .tts-voice-picker {+ grid-template-columns: minmax(0, 1fr);+ }++ .video-translation-dubbing-settings .tts-voice-picker > label:first-child {+ grid-template-columns: minmax(0, 1fr);+ gap: 7px;+ }++ .video-translation-dubbing-settings .tts-voice-picker-actions {+ justify-content: flex-end;+ }}@container video-translation-workspace (max-width: 480px) {+ .video-translation-wizard-main[data-phase="configure"] .video-translation-step-panel {+ padding: 16px;+ }++ .video-translation-typography-fields {+ grid-template-columns: repeat(2, minmax(0, 1fr));+ }++ .video-translation-typography-fields > :first-child {+ grid-column: 1 / -1;+ }+.video-translation-outline-fields {grid-template-columns: minmax(0, 1fr);}}@container video-translation-workspace (max-width: 720px) {+ .video-translation-wizard-main .video-result-toolbar {+ align-items: stretch;+ flex-direction: column;+ }++ .video-translation-wizard-main .video-result-version {+ align-self: flex-end;+ }+.auto-clip-settings-grid {grid-template-columns: minmax(0, 1fr);}@@ -12460,6 +12734,65 @@color: var(--muted);}+.creator-collaboration-task-summary {+ flex: 0 0 auto;+ min-width: 0;+ border-bottom: 1px solid var(--border-hairline);+}++.creator-task-summary-compact {+ position: static;+ padding: 14px;+ border: 0;+ border-radius: 0;+ background: transparent;+}++.creator-task-summary-compact summary {+ cursor: pointer;+ list-style: none;+}++.creator-task-summary-compact summary::-webkit-details-marker {+ display: none;+}++.creator-task-summary-compact summary:focus-visible {+ outline: 2px solid var(--accent);+ outline-offset: 2px;+}++.creator-task-summary-compact .video-translation-summary-heading {+ margin-bottom: 6px;+}++.creator-task-summary-compact .video-translation-summary-heading h2 {+ flex: 1;+ margin: 0;+}++.creator-task-summary-compact details[open] .video-translation-summary-heading > svg {+ transform: rotate(180deg);+}++.creator-task-summary-overview {+ margin: 0;+ color: var(--muted);+ font-size: 12px;+ line-height: 1.5;+ overflow-wrap: anywhere;+}++.creator-task-summary-details {+ max-height: min(240px, 28vh);+ overflow-y: auto;+ margin-top: 12px;+}++.creator-task-summary-details dl {+ margin-bottom: 0;+}+.creator-collaboration-context > span {min-width: 0;display: grid;@@ -12643,14 +12976,14 @@}.video-translation-wizard-main[data-phase="result"] .video-translation-header {- width: min(1080px, 100%);+ width: 100%;margin-right: auto;margin-bottom: 14px;margin-left: auto;}.video-translation-wizard-main[data-phase="result"] .video-translation-wizard-body {- width: min(1080px, 100%);+ width: 100%;}.video-translation-actions-stack {@@ -12709,6 +13042,14 @@box-shadow: 0 1px 2px color-mix(in srgb, var(--text) 7%, transparent);}+.video-translation-wizard-main .video-result-tabs {+ overflow-x: auto;+}++.video-translation-wizard-main .video-result-tabs > button {+ flex-shrink: 0;+}+.video-result-unsaved {width: 6px;height: 6px;@@ -13780,6 +14121,15 @@font-size: 13px;}+.video-result-empty p,+.video-result-subtitle-empty p {+ margin: 0;+ padding-inline: 16px;+ font-size: 12px;+ line-height: 1.5;+ overflow-wrap: anywhere;+}+.video-result-empty button {height: 34px;padding: 0 11px;@@ -13987,11 +14337,20 @@.video-result-video-grid {display: grid;- grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr));+ grid-template-columns: repeat(auto-fit, minmax(min(560px, 100%), 1fr));align-items: start;gap: 20px;}+.video-result-video-grid > .video-result-output-column {+ width: 100%;+ max-width: 720px;+}++.video-result-video-grid .video-result-player-frame[data-ratio="9:16"] {+ width: min(300px, 100%);+}+.video-result-subtitle-preview-layout {display: grid;grid-template-columns: minmax(0, .95fr) minmax(0, 1.05fr);diff --git a/apps/web/src/features/settings/GatewayAccountSettingsView.test.tsx b/apps/web/src/features/settings/GatewayAccountSettingsView.test.tsxindex 04bb2bed..31c3d31f 100644--- a/apps/web/src/features/settings/GatewayAccountSettingsView.test.tsx+++ b/apps/web/src/features/settings/GatewayAccountSettingsView.test.tsx@@ -35,7 +35,7 @@ it('keeps a plans link available with purchases disabled', async () => {const value = service();vi.mocked(value.getSummary).mockResolvedValue({ balance: { availableUnits: '0', reservedUnits: '0', periodEnd: null, asOf: '2026-10-05T01:00:00Z' }, subscription: null, billingAvailable: false });render(<LanguageProvider initialPreference="zh-CN"><GatewaySubscriptionSettingsView service={value}/></LanguageProvider>);- expect(await screen.findByText('充值暂未开放')).toBeInTheDocument();+ expect(await screen.findByText('充值暂不可用')).toBeInTheDocument();expect(screen.getByRole('button', { name: '充值积分' })).toBeDisabled();expect(screen.getByRole('link', { name: '查看积分方案' })).toHaveAttribute('href', 'https://www.open-creator.ai/pricing?lang=zh');});@@ -43,7 +43,7 @@ it('shows refund review and prevents new recharge', async () => {const value = service();vi.mocked(value.getSummary).mockResolvedValue({ balance: { availableUnits: '1000000', reservedUnits: '0', periodEnd: null, asOf: '2026-10-05T01:00:00Z' }, subscription: null, billingAvailable: false, paymentReview: true });render(<LanguageProvider initialPreference="zh-CN"><GatewaySubscriptionSettingsView service={value}/></LanguageProvider>);- expect(await screen.findByText(/官方额度已暂停/)).toBeInTheDocument();+ expect(await screen.findByText('付款正在审核,积分使用已暂停,请联系客服')).toBeInTheDocument();expect(screen.getByRole('button', { name: '充值积分' })).toBeDisabled();});it('keeps the last balance marked stale on failure and recovers through retry', async () => {diff --git a/apps/web/src/features/settings/GatewayAccountSettingsView.tsx b/apps/web/src/features/settings/GatewayAccountSettingsView.tsxindex fd2db4b1..ea045552 100644--- a/apps/web/src/features/settings/GatewayAccountSettingsView.tsx+++ b/apps/web/src/features/settings/GatewayAccountSettingsView.tsx@@ -84,8 +84,8 @@ export function GatewayAccountSettingsView(props: {const signedIn = state?.authState === 'signed_in';const status = <p role="status">{!service ? l('登录服务暂不可用', 'Sign-in service is unavailable'): state === undefined ? l('正在连接账户服务…', 'Connecting to account service…')- : state.authState === 'authorizing' ? l('等待浏览器确认登录', 'Waiting for browser authorization')- : state.authState === 'signing_out' ? l('正在退出', 'Signing out')+ : state.authState === 'authorizing' ? l('请在浏览器中完成登录', 'Complete sign-in in your browser')+ : state.authState === 'signing_out' ? l('正在退出登录…', 'Signing out…'): state.authState === 'expired' ? l('登录已过期,请重新登录', 'Session expired; sign in again'): signedIn && profile ? l('已登录', 'Signed in'): signedIn ? state.activationState === 'ready' && state.source === 'gateway' ? l('已登录,可以开始创作', 'Signed in and ready to create')@@ -102,10 +102,10 @@ export function GatewayAccountSettingsView(props: {{state?.activationError && (!profile || state.source === 'gateway') ? <p role="alert">{state.activationError.code === 'active_tasks' ? l('请等待当前任务结束后再连接官方服务。', 'Wait for the current tasks to finish before connecting official services.') : l('模型服务暂不可用,请重新连接。', 'Model service is unavailable. Please reconnect.')}</p> : null}{signedIn ? <div className="gateway-account__actions">{(profile ? state.source === 'gateway' && state.activationState !== 'ready' : state.activationState !== 'ready' || state.source !== 'gateway') ? <button type="button" disabled={busy || !service || state.activationState === 'loading'} onClick={() => void action(async () => update(await service!.activate()))}><RefreshCw size={16}/>{l('重新连接', 'Reconnect')}</button> : null}- {props.onOpenSubscription ? <button type="button" onClick={props.onOpenSubscription}><CreditCard size={16}/>{l('积分与充值', 'Credits & Recharge')}</button> : null}+ {props.onOpenSubscription ? <button type="button" onClick={props.onOpenSubscription}><CreditCard size={16}/>{l('积分与充值', 'Credits')}</button> : null}<button type="button" disabled={busy || !service} onClick={() => void action(async () => update(await service!.logout()))}><LogOut size={16}/>{l('退出登录', 'Sign out')}</button></div> : state?.authState === 'authorizing' ? <button type="button" disabled={busy} onClick={() => void action(async () => { update(await service!.cancel()); props.onSignInCanceled?.(); })}>{l('取消登录', 'Cancel sign-in')}</button>- : <button type="button" className="gateway-account__primary" disabled={busy || !service || !state || state.authState === 'signing_out' || state.authState === 'disabled'} onClick={() => void action(signIn)}><LogIn size={16}/>{busy ? l('正在登录…', 'Signing in…') : profile ? l('登录 / 注册', 'Sign in / Register') : l('登录 OpenCreator', 'Sign in to OpenCreator')}</button>}+ : <button type="button" className="gateway-account__primary" disabled={busy || !service || !state || state.authState === 'signing_out' || state.authState === 'disabled'} onClick={() => void action(signIn)}><LogIn size={16}/>{busy ? l('正在登录…', 'Signing in…') : profile ? l('登录 / 注册', 'Sign in / Sign up') : l('登录 OpenCreator', 'Sign in to OpenCreator')}</button>}{authorization ? <a href={authorization.authorizationUrl} target="_blank" rel="noreferrer">{l('打开登录页面', 'Open sign-in page')} <ExternalLink size={14}/></a> : null}{error ? <p role="alert">{error}</p> : null}{(compact || profile) && error && !state && service ? <button type="button" disabled={busy} onClick={() => void action(refresh)}><RefreshCw size={16}/>{l('重试', 'Retry')}</button> : null}diff --git a/apps/web/src/features/settings/GatewaySubscriptionSettingsView.tsx b/apps/web/src/features/settings/GatewaySubscriptionSettingsView.tsxindex 6dd145e1..fa5909bd 100644--- a/apps/web/src/features/settings/GatewaySubscriptionSettingsView.tsx+++ b/apps/web/src/features/settings/GatewaySubscriptionSettingsView.tsx@@ -81,7 +81,7 @@ export function GatewaySubscriptionSettingsView(props: {} finally { if (alive.current && id === owner.current) setBusy(false); }}- return <section className={`gateway-account gateway-subscription${props.embedded ? ' gateway-subscription--embedded' : ''}`} aria-label={l('积分与充值', 'Credits & Recharge')}>+ return <section className={`gateway-account gateway-subscription${props.embedded ? ' gateway-subscription--embedded' : ''}`} aria-label={l('积分与充值', 'Credits')}>{!props.embedded ? <GatewayAccountSettingsView service={service} variant="login" onStateChange={value => { setState(value); callback.current?.(value); void refresh(); }}/>: null}{loading && !summary ? <p className="gateway-subscription__loading" role="status"><LoaderCircle size={16}/>{l('正在加载积分', 'Loading credits')}</p> : null}{signedIn ? <div className="gateway-subscription__overview">@@ -89,12 +89,12 @@ export function GatewaySubscriptionSettingsView(props: {{summary ? <p className="gateway-subscription__detail">{l(error ? '上次更新' : '更新于', error ? 'Last updated' : 'Updated')} {new Date(summary.balance.asOf).toLocaleString()}</p> : null}</div><div><h2>{l('充值积分', 'Buy credits')}</h2><p className="gateway-subscription__detail">{l('一次性购买 · 积分长期有效 · 无自动续费', 'One-time purchase · Credits never expire · No automatic renewal')}</p>- {summary?.paymentReview ? <p role="status">{l('官方额度已暂停,付款需要审核,请联系支持', 'Official credits are paused pending payment review. Contact support.')}</p> : null}+ {summary?.paymentReview ? <p role="status">{l('付款正在审核,积分使用已暂停,请联系客服', 'Your payment is under review. Credit usage is paused. Contact support.')}</p> : null}{!overview ? <button type="button" className="gateway-account__primary" disabled={busy || loading || !summary || !plansURL || !!error || !summary.billingAvailable} onClick={() => { void recharge(); }}><CreditCard size={16}/>{l('充值积分', 'Buy credits')}<ExternalLink size={14}/></button> : null}- {!overview && summary && !summary.billingAvailable && !summary.paymentReview ? <p className="gateway-subscription__detail" role="status">{l('充值暂未开放', 'Purchases are not open yet')}</p> : null}+ {!overview && summary && !summary.billingAvailable && !summary.paymentReview ? <p className="gateway-subscription__detail" role="status">{l('充值暂不可用', 'Credit purchases are currently unavailable')}</p> : null}</div>- </div> : !loading && !overview ? <p className="gateway-subscription__detail">{l('登录后可使用官方模型与积分充值', 'Sign in for official models and credit purchases')}</p> : null}- {overview && props.onOpenSubscription ? <button type="button" className="gateway-subscription__entry" onClick={props.onOpenSubscription}><span>{l('积分与充值', 'Credits & Recharge')}</span><ArrowRight size={17}/></button> : null}+ </div> : !loading && !overview ? <p className="gateway-subscription__detail">{l('登录后可查看积分、购买积分并使用官方模型', 'Sign in to view your balance, buy credits, and use official models')}</p> : null}+ {overview && props.onOpenSubscription ? <button type="button" className="gateway-subscription__entry" onClick={props.onOpenSubscription}><span>{l('积分与充值', 'Credits')}</span><ArrowRight size={17}/></button> : null}{!overview && plansURL ? <a href={plansURL} target="_blank" rel="noreferrer">{l('查看积分方案', 'View credit plans')} <ExternalLink size={14}/></a> : null}{error ? <div className="gateway-subscription__error"><p role="alert">{error}</p><button type="button" disabled={loading} onClick={() => { setLoading(true); void refresh(); }}><RefreshCw size={16}/>{l('重试', 'Retry')}</button></div> : null}</section>;diff --git a/apps/web/src/features/settings/LocalTranscriptionComponents.test.tsx b/apps/web/src/features/settings/LocalTranscriptionComponents.test.tsxindex 36908920..20c39727 100644--- a/apps/web/src/features/settings/LocalTranscriptionComponents.test.tsx+++ b/apps/web/src/features/settings/LocalTranscriptionComponents.test.tsx@@ -293,32 +293,41 @@ describe('local transcription component management', () => {});describe('video translation component notice', () => {- it('explains conditional transcription and preserves context before navigating', () => {+ it('only shows the transcription settings link and preserves context before navigating', () => {const beforeNavigate = vi.fn();window.location.hash = '#/workbench?tool=video-translation&jobId=job_1';const controller = controllerFixture();- render(<LanguageProvider><LanguageSwitchControls /><LocalTranscriptionNotice controller={controller} platformCaptions importedSubtitle={false} beforeNavigate={beforeNavigate} /></LanguageProvider>);- expect(screen.getByText(/没有可用字幕时才需要本地转录/)).toBeInTheDocument();- const link = screen.getByRole('link', { name: '前往组件下载' });+ controller.componentsStatus!.selectedModel = null;+ render(<LanguageProvider><LanguageSwitchControls /><LocalTranscriptionNotice controller={controller} importedSubtitle={false} beforeNavigate={beforeNavigate} /></LanguageProvider>);+ const notice = screen.getByRole('status');+ expect(notice).toHaveTextContent(/^调整转录设置$/);+ expect(screen.getAllByRole('link')).toHaveLength(1);+ const link = screen.getByRole('link', { name: '调整转录设置' });+ expect(link.getAttribute('href')).toContain('tab=ai-services');+ expect(link.getAttribute('href')).toContain('section=transcription');expect(link.getAttribute('href')).toContain('component=whisperkit');expect(link.getAttribute('href')).toContain('returnPath=');const href = link.getAttribute('href');fireEvent.click(screen.getByRole('button', { name: 'en-US' }));- expect(screen.getByText(/Local transcription is needed only when captions are unavailable/)).toBeVisible();- expect(screen.getByRole('link', { name: 'Go to component downloads' })).toHaveAttribute('href', href);+ expect(notice).toHaveTextContent(/^Change transcription settings$/);+ expect(screen.getByRole('link', { name: 'Change transcription settings' })).toHaveAttribute('href', href);fireEvent.click(screen.getByRole('button', { name: 'sv-SE' }));- expect(screen.getByText(/Lokal transkription behövs endast när undertexter saknas/)).toBeVisible();- expect(screen.getByRole('link', { name: 'Gå till komponentnedladdningar' })).toHaveAttribute('href', href);+ expect(screen.getAllByRole('link')).toHaveLength(1);+ expect(screen.getByRole('link')).toHaveAttribute('href', href);expect(beforeNavigate).not.toHaveBeenCalled();expect(controller.downloadComponents).not.toHaveBeenCalled();fireEvent.click(link);expect(beforeNavigate).toHaveBeenCalledOnce();});- it('does not require downloading when subtitles were imported, or when using cloud transcription', () => {- const { rerender } = render(<LanguageProvider><LocalTranscriptionNotice controller={controllerFixture()} platformCaptions={false} importedSubtitle beforeNavigate={() => {}} /></LanguageProvider>);- expect(screen.getByText('当前任务使用导入字幕,无需本地语音转录。')).toBeInTheDocument();- rerender(<LanguageProvider><LocalTranscriptionNotice controller={controllerFixture({}, 'openai')} platformCaptions={false} importedSubtitle={false} beforeNavigate={() => {}} /></LanguageProvider>);- expect(screen.queryByText('本地转录组件尚未就绪')).not.toBeInTheDocument();+ it('hides the notice when subtitles were imported, cloud transcription is selected, or a local model is configured', () => {+ const { rerender } = render(<LanguageProvider><LocalTranscriptionNotice controller={controllerFixture()} importedSubtitle beforeNavigate={() => {}} /></LanguageProvider>);+ expect(screen.queryByRole('status')).not.toBeInTheDocument();+ rerender(<LanguageProvider><LocalTranscriptionNotice controller={controllerFixture({}, 'openai')} importedSubtitle={false} beforeNavigate={() => {}} /></LanguageProvider>);+ expect(screen.queryByRole('status')).not.toBeInTheDocument();+ for (const state of ['ready', 'not_installed', 'downloading', 'failed'] as const) {+ rerender(<LanguageProvider><LocalTranscriptionNotice controller={controllerFixture({ state })} importedSubtitle={false} beforeNavigate={() => {}} /></LanguageProvider>);+ expect(screen.queryByRole('status')).not.toBeInTheDocument();+ }});});diff --git a/apps/web/src/features/settings/OpenCreatorSettingsView.tsx b/apps/web/src/features/settings/OpenCreatorSettingsView.tsxindex 698bf775..01728a3f 100644--- a/apps/web/src/features/settings/OpenCreatorSettingsView.tsx+++ b/apps/web/src/features/settings/OpenCreatorSettingsView.tsx@@ -209,7 +209,7 @@ export function OpenCreatorSettingsView(props: OpenCreatorSettingsViewProps) {{gatewayState.authState === 'authorizing' ? l('正在登录', 'Signing in') : gatewayState.activationState === 'loading' ? l('正在连接', 'Connecting') : gatewayState.activationState === 'ready' ? l('已连接', 'Connected') : gatewayState.authState === 'expired' ? l('登录已过期', 'Session expired') : l('暂不可用', 'Unavailable')}</p></div>- {props.onOpenPersonalCenter ? <button type="button" onClick={props.onOpenPersonalCenter}><UserRound size={15} aria-hidden="true"/>{l('个人中心', 'Personal center')}</button> : null}+ {props.onOpenPersonalCenter ? <button type="button" onClick={props.onOpenPersonalCenter}><UserRound size={15} aria-hidden="true"/>{l('账户', 'Account')}</button> : null}</header>{props.gatewayAccountService ? <OfficialServicesSettingsView state={gatewayState} service={props.gatewayAccountService} onChange={next => { setGatewayState(next); props.onGatewayStateChange?.(next); }} /> : null}</section> : null}diff --git a/apps/web/src/features/settings/StartupAgentSetup.test.tsx b/apps/web/src/features/settings/StartupAgentSetup.test.tsxindex f823c555..2901e5ff 100644--- a/apps/web/src/features/settings/StartupAgentSetup.test.tsx+++ b/apps/web/src/features/settings/StartupAgentSetup.test.tsx@@ -226,7 +226,7 @@ describe('StartupAgentSetup', () => {await user.click(screen.getByRole('button', { name: '登录模式' }));await waitFor(() => expect(screen.getByRole('button', { name: '登录 OpenCreator' })).toBeEnabled());await user.click(screen.getByRole('button', { name: '登录 OpenCreator' }));- expect(await screen.findByText('等待浏览器确认登录')).toBeInTheDocument();+ expect(await screen.findByText('请在浏览器中完成登录')).toBeInTheDocument();await user.click(screen.getByRole('button', { name: '返回' }));expect(gateway.cancel).toHaveBeenCalledOnce();await user.click(screen.getByRole('button', { name: '本地模式' }));diff --git a/apps/web/src/features/shell/OpenCreatorSidebar.test.tsx b/apps/web/src/features/shell/OpenCreatorSidebar.test.tsxindex 2200e280..2430faed 100644--- a/apps/web/src/features/shell/OpenCreatorSidebar.test.tsx+++ b/apps/web/src/features/shell/OpenCreatorSidebar.test.tsx@@ -72,10 +72,10 @@ describe('OpenCreatorSidebar', () => {])('opens the personal center from the footer when collapsed=$collapsed and activeView=$activeView', ({ collapsed, activeView }) => {const onOpenView = vi.fn();renderSidebar({ collapsed, activeView, onOpenView });- const button = screen.getByRole('button', { name: '个人中心' });+ const button = screen.getByRole('button', { name: '账户' });expect(button.parentElement).toHaveClass('sidebar-bottom');expect(button).toHaveAttribute('aria-current', 'page');- expect(button).toHaveAttribute('title', '个人中心');+ expect(button).toHaveAttribute('title', '账户');fireEvent.click(button);expect(onOpenView).toHaveBeenCalledWith('account');});@@ -98,14 +98,14 @@ describe('OpenCreatorSidebar', () => {expect(screen.queryByText('Coca-Cola')).not.toBeInTheDocument();expect(screen.queryByRole('img', { name: 'OpenCreator' })).not.toBeInTheDocument();expect(screen.getByRole('button', { name: '收起侧栏' })).toBeInTheDocument();- expect(screen.getByRole('button', { name: '首页' })).toBeInTheDocument();+ expect(screen.getByRole('button', { name: '模版' })).toBeInTheDocument();expect(screen.getByRole('button', { name: '我的项目' })).toBeInTheDocument();expect(screen.getByRole('button', { name: '工作台' })).toBeInTheDocument();expect(screen.queryByRole('button', { name: '数据看板' })).not.toBeInTheDocument();expect(screen.queryByRole('button', { name: 'Agent动态' })).not.toBeInTheDocument();- const primaryActions = screen.getByRole('button', { name: '首页' }).parentElement;- expect(primaryActions?.children[0]).toBe(screen.getByRole('button', { name: '首页' }));- expect(primaryActions?.children[1]).toBe(screen.getByRole('button', { name: '工作台' }));+ const primaryActions = screen.getByRole('button', { name: '工作台' }).parentElement;+ expect(primaryActions?.children[0]).toBe(screen.getByRole('button', { name: '工作台' }));+ expect(primaryActions?.children[1]).toBe(screen.getByRole('button', { name: '模版' }));expect(primaryActions?.children[2]).toBe(screen.getByRole('button', { name: '我的项目' }));expect(screen.queryByRole('separator')).not.toBeInTheDocument();expect(screen.queryByRole('button', { name: '搜索' })).not.toBeInTheDocument();@@ -144,8 +144,8 @@ describe('OpenCreatorSidebar', () => {expect(screen.getByRole('button', { name: '工作台' }).querySelector('.lucide-panels-top-left')).toBeInTheDocument();- expect(screen.getByRole('button', { name: '首页' })- .querySelector('.lucide-house')).toBeInTheDocument();+ expect(screen.getByRole('button', { name: '模版' })+ .querySelector('.lucide-layout-template')).toBeInTheDocument();expect(screen.queryByRole('button', { name: '插件中心' })).not.toBeInTheDocument();expect(screen.queryByRole('button', { name: '我的资产' })).not.toBeInTheDocument();expect(screen.getByRole('button', { name: '我的项目' })@@ -177,7 +177,7 @@ describe('OpenCreatorSidebar', () => {);expect(screen.getByRole('button', { name: 'Dashboard' })).toHaveAttribute('aria-current', 'page');- expect(screen.getByRole('button', { name: 'Home' })).not.toHaveAttribute('aria-current');+ expect(screen.getByRole('button', { name: 'Templates' })).not.toHaveAttribute('aria-current');expect(screen.queryByRole('button', { name: 'Plugins' })).not.toBeInTheDocument();expect(screen.queryByRole('button', { name: 'My Assets' })).not.toBeInTheDocument();expect(screen.getByRole('button', { name: 'My Projects' })).toBeInTheDocument();@@ -586,13 +586,13 @@ describe('OpenCreatorSidebar', () => {expect(onNewConversation).toHaveBeenCalledWith('content-design');});- it('opens Home from primary navigation without starting a chat', async () => {+ it('opens Templates from primary navigation without starting a chat', async () => {const user = userEvent.setup();const onOpenHome = vi.fn();const onNewConversation = vi.fn();renderSidebar({ onOpenHome, onNewConversation });- await user.click(screen.getByRole('button', { name: '首页' }));+ await user.click(screen.getByRole('button', { name: '模版' }));expect(onOpenHome).toHaveBeenCalledTimes(1);expect(onNewConversation).not.toHaveBeenCalled();diff --git a/apps/web/src/features/shell/OpenCreatorSidebar.tsx b/apps/web/src/features/shell/OpenCreatorSidebar.tsxindex b6a5d6cd..a35ebfff 100644--- a/apps/web/src/features/shell/OpenCreatorSidebar.tsx+++ b/apps/web/src/features/shell/OpenCreatorSidebar.tsx@@ -10,7 +10,7 @@ import {FolderMinus,FolderPlus,FolderOpen,- House,+ LayoutTemplate,LoaderCircle,MoreHorizontal,Pencil,@@ -134,18 +134,18 @@ export function OpenCreatorSidebar(props: {current: boolean;onClick(): void;}> = [- {- label: t('nav.home'),- icon: House,- current: props.homeActive === true,- onClick: props.onOpenHome- },{label: t('nav.dashboard'),icon: PanelsTopLeft,current: props.activeView === 'dashboard',onClick: () => props.onOpenView('dashboard')},+ {+ label: t('nav.home'),+ icon: LayoutTemplate,+ current: props.homeActive === true,+ onClick: props.onOpenHome+ },{label: t('nav.projects'),icon: FolderKanban,@@ -813,9 +813,9 @@ export function OpenCreatorSidebar(props: {)}<div className="sidebar-bottom">- <button type="button" className="sidebar-account" aria-label={l('个人中心', 'Personal center')} title={l('个人中心', 'Personal center')} aria-current={props.activeView === 'account' || props.activeView === 'subscription' ? 'page' : undefined} onClick={() => props.onOpenView('account')}>+ <button type="button" className="sidebar-account" aria-label={l('账户', 'Account')} title={l('账户', 'Account')} aria-current={props.activeView === 'account' || props.activeView === 'subscription' ? 'page' : undefined} onClick={() => props.onOpenView('account')}><AccountAvatar email={accountEmail} accountId={props.gatewayAccountState?.account?.id} avatarUrl={props.gatewayAccountState?.account?.avatarUrl} loadAvatar={props.loadAccountAvatar}/>- {!collapsed ? <span className="sidebar-account__copy"><strong>{l('个人中心', 'Personal center')}</strong><small>{accountEmail ?? (props.gatewayAccountState?.authState === 'expired' ? l('登录已过期', 'Session expired') : l('未登录', 'Signed out'))}</small></span> : null}+ {!collapsed ? <span className="sidebar-account__copy"><strong>{l('账户', 'Account')}</strong><small>{accountEmail ?? (props.gatewayAccountState?.authState === 'expired' ? l('登录已过期', 'Session expired') : l('未登录', 'Signed out'))}</small></span> : null}</button></div>diff --git a/apps/web/src/i18n/LanguageProvider.tsx b/apps/web/src/i18n/LanguageProvider.tsxindex f231f51c..8348f1a4 100644--- a/apps/web/src/i18n/LanguageProvider.tsx+++ b/apps/web/src/i18n/LanguageProvider.tsx@@ -18,7 +18,7 @@ import {const messages = {'zh-CN': {- 'nav.home': '首页',+ 'nav.home': '模版','nav.dashboard': '工作台','nav.plugins': '插件中心','nav.projects': '我的项目',@@ -265,7 +265,7 @@ const messages = {'timeline.process.thinking': '正在思考'},'en-US': {- 'nav.home': 'Home',+ 'nav.home': 'Templates','nav.dashboard': 'Dashboard','nav.plugins': 'Plugins','nav.projects': 'My Projects',@@ -512,7 +512,7 @@ const messages = {'timeline.process.thinking': 'Thinking'},'sv-SE': {- 'nav.home': 'Hem', 'nav.dashboard': 'Arbetsyta', 'nav.plugins': 'Insticksprogram', 'nav.projects': 'Mina projekt', 'nav.settings': 'Inställningar', 'nav.schedules': 'Schemalagda jobb', 'nav.search': 'Sök', 'nav.collapse': 'Fäll ihop sidofältet', 'nav.expand': 'Fäll ut sidofältet', 'nav.autoCollapsed': 'Sidofältet fälldes ihop automatiskt', 'nav.autoCollapsedHint': 'Stäng filarbetsytan för att fälla ut sidofältet i det här fönstret',+ 'nav.home': 'Mallar', 'nav.dashboard': 'Arbetsyta', 'nav.plugins': 'Insticksprogram', 'nav.projects': 'Mina projekt', 'nav.settings': 'Inställningar', 'nav.schedules': 'Schemalagda jobb', 'nav.search': 'Sök', 'nav.collapse': 'Fäll ihop sidofältet', 'nav.expand': 'Fäll ut sidofältet', 'nav.autoCollapsed': 'Sidofältet fälldes ihop automatiskt', 'nav.autoCollapsedHint': 'Stäng filarbetsytan för att fälla ut sidofältet i det här fönstret','settings.navigation': 'Inställningsnavigering', 'settings.back': 'Tillbaka till appen', 'settings.categories': 'Inställningskategorier', 'settings.tab.general': 'Allmänt', 'settings.tab.aiServices': 'AI-tjänster', 'settings.tab.runtimeComponents': 'Tredjepartskomponenter', 'settings.tab.codexAgent': 'Codex Agent', 'settings.tab.plugins': 'Insticksprogram', 'settings.tab.memory': 'Minne', 'settings.tab.profiles': 'Profiler', 'settings.tab.cleanup': 'Rensa', 'settings.tab.diagnostics': 'Diagnostik', 'settings.tab.about': 'Om OpenCreator','settings.required': 'Krävs', 'settings.general.description': 'Justera OpenCreators standardinställningar och skrivbordsvisning.', 'settings.colorMode': 'Färgläge', 'settings.light': 'Ljust', 'settings.dark': 'Mörkt', 'settings.accent': 'Accentfärg', 'settings.permission': 'Standardbehörighet', 'settings.permission.followProject': 'Följ projektinställningen', 'settings.permission.approval': 'Begär godkännande', 'settings.permission.fullAccess': 'Fullständig åtkomst', 'settings.permission.confirm': 'Fullständig åtkomst låter OpenCreator läsa lokala filer och köra lokala åtgärder. Vill du ange den som standardbehörighet?','settings.defaultFileApp': 'Standardapp för filer', 'settings.systemDefaultApp': 'Systemets standardapp', 'settings.language': 'Visningsspråk', 'settings.language.system': 'Systemspråk ({{language}})', 'settings.language.zh': 'Förenklad kinesiska', 'settings.language.en': 'Engelska', 'settings.language.sv': 'Svenska', 'settings.menuBar': 'Visa i menyraden', 'settings.browserMode': 'Webbläsarläge', 'settings.closeWindow': 'När fönstret stängs', 'settings.hideToMenuBar': 'Dölj i menyraden', 'settings.quit': 'Avsluta OpenCreator',diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 3ea60516..769270de 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -245,6 +245,9 @@ importers:react:specifier: ^18.3.1version: 18.3.1+ react-colorful:+ specifier: ^5.6.1react-dom:specifier: ^18.3.1version: 18.3.1([email protected])@@ -3471,6 +3474,12 @@ packages:resolution: {integrity: sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==}hasBin: true+ resolution: {integrity: sha512-oz68bhsnFWnpDf1ZR8daiQbYpXUnM2h2J6hl9Zg2rTpM/DU6vCqe1E+CpqmqLnJucMZetHZeifSAfJ+geN9lcA==}+ peerDependencies:+ react: '>=16.8.0'+ react-dom: '>=16.8.0'+resolution: {integrity: sha512-5m4nQKp+rZRb09LNH59GM4BxTh9251/ylbKIbpe7TpGxfJ+9kv6BLkLBXIjjspbgbnIBNqlI23tRnTWT0snUIw==}peerDependencies:@@ -7561,6 +7570,11 @@ snapshots:minimist: 1.2.8strip-json-comments: 2.0.1+ dependencies:+ react: 18.3.1+ react-dom: 18.3.1([email protected])+dependencies:loose-envify: 1.4.0