顯示第 {logicStartIndex + 1} - {Math.min(logicEndIndex, logicQuestions.length)} 筆,共 {logicQuestions.length} 筆
{/* Desktop Pagination */}
{Array.from({ length: totalLogicPages }, (_, i) => i + 1).map((page) => (
))}
{/* Mobile Pagination */}
{(() => {
const maxVisiblePages = 3
const startPage = Math.max(1, currentLogicPage - 1)
const endPage = Math.min(totalLogicPages, startPage + maxVisiblePages - 1)
const pages = []
// 如果不在第一頁,顯示第一頁和省略號
if (startPage > 1) {
pages.push(
)
if (startPage > 2) {
pages.push(
...
)
}
}
// 顯示當前頁附近的頁碼
for (let i = startPage; i <= endPage; i++) {
pages.push(
)
}
// 如果不在最後一頁,顯示省略號和最後一頁
if (endPage < totalLogicPages) {
if (endPage < totalLogicPages - 1) {
pages.push(
...
)
}
pages.push(
)
}
return pages
})()}
)}