nav: 三级导航分页结构 + 中国地区索引
- 02-game-design 地图结构重写:洲→国家→城市,3x3棋盘分页 - 中国 40 城按 8 地区分组(华北/东北/华东/华中/华南/西南/西北/港澳) - 导航索引数据:continents/index + asia + regions/china + pagination工具 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
14
js/content/shared/pagination.js
Normal file
14
js/content/shared/pagination.js
Normal file
@@ -0,0 +1,14 @@
|
||||
// 通用分页工具 — 将数组按 pageSize 分页
|
||||
// 默认 pageSize = 9(3x3 棋盘)
|
||||
|
||||
export function paginate(items, pageSize = 9) {
|
||||
const pages = []
|
||||
for (let i = 0; i < items.length; i += pageSize) {
|
||||
pages.push(items.slice(i, i + pageSize))
|
||||
}
|
||||
return pages
|
||||
}
|
||||
|
||||
export function getPageCount(totalItems, pageSize = 9) {
|
||||
return Math.ceil(totalItems / pageSize)
|
||||
}
|
||||
Reference in New Issue
Block a user