Files
jiang13-forum/services/board_icon.go
freefire 3f50316ad0 fix: 完成 Gitea 目录改组收尾(import、构建与 LICENSE)
同步包路径与路由,去掉 SPA 构建步骤,对齐 Gitea 式 LICENSE,并更新规格/规则与占位 SSR。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-29 04:01:20 +08:00

37 lines
1.0 KiB
Go
Raw 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.
package services
import "strings"
// AllowedBoardIcons 与前端 BOARD_ICON_OPTIONS 的 key 保持一致
var AllowedBoardIcons = map[string]struct{}{
"code-2": {}, "coffee": {}, "help-circle": {}, "message-square": {},
"lightbulb": {}, "book-open": {}, "gamepad-2": {}, "palette": {},
"music": {}, "camera": {}, "heart": {}, "zap": {},
"globe": {}, "users": {}, "briefcase": {}, "graduation-cap": {},
"shopping-bag": {}, "map-pin": {}, "megaphone": {}, "flame": {},
"star": {}, "folder": {}, "wrench": {}, "cpu": {},
}
// NormalizeBoardIcon 校验并规范化板块图标 key非法或空则返回空串
func NormalizeBoardIcon(icon string) string {
icon = strings.TrimSpace(strings.ToLower(icon))
if icon == "" {
return ""
}
if _, ok := AllowedBoardIcons[icon]; !ok {
return ""
}
return icon
}
// NormalizeBoardColorIndex -1 表示自动07 为有效色槽
func NormalizeBoardColorIndex(colorIndex int) int {
if colorIndex < 0 {
return -1
}
if colorIndex > 7 {
return colorIndex % 8
}
return colorIndex
}