2026-05-25: 等级体系升级(20级)+论坛二级分类+会员空间
This commit is contained in:
@@ -0,0 +1,130 @@
|
||||
import { PrismaClient } from "@prisma/client";
|
||||
import { PrismaMariaDb } from "@prisma/adapter-mariadb";
|
||||
import "dotenv/config";
|
||||
|
||||
const base = process.env.DATABASE_URL;
|
||||
const sep = base.includes("?") ? "&" : "?";
|
||||
const connectionString = `${base}${sep}connection_limit=5&pool_timeout=10`;
|
||||
const adapter = new PrismaMariaDb(connectionString);
|
||||
const prisma = new PrismaClient({ adapter });
|
||||
|
||||
const CATEGORIES = [
|
||||
{
|
||||
name: "综合讨论区", slug: "general", icon: "💬", sortOrder: 1,
|
||||
description: "AI话题综合交流",
|
||||
children: [
|
||||
{ name: "新手入门", slug: "newbie", icon: "🌱", description: "新人报到,快速上手" },
|
||||
{ name: "AI资讯", slug: "ai-news", icon: "📰", description: "行业动态与新闻" },
|
||||
{ name: "观点讨论", slug: "discuss", icon: "💡", description: "AI发展趋势讨论" },
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "AI工具", slug: "ai-tools", icon: "🤖", sortOrder: 2,
|
||||
description: "AI工具推荐、测评与讨论",
|
||||
children: [
|
||||
{ name: "聊天写作", slug: "chat-writing", icon: "✍️", description: "ChatGPT/Claude/文心一言等" },
|
||||
{ name: "图像创作", slug: "image-gen", icon: "🎨", description: "Midjourney/Stable Diffusion等" },
|
||||
{ name: "视频音频", slug: "video-audio", icon: "🎬", description: "Sora/Runway/Suno等" },
|
||||
{ name: "代码编程", slug: "code-tools", icon: "💻", description: "GitHub Copilot/Cursor等" },
|
||||
{ name: "效率办公", slug: "productivity", icon: "📊", description: "Notion AI/办公自动化等" },
|
||||
{ name: "数据分析", slug: "data-analysis", icon: "📈", description: "商业智能与数据分析工具" },
|
||||
{ name: "教育学习", slug: "edu-tools", icon: "📚", description: "在线教育与学习辅助" },
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "开源技能", slug: "skills", icon: "⚡", sortOrder: 3,
|
||||
description: "开源AI框架、模型与工具技能",
|
||||
children: [
|
||||
{ name: "LLM框架", slug: "llm-framework", icon: "🧠", description: "LangChain/LlamaIndex等" },
|
||||
{ name: "Agent框架", slug: "agent-framework", icon: "🤖", description: "AutoGPT/CrewAI/MetaGPT等" },
|
||||
{ name: "RAG技术", slug: "rag", icon: "📖", description: "向量数据库/检索增强生成" },
|
||||
{ name: "模型训练", slug: "model-training", icon: "🔬", description: "LoRA/Fine-tune/PEFT等" },
|
||||
{ name: "部署推理", slug: "deploy-infer", icon: "🚀", description: "vLLM/Ollama/TensorRT等" },
|
||||
{ name: "多模态", slug: "multimodal", icon: "🎯", description: "视觉/语音/多模态技术" },
|
||||
{ name: "数据工程", slug: "data-eng", icon: "🗃️", description: "数据清洗/标注/管理工具" },
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "技术深度", slug: "tech", icon: "🔧", sortOrder: 4,
|
||||
description: "AI技术深度探讨",
|
||||
children: [
|
||||
{ name: "算法原理", slug: "algorithms", icon: "🧮", description: "Transformer/注意力机制等" },
|
||||
{ name: "模型评测", slug: "model-review", icon: "📋", description: "Benchmark/对比评测" },
|
||||
{ name: "安全对齐", slug: "safety", icon: "🛡️", description: "RLHF/安全/伦理" },
|
||||
{ name: "硬件加速", slug: "hardware", icon: "🔌", description: "GPU/TPU/NPU优化" },
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "教程与分享", slug: "tutorials", icon: "📚", sortOrder: 5,
|
||||
description: "教程、指南与经验分享",
|
||||
children: [
|
||||
{ name: "入门教程", slug: "beginner-guide", icon: "🌟", description: "从零开始学AI" },
|
||||
{ name: "实战项目", slug: "projects", icon: "🏗️", description: "完整项目实战" },
|
||||
{ name: "最佳实践", slug: "best-practice", icon: "✅", description: "经验分享与踩坑记录" },
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "社区互动", slug: "social", icon: "🎪", sortOrder: 6,
|
||||
description: "社区活动与交流",
|
||||
children: [
|
||||
{ name: "求助问答", slug: "qa", icon: "❓", description: "有问题来这里" },
|
||||
{ name: "求职招聘", slug: "jobs", icon: "💼", description: "AI领域求职招聘" },
|
||||
{ name: "闲聊灌水", slug: "random", icon: "🎲", description: "轻松交流区" },
|
||||
{ name: "反馈建议", slug: "feedback", icon: "📢", description: "对追光AI的建议" },
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
async function main() {
|
||||
console.log("Seeding forum categories (2-level)...");
|
||||
|
||||
for (const cat of CATEGORIES) {
|
||||
let parent = await prisma.forumCategory.findUnique({
|
||||
where: { slug: cat.slug },
|
||||
include: { children: true },
|
||||
});
|
||||
|
||||
if (!parent) {
|
||||
parent = await prisma.forumCategory.create({
|
||||
data: {
|
||||
name: cat.name,
|
||||
slug: cat.slug,
|
||||
icon: cat.icon,
|
||||
description: cat.description,
|
||||
sortOrder: cat.sortOrder,
|
||||
},
|
||||
include: { children: true },
|
||||
});
|
||||
console.log(` + ${cat.name}`);
|
||||
} else {
|
||||
console.log(` ✓ ${cat.name} (exists, checking children)`);
|
||||
}
|
||||
|
||||
const existingSlugs = new Set(parent.children.map(c => c.slug));
|
||||
|
||||
for (const child of cat.children) {
|
||||
if (existingSlugs.has(child.slug)) {
|
||||
console.log(` - ${child.name} (exists)`);
|
||||
} else {
|
||||
await prisma.forumCategory.create({
|
||||
data: {
|
||||
...child,
|
||||
parentId: parent.id,
|
||||
},
|
||||
});
|
||||
console.log(` + ${child.name}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
console.log("Done!");
|
||||
}
|
||||
|
||||
main()
|
||||
.catch((e) => {
|
||||
console.error(e);
|
||||
process.exit(1);
|
||||
})
|
||||
.finally(async () => {
|
||||
await prisma.$disconnect();
|
||||
});
|
||||
Reference in New Issue
Block a user