Update application code and dependencies

This commit is contained in:
root
2026-05-06 17:22:50 +08:00
parent efc8f4bf78
commit a3ee04379d
60 changed files with 6793 additions and 860 deletions
+189
View File
@@ -0,0 +1,189 @@
import { PrismaClient } from "@prisma/client"
import bcrypt from "bcryptjs"
const prisma = new PrismaClient()
async function main() {
// 创建管理员用户
const hashedPassword = await bcrypt.hash("admin123", 10)
const admin = await prisma.user.upsert({
where: { username: "admin" },
update: {},
create: {
email: "admin@nextapp.com",
username: "admin",
password: hashedPassword,
name: "管理员",
role: "admin",
},
})
console.log("Created admin user:", admin.username)
// 创建分类
const categories = await Promise.all([
prisma.category.upsert({
where: { name: "客服" },
update: {},
create: {
name: "客服",
icon: "🤖",
description: "适用于企业客服、在线问答、售后支持等场景,7×24小时在线服务。",
},
}),
prisma.category.upsert({
where: { name: "写作" },
update: {},
create: {
name: "写作",
icon: "✍️",
description: "适用于营销文案、博客文章、邮件草稿等场景,快速生成高质量内容。",
},
}),
prisma.category.upsert({
where: { name: "数据分析" },
update: {},
create: {
name: "数据分析",
icon: "📊",
description: "适用于数据清洗、分析、可视化等场景,自动生成结构化分析报告。",
},
}),
prisma.category.upsert({
where: { name: "编程" },
update: {},
create: {
name: "编程",
icon: "💻",
description: "适用于代码审查、SQL生成等场景,提高开发效率,减少bug。",
},
}),
prisma.category.upsert({
where: { name: "生活娱乐" },
update: {},
create: {
name: "生活娱乐",
icon: "✈️",
description: "适用于旅行规划、菜谱推荐等场景,让生活更加便捷智能。",
},
}),
prisma.category.upsert({
where: { name: "数字人" },
update: {},
create: {
name: "数字人",
icon: "🧑‍💼",
description: "适用于虚拟主播、数字客服、形象代言等场景,提供逼真的数字人交互体验。",
},
}),
])
console.log("Created categories:", categories.map(c => c.name).join(", "))
// 创建智能体
const agents = await Promise.all([
prisma.agent.upsert({
where: { slug: "smart-customer-service" },
update: {},
create: {
name: "智能客服助手",
slug: "smart-customer-service",
description: "7×24 小时在线,精准理解用户意图,自动处理常见咨询,支持多轮对话。",
icon: "🤖",
categoryId: categories[0].id,
features: "智能问答, 知识库查询, 工单提交",
usageCount: 1000,
status: "active",
},
}),
prisma.agent.upsert({
where: { slug: "writing-assistant-pro" },
update: {},
create: {
name: "写作助手 Pro",
slug: "writing-assistant-pro",
description: "营销文案、博客文章、邮件草稿,输入关键词即可生成高质量内容。",
icon: "✍️",
categoryId: categories[1].id,
features: "营销文案, 博客文章, 邮件草稿",
usageCount: 850,
status: "active",
},
}),
prisma.agent.upsert({
where: { slug: "data-analysis-master" },
update: {},
create: {
name: "数据分析大师",
slug: "data-analysis-master",
description: "上传 CSV/Excel,自动清洗、分析、可视化,输出结构化分析报告。",
icon: "📊",
categoryId: categories[2].id,
features: "数据清洗, 数据可视化, 分析报告",
usageCount: 620,
status: "active",
},
}),
prisma.agent.upsert({
where: { slug: "digital-human-assistant" },
update: {},
create: {
name: "数字人助手",
slug: "digital-human-assistant",
description: "超写实数字人,支持语音交互、表情动画、多场景应用,适用于虚拟主播、智能客服、形象代言等场景。",
icon: "🧑‍💼",
categoryId: categories[5].id,
features: "语音交互, 表情动画, 虚拟主播, 智能客服",
usageCount: 380,
status: "active",
},
}),
])
console.log("Created agents:", agents.map(a => a.name).join(", "))
// 创建新闻
const news = await Promise.all([
prisma.news.upsert({
where: { id: 1 },
update: {},
create: {
title: "智能客服助手 3.0 正式上线,支持多模态交互",
content: "全新版本集成图像识别与语音交互能力,响应速度提升 40%,企业客户满意度评分达 4.9/5.0。",
type: "news",
published: true,
},
}),
prisma.news.upsert({
where: { id: 2 },
update: {},
create: {
title: "2026 AI Agent 市场白皮书:企业渗透率突破 35%",
content: "据最新行业报告,AI 智能体正在从尝鲜阶段走向规模化落地,客服与内容生成场景率先规模化。",
type: "industry",
published: true,
},
}),
prisma.news.upsert({
where: { id: 3 },
update: {},
create: {
title: "江苏冲浪软件科技与华为云达成战略合作",
content: "双方将在 AI 智能体研发、云端部署与行业解决方案展开深度合作,首期联合创新实验室正式揭牌。",
type: "cooperation",
published: true,
},
}),
])
console.log("Created news:", news.map(n => n.title).join(", "))
console.log("Seed data created successfully!")
}
main()
.catch((e) => {
console.error(e)
process.exit(1)
})
.finally(async () => {
await prisma.$disconnect()
})