fix(web): 修复文件详情弹窗视图模式切换逻辑

- 改为检查 hasChunks(有实际分块数据)而非 hasIndexed(索引状态)
- 当文件没有 chunks 时正确重置为 markdown 视图
This commit is contained in:
Wenjie Zhang 2026-02-15 21:59:28 +08:00
parent e6ad5dfa1d
commit 426b3ddc5b

View File

@ -25,7 +25,7 @@
</span>
<!-- 视图模式切换 -->
<div class="view-controls" v-if="file && hasContent">
<div class="view-controls" v-if="file && hasChunks">
<a-segmented v-model:value="viewMode" :options="viewModeOptions" />
</div>
@ -141,21 +141,22 @@ const hasIndexed = computed(() => ['done', 'indexed'].includes(file.value?.statu
const hasContent = computed(
() => (file.value?.lines && file.value?.lines.length > 0) || file.value?.content
)
//
const hasChunks = computed(() => mappedChunks.value && mappedChunks.value.length > 0)
const viewModeOptions = computed(() => {
const options = [{ label: 'Markdown', value: 'markdown' }]
if (hasIndexed.value) {
// Chunks
if (hasChunks.value) {
options.push({ label: 'Chunks', value: 'chunks' })
}
return options
})
//
// chunks markdown
watch(file, (newFile) => {
if (newFile) {
if (!hasIndexed.value) {
viewMode.value = 'markdown'
}
if (newFile && !hasChunks.value) {
viewMode.value = 'markdown'
}
})