Files
jiang13-bbs/frontend/lib/coverColor.ts
freefire 4f3f3a265c feat: 友链/书库/移动端导航/排行榜等多模块功能
新增模块:
- 友链(friendlink)后端处理 + 前端管理页与友链板
- 书库(library):导入、章节、封面、阅读页、横竖版自适应 AdaptiveCoverSlot
- 顶栏导航(header_nav)配置与 MobileTabBar/MobileRailDrawers 移动端抽屉
- 排行榜 service 测试、站点页面测试、时间线发布(timeline_release)

其它改动:
- 后端 handlers/services 全量小幅调整
- 前端组件、库函数、URL/品牌/站点 URL 工具更新
- Lightbox 图片、MdEntries 条目卡、coverColor 派生色相等前端能力
2026-09-30 16:30:07 +08:00

12 lines
506 B
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* 书名 → 稳定色相(0-359):djb2 哈希取模。
* 无封面文本封面的配色来源——同一本书在任何页面、任何刷新下颜色一致,
* 不使用 Math.random()(那会导致每次刷新变色)。
* 用法:元素挂 .j13-text-cover 类并内联 --cover-h,取色规则见 globals.css。
*/
export function coverHue(title: string): number {
let h = 5381;
for (let i = 0; i < title.length; i++) h = (h * 33) ^ title.charCodeAt(i);
return (h >>> 0) % 360;
}