chore(dev): run mobile uni through portless

This commit is contained in:
2026-07-09 14:52:34 +08:00
parent 1c47e250c4
commit 54b2b0dbbc
5 changed files with 40 additions and 27 deletions
+1 -5
View File
@@ -21,14 +21,10 @@
## 快速启动
```bash
# 终端 1
./scripts/dev.sh
# 终端 2
cd mobile-uni && portless run --name wygj-mobile-uni npm run dev
```
首次启动或需要重建本地 MVP 数据库时执行 `./scripts/dev.sh --reset`。`./scripts/dev.sh` 启动后端、管理端和旧移动端兜底;后端与管理端默认分别通过 `https://wygj-api.localhost/`、`https://wygj-admin.localhost/` 访问,`portless` 启动当前 `mobile-uni` 用户侧。详细端口、默认账号和验证项见 [本地运行手册](docs/DEV_SETUP.md)。
首次启动或需要重建本地 MVP 数据库时执行 `./scripts/dev.sh --reset`。`./scripts/dev.sh` 默认通过 portless 启动后端、管理端和当前 `mobile-uni` 用户侧,对应入口为 `https://wygj-api.localhost/`、`https://wygj-admin.localhost/`、`https://wygj-mobile-uni.localhost/h5/`。只有显式 `PORTLESS=0 ./scripts/dev.sh` 时才回退固定端口和旧移动端兜底。详细端口、默认账号和验证项见 [本地运行手册](docs/DEV_SETUP.md)。
## 目录
@@ -115,7 +115,7 @@ mobile-uni/
- 本机开发入口已切到 portless: `https://wygj-mobile-uni.localhost/h5/`。
- README 和本地运行手册已对齐新用户侧工程: `mobile-uni/` 作为当前施工/测试入口,旧 `mobile/` 仅保留为 MVP 演示兜底;线上 H5 发布命令改为同步 `mobile-uni/dist/build/h5/`。
- 演示验收和 API 对接文档已切到 `mobile-uni` 路由;`scripts/demo-check.sh` 的移动端预检默认检查 `https://wygj-mobile-uni.localhost/h5/` 与新工程 marker,不再用旧 `mobile/src/App.vue` 证明当前用户侧。
- 快速启动口径已补齐: `./scripts/dev.sh` 明确只启动后端、管理端和旧移动端兜底,当前用户侧由 `portless` 启动;脚本输出同步提示 `wygj-mobile-uni.localhost`。
- 快速启动口径已补齐: `./scripts/dev.sh` 默认通过 portless 启动后端、管理端和当前 `mobile-uni` 用户侧;旧移动端兜底只在 `PORTLESS=0` 固定端口调试时启动。
- 主管端已接入最小复盘闭环: 团队概览、待复盘列表、复盘详情、标记已复盘。
- 候选人端已接入最小闭环: 候选首页、结构化面试、最近面试记录、补充资料列表、文件上传、审核状态展示。
- 主管到员工的训练闭环已接入: 主管指派专项、员工今日任务、每日三题提交与反馈。
+8 -13
View File
@@ -26,26 +26,25 @@
- 管理端:`https://wygj-admin.localhost/`
- 后端 API:`https://wygj-api.localhost`
从根目录一次性启动 portless 配置中的管理端和 uni-app 用户侧:
从根目录一次性启动本地依赖、后端、管理端和 uni-app 用户侧:
```bash
portless
./scripts/dev.sh
```
portless 会按根目录 `portless.json` 执行 `frontend` 和 `mobile-uni` 的 `npm run dev`。后端由 `./scripts/dev.sh` 默认通过 `portless run --name wygj-api ./scripts/dev-backend.sh` 启动;管理端 Vite 代理读取 `frontend/.env.development` 的 `VITE_APP_PROXY_TARGET=https://wygj-api.localhost`,`mobile-uni` Vite 代理默认指向 `https://wygj-api.localhost`,都不依赖固定 `8080`。如需单独启动后端,可执行:
`./scripts/dev.sh` 默认通过 portless 启动后端、管理端和 `mobile-uni`,并由 Docker 启动 MySQL/Redis/MinIO/Qdrant。管理端 Vite 代理读取 `frontend/.env.development` 的 `VITE_APP_PROXY_TARGET=https://wygj-api.localhost`,`mobile-uni` Vite 代理默认指向 `https://wygj-api.localhost`,都不依赖固定 `8080`。如需单独启动后端,可执行:
```bash
portless run --name wygj-api ./scripts/dev-backend.sh
```
若已经通过 `./scripts/dev.sh` 启动管理端,只需要单独启动当前用户侧:
也可以只让 portless 按根目录 `portless.json` 启动前端工程:
```bash
cd mobile-uni
portless run --name wygj-mobile-uni npm run dev
portless
```
旧 `./scripts/dev.sh` 仍会拉起 `mobile/` 作为演示兜底;后端开发测试优先看 `wygj-api.localhost`,管理端开发测试优先看 `wygj-admin.localhost`,新用户侧开发测试优先看 `wygj-mobile-uni.localhost`。
旧 `mobile/` 只在显式 `PORTLESS=0 ./scripts/dev.sh` 时作为固定端口兜底启动;后端开发测试优先看 `wygj-api.localhost`,管理端开发测试优先看 `wygj-admin.localhost`,新用户侧开发测试优先看 `wygj-mobile-uni.localhost`。
Qdrant 默认本地无需配置;远端或自定义 collection 可用 `AIHR_QDRANT_URL`、`AIHR_QDRANT_COLLECTION`、`AIHR_QDRANT_API_KEY` 覆盖。服务端资料导入根目录可用 `AIHR_IMPORT_ROOT` 或 `-Daihr.import.root` 覆盖。组织人员同步可用 `AIHR_ORG_SYNC_BASE_URL` 指向外部开放平台 `/api/open/v1` 前缀,并配置 `AIHR_ORG_SYNC_ACCESS_TOKEN` 或 `AIHR_ORG_SYNC_CLIENT_ID`/`AIHR_ORG_SYNC_CLIENT_SECRET`;业务请求会用 client secret 生成 HMAC-SHA256 hex 签名。移动端手机号登录的短信模板 ID、阿里云 AccessKey、Secret 和短信签名都通过环境变量注入;本地放根目录 `.env.local`,`scripts/dev-backend.sh` 会自动加载。若开放平台凭证放在 `backend/.env`,启动脚本也会加载该文件,并把 `client_id`/`client_secret` 映射为组织同步实际读取的 `AIHR_ORG_SYNC_CLIENT_ID`/`AIHR_ORG_SYNC_CLIENT_SECRET`。
@@ -79,14 +78,10 @@ AIHR_AI_SPEECH_ENABLED=true
在项目根目录执行:
```bash
# 终端 1
./scripts/dev.sh
# 终端 2
cd mobile-uni && portless run --name wygj-mobile-uni npm run dev
```
`./scripts/dev.sh` 启动后端、管理端和旧移动端兜底;后端与管理端默认通过 portless 暴露为 `https://wygj-api.localhost/` 和 `https://wygj-admin.localhost/`,`portless` 启动当前 `mobile-uni` 用户侧。若要显式使用旧端口调试,可执行 `PORTLESS=0 ./scripts/dev.sh`,后端入口为 `http://127.0.0.1:8080/`,管理端入口为 `http://127.0.0.1:5173/`。
`./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`。
首次启动或需要重建本地 `ry-vue` MVP 数据库时执行:
@@ -123,7 +118,7 @@ cd mobile-uni && portless run --name wygj-mobile-uni npm run dev
- 启用 `aihr_model_config.category='vector'` 的模型配置后,上传会同步写入片段 embedding,并尽力 upsert 到 Qdrant;模型配置页可查看 Qdrant 维度、点数和片段向量数,并在维度不一致时重建索引;未配置或 Qdrant 不可用时只走 MySQL Fulltext/seed fallback,不影响检索。
- 后端 `ruoyi-admin` 已完成 Maven 打包,并通过 portless 暴露为 `https://wygj-api.localhost/`
- 前端依赖已安装,Vite 已通过 portless 暴露为 `https://wygj-admin.localhost/`
- 旧移动端兜底依赖已安装,Vite 可启动在 `5174`;当前用户侧由 portless 启动 `mobile-uni`,入口 `https://wygj-mobile-uni.localhost/h5/`
- 当前用户侧由 `./scripts/dev.sh` 通过 portless 启动 `mobile-uni`,入口 `https://wygj-mobile-uni.localhost/h5/`;旧移动端兜底仅在 `PORTLESS=0` 调试时启动到 `5174`
- 移动端手机号登录页已接 `/resource/sms/code` 与 `/auth/mobile/sms-login`;未配置真实 `ALIYUN_SMS_ACCESS_KEY_ID`、`ALIYUN_SMS_ACCESS_KEY_SECRET`、`ALIYUN_SMS_SIGN_NAME`、`AIHR_SMS_LOGIN_TEMPLATE_ID` 时不会发送阿里云短信;手机号不存在时会自动注册为 `app_user`
- 移动端员工端“开始训练”已复用 `/api/train/practice/start`、`/turn`、`/finish`;移动端请求需带登录返回的 `Authorization` 与 `clientid`;完成后主管端完训人数、“待复盘对练”计数、复盘列表、复盘详情、员工训练历史和能力画像会变化
- 移动端候选人端“开始面试/面试练习”已复用 `/api/recruit/interview/start`、`/answer`、`/finish`;“补充资料”需带移动端 `Authorization` 与 `clientid`,上传后写 `sys_oss` 和 `aihr_candidate_material`,管理端 `/recruit/interview` 可审核为 `已通过/已驳回`
+1 -1
View File
@@ -10,7 +10,7 @@ if [[ ! -d node_modules ]]; then
fi
if [[ "${PORTLESS:-1}" != "0" ]] && command -v portless >/dev/null 2>&1; then
exec portless run --name wygj-admin bash -lc 'npm run dev -- --host "${HOST:-127.0.0.1}" --port "$PORT" --strictPort'
exec portless run --name wygj-admin --force bash -lc 'npm run dev -- --host "${HOST:-127.0.0.1}" --port "$PORT" --strictPort'
fi
if [[ "${PORTLESS:-1}" != "0" ]]; then
+27 -5
View File
@@ -8,7 +8,7 @@ usage() {
cat <<'EOF'
Usage: ./scripts/dev.sh [start|stop|restart|status|--reset]
Starts MySQL, Redis, MinIO, Qdrant, backend, admin frontend and legacy mobile fallback.
Starts MySQL, Redis, MinIO, Qdrant, backend, admin frontend and current mobile-uni frontend.
start start local demo services
stop stop backend and frontend dev processes
restart stop backend and frontend, then start again
@@ -130,6 +130,10 @@ using_portless_admin() {
using_portless
}
using_portless_mobile() {
using_portless
}
backend_url() {
if using_portless_backend; then
echo "https://wygj-api.localhost/"
@@ -146,6 +150,14 @@ admin_url() {
fi
}
mobile_url() {
if using_portless_mobile; then
echo "https://wygj-mobile-uni.localhost/h5/"
else
echo "http://127.0.0.1:5174/h5/user"
fi
}
stop_dev() {
stop_launchctl_job local.wygj.backend.dev
stop_launchctl_job local.wygj.admin.dev
@@ -153,6 +165,7 @@ stop_dev() {
stop_port 8080
stop_portless_route wygj-admin
stop_port 5173
stop_portless_route wygj-mobile-uni
stop_port 5174
}
@@ -209,7 +222,9 @@ fi
if ! using_portless_admin; then
ensure_port_free 5173
fi
if ! using_portless_mobile; then
ensure_port_free 5174
fi
if [[ "$RESET" == true ]]; then
./scripts/reset-dev-db.sh
@@ -221,7 +236,7 @@ trap cleanup INT TERM EXIT
if using_portless_backend; then
portless alias --remove wygj-api >/dev/null 2>&1 || true
portless run --name wygj-api ./scripts/dev-backend.sh &
portless run --name wygj-api --force ./scripts/dev-backend.sh &
else
./scripts/dev-backend.sh &
fi
@@ -230,15 +245,22 @@ PIDS+=("$!")
./scripts/dev-frontend.sh &
PIDS+=("$!")
if using_portless_mobile; then
portless alias --remove wygj-mobile-uni >/dev/null 2>&1 || true
portless run --name wygj-mobile-uni --force npm --prefix mobile-uni run dev &
else
./scripts/dev-mobile.sh &
fi
PIDS+=("$!")
echo "Backend: $(backend_url)"
echo "Admin: $(admin_url)"
echo "Legacy mobile fallback: http://127.0.0.1:5174/h5/user"
echo "Current user side: https://wygj-mobile-uni.localhost/h5/ (run: cd mobile-uni && portless run --name wygj-mobile-uni npm run dev)"
echo "Mobile: $(mobile_url)"
if using_portless_mobile; then
echo "Legacy mobile fallback: PORTLESS=0 ./scripts/dev.sh"
fi
echo "Qdrant: http://127.0.0.1:6333/"
echo "Press Ctrl+C to stop backend, admin frontend and legacy mobile frontend."
echo "Press Ctrl+C to stop backend, admin frontend and mobile frontend."
while :; do
for pid in "${PIDS[@]}"; do