WuYongJie ba98bf22cc feat: 添加许可证系统、Agent部署模块和Harbor镜像管理
- 新增许可证服务器 (license-server/)
- 新增 Agent 部署模块 (flnxi-agent/)
- 添加许可证验证和激活页面
- 添加 Harbor 镜像同步脚本
- 更新素材系统支持许可证验证
2025-12-15 21:19:46 +08:00

68 lines
1.6 KiB
TypeScript

import { NextResponse } from 'next/server';
import { prisma } from '@/lib/prisma';
import { getLicense, getLicenseType } from '@/lib/license';
export async function GET() {
try {
const license = getLicense();
if (!license) {
return NextResponse.json(
{ error: '未激活' },
{ status: 401 }
);
}
// 获取使用统计
const [userCount, materialCount] = await Promise.all([
prisma.user.count(),
prisma.material.count(),
]);
// 获取本地许可证数据
const localLicense = await prisma.systemConfig.findUnique({
where: { key: 'license' },
});
let lastVerified = new Date().toISOString();
if (localLicense) {
try {
const data = JSON.parse(localLicense.value);
lastVerified = data.lastVerified || lastVerified;
} catch {
// ignore
}
}
// 判断状态
let status: 'active' | 'expired' | 'grace' = 'active';
if (license.expiresAt && new Date(license.expiresAt) < new Date()) {
status = 'expired';
}
return NextResponse.json({
type: license.type,
status,
expiresAt: license.expiresAt,
usage: {
users: {
current: userCount,
max: license.limits.maxUsers,
},
materials: {
current: materialCount,
max: license.limits.maxMaterials,
},
},
features: license.features,
lastVerified,
});
} catch (error) {
console.error('获取许可证信息失败:', error);
return NextResponse.json(
{ error: '服务器错误' },
{ status: 500 }
);
}
}