feat: admin back-office system + AI assistant with action commands
- Admin analytics (recharts charts, overview stats, trend analysis, time range selector) - Admin permissions (AdminRole/AdminUser models, role CRUD, permission catalog) - Admin system config (site/AI/member category tabs, per-key save) - Admin operations (Banner CRUD, push notification send/delete) - Admin user management (table, search, create/edit, ban/delete) - Admin layout (custom top bar with branding + sidebar, admin AI assistant) - Admin login (adminToken localStorage, adminInfo display) - Admin AI assistant (purple '运营助手', context-aware prompts, action commands) - Public AI assistant Phase B (action commands: navigate, setModel, startChat, openSkill, setParameter) - Assistant context mapping + action executor - Skills API fix: tags parsing fallback (JSON.parse → split) - Sandbox crash fix: curScene fallback system prompt - JWT token expiration: access 2h→7d, refresh 7d→30d, admin 8h→7d - i18n: assistant-related translations (zh/en) - PM2 ecosystem config for process management - AI assistant login prompt fix: admin uses getAdminToken(), public uses apiFetch with token refresh
This commit is contained in:
@@ -11,7 +11,10 @@ export class AdminService {
|
||||
) {}
|
||||
|
||||
async login(username: string, password: string) {
|
||||
const admin = await this.prisma.adminUser.findUnique({ where: { username } });
|
||||
const admin = await this.prisma.adminUser.findUnique({
|
||||
where: { username },
|
||||
include: { role: true },
|
||||
});
|
||||
if (!admin || admin.status !== 'ACTIVE') {
|
||||
throw new UnauthorizedException('管理员账号不可用');
|
||||
}
|
||||
@@ -28,10 +31,10 @@ export class AdminService {
|
||||
|
||||
const token = this.jwtService.sign(
|
||||
{ sub: admin.id, type: 'admin' },
|
||||
{ expiresIn: '8h' },
|
||||
{ expiresIn: '7d' },
|
||||
);
|
||||
|
||||
return { token, id: admin.id, username: admin.username, role: admin.role };
|
||||
return { token, id: admin.id, username: admin.username, role: admin.role?.name };
|
||||
}
|
||||
|
||||
async getDashboard() {
|
||||
|
||||
Reference in New Issue
Block a user