Browse Source

fix(agent-document): deserialize tags in listDocuments + null guard in template

- Service layer: map rows with deserializeTags to return string[] not JSON string
- Frontend: add null guard on item.tags.length to prevent render crash when tags is null

Co-authored-by: CodeFree <codefree@chinatelcom.cn>
feat/agent-independence
npmrun 2 months ago
parent
commit
c5e9ae924b
  1. 2
      app/pages/agent-documents/index.vue
  2. 2
      server/service/agent-document/index.ts

2
app/pages/agent-documents/index.vue

@ -151,7 +151,7 @@ onMounted(() => {
{{ item.type === 'document' ? '文档' : '记忆' }} {{ item.type === 'document' ? '文档' : '记忆' }}
</span> </span>
<span class="card-date">{{ new Date(item.updatedAt).toLocaleDateString('zh-CN') }}</span> <span class="card-date">{{ new Date(item.updatedAt).toLocaleDateString('zh-CN') }}</span>
<span v-if="item.tags.length > 0" class="card-tags"> <span v-if="item.tags && item.tags.length > 0" class="card-tags">
<span v-for="tag in item.tags" :key="tag" class="tag-chip">{{ tag }}</span> <span v-for="tag in item.tags" :key="tag" class="tag-chip">{{ tag }}</span>
</span> </span>
</div> </div>

2
server/service/agent-document/index.ts

@ -155,7 +155,7 @@ export async function listDocuments(
const total = countResult[0]?.count ?? 0; const total = countResult[0]?.count ?? 0;
return { return {
items: rows, items: rows.map((r) => ({ ...r, tags: deserializeTags(r.tags) })),
total, total,
page, page,
pageSize, pageSize,

Loading…
Cancel
Save