- 新增用户登录页面与API端点(/api/auth/login、/api/auth/logout、/api/auth/me) - 引入基于密码哈希的认证机制,支持默认管理员账号登录 - 创建访问控制模块(lib/access-control.ts),实现基于角色的权限验证 - 在现有API端点中集成权限检查,限制非管理员用户只能访问其所属项目数据 - 更新应用布局,要求用户登录后才能访问主界面 - 扩展用户表结构,增加用户名和密码哈希字段 - 调整项目、KR、目标、会议记录等资源的查询逻辑,根据用户权限过滤数据 - 改进管理页面(指标、模板)的删除操作,使用确认对话框替代直接确认 - 优化“我的KR”页面,为管理员提供全员KR概览视图 - 修复.gitignore文件中的拼写错误(.trae → .travis) - 添加数据库迁移脚本,支持任务直接关联项目、禁用RLS、添加求助字段等 - 配置Next.js以支持独立输出和子路径部署
59 lines
1.6 KiB
TypeScript
59 lines
1.6 KiB
TypeScript
'use client';
|
|
|
|
import { cn } from '@/lib/utils';
|
|
import { STATUS_COLORS } from '@/lib/constants';
|
|
import type { ProjectStatus } from '@/types/database';
|
|
|
|
interface StatusBadgeProps {
|
|
status: ProjectStatus;
|
|
size?: 'sm' | 'md' | 'lg';
|
|
showLabel?: boolean;
|
|
text?: string;
|
|
}
|
|
|
|
export function StatusBadge({ status, size = 'md', showLabel = true, text }: StatusBadgeProps) {
|
|
const colors = STATUS_COLORS[status];
|
|
const sizeClasses = {
|
|
sm: 'h-2 w-2',
|
|
md: 'h-3 w-3',
|
|
lg: 'h-4 w-4',
|
|
};
|
|
|
|
return (
|
|
<div className="flex items-center gap-1.5">
|
|
<div className={cn('rounded-full', sizeClasses[size], colors.bg, 'ring-2', colors.border.replace('border', 'ring'))} />
|
|
{showLabel && (
|
|
<span className={cn('text-sm font-medium', colors.text)}>
|
|
{text || colors.label}
|
|
</span>
|
|
)}
|
|
</div>
|
|
);
|
|
}
|
|
|
|
interface StatusDotProps {
|
|
status: ProjectStatus;
|
|
size?: 'sm' | 'md' | 'lg';
|
|
pulse?: boolean;
|
|
}
|
|
|
|
export function StatusDot({ status, size = 'md', pulse = false }: StatusDotProps) {
|
|
const colors = STATUS_COLORS[status];
|
|
const sizeClasses = {
|
|
sm: 'h-2 w-2',
|
|
md: 'h-3 w-3',
|
|
lg: 'h-4 w-4',
|
|
};
|
|
|
|
const bgColor = status === 'green' ? 'bg-emerald-500' : status === 'yellow' ? 'bg-amber-500' : 'bg-rose-500';
|
|
|
|
return (
|
|
<span className="relative flex">
|
|
{pulse && status !== 'green' && (
|
|
<span className={cn('animate-ping absolute inline-flex h-full w-full rounded-full opacity-75', bgColor)} />
|
|
)}
|
|
<span className={cn('relative inline-flex rounded-full', sizeClasses[size], bgColor)} />
|
|
</span>
|
|
);
|
|
}
|