Skip to content

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.

feat(creator): refine template browsing filters

卡皮巴拉9b3964656179
diff --git a/apps/daemon/src/creator/presets/catalog.ts b/apps/daemon/src/creator/presets/catalog.ts
index 46e537b9..928046bd 100644
--- a/apps/daemon/src/creator/presets/catalog.ts
+++ b/apps/daemon/src/creator/presets/catalog.ts
@@ -300,6 +300,7 @@ function localizePreset(
}),
prompt: createCreatorPresetPrompt(preset, locale),
tags: createCreatorPresetTags(preset, locale),
+ tagIds: [...preset.tags],
featured: preset.featured,
sortOrder: preset.sortOrder,
requirements: preset.requirements ?? null,
diff --git a/apps/daemon/src/creator/presets/presentation.ts b/apps/daemon/src/creator/presets/presentation.ts
index 22a48715..22ee0034 100644
--- a/apps/daemon/src/creator/presets/presentation.ts
+++ b/apps/daemon/src/creator/presets/presentation.ts
@@ -117,7 +117,10 @@ const highlightBuilders: Record<
};
const presetTagLabels: Record<string, [string, string]> = {
+ '3d-render': ['三维场景', '3D render'],
action: ['动作', 'Action'],
+ 'anime-style': ['动漫风格', 'Anime style'],
+ 'architecture-interior': ['建筑空间', 'Architecture and interiors'],
advertising: ['广告', 'Advertising'],
aerial: ['航拍', 'Aerial'],
animation: ['动画', 'Animation'],
@@ -128,6 +131,7 @@ const presetTagLabels: Record<string, [string, string]> = {
'camera-motion': ['镜头运动', 'Camera motion'],
'character-interaction': ['角色互动', 'Character interaction'],
cinematic: ['电影感', 'Cinematic'],
+ 'city-street': ['城市街景', 'City streets'],
'condensed-source': ['精简提示词', 'Condensed prompt'],
cooking: ['烹饪', 'Cooking'],
corporate: ['企业', 'Corporate'],
@@ -149,11 +153,13 @@ const presetTagLabels: Record<string, [string, string]> = {
'image-to-video': ['图生视频', 'Image to video'],
insight: ['洞察', 'Insight'],
jewelry: ['珠宝', 'Jewelry'],
+ minimalist: ['极简设计', 'Minimalist'],
knowledge: ['知识', 'Knowledge'],
'martial-arts': ['武术', 'Martial arts'],
'multi-reference': ['多参考图', 'Multiple references'],
'multi-stage': ['多阶段', 'Multi-stage'],
mystery: ['悬疑', 'Mystery'],
+ 'nature-landscape': ['自然风光', 'Natural landscapes'],
narration: ['旁白', 'Narration'],
news: ['资讯', 'News'],
nostalgic: ['怀旧', 'Nostalgic'],
@@ -177,6 +183,7 @@ const presetTagLabels: Record<string, [string, string]> = {
social: ['社交媒体', 'Social media'],
square: ['方形', 'Square'],
'stop-motion': ['定格动画', 'Stop motion'],
+ storyboard: ['故事分镜', 'Storyboard'],
story: ['故事', 'Story'],
storytelling: ['故事讲述', 'Storytelling'],
subtitles: ['字幕', 'Subtitles'],
diff --git a/apps/daemon/test/integration/creator-api.test.ts b/apps/daemon/test/integration/creator-api.test.ts
index 73e09ba7..529440b4 100644
--- a/apps/daemon/test/integration/creator-api.test.ts
+++ b/apps/daemon/test/integration/creator-api.test.ts
@@ -316,6 +316,7 @@ describe('creator api', () => {
coverUrl: expect.stringMatching(/^\/creator-presets\/[a-f0-9]{64}\.jpg$/),
prompt: expect.stringContaining('Create a hyper-realistic exploded vertical infographic'),
tags: ['Reference template', 'Product visuals', 'Infographics', 'Food and beverage'],
+ tagIds: ['reference-template', '产品视觉', '信息图表', '食品饮料'],
highlights: [
{ text: '1024 × 1024', colors: [] },
{ text: 'High quality', colors: [] },
diff --git a/apps/daemon/test/unit/creator-preset-registry.test.ts b/apps/daemon/test/unit/creator-preset-registry.test.ts
index cf0538c2..ae3f6081 100644
--- a/apps/daemon/test/unit/creator-preset-registry.test.ts
+++ b/apps/daemon/test/unit/creator-preset-registry.test.ts
@@ -100,6 +100,73 @@ describe('creator preset registry', () => {
]);
});
+ it('validates and localizes video taxonomy tags from their source manifests', async () => {
+ const fixture = setup();
+ const cases = [
+ ['rainforest-mysterious-light', 'nature-landscape', '自然风光', 'Natural landscapes'],
+ ['brutalist-courtyard-martial-arts', 'architecture-interior', '建筑空间', 'Architecture and interiors'],
+ ['bedroom-falling-book-catch', 'architecture-interior', '建筑空间', 'Architecture and interiors'],
+ ['nyc-parkour-web-swing', 'city-street', '城市街景', 'City streets'],
+ ['anime-skateboard-chase-nyc', 'anime-style', '动漫风格', 'Anime style'],
+ ['seoul-sunday-dv-home-video', 'city-street', '城市街景', 'City streets']
+ ] as const;
+ for (const [id, tag, zh, en] of cases) {
+ const source = JSON.parse(readFileSync(
+ join(officialPresetRoot, 'video-generation', id, '1', 'template.json'),
+ 'utf8'
+ )) as { tags: string[] };
+ expect(source.tags).toContain(tag);
+ expect(createCreatorPresetTags(source, 'zh-CN')).toContain(zh);
+ expect(createCreatorPresetTags(source, 'en-US')).toContain(en);
+ copyOfficialPreset({ sourceRoot: fixture.sourceRoot, module: 'video-generation', sourceId: id });
+ }
+ const catalog = await validateCreatorPresets({ sourceRoot: fixture.sourceRoot });
+ const registry = createCreatorPresetRegistry({
+ catalog,
+ catalogHash: sha256(canonicalJson(catalog))
+ });
+ for (const [id, tag, zh, en] of cases) {
+ const chinese = registry.listPublished('zh-CN').find(preset => preset.id === id);
+ const english = registry.listPublished('en-US').find(preset => preset.id === id);
+ expect(chinese?.tags).toContain(zh);
+ expect(english?.tags).toContain(en);
+ expect(chinese?.tagIds).toEqual(english?.tagIds);
+ expect(chinese?.tagIds).toContain(tag);
+ }
+ });
+
+ it('keeps specific image filter tags available in both locales', async () => {
+ const fixture = setup();
+ const cases = [
+ ['animated-campus-world-reference-board', 'anime-style', '动漫风格', 'Anime style'],
+ ['city-corner-3d-billboard-photography', '3d-render', '三维场景', '3D render'],
+ ['croissant-baking-storyboard', 'storyboard', '故事分镜', 'Storyboard'],
+ ['watercolor-editorial-illustration-poster', 'watercolor', '水彩', 'Watercolor'],
+ ['minimal-conceptual-line-art-poster', 'minimalist', '极简设计', 'Minimalist']
+ ] as const;
+ for (const [id, tag] of cases) {
+ copyOfficialPreset({ sourceRoot: fixture.sourceRoot, module: 'image-generation', sourceId: id });
+ const source = JSON.parse(readFileSync(
+ join(officialPresetRoot, 'image-generation', id, '1', 'template.json'),
+ 'utf8'
+ )) as { tags: string[] };
+ expect(source.tags).toContain(tag);
+ }
+ const catalog = await validateCreatorPresets({ sourceRoot: fixture.sourceRoot });
+ const registry = createCreatorPresetRegistry({
+ catalog,
+ catalogHash: sha256(canonicalJson(catalog))
+ });
+ for (const [id, tag, zh, en] of cases) {
+ const chinese = registry.listPublished('zh-CN').find(preset => preset.id === id);
+ const english = registry.listPublished('en-US').find(preset => preset.id === id);
+ expect(chinese?.tagIds).toContain(tag);
+ expect(english?.tagIds).toContain(tag);
+ expect(chinese?.tags).toContain(zh);
+ expect(english?.tags).toContain(en);
+ }
+ });
+
it('returns localized latest published presets and keeps hidden presets addressable', async () => {
const fixture = setup();
copyOfficialPreset({
diff --git a/apps/web/src/features/conversation/CreatorDashboard.test.tsx b/apps/web/src/features/conversation/CreatorDashboard.test.tsx
index ea6894c3..bb335a62 100644
--- a/apps/web/src/features/conversation/CreatorDashboard.test.tsx
+++ b/apps/web/src/features/conversation/CreatorDashboard.test.tsx
@@ -1,6 +1,6 @@
-import { fireEvent, render, screen, waitFor } from '@testing-library/react';
+import { fireEvent, render, screen, waitFor, within } from '@testing-library/react';
import type { CreatorPresetSummary } from '@opencreator/protocol';
-import { beforeEach, describe, expect, it, vi } from 'vitest';
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import { LanguageProvider } from '../../i18n/LanguageProvider.js';
import {
CreatorDashboard,
@@ -101,11 +101,20 @@ const presets: CreatorPresetSummary[] = [{
highlights: [{ text: '16:9', colors: [] }]
}];
+function mockNarrowTagRow() {
+ vi.spyOn(HTMLElement.prototype, 'getBoundingClientRect').mockImplementation(function (this: HTMLElement) {
+ const width = this.classList.contains('creator-template-tags-filter') ? 350 : 100;
+ return { width } as DOMRect;
+ });
+}
+
describe('CreatorDashboard', () => {
beforeEach(() => {
window.localStorage.clear();
});
+ afterEach(() => vi.restoreAllMocks());
+
it.each([
['video-generation', true],
['video-translation', true],
@@ -142,7 +151,7 @@ describe('CreatorDashboard', () => {
render(<CreatorDashboard presets={presets} onSelectPreset={onSelectPreset} />);
expect(screen.getByRole('heading', { name: '精选模板' })).toBeInTheDocument();
- expect(screen.getAllByRole('tab')).toHaveLength(4);
+ expect(screen.getAllByRole('tab')).toHaveLength(5);
expect(screen.getByRole('tab', { name: '推荐' }))
.toHaveAttribute('aria-selected', 'true');
const presetCard = screen.getByRole('button', { name: '查看B站双语精翻模板详情' });
@@ -263,6 +272,342 @@ describe('CreatorDashboard', () => {
.toBeInTheDocument();
});
+ it('omits tag filters on Recent, Recommended and All while keeping search available', () => {
+ render(<CreatorDashboard presets={presets} />);
+
+ for (const category of ['推荐', '全部', '最近']) {
+ fireEvent.click(screen.getByRole('tab', { name: category }));
+ expect(screen.queryByRole('group', { name: '筛选模板' })).not.toBeInTheDocument();
+ expect(screen.getByRole('button', { name: '搜索模板' })).toBeInTheDocument();
+ }
+
+ fireEvent.click(screen.getByRole('tab', { name: '图像设计' }));
+ expect(screen.getByRole('group', { name: '筛选模板' })).toBeInTheDocument();
+ fireEvent.click(screen.getByRole('button', { name: '商品产品' }));
+ fireEvent.click(screen.getByRole('tab', { name: '全部' }));
+ expect(screen.queryByRole('group', { name: '筛选模板' })).not.toBeInTheDocument();
+ expect(screen.getByRole('button', { name: '查看社交媒体海报模板详情' })).toBeInTheDocument();
+ fireEvent.click(screen.getByRole('tab', { name: '图像设计' }));
+ expect(screen.getByRole('button', { name: '全部' })).toHaveAttribute('aria-pressed', 'true');
+ });
+
+ it('uses one tag at a time and resets with All or a category change', () => {
+ const catalog = [
+ { ...presets[1]!, tags: ['商业广告', '产品视觉', '创意摄影'] },
+ { ...presets[2]!, tags: ['海报设计', '手绘插画', '角色场景'] },
+ { ...presets[3]!, tags: ['商业广告', 'cinematic', '产品视觉'] }
+ ];
+ render(<CreatorDashboard presets={catalog} />);
+
+ expect(screen.queryByRole('group', { name: '筛选模板' })).not.toBeInTheDocument();
+ expect(screen.queryByText('使用场景')).not.toBeInTheDocument();
+ fireEvent.click(screen.getByRole('tab', { name: '视频创作' }));
+ expect(screen.getByRole('button', { name: '全部' })).toHaveAttribute('aria-pressed', 'true');
+ expect(screen.getByRole('button', { name: '电影短片' })).toBeInTheDocument();
+ expect(screen.queryByRole('button', { name: '海报设计' })).not.toBeInTheDocument();
+ fireEvent.click(screen.getByRole('button', { name: '电影短片' }));
+ expect(screen.getByRole('tab', { name: '视频创作' })).toHaveAttribute('aria-selected', 'true');
+ expect(screen.queryByRole('button', { name: '查看电商商品主图增强版模板详情' })).not.toBeInTheDocument();
+ expect(screen.getByRole('button', { name: '查看电影感视频预览模板详情' })).toBeInTheDocument();
+ fireEvent.click(screen.getByRole('button', { name: '全部' }));
+ expect(screen.getByRole('tab', { name: '视频创作' })).toHaveAttribute('aria-selected', 'true');
+ expect(screen.queryByRole('button', { name: '查看电商商品主图增强版模板详情' })).not.toBeInTheDocument();
+
+ fireEvent.click(screen.getByRole('tab', { name: '图像设计' }));
+ fireEvent.click(screen.getByRole('button', { name: '商品产品' }));
+ expect(screen.getByRole('tab', { name: '图像设计' })).toHaveAttribute('aria-selected', 'true');
+ expect(screen.getByRole('button', { name: '查看电商商品主图增强版模板详情' })).toBeInTheDocument();
+ expect(screen.queryByRole('button', { name: '查看社交媒体海报模板详情' })).not.toBeInTheDocument();
+ fireEvent.click(screen.getByRole('tab', { name: '全部' }));
+ expect(screen.queryByRole('button', { name: '商品产品' })).not.toBeInTheDocument();
+ expect(screen.queryByRole('group', { name: '筛选模板' })).not.toBeInTheDocument();
+ expect(screen.getByRole('button', { name: '查看社交媒体海报模板详情' })).toBeInTheDocument();
+ });
+
+ it('keeps one tag row and moves overflow selections into view without changing the category', () => {
+ mockNarrowTagRow();
+ render(<CreatorDashboard presets={[
+ { ...presets[3]!, tags: ['cinematic', 'camera-motion', 'action'] },
+ presets[0]!,
+ { ...presets[1]!, tags: ['产品视觉', '电商视觉', '人像摄影'] },
+ { ...presets[2]!, tags: ['海报设计'] }
+ ]} />);
+
+ fireEvent.click(screen.getByRole('tab', { name: '视频创作' }));
+ const filter = screen.getByRole('group', { name: '筛选模板' });
+ const line = filter.querySelector('.creator-template-tags-line')!;
+ expect(within(line as HTMLElement).getByRole('button', { name: '视频翻译' })).toBeInTheDocument();
+ expect(within(line as HTMLElement).queryByRole('button', { name: '镜头运动' })).not.toBeInTheDocument();
+ const more = within(line as HTMLElement).getByRole('button', { name: '更多' });
+ expect(more).toHaveAttribute('aria-expanded', 'false');
+ expect(filter.querySelectorAll('.creator-template-tags-measure button[tabindex="-1"]')).toHaveLength(
+ filter.querySelectorAll('.creator-template-tags-measure button').length
+ );
+
+ fireEvent.click(more);
+ const overflow = screen.getByRole('group', { name: '更多模板分类' });
+ expect(more).toHaveAttribute('aria-expanded', 'true');
+ expect(more).toHaveTextContent('收起');
+ expect(within(overflow).queryByRole('button', { name: '视频翻译' })).not.toBeInTheDocument();
+ fireEvent.click(more);
+ expect(more).toHaveAttribute('aria-expanded', 'false');
+ expect(more).toHaveTextContent('更多');
+ expect(screen.queryByRole('group', { name: '更多模板分类' })).not.toBeInTheDocument();
+ fireEvent.click(more);
+ fireEvent.click(within(screen.getByRole('group', { name: '更多模板分类' }))
+ .getByRole('button', { name: '镜头运动' }));
+ expect(screen.queryByRole('group', { name: '更多模板分类' })).not.toBeInTheDocument();
+ expect(within(line as HTMLElement).getByRole('button', { name: '镜头运动' }))
+ .toHaveAttribute('aria-pressed', 'true');
+ expect(screen.getByRole('tab', { name: '视频创作' })).toHaveAttribute('aria-selected', 'true');
+ expect(screen.getByRole('button', { name: '查看电影感视频预览模板详情' })).toBeInTheDocument();
+ expect(screen.queryByRole('button', { name: '查看B站双语精翻模板详情' })).not.toBeInTheDocument();
+
+ fireEvent.click(more);
+ fireEvent.keyDown(document, { key: 'Escape' });
+ expect(screen.queryByRole('group', { name: '更多模板分类' })).not.toBeInTheDocument();
+ expect(more).toHaveFocus();
+ fireEvent.click(more);
+ fireEvent.pointerDown(document.body);
+ expect(screen.queryByRole('group', { name: '更多模板分类' })).not.toBeInTheDocument();
+
+ fireEvent.click(screen.getByRole('tab', { name: '图像设计' }));
+ expect(within(line as HTMLElement).getByRole('button', { name: '人像写真' })).toBeInTheDocument();
+ fireEvent.click(within(line as HTMLElement).getByRole('button', { name: '更多' }));
+ fireEvent.click(within(screen.getByRole('group', { name: '更多模板分类' }))
+ .getByRole('button', { name: '商品产品' }));
+ expect(within(line as HTMLElement).getByRole('button', { name: '商品产品' }))
+ .toHaveAttribute('aria-pressed', 'true');
+ expect(screen.getByRole('tab', { name: '图像设计' })).toHaveAttribute('aria-selected', 'true');
+ expect(screen.getByRole('button', { name: '查看电商商品主图增强版模板详情' })).toBeInTheDocument();
+ expect(screen.queryByRole('button', { name: '查看社交媒体海报模板详情' })).not.toBeInTheDocument();
+ });
+
+ it('localizes the overflow control and its options in English', () => {
+ mockNarrowTagRow();
+ render(
+ <LanguageProvider initialPreference="en-US">
+ <CreatorDashboard presets={[{ ...presets[3]!, tags: ['cinematic', 'camera-motion'] }]} />
+ </LanguageProvider>
+ );
+
+ fireEvent.click(screen.getByRole('tab', { name: 'Video Creation' }));
+ const more = screen.getByRole('button', { name: 'More' });
+ fireEvent.click(more);
+ expect(more).toHaveTextContent('Show less');
+ const overflow = screen.getByRole('group', { name: 'More template filters' });
+ fireEvent.click(within(overflow).getByRole('button', { name: 'Camera Motion' }));
+ expect(screen.getByRole('button', { name: 'Camera Motion' })).toHaveAttribute('aria-pressed', 'true');
+ expect(screen.getByRole('tab', { name: 'Video Creation' })).toHaveAttribute('aria-selected', 'true');
+ });
+
+ it('matches localized English tags within the selected category', () => {
+ const catalog = [
+ { ...presets[1]!, title: 'Product Hero', tags: ['Commercial advertising', 'Product visuals'] },
+ { ...presets[2]!, title: 'Illustrated Poster', tags: ['Poster design', 'Hand-drawn illustration'] },
+ { ...presets[3]!, title: 'Cinematic Motion', tags: ['Cinematic storytelling', 'Animation'] }
+ ];
+ render(
+ <LanguageProvider initialPreference="en-US">
+ <CreatorDashboard presets={catalog} />
+ </LanguageProvider>
+ );
+
+ fireEvent.click(screen.getByRole('tab', { name: 'Image Design' }));
+ expect(screen.getByRole('button', { name: 'Brand Ads' })).toBeInTheDocument();
+ expect(screen.getByRole('button', { name: 'Posters' })).toBeInTheDocument();
+ expect(screen.queryByRole('button', { name: 'Cinematic' })).not.toBeInTheDocument();
+ fireEvent.click(screen.getByRole('button', { name: 'Brand Ads' }));
+ expect(screen.getByRole('tab', { name: 'Image Design' })).toHaveAttribute('aria-selected', 'true');
+ expect(screen.getByRole('button', { name: 'View Product Hero template details' })).toBeInTheDocument();
+ expect(screen.queryByRole('button', { name: 'View Illustrated Poster template details' })).not.toBeInTheDocument();
+ fireEvent.click(screen.getByRole('button', { name: 'All' }));
+ expect(screen.getByRole('tab', { name: 'Image Design' })).toHaveAttribute('aria-selected', 'true');
+ expect(screen.getByRole('button', { name: 'View Illustrated Poster template details' })).toBeInTheDocument();
+ });
+
+ it('shows video workflows and motion tags separately from image design tags', () => {
+ const catalog = [
+ presets[0]!,
+ presets[4]!,
+ { ...presets[3]!, tags: ['camera-motion', 'action', 'image-to-video'] },
+ { ...presets[1]!, tags: ['产品视觉', '产品摄影'] },
+ { ...presets[2]!, tags: ['海报设计', '手绘插画'] }
+ ];
+ render(<CreatorDashboard presets={catalog} />);
+
+ fireEvent.click(screen.getByRole('tab', { name: '视频创作' }));
+ 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();
+ fireEvent.click(screen.getByRole('button', { name: '镜头运动' }));
+ expect(screen.getByRole('button', { name: '查看电影感视频预览模板详情' })).toBeInTheDocument();
+ expect(screen.queryByRole('button', { name: '查看B站双语精翻模板详情' })).not.toBeInTheDocument();
+
+ fireEvent.click(screen.getByRole('tab', { name: '图像设计' }));
+ expect(screen.getByRole('button', { name: '海报设计' })).toBeInTheDocument();
+ expect(screen.getByRole('button', { name: '摄影' })).toBeInTheDocument();
+ expect(screen.queryByRole('button', { name: '镜头运动' })).not.toBeInTheDocument();
+ expect(screen.queryByRole('button', { name: '视频翻译' })).not.toBeInTheDocument();
+ });
+
+ it('shows specific image uses, styles and subjects in one localized filter', () => {
+ const catalog: CreatorPresetSummary[] = [
+ {
+ ...presets[1]!,
+ title: '极简城市海报',
+ tags: ['极简设计', '城市街景', '海报设计'],
+ tagIds: ['minimalist', 'city-street', '海报设计']
+ },
+ {
+ ...presets[2]!,
+ title: '水彩故事分镜',
+ tags: ['水彩', '故事分镜', '手绘插画'],
+ tagIds: ['watercolor', 'storyboard', '手绘插画']
+ },
+ {
+ ...presets[5]!,
+ title: '品牌商品广告',
+ tags: ['商业广告', '产品视觉', '电商'],
+ tagIds: ['商业广告', '产品视觉', 'ecommerce']
+ }
+ ];
+ const view = render(<CreatorDashboard presets={catalog} />);
+ fireEvent.click(screen.getByRole('tab', { name: '图像设计' }));
+ const filter = screen.getByRole('group', { name: '筛选模板' });
+ expect(filter.querySelectorAll('button').length).toBeGreaterThan(9);
+ for (const label of ['海报设计', '故事分镜', '电商主图', '品牌广告', '水彩画', '极简设计', '城市街景', '商品产品']) {
+ expect(screen.getByRole('button', { name: label })).toBeInTheDocument();
+ }
+ expect(screen.queryByRole('button', { name: '游戏视觉' })).not.toBeInTheDocument();
+ fireEvent.click(screen.getByRole('button', { name: '城市街景' }));
+ expect(screen.getByRole('tab', { name: '图像设计' })).toHaveAttribute('aria-selected', 'true');
+ expect(screen.getByRole('button', { name: '查看极简城市海报模板详情' })).toBeInTheDocument();
+ expect(screen.queryByRole('button', { name: '查看水彩故事分镜模板详情' })).not.toBeInTheDocument();
+
+ view.unmount();
+ render(
+ <LanguageProvider initialPreference="en-US">
+ <CreatorDashboard presets={[
+ { ...catalog[0]!, title: 'Minimal City Poster', tags: ['Minimalist', 'City streets', 'Poster design'] },
+ { ...catalog[1]!, title: 'Watercolor Storyboard', tags: ['Watercolor', 'Storyboard', 'Hand-drawn illustration'] }
+ ]} />
+ </LanguageProvider>
+ );
+ fireEvent.click(screen.getByRole('tab', { name: 'Image Design' }));
+ fireEvent.click(screen.getByRole('button', { name: 'Watercolor' }));
+ expect(screen.getByRole('tab', { name: 'Image Design' })).toHaveAttribute('aria-selected', 'true');
+ expect(screen.getByRole('button', { name: 'View Watercolor Storyboard template details' })).toBeInTheDocument();
+ expect(screen.queryByRole('button', { name: 'View Minimal City Poster template details' })).not.toBeInTheDocument();
+ });
+
+ it('shows localized video-specific tags in English', () => {
+ render(
+ <LanguageProvider initialPreference="en-US">
+ <CreatorDashboard presets={[
+ { ...presets[0]!, title: 'Bilingual Translation', tags: ['Bilingual', 'Subtitles'] },
+ { ...presets[3]!, title: 'Moving Camera', tags: ['Camera motion', 'Cinematic'] }
+ ]} />
+ </LanguageProvider>
+ );
+
+ fireEvent.click(screen.getByRole('tab', { name: 'Video Creation' }));
+ expect(screen.getByRole('button', { name: 'Video Translation' })).toBeInTheDocument();
+ expect(screen.getByRole('button', { name: 'Stick Figure Animation' })).toBeInTheDocument();
+ expect(screen.getByRole('button', { name: 'Camera Motion' })).toBeInTheDocument();
+ expect(screen.getByRole('button', { name: 'Cinematic Shorts' })).toBeInTheDocument();
+ fireEvent.click(screen.getByRole('button', { name: 'Camera Motion' }));
+ expect(screen.getByRole('tab', { name: 'Video Creation' })).toHaveAttribute('aria-selected', 'true');
+ expect(screen.getByRole('button', { name: 'View Moving Camera template details' })).toBeInTheDocument();
+ });
+
+ it('shows the complete video tag list in order, including tags awaiting templates', () => {
+ const catalog = [
+ { ...presets[3]!, tags: ['nature-landscape', 'city-street', 'architecture-interior', 'anime-style'] },
+ { ...presets[3]!, id: 'stickman-preview', title: '火柴人动画预览', tags: ['stickman-video'], tagIds: ['stickman-video'] },
+ presets[0]!
+ ];
+ render(<CreatorDashboard presets={catalog} />);
+ fireEvent.click(screen.getByRole('tab', { name: '视频创作' }));
+ expect(Array.from(document.querySelectorAll('.creator-template-tags-line button'), button => button.textContent))
+ .toEqual([
+ '全部', '视频翻译', '火柴人动画', '电影短片', '生活 Vlog', '品牌广告', 'UGC 内容', '知识讲解',
+ '片头包装', '游戏宣传', '写实电影感', '奇幻冒险', '未来科幻',
+ '动漫风格', '复古胶片', '梦境视觉', '定格动画', '手绘动画',
+ '人物角色', '运动动作', '自然风光', '建筑空间', '城市街景',
+ '美食料理', '产品特写', '镜头运动', '视频配音', '视频下载'
+ ]);
+ fireEvent.click(screen.getByRole('button', { name: '视频翻译' }));
+ expect(screen.getByRole('button', { name: '查看B站双语精翻模板详情' })).toBeInTheDocument();
+ expect(screen.queryByRole('button', { name: '查看火柴人动画预览模板详情' })).not.toBeInTheDocument();
+ fireEvent.click(screen.getByRole('button', { name: '火柴人动画' }));
+ expect(screen.getByRole('button', { name: '查看火柴人动画预览模板详情' })).toBeInTheDocument();
+ expect(screen.queryByRole('button', { name: '查看B站双语精翻模板详情' })).not.toBeInTheDocument();
+ fireEvent.click(screen.getByRole('button', { name: '片头包装' }));
+ expect(screen.getByText('该标签暂时没有模板。')).toBeInTheDocument();
+ expect(screen.getByRole('tab', { name: '视频创作' })).toHaveAttribute('aria-selected', 'true');
+ fireEvent.click(screen.getByRole('button', { name: '城市街景' }));
+ expect(screen.getByRole('button', { name: '查看电影感视频预览模板详情' })).toBeInTheDocument();
+ });
+
+ it('filters localized video presets by stable tag IDs in Chinese and English', () => {
+ const catalog: CreatorPresetSummary[] = [
+ {
+ ...presets[3]!,
+ title: '城市自然镜头',
+ tags: ['电影感', '镜头运动', '自然风光', '城市街景', '建筑空间'],
+ tagIds: ['cinematic', 'camera-motion', 'nature-landscape', 'city-street', 'architecture-interior']
+ },
+ {
+ ...presets[3]!,
+ id: 'anime-action',
+ title: '动漫动作',
+ tags: ['动漫风格', '动作', '怀旧'],
+ tagIds: ['anime-style', 'action', 'nostalgic']
+ },
+ presets[0]!
+ ];
+ const view = render(<CreatorDashboard presets={catalog} />);
+ fireEvent.click(screen.getByRole('tab', { name: '视频创作' }));
+
+ const filter = screen.getByRole('group', { name: '筛选模板' });
+ expect(filter.querySelectorAll('button').length).toBeGreaterThan(5);
+ for (const label of ['视频翻译', '火柴人动画', '电影短片', '写实电影感', '镜头运动', '自然风光', '城市街景', '建筑空间', '动漫风格', '运动动作', '复古胶片']) {
+ expect(screen.getByRole('button', { name: label })).toBeInTheDocument();
+ }
+ fireEvent.click(screen.getByRole('button', { name: '自然风光' }));
+ expect(screen.getByRole('tab', { name: '视频创作' })).toHaveAttribute('aria-selected', 'true');
+ expect(screen.getByRole('button', { name: '查看城市自然镜头模板详情' })).toBeInTheDocument();
+ expect(screen.queryByRole('button', { name: '查看动漫动作模板详情' })).not.toBeInTheDocument();
+
+ view.unmount();
+ render(
+ <LanguageProvider initialPreference="en-US">
+ <CreatorDashboard presets={[
+ {
+ ...catalog[0]!,
+ title: 'City and Nature Camera',
+ tags: ['Cinematic', 'Camera motion', 'Natural landscapes', 'City streets', 'Architecture and interiors']
+ },
+ {
+ ...catalog[1]!,
+ title: 'Anime Action',
+ tags: ['Anime style', 'Action', 'Nostalgic']
+ },
+ catalog[2]!
+ ]} />
+ </LanguageProvider>
+ );
+ fireEvent.click(screen.getByRole('tab', { name: 'Video Creation' }));
+ fireEvent.click(screen.getByRole('button', { name: 'Natural Landscapes' }));
+ expect(screen.getByRole('tab', { name: 'Video Creation' })).toHaveAttribute('aria-selected', 'true');
+ expect(screen.getByRole('button', { name: 'View City and Nature Camera template details' })).toBeInTheDocument();
+ expect(screen.queryByRole('button', { name: 'View Anime Action template details' })).not.toBeInTheDocument();
+ });
+
it('highlights replaceable prompt variables without styling section headings', () => {
render(<CreatorDashboard presets={presets} />);
fireEvent.click(screen.getByRole('tab', { name: '图像设计' }));
diff --git a/apps/web/src/features/conversation/CreatorDashboard.tsx b/apps/web/src/features/conversation/CreatorDashboard.tsx
index 37623227..e690dcc1 100644
--- a/apps/web/src/features/conversation/CreatorDashboard.tsx
+++ b/apps/web/src/features/conversation/CreatorDashboard.tsx
@@ -41,11 +41,82 @@ export type CreatorSkill = {
};
};
-type CreatorHomeCategory = 'recent' | 'recommended' | 'video' | 'image';
+type CreatorHomeCategory = 'recent' | 'recommended' | 'all' | 'video' | 'image';
+type FacetOption = {
+ id: string;
+ zh: string;
+ en: string;
+ tags: string[];
+ modules?: CreatorRuntimeWorkspace[];
+};
+
+const videoTagOptions: FacetOption[] = [
+ { id: 'translation', zh: '视频翻译', en: 'Video Translation', tags: [], modules: ['video-translation'] },
+ { id: 'stickman-animation', zh: '火柴人动画', en: 'Stick Figure Animation', tags: ['stickman-video', 'stick-figure-animation', '火柴人动画', 'Stick figure animation'] },
+ { id: 'short-film', zh: '电影短片', en: 'Cinematic Shorts', tags: ['cinematic', 'Cinematic', 'mystery', 'Mystery'] },
+ { id: 'vlog', zh: '生活 Vlog', en: 'Lifestyle Vlogs', tags: ['dv', 'DV', 'ugc', 'UGC'] },
+ { id: 'brand-ad', zh: '品牌广告', en: 'Brand Ads', tags: ['advertising', 'Advertising', 'jewelry', 'Jewelry'] },
+ { id: 'ugc', zh: 'UGC 内容', en: 'UGC Content', tags: ['ugc', 'UGC'] },
+ { id: 'tutorial', zh: '知识讲解', en: 'Explainers', tags: ['cooking', 'Cooking', 'multi-stage', 'Multi-stage'] },
+ { id: 'intro', zh: '片头包装', en: 'Intros / Branding', tags: [] },
+ { id: 'game-promo', zh: '游戏宣传', en: 'Game Promos', tags: [] },
+ { id: 'cinematic-realism', zh: '写实电影感', en: 'Cinematic Realism', tags: ['cinematic', 'Cinematic'] },
+ { id: 'fantasy', zh: '奇幻冒险', en: 'Fantasy Adventures', tags: ['fantasy', 'Fantasy'] },
+ { id: 'scifi', zh: '未来科幻', en: 'Future Sci-fi', tags: ['sci-fi', 'Sci-fi'] },
+ { id: 'anime', zh: '动漫风格', en: 'Anime Style', tags: ['anime-style', 'Anime style'] },
+ { id: 'retro-film', zh: '复古胶片', en: 'Retro Film', tags: ['nostalgic', 'Nostalgic', 'dv', 'DV'] },
+ { id: 'dreamlike', zh: '梦境视觉', en: 'Dreamlike Visuals', tags: [] },
+ { id: 'stop-motion', zh: '定格动画', en: 'Stop Motion', tags: ['stop-motion', 'Stop motion'] },
+ { id: 'drawn-animation', zh: '手绘动画', en: 'Hand-drawn Animation', tags: ['watercolor', 'Watercolor', '手绘插画', 'Hand-drawn illustration'] },
+ { id: 'characters', zh: '人物角色', en: 'People / Characters', tags: ['character-interaction', 'Character interaction', 'first-person', 'First person', '真人贴纸', 'ugc', 'UGC'] },
+ { id: 'motion-action', zh: '运动动作', en: 'Sports / Action', tags: ['action', 'Action', 'martial-arts', 'Martial arts', 'parkour', 'Parkour', 'skateboard', 'Skateboard'] },
+ { id: 'landscape', zh: '自然风光', en: 'Natural Landscapes', tags: ['nature-landscape', 'Natural landscapes'] },
+ { id: 'architecture', zh: '建筑空间', en: 'Architecture / Interiors', tags: ['architecture-interior', 'Architecture and interiors'] },
+ { id: 'city', zh: '城市街景', en: 'City Streets', tags: ['city-street', 'City streets'] },
+ { id: 'food-video', zh: '美食料理', en: 'Food / Cooking', tags: ['cooking', 'Cooking'] },
+ { id: 'product-video', zh: '产品特写', en: 'Product Close-ups', tags: ['advertising', 'Advertising', 'jewelry', 'Jewelry'] },
+ { id: 'camera-video', zh: '镜头运动', en: 'Camera Motion', tags: ['camera-motion', 'Camera motion', 'rack-focus', 'Rack focus', 'drone-orbit', 'Drone orbit', 'dolly-zoom', 'Dolly zoom', 'crane-up', 'Crane up', 'pan-right', 'Pan right', 'aerial', 'Aerial'] },
+ { id: 'dubbing', zh: '视频配音', en: 'Video Dubbing', tags: [], modules: ['smart-dubbing'] },
+ { id: 'download', zh: '视频下载', en: 'Video Downloads', tags: [], modules: ['video-download'] }
+];
+
+const imageTagOptions: FacetOption[] = [
+ { id: 'image-portrait', zh: '人像写真', en: 'Portraits', tags: ['人像摄影', 'Portrait photography', 'portrait', 'Portrait'] },
+ { id: 'image-social', zh: '社交帖子', en: 'Social Posts', tags: ['社交媒体', 'Social media', 'social', 'Social'] },
+ { id: 'image-infographic', zh: '信息图解', en: 'Infographics', tags: ['信息图表', 'Infographics', '教育科普', 'Educational content'] },
+ { id: 'image-thumbnail', zh: '视频封面', en: 'Video Thumbnails', tags: ['视频缩略图', 'Video thumbnails', 'youtube', 'YouTube', 'cover', 'Cover'] },
+ { id: 'image-storyboard', zh: '故事分镜', en: 'Storyboards', tags: ['storyboard', 'Storyboard'] },
+ { id: 'image-ad', zh: '品牌广告', en: 'Brand Ads', tags: ['商业广告', 'Commercial advertising', 'advertising', 'Advertising'] },
+ { id: 'image-ecommerce', zh: '电商主图', en: 'E-commerce', tags: ['电商视觉', 'E-commerce visuals', 'ecommerce', 'E-commerce'] },
+ { id: 'image-game', zh: '游戏视觉', en: 'Game Art', tags: ['游戏视觉', 'Game visuals'] },
+ { id: 'image-poster', zh: '海报设计', en: 'Posters', tags: ['海报设计', 'Poster design', '活动物料', 'Event collateral', 'poster', 'Poster'] },
+ { id: 'image-web', zh: '网页设计', en: 'Web Design', tags: ['网页界面', 'Web interfaces'] },
+ { id: 'image-photography', zh: '摄影', en: 'Photography', tags: ['人像摄影', 'Portrait photography', '创意摄影', 'Creative photography', '产品摄影', 'Product photography'] },
+ { id: 'image-cinematic', zh: '电影感', en: 'Cinematic', tags: ['cinematic', 'Cinematic', '电影感'] },
+ { id: 'image-anime', zh: '动漫插画', en: 'Anime Illustration', tags: ['anime-style', 'Anime style'] },
+ { id: 'image-illustration', zh: '手绘插画', en: 'Hand-drawn Art', tags: ['手绘插画', 'Hand-drawn illustration', '概念艺术', 'Concept art'] },
+ { id: 'image-3d', zh: '三维场景', en: '3D Scenes', tags: ['3d-render', '3D render', '等轴测', 'Isometric', '微缩场景', 'Miniature scenes'] },
+ { id: 'image-collage', zh: '拼贴手作', en: 'Collage / Craft', tags: ['拼贴设计', 'Collage design', '手工材质', 'Handcrafted textures'] },
+ { id: 'image-watercolor', zh: '水彩画', en: 'Watercolor', tags: ['watercolor', 'Watercolor'] },
+ { id: 'image-traditional', zh: '国风美学', en: 'Chinese-inspired', tags: ['传统文化', 'Traditional culture'] },
+ { id: 'image-retro', zh: '复古怀旧', en: 'Retro', tags: ['nostalgic', 'Nostalgic'] },
+ { id: 'image-future', zh: '未来科技', en: 'Futuristic', tags: ['未来科技', 'Future technology'] },
+ { id: 'image-minimal', zh: '极简设计', en: 'Minimalist', tags: ['minimalist', 'Minimalist'] },
+ { id: 'image-people', zh: '人物角色', en: 'People / Characters', tags: ['人像摄影', 'Portrait photography', '角色场景', 'Character scenes', '真人贴纸', 'Real-person stickers'] },
+ { id: 'image-product', zh: '商品产品', en: 'Products', tags: ['产品视觉', 'Product visuals', '产品摄影', 'Product photography', '电商视觉', 'E-commerce visuals', '工业设计', 'Industrial design', 'product', 'Product'] },
+ { id: 'image-food', zh: '美食饮品', en: 'Food / Drink', tags: ['食品饮料', 'Food and beverage'] },
+ { id: 'image-fashion', zh: '时尚穿搭', en: 'Fashion / Beauty', tags: ['时尚美妆', 'Fashion and beauty'] },
+ { id: 'image-architecture', zh: '建筑空间', en: 'Architecture', tags: ['建筑空间', 'Architecture and interiors'] },
+ { id: 'image-city', zh: '城市街景', en: 'City Streets', tags: ['city-street', 'City streets'] },
+ { id: 'image-nature', zh: '自然植物', en: 'Nature / Plants', tags: ['自然植物', 'Nature and botanicals'] },
+ { id: 'image-maps', zh: '地图图表', en: 'Maps / Charts', tags: ['地图视觉', 'Map visuals', '信息图表', 'Infographics'] },
+ { id: 'image-type', zh: '文字排版', en: 'Typography', tags: ['文本排版', 'Text layout', '编辑设计', 'Editorial design'] }
+];
const categoryOrder: CreatorHomeCategory[] = [
'recent',
'recommended',
+ 'all',
'video',
'image'
];
@@ -72,6 +143,9 @@ export function CreatorDashboard(props: {
}) {
const { language } = useAppLanguage();
const [category, setCategory] = useState<CreatorHomeCategory>('recommended');
+ const [selectedTag, setSelectedTag] = useState<string>();
+ const [visibleTagCount, setVisibleTagCount] = useState(Infinity);
+ const [moreTagsOpen, setMoreTagsOpen] = useState(false);
const [query, setQuery] = useState('');
const [searchOpen, setSearchOpen] = useState(false);
const [selectedPresetIdentity, setSelectedPresetIdentity] = useState<string>();
@@ -87,6 +161,9 @@ export function CreatorDashboard(props: {
const previewTriggerRef = useRef<HTMLButtonElement>(null);
const previewCloseRef = useRef<HTMLButtonElement>(null);
const promptRef = useRef<HTMLParagraphElement>(null);
+ const tagsFilterRef = useRef<HTMLDivElement>(null);
+ const tagsMeasureRef = useRef<HTMLDivElement>(null);
+ const moreTagsButtonRef = useRef<HTMLButtonElement>(null);
const busyIdentitiesRef = useRef(new Set<string>());
const [actionError, setActionError] = useState<string>();
const presets = props.presets ?? [];
@@ -100,18 +177,84 @@ export function CreatorDashboard(props: {
});
}
if (category === 'recommended') return presets.filter(preset => preset.featured);
+ if (category === 'all') return presets;
const modules = category === 'video' ? videoModules : imageModules;
return presets.filter(preset => modules.has(preset.module));
}, [category, presets, recentPresetIds]);
+ const categoryTagOptions = category === 'video'
+ ? videoTagOptions
+ : category === 'image'
+ ? imageTagOptions
+ : [];
+ const availableTagOptions = category === 'video'
+ ? videoTagOptions
+ : categoryTagOptions.filter(option => (
+ categoryPresets.some(preset => matchesFacet(preset, option))
+ ));
+ const pinnedTag = availableTagOptions.findIndex(option => option.id === selectedTag) >= visibleTagCount
+ ? selectedTag
+ : undefined;
+ const orderedTagOptions = pinnedTag === undefined
+ ? availableTagOptions
+ : [
+ ...availableTagOptions.filter(option => option.id === pinnedTag),
+ ...availableTagOptions.filter(option => option.id !== pinnedTag)
+ ];
+ const visibleTagOptions = orderedTagOptions.slice(0, visibleTagCount);
+ const overflowTagOptions = orderedTagOptions.slice(visibleTagCount);
+ const availableTagKey = orderedTagOptions.map(option => option.id).join('|');
const visiblePresets = useMemo(() => categoryPresets.filter(preset => (
- normalizedQuery === ''
- || `${preset.title} ${preset.description} ${preset.tags.join(' ')}`
- .toLocaleLowerCase()
- .includes(normalizedQuery)
- )), [categoryPresets, normalizedQuery]);
+ (selectedTag === undefined
+ || categoryTagOptions.some(option => option.id === selectedTag && matchesFacet(preset, option)))
+ && (normalizedQuery === ''
+ || `${preset.title} ${preset.description} ${preset.tags.join(' ')}`
+ .toLocaleLowerCase()
+ .includes(normalizedQuery))
+ )), [categoryPresets, selectedTag, normalizedQuery, category]);
const selectedPreset = selectedPresetIdentity === undefined
? undefined
: presets.find(preset => presetIdentity(preset) === selectedPresetIdentity);
+ useLayoutEffect(() => {
+ const filter = tagsFilterRef.current;
+ const measure = tagsMeasureRef.current;
+ if (filter === null || measure === null) return;
+
+ const update = () => {
+ const widths = Array.from(measure.children, child => child.getBoundingClientRect().width);
+ const toggleWidths = widths.splice(-2);
+ widths.push(Math.max(...toggleWidths));
+ const gap = Number.parseFloat(window.getComputedStyle(measure).columnGap) || 0;
+ const count = fitTagCount(widths, filter.getBoundingClientRect().width, gap);
+ setVisibleTagCount(count);
+ if (count === availableTagOptions.length) setMoreTagsOpen(false);
+ };
+ update();
+ const observer = typeof ResizeObserver === 'undefined' ? undefined : new ResizeObserver(update);
+ observer?.observe(filter);
+ window.addEventListener('resize', update);
+ return () => {
+ observer?.disconnect();
+ window.removeEventListener('resize', update);
+ };
+ }, [availableTagKey, language]);
+
+ useEffect(() => {
+ if (!moreTagsOpen) return;
+ const closeOnOutsideClick = (event: PointerEvent) => {
+ if (!tagsFilterRef.current?.contains(event.target as Node)) setMoreTagsOpen(false);
+ };
+ const closeOnEscape = (event: KeyboardEvent) => {
+ if (event.key !== 'Escape') return;
+ setMoreTagsOpen(false);
+ moreTagsButtonRef.current?.focus();
+ };
+ document.addEventListener('pointerdown', closeOnOutsideClick);
+ document.addEventListener('keydown', closeOnEscape);
+ return () => {
+ document.removeEventListener('pointerdown', closeOnOutsideClick);
+ document.removeEventListener('keydown', closeOnEscape);
+ };
+ }, [moreTagsOpen]);
const closePreview = useCallback(() => {
setPreviewOpen(false);
window.setTimeout(() => previewTriggerRef.current?.focus(), 0);
@@ -168,6 +311,8 @@ export function CreatorDashboard(props: {
function selectCategory(nextCategory: CreatorHomeCategory) {
setCategory(nextCategory);
+ setSelectedTag(undefined);
+ setMoreTagsOpen(false);
setQuery('');
setSearchOpen(false);
setActionError(undefined);
@@ -516,6 +661,81 @@ export function CreatorDashboard(props: {
)}
</div>
+ {(category === 'video' || category === 'image') ? (
+ <div className="creator-template-tags-filter" role="group" aria-label={language === 'en-US' ? 'Filter templates' : '筛选模板'} ref={tagsFilterRef}>
+ <div className="creator-template-tags-line">
+ <button
+ type="button"
+ aria-pressed={selectedTag === undefined}
+ onClick={() => {
+ setSelectedTag(undefined);
+ setMoreTagsOpen(false);
+ }}
+ >
+ {language === 'en-US' ? 'All' : '全部'}
+ </button>
+ {visibleTagOptions.map(option => (
+ <button
+ type="button"
+ key={option.id}
+ aria-pressed={selectedTag === option.id}
+ onClick={() => setSelectedTag(option.id)}
+ >
+ {language === 'en-US' ? option.en : option.zh}
+ </button>
+ ))}
+ {overflowTagOptions.length > 0 ? (
+ <button
+ className="creator-template-tags-more"
+ type="button"
+ ref={moreTagsButtonRef}
+ aria-expanded={moreTagsOpen}
+ aria-controls="creator-template-tags-overflow"
+ onClick={() => setMoreTagsOpen(open => !open)}
+ >
+ {moreTagsOpen
+ ? (language === 'en-US' ? 'Show less' : '收起')
+ : (language === 'en-US' ? 'More' : '更多')}
+ <ChevronDown size={14} aria-hidden="true" />
+ </button>
+ ) : null}
+ </div>
+ {moreTagsOpen && overflowTagOptions.length > 0 ? (
+ <div className="creator-template-tags-overflow" id="creator-template-tags-overflow" role="group" aria-label={language === 'en-US' ? 'More template filters' : '更多模板分类'}>
+ {overflowTagOptions.map(option => (
+ <button
+ type="button"
+ key={option.id}
+ aria-pressed={selectedTag === option.id}
+ onClick={() => {
+ setSelectedTag(option.id);
+ setMoreTagsOpen(false);
+ }}
+ >
+ {language === 'en-US' ? option.en : option.zh}
+ </button>
+ ))}
+ </div>
+ ) : null}
+ <div className="creator-template-tags-measure" aria-hidden="true" ref={tagsMeasureRef}>
+ <button type="button" tabIndex={-1}>{language === 'en-US' ? 'All' : '全部'}</button>
+ {orderedTagOptions.map(option => (
+ <button type="button" tabIndex={-1} key={option.id} aria-pressed={selectedTag === option.id}>
+ {language === 'en-US' ? option.en : option.zh}
+ </button>
+ ))}
+ <button type="button" tabIndex={-1} className="creator-template-tags-more">
+ {language === 'en-US' ? 'More' : '更多'}
+ <ChevronDown size={14} aria-hidden="true" />
+ </button>
+ <button type="button" tabIndex={-1} className="creator-template-tags-more">
+ {language === 'en-US' ? 'Show less' : '收起'}
+ <ChevronDown size={14} aria-hidden="true" />
+ </button>
+ </div>
+ </div>
+ ) : null}
+
{props.loading ? (
<div
className="creator-template-grid creator-template-loading-grid"
@@ -583,6 +803,8 @@ export function CreatorDashboard(props: {
<p className="creator-template-empty">
{normalizedQuery
? (language === 'en-US' ? 'No matching presets.' : '没有匹配的模板。')
+ : selectedTag !== undefined
+ ? (language === 'en-US' ? 'No templates for this tag yet.' : '该标签暂时没有模板。')
: category === 'recent'
? (language === 'en-US'
? 'No recently used templates.'
@@ -652,12 +874,35 @@ function categoryLabel(
const labels: Record<CreatorHomeCategory, { zh: string; en: string }> = {
recent: { zh: '最近', en: 'Recent' },
recommended: { zh: '推荐', en: 'Recommended' },
+ all: { zh: '全部', en: 'All' },
video: { zh: '视频创作', en: 'Video Creation' },
image: { zh: '图像设计', en: 'Image Design' }
};
return language === 'en-US' ? labels[category].en : labels[category].zh;
}
+function matchesFacet(preset: CreatorPresetSummary, option: FacetOption): boolean {
+ return option.modules?.includes(preset.module) === true
+ || (preset.tagIds ?? preset.tags).some(tag => option.tags.includes(tag));
+}
+
+function fitTagCount(widths: number[], availableWidth: number, gap: number): number {
+ if (widths.length < 2) return 0;
+ const optionWidths = widths.slice(1, -1);
+ const allWidth = widths[0]!;
+ const fullWidth = allWidth + optionWidths.reduce((sum, width) => sum + width + gap, 0);
+ if (fullWidth <= availableWidth) return optionWidths.length;
+
+ let usedWidth = allWidth + widths[widths.length - 1]! + gap;
+ let count = 0;
+ for (const width of optionWidths) {
+ if (usedWidth + width + gap > availableWidth) break;
+ usedWidth += width + gap;
+ count++;
+ }
+ return count;
+}
+
function moduleLabel(
module: CreatorRuntimeWorkspace,
language: 'zh-CN' | 'en-US'
diff --git a/apps/web/src/styles/app.css b/apps/web/src/styles/app.css
index ad615604..d8a6992b 100644
--- a/apps/web/src/styles/app.css
+++ b/apps/web/src/styles/app.css
@@ -3404,7 +3404,7 @@ html.is-pane-resizing * {
width: min(760px, 100%);
min-height: 42px;
display: grid;
- grid-template-columns: repeat(4, minmax(0, 1fr));
+ grid-template-columns: repeat(5, minmax(0, 1fr));
gap: 4px;
margin: 0 auto;
padding: 4px;
@@ -3446,12 +3446,88 @@ html.is-pane-resizing * {
}
.creator-template-tabs button:focus-visible,
+.creator-template-tags-filter button:focus-visible,
.creator-template-search-trigger:focus-visible,
.creator-template-search button:focus-visible {
outline: 2px solid var(--state-focus-ring);
outline-offset: -2px;
}
+.creator-template-tags-filter {
+ position: relative;
+ min-width: 0;
+ margin: 0 0 22px;
+ padding: 2px 0 0;
+}
+
+.creator-template-tags-line,
+.creator-template-tags-measure {
+ display: flex;
+ align-items: center;
+ gap: 5px;
+ white-space: nowrap;
+}
+
+.creator-template-tags-line {
+ width: 100%;
+ min-width: 0;
+ overflow: hidden;
+}
+
+.creator-template-tags-measure {
+ position: absolute;
+ top: 0;
+ left: 0;
+ width: max-content;
+ visibility: hidden;
+ pointer-events: none;
+}
+
+.creator-template-tags-filter button {
+ flex: 0 0 auto;
+ min-height: 34px;
+ padding: 7px 10px;
+ border: 1px solid transparent;
+ border-radius: 999px;
+ background: transparent;
+ color: var(--muted);
+ font-size: 13px;
+ font-weight: 500;
+ line-height: 1.25;
+ white-space: nowrap;
+ cursor: pointer;
+}
+
+.creator-template-tags-filter button:hover {
+ color: var(--text);
+ background: color-mix(in srgb, var(--surface-2) 65%, transparent);
+}
+
+.creator-template-tags-filter button[aria-pressed="true"] {
+ border-color: var(--border);
+ background: var(--surface-2);
+ color: var(--text);
+ font-weight: 600;
+ box-shadow: 0 1px 3px color-mix(in srgb, var(--text) 7%, transparent);
+}
+
+.creator-template-tags-filter .creator-template-tags-more {
+ display: inline-flex;
+ align-items: center;
+ gap: 4px;
+}
+
+.creator-template-tags-more[aria-expanded="true"] svg {
+ transform: rotate(180deg);
+}
+
+.creator-template-tags-overflow {
+ display: flex;
+ flex-wrap: wrap;
+ gap: 4px 5px;
+ margin-top: 4px;
+}
+
.creator-template-search-trigger {
width: 32px;
height: 32px;
@@ -7472,11 +7548,17 @@ button.creator-template-outcome-expand:hover {
}
.creator-template-tabs {
- grid-template-columns: repeat(4, minmax(84px, 1fr));
+ grid-template-columns: repeat(5, minmax(84px, 1fr));
justify-content: stretch;
overflow-x: auto;
}
+ .creator-template-tags-filter button {
+ padding-right: 10px;
+ padding-left: 10px;
+ font-size: 12px;
+ }
+
.creator-tool-button {
min-height: 72px;
grid-template-columns: 32px minmax(0, 1fr);
diff --git a/packages/protocol/src/creator.ts b/packages/protocol/src/creator.ts
index ce2e71fd..0a96b7e4 100644
--- a/packages/protocol/src/creator.ts
+++ b/packages/protocol/src/creator.ts
@@ -164,6 +164,7 @@ export type CreatorPresetSummary = CreatorPresetRef & {
author?: CreatorPresetAuthor;
prompt: string | null;
tags: string[];
+ tagIds?: string[];
featured: boolean;
sortOrder: number;
requirements: CreatorPresetRequirements | null;
diff --git a/template/image-generation/animated-campus-world-reference-board/1/template.json b/template/image-generation/animated-campus-world-reference-board/1/template.json
index 32376e3a..2ec7a12d 100644
--- a/template/image-generation/animated-campus-world-reference-board/1/template.json
+++ b/template/image-generation/animated-campus-world-reference-board/1/template.json
@@ -29,6 +29,7 @@
"影视叙事",
"角色场景",
"多视角一致性",
+ "anime-style",
"reference-template"
],
"defaults": {
diff --git a/template/image-generation/city-corner-3d-billboard-photography/1/template.json b/template/image-generation/city-corner-3d-billboard-photography/1/template.json
index 2e87c809..2dafaf76 100644
--- a/template/image-generation/city-corner-3d-billboard-photography/1/template.json
+++ b/template/image-generation/city-corner-3d-billboard-photography/1/template.json
@@ -28,6 +28,8 @@
"商业广告",
"旅行城市",
"未来科技",
+ "3d-render",
+ "city-street",
"reference-template"
],
"defaults": {
diff --git a/template/image-generation/croissant-baking-storyboard/1/template.json b/template/image-generation/croissant-baking-storyboard/1/template.json
index f045b26d..d69e1da5 100644
--- a/template/image-generation/croissant-baking-storyboard/1/template.json
+++ b/template/image-generation/croissant-baking-storyboard/1/template.json
@@ -29,6 +29,7 @@
"影视叙事",
"食品饮料",
"商业广告",
+ "storyboard",
"reference-template"
],
"defaults": {
diff --git a/template/image-generation/desert-car-wash-documentary-photo/1/template.json b/template/image-generation/desert-car-wash-documentary-photo/1/template.json
index 2ab4ad6e..6520e8a9 100644
--- a/template/image-generation/desert-car-wash-documentary-photo/1/template.json
+++ b/template/image-generation/desert-car-wash-documentary-photo/1/template.json
@@ -28,6 +28,7 @@
"商业广告",
"人像摄影",
"创意摄影",
+ "cinematic",
"reference-template"
],
"defaults": {
diff --git a/template/image-generation/four-city-minimal-travel-poster-series/1/template.json b/template/image-generation/four-city-minimal-travel-poster-series/1/template.json
index f9c8d9b2..8f244225 100644
--- a/template/image-generation/four-city-minimal-travel-poster-series/1/template.json
+++ b/template/image-generation/four-city-minimal-travel-poster-series/1/template.json
@@ -29,6 +29,7 @@
"海报设计",
"旅行城市",
"系列视觉",
+ "minimalist",
"reference-template"
],
"defaults": {
diff --git a/template/image-generation/futuristic-biophilic-atrium/1/template.json b/template/image-generation/futuristic-biophilic-atrium/1/template.json
index fc285cbe..7888d775 100644
--- a/template/image-generation/futuristic-biophilic-atrium/1/template.json
+++ b/template/image-generation/futuristic-biophilic-atrium/1/template.json
@@ -29,6 +29,7 @@
"设计参考",
"建筑空间",
"未来科技",
+ "3d-render",
"reference-template"
],
"defaults": {
diff --git a/template/image-generation/minimal-abstract-geometric-deconstruction-poster/1/template.json b/template/image-generation/minimal-abstract-geometric-deconstruction-poster/1/template.json
index f19a21fc..26cccc61 100644
--- a/template/image-generation/minimal-abstract-geometric-deconstruction-poster/1/template.json
+++ b/template/image-generation/minimal-abstract-geometric-deconstruction-poster/1/template.json
@@ -29,6 +29,7 @@
"海报设计",
"图片转绘",
"编辑设计",
+ "minimalist",
"reference-template"
],
"defaults": {
diff --git a/template/image-generation/minimal-conceptual-line-art-poster/1/template.json b/template/image-generation/minimal-conceptual-line-art-poster/1/template.json
index e916678e..81193469 100644
--- a/template/image-generation/minimal-conceptual-line-art-poster/1/template.json
+++ b/template/image-generation/minimal-conceptual-line-art-poster/1/template.json
@@ -29,6 +29,7 @@
"海报设计",
"图片转绘",
"概念艺术",
+ "minimalist",
"reference-template"
],
"defaults": {
diff --git a/template/image-generation/paper-relief-neighborhood-grid/1/template.json b/template/image-generation/paper-relief-neighborhood-grid/1/template.json
index a7d01aa9..288e274e 100644
--- a/template/image-generation/paper-relief-neighborhood-grid/1/template.json
+++ b/template/image-generation/paper-relief-neighborhood-grid/1/template.json
@@ -29,6 +29,7 @@
"设计参考",
"建筑空间",
"手工材质",
+ "city-street",
"reference-template"
],
"defaults": {
diff --git a/template/image-generation/playful-ceramic-ecommerce-hero/1/template.json b/template/image-generation/playful-ceramic-ecommerce-hero/1/template.json
index 42731c90..bbca4f09 100644
--- a/template/image-generation/playful-ceramic-ecommerce-hero/1/template.json
+++ b/template/image-generation/playful-ceramic-ecommerce-hero/1/template.json
@@ -28,6 +28,7 @@
"网页界面",
"产品视觉",
"编辑设计",
+ "ecommerce",
"reference-template"
],
"defaults": {
diff --git a/template/image-generation/premium-food-commercial-storyboard/1/template.json b/template/image-generation/premium-food-commercial-storyboard/1/template.json
index 62a7e0ff..d095d4e6 100644
--- a/template/image-generation/premium-food-commercial-storyboard/1/template.json
+++ b/template/image-generation/premium-food-commercial-storyboard/1/template.json
@@ -29,6 +29,7 @@
"影视叙事",
"食品饮料",
"商业广告",
+ "storyboard",
"reference-template"
],
"defaults": {
diff --git a/template/image-generation/vintage-scientific-botanical-poster/1/template.json b/template/image-generation/vintage-scientific-botanical-poster/1/template.json
index 9f20675d..ccd74e50 100644
--- a/template/image-generation/vintage-scientific-botanical-poster/1/template.json
+++ b/template/image-generation/vintage-scientific-botanical-poster/1/template.json
@@ -29,6 +29,7 @@
"教育科普",
"自然植物",
"手绘插画",
+ "nostalgic",
"reference-template"
],
"defaults": {
diff --git a/template/image-generation/watercolor-editorial-illustration-poster/1/template.json b/template/image-generation/watercolor-editorial-illustration-poster/1/template.json
index 4b3cdd93..6fafcf03 100644
--- a/template/image-generation/watercolor-editorial-illustration-poster/1/template.json
+++ b/template/image-generation/watercolor-editorial-illustration-poster/1/template.json
@@ -29,6 +29,7 @@
"海报设计",
"图片转绘",
"手绘插画",
+ "watercolor",
"reference-template"
],
"defaults": {
diff --git a/template/image-generation/wuhan-vintage-map-poster/1/template.json b/template/image-generation/wuhan-vintage-map-poster/1/template.json
index b43cee54..f3b8e31a 100644
--- a/template/image-generation/wuhan-vintage-map-poster/1/template.json
+++ b/template/image-generation/wuhan-vintage-map-poster/1/template.json
@@ -29,6 +29,7 @@
"海报设计",
"旅行城市",
"地图视觉",
+ "nostalgic",
"reference-template"
],
"defaults": {
diff --git a/template/video-generation/anime-skateboard-chase-nyc/1/template.json b/template/video-generation/anime-skateboard-chase-nyc/1/template.json
index e2bebfa1..1f1dc7b8 100644
--- a/template/video-generation/anime-skateboard-chase-nyc/1/template.json
+++ b/template/video-generation/anime-skateboard-chase-nyc/1/template.json
@@ -21,6 +21,8 @@
"cover": "cover.jpg",
"tags": [
"animation",
+ "anime-style",
+ "city-street",
"skateboard",
"horizontal",
"image-to-video"
diff --git a/template/video-generation/bedroom-falling-book-catch/1/template.json b/template/video-generation/bedroom-falling-book-catch/1/template.json
index 77624694..556c4469 100644
--- a/template/video-generation/bedroom-falling-book-catch/1/template.json
+++ b/template/video-generation/bedroom-falling-book-catch/1/template.json
@@ -21,6 +21,7 @@
"cover": "cover.jpg",
"tags": [
"character-interaction",
+ "architecture-interior",
"vertical",
"image-to-video"
],
diff --git a/template/video-generation/brutalist-courtyard-martial-arts/1/template.json b/template/video-generation/brutalist-courtyard-martial-arts/1/template.json
index 3aed1440..a849a3a2 100644
--- a/template/video-generation/brutalist-courtyard-martial-arts/1/template.json
+++ b/template/video-generation/brutalist-courtyard-martial-arts/1/template.json
@@ -22,6 +22,7 @@
"tags": [
"action",
"martial-arts",
+ "architecture-interior",
"horizontal",
"text-to-video"
],
diff --git a/template/video-generation/nyc-parkour-web-swing/1/template.json b/template/video-generation/nyc-parkour-web-swing/1/template.json
index c0b63b7e..3503c52f 100644
--- a/template/video-generation/nyc-parkour-web-swing/1/template.json
+++ b/template/video-generation/nyc-parkour-web-swing/1/template.json
@@ -22,6 +22,7 @@
"tags": [
"action",
"parkour",
+ "city-street",
"horizontal",
"image-to-video"
],
diff --git a/template/video-generation/rainforest-mysterious-light/1/template.json b/template/video-generation/rainforest-mysterious-light/1/template.json
index 113902d3..7b8cc4d5 100644
--- a/template/video-generation/rainforest-mysterious-light/1/template.json
+++ b/template/video-generation/rainforest-mysterious-light/1/template.json
@@ -22,6 +22,7 @@
"tags": [
"cinematic",
"mystery",
+ "nature-landscape",
"vertical",
"image-to-video"
],
diff --git a/template/video-generation/seoul-sunday-dv-home-video/1/template.json b/template/video-generation/seoul-sunday-dv-home-video/1/template.json
index a4409bd7..e2d87153 100644
--- a/template/video-generation/seoul-sunday-dv-home-video/1/template.json
+++ b/template/video-generation/seoul-sunday-dv-home-video/1/template.json
@@ -22,6 +22,7 @@
"tags": [
"dv",
"nostalgic",
+ "city-street",
"horizontal",
"text-to-video"
],