fix(knowledge): paginate document list without content
This commit is contained in:
@@ -54,6 +54,26 @@ func BuildKnowledgeDocument(item *models.KnowledgeDocument) response.KnowledgeDo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func BuildKnowledgeDocumentList(item *models.KnowledgeDocument) response.KnowledgeDocumentListResponse {
|
||||||
|
return response.KnowledgeDocumentListResponse{
|
||||||
|
ID: item.ID,
|
||||||
|
KnowledgeBaseID: item.KnowledgeBaseID,
|
||||||
|
Title: item.Title,
|
||||||
|
Status: item.Status,
|
||||||
|
StatusName: enums.GetStatusLabel(item.Status),
|
||||||
|
IndexStatus: item.IndexStatus,
|
||||||
|
IndexStatusName: enums.GetKnowledgeDocumentIndexStatusLabel(item.IndexStatus),
|
||||||
|
IndexedAt: item.IndexedAt,
|
||||||
|
IndexError: item.IndexError,
|
||||||
|
ContentHash: item.ContentHash,
|
||||||
|
ContentType: item.ContentType,
|
||||||
|
CreatedAt: item.CreatedAt,
|
||||||
|
UpdatedAt: item.UpdatedAt,
|
||||||
|
CreateUserName: item.CreateUserName,
|
||||||
|
UpdateUserName: item.UpdateUserName,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func BuildKnowledgeFAQ(item *models.KnowledgeFAQ) response.KnowledgeFAQResponse {
|
func BuildKnowledgeFAQ(item *models.KnowledgeFAQ) response.KnowledgeFAQResponse {
|
||||||
return response.KnowledgeFAQResponse{
|
return response.KnowledgeFAQResponse{
|
||||||
ID: item.ID,
|
ID: item.ID,
|
||||||
|
|||||||
@@ -39,10 +39,10 @@ func (c *KnowledgeDocumentController) AnyList() *web.JsonResult {
|
|||||||
cnd.Where("index_status = ?", indexStatus)
|
cnd.Where("index_status = ?", indexStatus)
|
||||||
}
|
}
|
||||||
|
|
||||||
list, paging := services.KnowledgeDocumentService.FindPageByCnd(cnd)
|
list, paging := services.KnowledgeDocumentService.FindPageListByCnd(cnd)
|
||||||
results := make([]response.KnowledgeDocumentResponse, 0, len(list))
|
results := make([]response.KnowledgeDocumentListResponse, 0, len(list))
|
||||||
for _, item := range list {
|
for _, item := range list {
|
||||||
results = append(results, builders.BuildKnowledgeDocument(&item))
|
results = append(results, builders.BuildKnowledgeDocumentList(&item))
|
||||||
}
|
}
|
||||||
return web.JsonData(&web.PageResult{Results: results, Page: paging})
|
return web.JsonData(&web.PageResult{Results: results, Page: paging})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,6 +51,25 @@ type KnowledgeDocumentResponse struct {
|
|||||||
UpdateUserName string `json:"updateUserName"`
|
UpdateUserName string `json:"updateUserName"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type KnowledgeDocumentListResponse struct {
|
||||||
|
ID int64 `json:"id"`
|
||||||
|
KnowledgeBaseID int64 `json:"knowledgeBaseId"`
|
||||||
|
KnowledgeBaseName string `json:"knowledgeBaseName,omitempty"`
|
||||||
|
Title string `json:"title"`
|
||||||
|
ContentType enums.KnowledgeDocumentContentType `json:"contentType"`
|
||||||
|
Status enums.Status `json:"status"`
|
||||||
|
StatusName string `json:"statusName"`
|
||||||
|
IndexStatus enums.KnowledgeDocumentIndexStatus `json:"indexStatus"`
|
||||||
|
IndexStatusName string `json:"indexStatusName"`
|
||||||
|
IndexedAt *time.Time `json:"indexedAt"`
|
||||||
|
IndexError string `json:"indexError"`
|
||||||
|
ContentHash string `json:"contentHash"`
|
||||||
|
CreatedAt time.Time `json:"createdAt"`
|
||||||
|
UpdatedAt time.Time `json:"updatedAt"`
|
||||||
|
CreateUserName string `json:"createUserName"`
|
||||||
|
UpdateUserName string `json:"updateUserName"`
|
||||||
|
}
|
||||||
|
|
||||||
type KnowledgeFAQResponse struct {
|
type KnowledgeFAQResponse struct {
|
||||||
ID int64 `json:"id"`
|
ID int64 `json:"id"`
|
||||||
KnowledgeBaseID int64 `json:"knowledgeBaseId"`
|
KnowledgeBaseID int64 `json:"knowledgeBaseId"`
|
||||||
|
|||||||
@@ -62,6 +62,18 @@ func (r *knowledgeDocumentRepository) FindPageByCnd(db *gorm.DB, cnd *sqls.Cnd)
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r *knowledgeDocumentRepository) FindPageListByCnd(db *gorm.DB, cnd *sqls.Cnd) (list []models.KnowledgeDocument, paging *sqls.Paging) {
|
||||||
|
cnd.Find(db.Omit("content"), &list)
|
||||||
|
count := cnd.Count(db, &models.KnowledgeDocument{})
|
||||||
|
|
||||||
|
paging = &sqls.Paging{
|
||||||
|
Page: cnd.Paging.Page,
|
||||||
|
Limit: cnd.Paging.Limit,
|
||||||
|
Total: count,
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func (r *knowledgeDocumentRepository) Count(db *gorm.DB, cnd *sqls.Cnd) int64 {
|
func (r *knowledgeDocumentRepository) Count(db *gorm.DB, cnd *sqls.Cnd) int64 {
|
||||||
return cnd.Count(db, &models.KnowledgeDocument{})
|
return cnd.Count(db, &models.KnowledgeDocument{})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,55 @@
|
|||||||
|
package repositories
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"cs-agent/internal/models"
|
||||||
|
"cs-agent/internal/pkg/enums"
|
||||||
|
|
||||||
|
"github.com/glebarez/sqlite"
|
||||||
|
"github.com/mlogclub/simple/sqls"
|
||||||
|
"gorm.io/gorm"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestKnowledgeDocumentRepositoryFindPageListByCndOmitsContentAndPaginates(t *testing.T) {
|
||||||
|
db, err := gorm.Open(sqlite.Open("file:knowledge_document_repository_test?mode=memory&cache=shared"), &gorm.Config{})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("open sqlite error = %v", err)
|
||||||
|
}
|
||||||
|
if err := db.AutoMigrate(&models.KnowledgeDocument{}); err != nil {
|
||||||
|
t.Fatalf("auto migrate error = %v", err)
|
||||||
|
}
|
||||||
|
if err := db.Exec("DELETE FROM knowledge_documents").Error; err != nil {
|
||||||
|
t.Fatalf("clean knowledge documents error = %v", err)
|
||||||
|
}
|
||||||
|
sqls.SetDB(db)
|
||||||
|
|
||||||
|
for i := 1; i <= 3; i++ {
|
||||||
|
item := &models.KnowledgeDocument{
|
||||||
|
KnowledgeBaseID: 1,
|
||||||
|
Title: fmt.Sprintf("doc-%d", i),
|
||||||
|
ContentType: enums.KnowledgeDocumentContentTypeMarkdown,
|
||||||
|
Content: strings.Repeat("large document content ", 200),
|
||||||
|
Status: enums.StatusOk,
|
||||||
|
IndexStatus: enums.KnowledgeDocumentIndexStatusPending,
|
||||||
|
}
|
||||||
|
if err := db.Create(item).Error; err != nil {
|
||||||
|
t.Fatalf("create document %d error = %v", i, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
list, paging := KnowledgeDocumentRepository.FindPageListByCnd(db, sqls.NewCnd().Eq("knowledge_base_id", 1).Asc("id").Page(1, 2))
|
||||||
|
if len(list) != 2 {
|
||||||
|
t.Fatalf("len(list) = %d, want 2", len(list))
|
||||||
|
}
|
||||||
|
if paging.Total != 3 {
|
||||||
|
t.Fatalf("paging.Total = %d, want 3", paging.Total)
|
||||||
|
}
|
||||||
|
for _, item := range list {
|
||||||
|
if item.Content != "" {
|
||||||
|
t.Fatalf("list item content should be empty, got %q", item.Content)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -54,6 +54,10 @@ func (s *knowledgeDocumentService) FindPageByCnd(cnd *sqls.Cnd) (list []models.K
|
|||||||
return repositories.KnowledgeDocumentRepository.FindPageByCnd(sqls.DB(), cnd)
|
return repositories.KnowledgeDocumentRepository.FindPageByCnd(sqls.DB(), cnd)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *knowledgeDocumentService) FindPageListByCnd(cnd *sqls.Cnd) (list []models.KnowledgeDocument, paging *sqls.Paging) {
|
||||||
|
return repositories.KnowledgeDocumentRepository.FindPageListByCnd(sqls.DB(), cnd)
|
||||||
|
}
|
||||||
|
|
||||||
func (s *knowledgeDocumentService) Count(cnd *sqls.Cnd) int64 {
|
func (s *knowledgeDocumentService) Count(cnd *sqls.Cnd) int64 {
|
||||||
return repositories.KnowledgeDocumentRepository.Count(sqls.DB(), cnd)
|
return repositories.KnowledgeDocumentRepository.Count(sqls.DB(), cnd)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import {
|
|||||||
import { useCallback, useEffect, useState } from "react";
|
import { useCallback, useEffect, useState } from "react";
|
||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
|
|
||||||
|
import { ListPagination } from "@/components/list-pagination";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Badge } from "@/components/ui/badge";
|
import { Badge } from "@/components/ui/badge";
|
||||||
import {
|
import {
|
||||||
@@ -47,7 +48,7 @@ import {
|
|||||||
fetchKnowledgeDocuments,
|
fetchKnowledgeDocuments,
|
||||||
updateKnowledgeDocument,
|
updateKnowledgeDocument,
|
||||||
type CreateKnowledgeDocumentPayload,
|
type CreateKnowledgeDocumentPayload,
|
||||||
type KnowledgeDocument,
|
type KnowledgeDocumentListItem,
|
||||||
type PageResult,
|
type PageResult,
|
||||||
} from "@/lib/api/admin";
|
} from "@/lib/api/admin";
|
||||||
import { getEnumLabel, getEnumOptions } from "@/lib/enums";
|
import { getEnumLabel, getEnumOptions } from "@/lib/enums";
|
||||||
@@ -93,7 +94,7 @@ function getIndexStatusBadgeVariant(status: string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderIndexStatusBadge(item: KnowledgeDocument) {
|
function renderIndexStatusBadge(item: KnowledgeDocumentListItem) {
|
||||||
const badge = (
|
const badge = (
|
||||||
<Badge variant={getIndexStatusBadgeVariant(item.indexStatus)}>
|
<Badge variant={getIndexStatusBadgeVariant(item.indexStatus)}>
|
||||||
{item.indexStatusName}
|
{item.indexStatusName}
|
||||||
@@ -121,21 +122,6 @@ function renderIndexStatusBadge(item: KnowledgeDocument) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDocumentPreview(content: string, contentType: string) {
|
|
||||||
const preview =
|
|
||||||
contentType === "markdown"
|
|
||||||
? content
|
|
||||||
.replace(/[`*_>#-]/g, " ")
|
|
||||||
.replace(/\[(.*?)\]\((.*?)\)/g, "$1")
|
|
||||||
.replace(/\s+/g, " ")
|
|
||||||
.trim()
|
|
||||||
: content
|
|
||||||
.replace(/<[^>]+>/g, " ")
|
|
||||||
.replace(/\s+/g, " ")
|
|
||||||
.trim();
|
|
||||||
return preview || "暂无内容";
|
|
||||||
}
|
|
||||||
|
|
||||||
const VIEW_MODE_STORAGE_KEY = "knowledge-document-view-mode";
|
const VIEW_MODE_STORAGE_KEY = "knowledge-document-view-mode";
|
||||||
|
|
||||||
export function DocumentList({ knowledgeBaseId, onActionStateChange }: DocumentListProps) {
|
export function DocumentList({ knowledgeBaseId, onActionStateChange }: DocumentListProps) {
|
||||||
@@ -145,11 +131,13 @@ export function DocumentList({ knowledgeBaseId, onActionStateChange }: DocumentL
|
|||||||
const [keyword, setKeyword] = useState("");
|
const [keyword, setKeyword] = useState("");
|
||||||
const [statusFilter, setStatusFilter] = useState("all");
|
const [statusFilter, setStatusFilter] = useState("all");
|
||||||
const [indexStatusFilter, setIndexStatusFilter] = useState("all");
|
const [indexStatusFilter, setIndexStatusFilter] = useState("all");
|
||||||
|
const [page, setPage] = useState(1);
|
||||||
|
const [limit, setLimit] = useState(20);
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
const [saving, setSaving] = useState(false);
|
const [saving, setSaving] = useState(false);
|
||||||
const [actionLoadingMap, setActionLoadingMap] = useState<Record<number, { rebuildIndex: boolean; delete: boolean }>>({});
|
const [actionLoadingMap, setActionLoadingMap] = useState<Record<number, { rebuildIndex: boolean; delete: boolean }>>({});
|
||||||
const [dialogOpen, setDialogOpen] = useState(false);
|
const [dialogOpen, setDialogOpen] = useState(false);
|
||||||
const [editingItem, setEditingItem] = useState<KnowledgeDocument | null>(
|
const [editingItem, setEditingItem] = useState<KnowledgeDocumentListItem | null>(
|
||||||
null,
|
null,
|
||||||
);
|
);
|
||||||
const [viewMode, setViewMode] = useState<"list" | "grid">(() => {
|
const [viewMode, setViewMode] = useState<"list" | "grid">(() => {
|
||||||
@@ -157,14 +145,26 @@ export function DocumentList({ knowledgeBaseId, onActionStateChange }: DocumentL
|
|||||||
const saved = localStorage.getItem(VIEW_MODE_STORAGE_KEY);
|
const saved = localStorage.getItem(VIEW_MODE_STORAGE_KEY);
|
||||||
return saved === "list" || saved === "grid" ? saved : "grid";
|
return saved === "list" || saved === "grid" ? saved : "grid";
|
||||||
});
|
});
|
||||||
const [documents, setDocuments] = useState<PageResult<KnowledgeDocument>>({
|
const [documents, setDocuments] = useState<PageResult<KnowledgeDocumentListItem>>({
|
||||||
results: [],
|
results: [],
|
||||||
page: { page: 1, limit: 20, total: 0 },
|
page: { page: 1, limit: 20, total: 0 },
|
||||||
});
|
});
|
||||||
|
|
||||||
const loadData = useCallback(async () => {
|
const loadData = useCallback(async (options?: {
|
||||||
|
keyword?: string;
|
||||||
|
statusFilter?: string;
|
||||||
|
indexStatusFilter?: string;
|
||||||
|
page?: number;
|
||||||
|
limit?: number;
|
||||||
|
}) => {
|
||||||
|
const nextKeyword = options?.keyword ?? keyword;
|
||||||
|
const nextStatusFilter = options?.statusFilter ?? statusFilter;
|
||||||
|
const nextIndexStatusFilter = options?.indexStatusFilter ?? indexStatusFilter;
|
||||||
|
const nextPage = options?.page ?? page;
|
||||||
|
const nextLimit = options?.limit ?? limit;
|
||||||
|
|
||||||
if (!knowledgeBaseId) {
|
if (!knowledgeBaseId) {
|
||||||
setDocuments({ results: [], page: { page: 1, limit: 20, total: 0 } });
|
setDocuments({ results: [], page: { page: 1, limit, total: 0 } });
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -172,11 +172,12 @@ export function DocumentList({ knowledgeBaseId, onActionStateChange }: DocumentL
|
|||||||
setLoading(true);
|
setLoading(true);
|
||||||
try {
|
try {
|
||||||
const data = await fetchKnowledgeDocuments({
|
const data = await fetchKnowledgeDocuments({
|
||||||
title: keyword.trim() || undefined,
|
title: nextKeyword.trim() || undefined,
|
||||||
status: statusFilter === "all" ? undefined : statusFilter,
|
status: nextStatusFilter === "all" ? undefined : nextStatusFilter,
|
||||||
indexStatus: indexStatusFilter === "all" ? undefined : indexStatusFilter,
|
indexStatus: nextIndexStatusFilter === "all" ? undefined : nextIndexStatusFilter,
|
||||||
knowledgeBaseId,
|
knowledgeBaseId,
|
||||||
limit: 1000,
|
page: nextPage,
|
||||||
|
limit: nextLimit,
|
||||||
});
|
});
|
||||||
setDocuments(data);
|
setDocuments(data);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -184,7 +185,7 @@ export function DocumentList({ knowledgeBaseId, onActionStateChange }: DocumentL
|
|||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
}, [indexStatusFilter, keyword, statusFilter, knowledgeBaseId]);
|
}, [indexStatusFilter, keyword, statusFilter, knowledgeBaseId, limit, page]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
void loadData();
|
void loadData();
|
||||||
@@ -207,9 +208,19 @@ export function DocumentList({ knowledgeBaseId, onActionStateChange }: DocumentL
|
|||||||
}
|
}
|
||||||
|
|
||||||
function applyFilters() {
|
function applyFilters() {
|
||||||
setKeyword(keywordInput);
|
const nextKeyword = keywordInput;
|
||||||
setStatusFilter(statusFilterInput);
|
const nextStatusFilter = statusFilterInput;
|
||||||
setIndexStatusFilter(indexStatusFilterInput);
|
const nextIndexStatusFilter = indexStatusFilterInput;
|
||||||
|
setKeyword(nextKeyword);
|
||||||
|
setStatusFilter(nextStatusFilter);
|
||||||
|
setIndexStatusFilter(nextIndexStatusFilter);
|
||||||
|
setPage(1);
|
||||||
|
void loadData({
|
||||||
|
keyword: nextKeyword,
|
||||||
|
statusFilter: nextStatusFilter,
|
||||||
|
indexStatusFilter: nextIndexStatusFilter,
|
||||||
|
page: 1,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleFilterKeyDown(event: React.KeyboardEvent<HTMLInputElement>) {
|
function handleFilterKeyDown(event: React.KeyboardEvent<HTMLInputElement>) {
|
||||||
@@ -239,7 +250,7 @@ export function DocumentList({ knowledgeBaseId, onActionStateChange }: DocumentL
|
|||||||
});
|
});
|
||||||
}, [onActionStateChange, loadData, openCreateDialog, viewMode, loading]);
|
}, [onActionStateChange, loadData, openCreateDialog, viewMode, loading]);
|
||||||
|
|
||||||
function openEditDialog(item: KnowledgeDocument) {
|
function openEditDialog(item: KnowledgeDocumentListItem) {
|
||||||
setEditingItem(item);
|
setEditingItem(item);
|
||||||
setDialogOpen(true);
|
setDialogOpen(true);
|
||||||
}
|
}
|
||||||
@@ -281,7 +292,7 @@ export function DocumentList({ knowledgeBaseId, onActionStateChange }: DocumentL
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleDelete(item: KnowledgeDocument) {
|
async function handleDelete(item: KnowledgeDocumentListItem) {
|
||||||
setActionLoadingMap((prev) => ({ ...prev, [item.id]: { ...prev[item.id], delete: true } }));
|
setActionLoadingMap((prev) => ({ ...prev, [item.id]: { ...prev[item.id], delete: true } }));
|
||||||
try {
|
try {
|
||||||
await deleteKnowledgeDocument(item.id);
|
await deleteKnowledgeDocument(item.id);
|
||||||
@@ -294,7 +305,7 @@ export function DocumentList({ knowledgeBaseId, onActionStateChange }: DocumentL
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleBuildIndex(item: KnowledgeDocument) {
|
async function handleBuildIndex(item: KnowledgeDocumentListItem) {
|
||||||
setActionLoadingMap((prev) => ({ ...prev, [item.id]: { ...prev[item.id], rebuildIndex: true } }));
|
setActionLoadingMap((prev) => ({ ...prev, [item.id]: { ...prev[item.id], rebuildIndex: true } }));
|
||||||
try {
|
try {
|
||||||
await buildKnowledgeDocumentIndex(item.id);
|
await buildKnowledgeDocumentIndex(item.id);
|
||||||
@@ -398,9 +409,6 @@ export function DocumentList({ knowledgeBaseId, onActionStateChange }: DocumentL
|
|||||||
<div className="text-sm font-medium">{item.title}</div>
|
<div className="text-sm font-medium">{item.title}</div>
|
||||||
{renderIndexStatusBadge(item)}
|
{renderIndexStatusBadge(item)}
|
||||||
</div>
|
</div>
|
||||||
<div className="mt-1 text-xs text-muted-foreground line-clamp-2">
|
|
||||||
{getDocumentPreview(item.content, item.contentType)}
|
|
||||||
</div>
|
|
||||||
<div className="mt-2 flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-muted-foreground">
|
<div className="mt-2 flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-muted-foreground">
|
||||||
<span>{item.createUserName || "-"}</span>
|
<span>{item.createUserName || "-"}</span>
|
||||||
<span>{formatDateTime(item.createdAt)}</span>
|
<span>{formatDateTime(item.createdAt)}</span>
|
||||||
@@ -477,9 +485,6 @@ export function DocumentList({ knowledgeBaseId, onActionStateChange }: DocumentL
|
|||||||
<div className="truncate text-sm font-medium">{item.title}</div>
|
<div className="truncate text-sm font-medium">{item.title}</div>
|
||||||
{renderIndexStatusBadge(item)}
|
{renderIndexStatusBadge(item)}
|
||||||
</div>
|
</div>
|
||||||
<div className="mt-0.5 truncate text-xs text-muted-foreground">
|
|
||||||
{getDocumentPreview(item.content, item.contentType)}
|
|
||||||
</div>
|
|
||||||
<div className="mt-1 text-xs text-muted-foreground">
|
<div className="mt-1 text-xs text-muted-foreground">
|
||||||
{item.indexStatus === KnowledgeDocumentIndexStatus.Indexed
|
{item.indexStatus === KnowledgeDocumentIndexStatus.Indexed
|
||||||
? `索引时间:${formatDateTime(item.indexedAt)}`
|
? `索引时间:${formatDateTime(item.indexedAt)}`
|
||||||
@@ -551,6 +556,23 @@ export function DocumentList({ knowledgeBaseId, onActionStateChange }: DocumentL
|
|||||||
</div>
|
</div>
|
||||||
</ScrollArea>
|
</ScrollArea>
|
||||||
</div>
|
</div>
|
||||||
|
<div className="border-t px-6 py-3">
|
||||||
|
<ListPagination
|
||||||
|
page={documents.page.page}
|
||||||
|
limit={documents.page.limit}
|
||||||
|
total={documents.page.total}
|
||||||
|
loading={loading}
|
||||||
|
onPageChange={(nextPage) => {
|
||||||
|
setPage(nextPage);
|
||||||
|
void loadData({ page: nextPage });
|
||||||
|
}}
|
||||||
|
onLimitChange={(nextLimit) => {
|
||||||
|
setLimit(nextLimit);
|
||||||
|
setPage(1);
|
||||||
|
void loadData({ limit: nextLimit, page: 1 });
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<DocumentEditDialog
|
<DocumentEditDialog
|
||||||
open={dialogOpen}
|
open={dialogOpen}
|
||||||
|
|||||||
@@ -1336,6 +1336,8 @@ export type KnowledgeDocument = {
|
|||||||
updateUserName: string
|
updateUserName: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type KnowledgeDocumentListItem = Omit<KnowledgeDocument, "content">
|
||||||
|
|
||||||
export type KnowledgeFAQ = {
|
export type KnowledgeFAQ = {
|
||||||
id: number
|
id: number
|
||||||
knowledgeBaseId: number
|
knowledgeBaseId: number
|
||||||
@@ -1579,7 +1581,7 @@ export function rebuildKnowledgeBaseIndex(id: number) {
|
|||||||
export function fetchKnowledgeDocuments(
|
export function fetchKnowledgeDocuments(
|
||||||
query?: Record<string, string | number | undefined>
|
query?: Record<string, string | number | undefined>
|
||||||
) {
|
) {
|
||||||
return request<PageResult<KnowledgeDocument>>(
|
return request<PageResult<KnowledgeDocumentListItem>>(
|
||||||
`/api/dashboard/knowledge-document/list${toQueryString(query)}`
|
`/api/dashboard/knowledge-document/list${toQueryString(query)}`
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user