feat(*): 技能库与认证体验 - 重构共享技能库并优化登录页面与默认创作入口
This commit is contained in:
1 parent
d6e5c3748b
commit
401600d165
28 files changed
+2480
-963
No files matched your search
@@ -0,0 +1,28 @@
|
||||
import type { Skill, SkillCategory } from "@/services/api/skills";
|
||||
|
||||
export const fallbackSkillCategories: SkillCategory[] = [
|
||||
{ value: "drama", label: "短剧影视" },
|
||||
{ value: "ecommerce", label: "电商营销" },
|
||||
{ value: "creative", label: "创意设计" },
|
||||
{ value: "social", label: "社媒内容" },
|
||||
{ value: "others", label: "其他" },
|
||||
];
|
||||
|
||||
export function skillCategoryLabel(value: string, categories: SkillCategory[] = fallbackSkillCategories) {
|
||||
return categories.find((item) => item.value === value)?.label || "其他";
|
||||
}
|
||||
|
||||
export function groupSkills(skills: Skill[], categories: SkillCategory[]) {
|
||||
const ordered = categories.length ? categories : fallbackSkillCategories;
|
||||
return ordered
|
||||
.map((category) => ({ ...category, skills: skills.filter((skill) => skill.tag === category.value) }))
|
||||
.filter((group) => group.skills.length > 0);
|
||||
}
|
||||
|
||||
export function formatSkillCount(value: number) {
|
||||
return new Intl.NumberFormat("zh-CN", { notation: "compact", maximumFractionDigits: 1 }).format(value);
|
||||
}
|
||||
|
||||
export function formatSkillDate(value: number) {
|
||||
return new Intl.DateTimeFormat("zh-CN", { year: "numeric", month: "short", day: "numeric" }).format(new Date(value));
|
||||
}
|
||||
Reference in new issue
Block a user