fix: align Windows dev, App compiler, and ASR
This commit is contained in:
+134
-18
@@ -26,7 +26,7 @@
|
||||
- 管理端:`https://wygj-admin.localhost/`
|
||||
- 后端 API:`https://wygj-api.localhost`
|
||||
|
||||
从根目录一次性启动本地依赖、后端、管理端和 uni-app 用户侧:
|
||||
Linux/macOS 或已完整配置的 Linux shell 可从根目录一次性启动本地依赖、后端、管理端和 uni-app 用户侧:
|
||||
|
||||
```bash
|
||||
./scripts/dev.sh
|
||||
@@ -38,16 +38,12 @@
|
||||
portless run --name wygj-api ./scripts/dev-backend.sh
|
||||
```
|
||||
|
||||
Windows 10/11 + Docker Desktop 不要从 PowerShell 直接执行 `./scripts/dev.sh`:Windows 的 `bash` 可能解析到 WSL,而 WSL 的 Node、Docker 集成和检出文件换行符未必满足脚本要求。使用本文件的 [Windows 10/11 + Docker Desktop](#windows-docker-desktop) 流程。
|
||||
|
||||
本地启动默认关闭管理端图形验证码;需要专门验证验证码链路时设置 `AIHR_DEV_CAPTCHA_ENABLED=true`。生产启动不使用该开发开关,验证码保持开启。
|
||||
|
||||
重复启动或切换分支时优先使用 `./scripts/dev.sh restart`,停止使用 `./scripts/dev.sh stop`。脚本会递归终止 portless 包装进程及其 Java/Vite 子进程,避免旧后端脱离后继续占用 MySQL 连接池;进程树回归可用 `bash scripts/tests/process-tree.test.sh` 验证。
|
||||
|
||||
也可以只让 portless 按根目录 `portless.json` 启动前端工程:
|
||||
|
||||
```bash
|
||||
portless
|
||||
```
|
||||
|
||||
旧 `mobile/` 只在显式 `PORTLESS=0 ./scripts/dev.sh` 时作为固定端口兜底启动;后端开发测试优先看 `wygj-api.localhost`,管理端开发测试优先看 `wygj-admin.localhost`,新用户侧开发测试优先看 `wygj-mobile-uni.localhost`。
|
||||
|
||||
原生 Android/iOS 资源使用 `npm --prefix mobile-uni run build:app` 构建;它不生成签名 APK/IPA,也不适用本文件的 H5 `rsync` 发布流程。自定义基座、协议链接、签名和真机门禁见 [MOBILE_APP_PACKAGING.md](MOBILE_APP_PACKAGING.md)。
|
||||
@@ -91,23 +87,143 @@ AIHR_AI_SPEECH_ENABLED=true
|
||||
|
||||
`application-dev.yml` 只保留占位和默认值,不提交真实短信密钥。dev 环境不配阿里云短信也能登录移动端:验证码固定 `123456`。
|
||||
|
||||
## 启动步骤
|
||||
<a id="windows-docker-desktop"></a>
|
||||
|
||||
在项目根目录执行:
|
||||
## Windows 10/11 + Docker Desktop
|
||||
|
||||
```bash
|
||||
./scripts/dev.sh
|
||||
Windows 推荐让 Docker Desktop 承载 MySQL、Redis、MinIO 和 Qdrant,Java/Vite/portless 仍作为 Windows 进程运行;无需在 Windows 单独安装数据库或 Redis 服务。基础环境要求:
|
||||
|
||||
- Docker Desktop 已启动,`docker info` 可连接 daemon
|
||||
- Git for Windows(使用其 Git Bash 和 OpenSSL)
|
||||
- JDK 17、Maven
|
||||
- Node.js 24+、npm、全局 `portless`
|
||||
- 可选:测试视频解析时另装 `ffmpeg` 和 `ffprobe`
|
||||
|
||||
### 1. PowerShell 会话准备
|
||||
|
||||
在仓库根目录打开 PowerShell。下面通过 `git.exe` 自动定位 Git for Windows,不依赖仓库或 Git 的固定安装盘符:
|
||||
|
||||
```powershell
|
||||
$gitRoot = Split-Path (Split-Path (Get-Command git).Source -Parent) -Parent
|
||||
$gitBash = Join-Path $gitRoot 'bin\bash.exe'
|
||||
$env:Path = "$(Join-Path $gitRoot 'usr\bin');$(Join-Path $gitRoot 'bin');$env:Path"
|
||||
|
||||
docker info
|
||||
docker compose -f docker-compose.dev.yml config --quiet
|
||||
java -version
|
||||
mvn -version
|
||||
node --version
|
||||
portless --version
|
||||
portless doctor
|
||||
```
|
||||
|
||||
`./scripts/dev.sh` 默认通过 portless 暴露后端、管理端和当前 `mobile-uni` 用户侧。若要显式使用旧端口调试,可执行 `PORTLESS=0 ./scripts/dev.sh`,后端入口为 `http://127.0.0.1:8080/`,管理端入口为 `http://127.0.0.1:5173/`,旧移动端兜底入口为 `http://127.0.0.1:5174/h5/user`。
|
||||
若 `portless doctor` 仅提示代理未启动,属于首启正常状态;若提示找不到 OpenSSL,确认本会话已执行上面的 `$env:Path` 设置。首次使用 HTTPS 本地域名时执行一次:
|
||||
|
||||
首次启动或需要重建本地 `ry-vue` MVP 数据库时执行:
|
||||
|
||||
```bash
|
||||
./scripts/dev.sh --reset
|
||||
```powershell
|
||||
portless trust
|
||||
```
|
||||
|
||||
`--reset` 会删除并重建本地 MVP 数据库,只用于本地开发环境。
|
||||
公司代理、VPN 或 TUN 软件可能把 `*.localhost` 在 Node.js 中解析到 `198.18.0.0/15`,导致 Vite 页面能打开、`/dev-api` 却返回 `500`。下面的 Windows 流程先让 portless 为后端分配内部端口,再让两个 Vite 代理从 `portless list` 读取该端口并直连 `127.0.0.1`,因此不依赖 Node.js 对 `*.localhost` 的解析,也不要求 `8080` 空闲;浏览器入口仍使用 portless HTTPS 域名。若浏览器本身也无法解析这些域名,可在路由启动后,用**管理员 PowerShell** 执行一次 `portless hosts sync`。
|
||||
|
||||
### 2. 首次初始化
|
||||
|
||||
首次检出时安装两个当前前端工程的锁定依赖:
|
||||
|
||||
```powershell
|
||||
npm --prefix frontend ci
|
||||
npm --prefix mobile-uni ci
|
||||
```
|
||||
|
||||
首次创建本地测试库时,通过 Git Bash 执行初始化脚本:
|
||||
|
||||
```powershell
|
||||
& $gitBash ./scripts/reset-dev-db.sh
|
||||
```
|
||||
|
||||
该脚本会在 Docker Desktop 中启动 `wygj-mysql`、`wygj-redis`、`wygj-minio`、`wygj-qdrant`,并**删除后重建**本地 `ry-vue`、导入若依与 AIHR schema/seed。仅首次初始化或明确需要清空本地测试数据时使用。
|
||||
|
||||
后续日常启动依赖容器不重建数据:
|
||||
|
||||
```powershell
|
||||
docker compose -f docker-compose.dev.yml up -d mysql redis qdrant minio minio-init
|
||||
```
|
||||
|
||||
基础开发不要求 `.env.local`:dev 短信验证码默认固定为 `123456`,模型调用失败仍保留 seed fallback。真实短信、外部组织同步或外部 AI 模型联调时,再按前文示例创建被 Git 忽略的 `.env.local`。
|
||||
|
||||
### 3. 启动后端
|
||||
|
||||
新开一个 PowerShell,重复“PowerShell 会话准备”中的 `$gitRoot`、`$gitBash` 和 `$env:Path` 三行,然后执行:
|
||||
|
||||
```powershell
|
||||
portless run --name wygj-api --force bash ./scripts/dev-backend.sh
|
||||
```
|
||||
|
||||
首次启动没有 `backend/ruoyi-admin/target/ruoyi-admin.jar` 时,脚本会先执行 Maven 打包;保持该终端运行。portless 分配的内部端口是动态的,对外入口始终是 `https://wygj-api.localhost/`。
|
||||
|
||||
### 4. 启动管理端与 mobile-uni
|
||||
|
||||
管理端和 `mobile-uni` 各使用一个 PowerShell,两个终端都先重复“PowerShell 会话准备”中的变量设置。
|
||||
|
||||
管理端终端在仓库根目录执行:
|
||||
|
||||
```powershell
|
||||
$apiRoute = (portless list | Select-String 'https://wygj-api\.localhost').Line
|
||||
$apiPort = [regex]::Match($apiRoute, 'localhost:(\d+)').Groups[1].Value
|
||||
if (-not $apiPort) { throw 'wygj-api portless route not found' }
|
||||
$env:VITE_APP_PROXY_TARGET = "http://127.0.0.1:$apiPort"
|
||||
& $gitBash ./scripts/dev-frontend.sh
|
||||
```
|
||||
|
||||
`mobile-uni` 终端在仓库根目录执行:
|
||||
|
||||
```powershell
|
||||
$apiRoute = (portless list | Select-String 'https://wygj-api\.localhost').Line
|
||||
$apiPort = [regex]::Match($apiRoute, 'localhost:(\d+)').Groups[1].Value
|
||||
if (-not $apiPort) { throw 'wygj-api portless route not found' }
|
||||
Set-Location .\mobile-uni
|
||||
$env:VITE_PROXY_TARGET = "http://127.0.0.1:$apiPort"
|
||||
portless run --name wygj-mobile-uni --force npm run dev
|
||||
```
|
||||
|
||||
本机 portless `0.15.4` 在没有根 `package.json` workspace 时不会仅凭 `portless.json` 批量启动两个前端,因此不要用根目录裸命令 `portless` 代替上述两个入口。后端重新启动后内部端口可能变化,此时也要重新启动两个前端以刷新代理目标。保持三个应用终端运行,访问:
|
||||
|
||||
- 管理端:`https://wygj-admin.localhost/`
|
||||
- 用户侧:`https://wygj-mobile-uni.localhost/h5/`
|
||||
- 后端:`https://wygj-api.localhost/`
|
||||
|
||||
### 5. 冒烟与测试
|
||||
|
||||
```powershell
|
||||
$gitBash = Join-Path $gitRoot 'bin\bash.exe'
|
||||
|
||||
docker compose -f docker-compose.dev.yml ps
|
||||
portless list
|
||||
|
||||
curl.exe -k -fsS https://wygj-admin.localhost/dev-api/auth/tenant/list
|
||||
curl.exe -k -fsS https://wygj-admin.localhost/dev-api/auth/code
|
||||
curl.exe -k -fsS https://wygj-mobile-uni.localhost/dev-api/api/aihr/mobile/home/user
|
||||
docker exec wygj-mysql mysql -uroot -proot --default-character-set=utf8mb4 -N -B -e "SELECT COUNT(*) FROM information_schema.tables WHERE table_schema='ry-vue';"
|
||||
docker exec wygj-redis redis-cli -a ruoyi123 ping
|
||||
curl.exe -fsS http://127.0.0.1:9000/minio/health/live
|
||||
curl.exe -k -fsS http://127.0.0.1:6333/
|
||||
|
||||
npm --prefix mobile-uni run test:unit
|
||||
npm --prefix mobile-uni run typecheck
|
||||
npm --prefix frontend run build:dev
|
||||
mvn -f backend/pom.xml -pl ruoyi-modules/ruoyi-aihr -am -DskipTests=false test
|
||||
& $gitBash ./scripts/demo-check.sh
|
||||
```
|
||||
|
||||
### 6. 停止
|
||||
|
||||
先在后端、管理端和 `mobile-uni` 三个终端按 `Ctrl+C`。需要同时停止代理和依赖容器时执行:
|
||||
|
||||
```powershell
|
||||
portless proxy stop
|
||||
docker compose -f docker-compose.dev.yml stop
|
||||
```
|
||||
|
||||
日常停止不需要 `docker compose down -v`;当前数据库等数据使用仓库 `.data/` bind mount,只有明确重置时才运行 `reset-dev-db.sh`,不要手工删除 `.data/mysql` 等目录。
|
||||
|
||||
## 默认登录
|
||||
|
||||
@@ -233,7 +349,7 @@ RELEASE_REMOTE_URL=https://peilian.njzhmj.top RELEASE_VERIFY_REMOTE_MATCH=true R
|
||||
- 移动端登录后若组织快照接口返回 `401/403`,只降级为手动岗位确认,不应清除手机号登录态;岗位确认页仍需允许员工选择“生活顾问”后继续进入业务页。
|
||||
- uni-app 主管端:进入 `https://wygj-mobile-uni.localhost/h5/#/pages/supervisor/index/index`,应看到团队概览、团队画像、团队预警、指派专项、待复盘和复盘详情;从团队画像派专项后,最近专项应立即回读新记录。
|
||||
- uni-app 候选人端:进入 `https://wygj-mobile-uni.localhost/h5/#/pages/candidate/index/index`,手机号登录(dev 验证码固定 `123456`)→ “开始面试/面试练习”完成答题评分;“补充资料”选择 PDF/Word/图片后上传,应看到资料状态。Codex 内置浏览器不支持本地文件选择时,用真实 HTTP multipart smoke 代替浏览器文件选择。
|
||||
- 真 LLM 激活:在 `/system/model` 给供应商填 api_host/api_key 并启用 `category=chat` 模型后,三角色对练的客户回复与评分即为真实 LLM 生成;再启用 `category=asr/tts`(如硅基流动 SenseVoice/CosyVoice2)语音路径生效。未配置时全链路自动回退 seed。
|
||||
- 真 LLM 激活:在 `/system/model` 给供应商填 api_host/api_key 并启用 `category=chat` 模型后,三角色对练的客户回复与评分即为真实 LLM 生成;再启用 `category=asr/tts` 语音路径生效。阿里云短音频 ASR 使用 `provider_code=dashscope`、`model_name=qwen3-asr-flash` 和北京工作空间的 `/compatible-mode/v1` Base URL;现有 `backend/.env` 中同一工作空间的 `AIHR_QWEN_REALTIME_ENDPOINT` / `AIHR_QWEN_REALTIME_API_KEY` 可作为本地模型管理的配置来源,但应用不会自动把私密变量导入模型表。密钥只通过模型管理或本地私密配置提供,不写入文档、SQL 或受版本控制配置。SiliconFlow SenseVoice/CosyVoice2 仍作为兼容供应商。未配置时全链路自动回退 seed。
|
||||
|
||||
演示前可先跑最小预检:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user