feat: 系统配置页动态渲染 + AI 配置完善
- 配置页重写:从 API 动态加载配置项,不再依赖硬编码字段列表 - AI 配置扩展:新增 provider API Key/URL、配额、Token 等 11 项配置 - 站点配置扩展:联系电话、公司名称 - 支持新增自定义配置项(+ 新增配置按钮) - 配置项显示已有 DB 数据 + 预定义字段的合并列表
This commit is contained in:
@@ -13,23 +13,12 @@ export class SettingsController {
|
||||
|
||||
@Get('roles')
|
||||
async roles() {
|
||||
return {
|
||||
items: await this.prisma.adminRole.findMany({
|
||||
where: { status: 'ACTIVE' },
|
||||
orderBy: { createdAt: 'desc' },
|
||||
}),
|
||||
};
|
||||
return { items: await this.prisma.adminRole.findMany({ where: { status: 'ACTIVE' }, orderBy: { createdAt: 'desc' } }) };
|
||||
}
|
||||
|
||||
@Post('roles')
|
||||
async createRole(@Body() body: { name: string; description?: string; permissions?: string[] }) {
|
||||
return this.prisma.adminRole.create({
|
||||
data: {
|
||||
name: body.name,
|
||||
description: body.description || '',
|
||||
permissions: body.permissions || [],
|
||||
},
|
||||
});
|
||||
return this.prisma.adminRole.create({ data: { name: body.name, description: body.description || '', permissions: body.permissions || [] } });
|
||||
}
|
||||
|
||||
@Put('roles/:id')
|
||||
@@ -48,27 +37,14 @@ export class SettingsController {
|
||||
|
||||
@Get('admins')
|
||||
async admins() {
|
||||
return {
|
||||
items: await this.prisma.adminUser.findMany({
|
||||
where: { status: 'ACTIVE' },
|
||||
include: { role: true },
|
||||
orderBy: { createdAt: 'desc' },
|
||||
}),
|
||||
};
|
||||
return { items: await this.prisma.adminUser.findMany({ where: { status: 'ACTIVE' }, include: { role: true }, orderBy: { createdAt: 'desc' } }) };
|
||||
}
|
||||
|
||||
@Post('admins')
|
||||
async createAdmin(@Body() body: { username: string; password: string; nickname?: string; roleId?: string }) {
|
||||
const bcrypt = require('bcryptjs');
|
||||
const passwordHash = await bcrypt.hash(body.password, 10);
|
||||
return this.prisma.adminUser.create({
|
||||
data: {
|
||||
username: body.username,
|
||||
passwordHash,
|
||||
nickname: body.nickname || '',
|
||||
roleId: body.roleId || null,
|
||||
},
|
||||
});
|
||||
return this.prisma.adminUser.create({ data: { username: body.username, passwordHash, nickname: body.nickname || '', roleId: body.roleId || null } });
|
||||
}
|
||||
|
||||
@Put('admins/:id')
|
||||
@@ -89,22 +65,15 @@ export class SettingsController {
|
||||
permissions() {
|
||||
return {
|
||||
items: [
|
||||
{ key: 'dashboard', name: '仪表盘', category: '首页' },
|
||||
{ key: 'users', name: '用户管理', category: '用户' },
|
||||
{ key: 'courses', name: '课程管理', category: '内容' },
|
||||
{ key: 'prompts', name: '提示词管理', category: '内容' },
|
||||
{ key: 'contents', name: '内容管理', category: '内容' },
|
||||
{ key: 'tools', name: '工具管理', category: '内容' },
|
||||
{ key: 'orders', name: '订单管理', category: '交易' },
|
||||
{ key: 'enterprise', name: '企业版管理', category: '交易' },
|
||||
{ key: 'comments', name: '评论审核', category: '社区' },
|
||||
{ key: 'analytics', name: '数据分析', category: '统计' },
|
||||
{ key: 'roles', name: '角色权限', category: '设置' },
|
||||
{ key: 'admins', name: '管理员', category: '设置' },
|
||||
{ key: 'config', name: '系统配置', category: '设置' },
|
||||
{ key: 'banners', name: 'Banner管理', category: '运营' },
|
||||
{ key: 'dashboard', name: '仪表盘', category: '首页' }, { key: 'users', name: '用户管理', category: '用户' },
|
||||
{ key: 'courses', name: '课程管理', category: '内容' }, { key: 'prompts', name: '提示词管理', category: '内容' },
|
||||
{ key: 'contents', name: '内容管理', category: '内容' }, { key: 'tools', name: '工具管理', category: '内容' },
|
||||
{ key: 'orders', name: '订单管理', category: '交易' }, { key: 'enterprise', name: '企业版管理', category: '交易' },
|
||||
{ key: 'comments', name: '评论审核', category: '社区' }, { key: 'analytics', name: '数据分析', category: '统计' },
|
||||
{ key: 'roles', name: '角色权限', category: '设置' }, { key: 'admins', name: '管理员', category: '设置' },
|
||||
{ key: 'config', name: '系统配置', category: '设置' }, { key: 'banners', name: 'Banner管理', category: '运营' },
|
||||
{ key: 'notifications', name: '推送管理', category: '运营' },
|
||||
],
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user