fix: 新生成短篇剧本刷新到历史列表 + 分类标签从实际数据动态生成

- novel_done 事件处理中调用 store.fetchScripts() 刷新剧本列表
- typeTabs 从硬编码改为 computed,根据实际 length 值动态生成
- activeType 默认值从 'long' 改为 'all'(显示全部)
- 过滤逻辑改为精确匹配 length 字段
- 移除无效的 '风格' 硬编码分类标签

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-21 08:39:14 +08:00
parent 1f5ad3abe2
commit 9a215a89e9
2 changed files with 17 additions and 8 deletions
@@ -152,7 +152,7 @@ import { useAppStore } from '../../stores/app.js'
import { toggleFavoriteScript, checkFavoriteScript } from '../../services/epicScript.js'
const store = useAppStore()
const activeType = ref('long')
const activeType = ref('all')
const activeStatus = ref('all')
const keyword = ref('')
const sortMode = ref('updated')
@@ -162,11 +162,18 @@ const activeMenuId = ref('')
const deleteTarget = ref(null)
const deletingScript = ref(false)
const typeTabs = [
{ label: '篇', value: 'long' },
{ label: '短篇', value: 'short' },
{ label: '风格', value: 'style' }
]
// length 字段值 → 显示标签映射
const LENGTH_LABELS = { short: '短篇', medium: '篇', long: '长篇' }
// 从实际剧本数据中提取分类标签,禁止硬编码
const typeTabs = computed(() => {
const lengths = new Set(scripts.value.map(s => s.length || 'medium'))
const tabs = [{ label: '全部', value: 'all' }]
lengths.forEach(l => {
tabs.push({ label: LENGTH_LABELS[l] || l, value: l })
})
return tabs
})
const statusFilters = [
{ label: '全部', value: 'all' },
@@ -187,8 +194,8 @@ const visibleScripts = computed(() => {
}
if (activeStatus.value === 'favorite') return isFavorite(script)
if (activeStatus.value !== 'all' && status !== activeStatus.value) return false
if (activeType.value === 'short') return script.length === 'short'
if (activeType.value === 'long') return script.length !== 'short'
// 精确匹配 length 字段,禁止硬编码分类
if (activeType.value !== 'all') return script.length === activeType.value
return true
})
return [...filtered].sort((a, b) => {
@@ -1733,6 +1733,8 @@ const handleShortNovelEvent = (event) => {
generationStatus.value = 'idle'
pendingNextResponse.value = false
persistResultMessages()
// 从后端刷新剧本列表,确保新生成的短篇出现在历史中(非阻塞)
store.fetchScripts()
break
}
case 'error':