- 新增许可证服务器 (license-server/) - 新增 Agent 部署模块 (flnxi-agent/) - 添加许可证验证和激活页面 - 添加 Harbor 镜像同步脚本 - 更新素材系统支持许可证验证
43 lines
926 B
TypeScript
43 lines
926 B
TypeScript
import { PrismaClient } from '@prisma/client';
|
||
import bcrypt from 'bcryptjs';
|
||
|
||
const prisma = new PrismaClient();
|
||
|
||
async function main() {
|
||
const username = process.argv[2] || 'admin';
|
||
const password = process.argv[3] || 'admin123';
|
||
|
||
// 检查是否已存在
|
||
const existing = await prisma.admin.findUnique({
|
||
where: { username },
|
||
});
|
||
|
||
if (existing) {
|
||
console.log(`管理员 "${username}" 已存在`);
|
||
return;
|
||
}
|
||
|
||
const passwordHash = await bcrypt.hash(password, 10);
|
||
|
||
await prisma.admin.create({
|
||
data: {
|
||
username,
|
||
passwordHash,
|
||
},
|
||
});
|
||
|
||
console.log(`管理员创建成功!`);
|
||
console.log(`用户名: ${username}`);
|
||
console.log(`密码: ${password}`);
|
||
console.log(`\n请登录后立即修改密码!`);
|
||
}
|
||
|
||
main()
|
||
.catch((e) => {
|
||
console.error('创建管理员失败:', e);
|
||
process.exit(1);
|
||
})
|
||
.finally(async () => {
|
||
await prisma.$disconnect();
|
||
});
|