Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
黄南光
/
wiki_knowledge
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit e3872b2d
authored
Jul 17, 2026
by
黄南光
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
优化前端页码展示
1 parent
bf332f48
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
95 additions
and
12 deletions
frontend/src/app/page.tsx
frontend/src/app/page.tsx
View file @
e3872b2
...
@@ -9,7 +9,8 @@ import {
...
@@ -9,7 +9,8 @@ import {
Clock, HardDrive, Filter, MoreVertical, LayoutGrid, List as ListIcon,
Clock, HardDrive, Filter, MoreVertical, LayoutGrid, List as ListIcon,
ShieldCheck, Zap, Globe, Settings, LogOut, ChevronDown, Check,
ShieldCheck, Zap, Globe, Settings, LogOut, ChevronDown, Check,
X, AlertCircle, Eye, LogOut as Eject, Folder, Square, RefreshCw,
X, AlertCircle, Eye, LogOut as Eject, Folder, Square, RefreshCw,
FileImage, FileSpreadsheet, FileArchive, FileCode
FileImage, FileSpreadsheet, FileArchive, FileCode,
ChevronLeft, ChevronsLeft, ChevronsRight
} from "lucide-react";
} from "lucide-react";
import { cn } from "@/lib/utils";
import { cn } from "@/lib/utils";
import { MessageBubble, type ReasoningStep } from "@/components/MessageBubble";
import { MessageBubble, type ReasoningStep } from "@/components/MessageBubble";
...
@@ -238,6 +239,27 @@ const buildTree = (links: string[]) => {
...
@@ -238,6 +239,27 @@ const buildTree = (links: string[]) => {
return root;
return root;
};
};
const PAGE_SIZE_OPTIONS = [10, 20, 50, 100];
// 生成分页页码列表,用 "ellipsis" 表示省略号
const getPaginationRange = (currentPage: number, totalPages: number): (number | "ellipsis")[] => {
if (totalPages <= 7) {
return Array.from({ length: totalPages }, (_, i) => i + 1);
}
const pages = new Set<number>([1, totalPages, currentPage, currentPage - 1, currentPage + 1]);
const sorted = Array.from(pages).filter(p => p >= 1 && p <= totalPages).sort((a, b) => a - b);
const result: (number | "ellipsis")[] = [];
sorted.forEach((page, idx) => {
if (idx > 0 && page - sorted[idx - 1] > 1) {
result.push("ellipsis");
}
result.push(page);
});
return result;
};
const TreeNode = ({ node, level = 0, onSelect, selectedPath }: { node: TreeFolder | TreeFile, level?: number, onSelect: (path: string) => void, selectedPath: string | null }) => {
const TreeNode = ({ node, level = 0, onSelect, selectedPath }: { node: TreeFolder | TreeFile, level?: number, onSelect: (path: string) => void, selectedPath: string | null }) => {
const [isOpen, setIsOpen] = useState(true);
const [isOpen, setIsOpen] = useState(true);
...
@@ -1717,27 +1739,88 @@ export default function EnterpriseWiki() {
...
@@ -1717,27 +1739,88 @@ export default function EnterpriseWiki() {
{/* Pagination */}
{/* Pagination */}
<div className="mt-6 flex items-center justify-end shrink-0 pb-6 pr-24">
<div className="mt-6 flex items-center justify-end shrink-0 pb-6 pr-24">
<div className="flex items-center gap-
6
">
<div className="flex items-center gap-
4
">
<div className="text-sm text-slate-500
font-medium
">
<div className="text-sm text-slate-500
whitespace-nowrap
">
共 <span className="text-slate-800">{totalCount}</span> 个文件
共 <span className="text-slate-800">{totalCount}</span> 个文件
</div>
</div>
<div className="flex items-center gap-2">
<div className="w-px h-5 bg-slate-200" />
<div className="flex items-center gap-2 whitespace-nowrap">
<span className="text-sm text-slate-400">每页</span>
<div className="relative flex items-center">
<select
value={pageSize}
onChange={(e) => {
const size = Number(e.target.value);
setPageSize(size);
setCurrentPage(1);
}}
className="appearance-none h-8 rounded-lg bg-slate-50 pl-2.5 pr-7 text-sm text-slate-700 outline-none cursor-pointer transition hover:bg-slate-100 focus:ring-2 focus:ring-blue-500/20"
>
{PAGE_SIZE_OPTIONS.map(size => (
<option key={size} value={size}>{size}</option>
))}
</select>
<ChevronDown className="w-3.5 h-3.5 text-slate-400 absolute right-2 pointer-events-none" />
</div>
<span className="text-sm text-slate-400">条</span>
</div>
<div className="w-px h-5 bg-slate-200" />
<div className="flex items-center gap-0.5">
<button
onClick={() => setCurrentPage(1)}
disabled={currentPage === 1}
title="第一页"
className="w-8 h-8 flex items-center justify-center rounded-lg text-slate-500 hover:bg-slate-100 hover:text-slate-700 disabled:opacity-30 disabled:hover:bg-transparent disabled:cursor-not-allowed cursor-pointer transition-colors"
>
<ChevronsLeft className="w-4 h-4" />
</button>
<button
<button
onClick={() => setCurrentPage(p => Math.max(1, p - 1))}
onClick={() => setCurrentPage(p => Math.max(1, p - 1))}
disabled={currentPage === 1}
disabled={currentPage === 1}
className="px-4 py-2 bg-white border border-slate-200 rounded-xl text-sm font-bold text-slate-600 hover:bg-slate-50 disabled:opacity-50 disabled:cursor-not-allowed cursor-pointer transition-colors"
title="上一页"
className="w-8 h-8 flex items-center justify-center rounded-lg text-slate-500 hover:bg-slate-100 hover:text-slate-700 disabled:opacity-30 disabled:hover:bg-transparent disabled:cursor-not-allowed cursor-pointer transition-colors"
>
>
上一页
<ChevronLeft className="w-4 h-4" />
</button>
{getPaginationRange(currentPage, Math.max(1, Math.ceil(totalCount / pageSize))).map((page, idx) => (
page === "ellipsis" ? (
<span key={`ellipsis-${idx}`} className="w-8 h-8 flex items-center justify-center text-sm text-slate-300 select-none">···</span>
) : (
<button
key={page}
onClick={() => setCurrentPage(page)}
className={cn(
"w-8 h-8 flex items-center justify-center rounded-lg text-sm font-bold transition-all cursor-pointer",
page === currentPage
? "bg-blue-600 text-white shadow-md shadow-blue-600/30"
: "text-slate-500 hover:bg-slate-100 hover:text-slate-800"
)}
>
{page}
</button>
)
))}
<button
onClick={() => setCurrentPage(p => (p * pageSize >= totalCount ? p : p + 1))}
disabled={currentPage * pageSize >= totalCount}
title="下一页"
className="w-8 h-8 flex items-center justify-center rounded-lg text-slate-500 hover:bg-slate-100 hover:text-slate-700 disabled:opacity-30 disabled:hover:bg-transparent disabled:cursor-not-allowed cursor-pointer transition-colors"
>
<ChevronRight className="w-4 h-4" />
</button>
</button>
<div className="text-sm font-bold text-slate-700 px-4">
第 {currentPage} 页
</div>
<button
<button
onClick={() => setCurrentPage(
p => p + 1
)}
onClick={() => setCurrentPage(
Math.max(1, Math.ceil(totalCount / pageSize))
)}
disabled={currentPage * pageSize >= totalCount}
disabled={currentPage * pageSize >= totalCount}
className="px-4 py-2 bg-white border border-slate-200 rounded-xl text-sm font-bold text-slate-600 hover:bg-slate-50 disabled:opacity-50 disabled:cursor-not-allowed cursor-pointer transition-colors"
title="最后一页"
className="w-8 h-8 flex items-center justify-center rounded-lg text-slate-500 hover:bg-slate-100 hover:text-slate-700 disabled:opacity-30 disabled:hover:bg-transparent disabled:cursor-not-allowed cursor-pointer transition-colors"
>
>
下一页
<ChevronsRight className="w-4 h-4" />
</button>
</button>
</div>
</div>
</div>
</div>
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment