# safe-exam **Repository Path**: happymoon/safe-exam ## Basic Information - **Project Name**: safe-exam - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-04-23 - **Last Updated**: 2026-04-23 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ================================================================================ 安全考试系统 - 部署运行指南 ================================================================================ 生成时间: 2026-04-23 ================================================================================ 一、环境要求 ================================================================================ 1. Node.js - 版本: >= 20.x(推荐 Node.js 20 LTS) - 下载地址: https://nodejs.org/ 2. pnpm - 版本: >= 9.0.0 - 安装命令: npm install -g pnpm 3. 数据库 - PostgreSQL 14+(本地或远程均可) - 或使用 Supabase 云数据库 4. 操作系统 - Windows 10/11 - Linux (Ubuntu 20.04+) - macOS 12+ ================================================================================ 二、部署步骤 ================================================================================ 步骤 1: 克隆项目 git clone <项目地址> cd safe-exam 步骤 2: 安装依赖 pnpm install 步骤 3: 配置环境变量 编辑 .env 文件,配置以下必填项: # 数据库连接 DATABASE_URL=postgres://postgres:[密码]@db.[项目].supabase.co:5432/postgres SUPABASE_URL=https://[项目].supabase.co SUPABASE_SERVICE_KEY=sk-[服务密钥] NEXT_PUBLIC_SUPABASE_URL=https://[项目].supabase.co NEXT_PUBLIC_SUPABASE_ANON_KEY=[ anon key ] 步骤 4: 初始化数据库 # 执行数据库初始化脚本 psql -U exam_user -d exam_system -f ./scripts/init-db.sql # 或执行数据库快照(含表结构和示例数据) psql -U exam_user -d exam_system -f ./sql/2026-04-23.sql 步骤 5: 启动开发服务器 pnpm dev 启动成功后访问: http://localhost:5000 ================================================================================ 三、原生 pnpm 命令(不走 package.json) ================================================================================ # 安装依赖 pnpm install # 类型检查 pnpm ts-check # 开发模式(热更新) pnpm next dev -p 5000 # 生产模式构建 pnpm next build # 生产模式启动 pnpm next start -p 5000 ================================================================================ 四、常用命令 ================================================================================ # 安装依赖 pnpm install # 开发模式启动(当前端口: 5000) pnpm dev # 生产模式构建 pnpm build # 生产模式启动 pnpm start # 代码检查 pnpm lint # 类型检查 pnpm ts-check # 数据库迁移(Drizzle) pnpm drizzle-kit generate # 生成迁移文件 pnpm drizzle-kit push # 推送更改到数据库 pnpm drizzle-kit studio # 打开数据库管理界面 ================================================================================ 五、目录结构 ================================================================================ safe-exam/ ├── src/ # 源代码 │ ├── app/ # Next.js App Router 页面 │ ├── pages/ # Next.js Pages Router 页面 │ ├── components/ # React 组件 │ ├── storage/ # 数据库相关代码 │ │ └── database/ # Drizzle ORM 表定义 │ │ ├── shared/ # 核心表(Phase 1) │ │ └── phase2/ # 扩展表(Phase 2) │ └── lib/ # 工具函数 ├── scripts/ # 构建和部署脚本 ├── sql/ # SQL 脚本和数据库文档 ├── public/ # 静态资源 ├── nginx/ # Nginx 配置 └── Dockerfile # Docker 配置文件 ================================================================================ 六、数据库表说明 ================================================================================ 核心表(Phase 1): - health_check # 健康检查 - users # 用户表 - questions # 题目表 - exam_records # 考试记录表 - system_config # 系统配置表 - operation_logs # 操作日志表 - exam_configs # 考试配置表 扩展表(Phase 2): - F2 HR数据导入: hr_departments, hr_employees, hr_import_batches - F3 新员工转正考核: exam_categories, question_banks, exam_assignments - F7 企业集成: ldap_config, sso_config, wecom_config, wecom_user_bindings, sso_sessions - F8 API开放平台: api_apps, api_keys, api_access_logs, webhooks, oauth2_clients, oauth2_tokens 详细文档: ./sql/2026-04-23-schema.md ================================================================================ 六、默认账户 ================================================================================ 管理员账户: - 邮箱: admin@example.com - 密码: admin123 用户账户: - 邮箱: user@example.com - 密码: user123 ================================================================================ 七、常见问题 ================================================================================ Q1: pnpm install 失败? A1: 确保 Node.js >= 20,pnpm >= 9.0.0,运行 pnpm --version 检查版本。 Q2: 数据库连接失败? A2: 检查 .env 中的 DATABASE_URL 配置,确保 PostgreSQL 服务已启动。 Q3: 端口 5000 被占用? A3: 停止占用端口的其他服务,或修改启动命令指定其他端口。 Q4: 启动后页面空白? A4: 先执行 pnpm build 再启动,确保构建产物完整。 ================================================================================ 八、联系方式 ================================================================================ 技术支持: 请联系系统管理员 ================================================================================