专题和短剧 slug 改为 8 位随机小写字母

后台新建/修改(未填 slug)和媒资入库时生成随机 slug,不再按标题拼音生成;标签、分类不变。

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-09-23 22:10:53 +08:00
co-authored by Claude Opus 5.5
parent 5a6cd2a51b
commit ad016ee1ac
3 changed files with 18 additions and 26 deletions
+13
View File
@@ -113,6 +113,19 @@ func IsSlugAllDigits(s string) bool {
return true
}
// RandomSlugLength 随机 slug 长度
const RandomSlugLength = 8
// MakeRandomSlug 生成唯一的随机 slug(8 位小写字母);exists 返回 true 表示已被占用。
func MakeRandomSlug(exists func(string) bool) string {
for {
s := strings.ToLower(GetRandomLetters(RandomSlugLength))
if !exists(s) {
return s
}
}
}
// MakeUniqueSlug 生成唯一 slug;exists 返回 true 表示已被占用。生成结果不能全是数字。
func MakeUniqueSlug(source string, exists func(string) bool) string {
pinyin := GetSlugInfo(source)