diff --git a/components/department-dashboard/BrandKnowledgeDashboard.test.tsx b/components/department-dashboard/BrandKnowledgeDashboard.test.tsx
index 759fb05..80776ad 100644
--- a/components/department-dashboard/BrandKnowledgeDashboard.test.tsx
+++ b/components/department-dashboard/BrandKnowledgeDashboard.test.tsx
@@ -1,4 +1,4 @@
-import { fireEvent, render, screen, waitFor } from '@testing-library/react'
+import { fireEvent, render, screen, waitFor, within } from '@testing-library/react'
import BrandKnowledgeDashboard from './BrandKnowledgeDashboard'
import { BRAND_KNOWLEDGE_TYPE_OPTIONS } from '@/lib/brand-knowledge-file-types'
@@ -42,6 +42,46 @@ describe('BrandKnowledgeDashboard', () => {
expect(screen.getByText('没有找到与“索菲亚”匹配的知识内容')).toBeInTheDocument()
})
+ it('shows uploaded knowledge with the material-library card hierarchy', async () => {
+ global.fetch = jest.fn().mockResolvedValue({
+ ok: true,
+ json: async () => ({
+ success: true,
+ data: [{
+ id: 'knowledge-1',
+ title: '索菲亚图像影像规范',
+ knowledgeType: '影像规范',
+ brand: '索菲亚',
+ productCategoryName: '衣柜',
+ fileName: '索菲亚图像影像规范.rar',
+ mimeType: 'application/vnd.rar',
+ fileSize: 668886630,
+ createdAt: '2026-09-12T00:00:00.000Z',
+ uploadedBy: '无邪',
+ downloadUrl: '/api/department-dashboard/brand-knowledge/knowledge-1/file',
+ previewUrl: '/api/department-dashboard/brand-knowledge/knowledge-1/preview',
+ previewImageName: 'preview.png',
+ }],
+ }),
+ } as Response)
+
+ render()
+
+ expect(await screen.findByRole('img', { name: '预览图:索菲亚图像影像规范' })).toBeInTheDocument()
+ expect(screen.getByRole('heading', { level: 3, name: '索菲亚图像影像规范' })).toBeInTheDocument()
+ expect(screen.getByText(/637\.9 MB/)).toBeInTheDocument()
+ expect(screen.getByText(/上传人:无邪/)).toBeInTheDocument()
+ expect(screen.getByText('索菲亚图像影像规范.rar')).toBeInTheDocument()
+ const knowledgeList = screen.getByRole('list', { name: '品牌知识内容列表' })
+ expect(within(knowledgeList).getByText('影像规范')).toBeInTheDocument()
+ expect(within(knowledgeList).getByText('索菲亚')).toBeInTheDocument()
+ expect(within(knowledgeList).getByText('衣柜')).toBeInTheDocument()
+ expect(screen.getByRole('link', { name: '下载索菲亚图像影像规范' })).toHaveAttribute(
+ 'href',
+ '/api/department-dashboard/brand-knowledge/knowledge-1/file',
+ )
+ })
+
it('submits a selected knowledge file to the independent API', async () => {
const fetchMock = global.fetch as jest.Mock
fetchMock.mockImplementation((input: RequestInfo | URL, init?: RequestInit) => {
diff --git a/components/department-dashboard/BrandKnowledgeDashboard.tsx b/components/department-dashboard/BrandKnowledgeDashboard.tsx
index 7ec19bf..61c8e4d 100644
--- a/components/department-dashboard/BrandKnowledgeDashboard.tsx
+++ b/components/department-dashboard/BrandKnowledgeDashboard.tsx
@@ -12,6 +12,77 @@ type BrandKnowledgeItem = { id: string; title: string; knowledgeType: string; br
function formatFileSize(size: number) { if (size < 1024) return `${size} B`; if (size < 1024 * 1024) return `${(size / 1024).toFixed(1)} KB`; if (size < 1024 * 1024 * 1024) return `${(size / (1024 * 1024)).toFixed(1)} MB`; return `${(size / (1024 * 1024 * 1024)).toFixed(1)} GB` }
function formatDate(value: string) { const date = new Date(value); return Number.isNaN(date.getTime()) ? value : new Intl.DateTimeFormat('zh-CN', { year: 'numeric', month: '2-digit', day: '2-digit' }).format(date) }
+function BrandKnowledgeCard({ item }: { item: BrandKnowledgeItem }) {
+ const details = [
+ formatFileSize(item.fileSize),
+ item.uploadedBy ? `上传人:${item.uploadedBy}` : '',
+ formatDate(item.createdAt),
+ ].filter(Boolean)
+
+ return (
+
+
+
+ {item.previewUrl ? (
+
+ ) : (
+
+
+ 暂无预览图
+
+ )}
+
+
+
+
+ {item.title}
+
+
+ {details.map((detail, index) => (
+
+ {index > 0 && · }
+ {detail}
+
+ ))}
+
+
+ {item.fileName}
+
+
+
+ {item.knowledgeType}
+ {item.brand && item.brand !== '未关联品牌' && (
+ <>/{item.brand}>
+ )}
+ {item.productCategoryName && (
+ <>/{item.productCategoryName}>
+ )}
+
+
+
+
+
+
+ )
+}
+
export default function BrandKnowledgeDashboard() {
const [selectedType, setSelectedType] = useState('全部')
const [searchKeyword, setSearchKeyword] = useState('')
@@ -123,7 +194,7 @@ export default function BrandKnowledgeDashboard() {
- {isLoading ? 正在读取知识内容…
: visibleItems.length > 0 ? :
+ {isLoading ?
正在读取知识内容…
: visibleItems.length > 0 ?
{visibleItems.map((item) => )}
:
{emptyMessage}
点击右上角“上传知识”,即可将文件保存到品牌知识库。