Files
ops2/.workbuddy/memory/2026-04-27.md
T
2026-04-27 13:37:51 +08:00

56 lines
2.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 2026-04-27 工作记录
## 移动端仓库 - 物品列表显示数量
- `pages/warehouse/warehouse.vue`:两处物品卡片(全部 Tab / 仅物品 Tab)均加入 `数量: {{ item.Quantity ?? 1 }}` 显示
## 后端 - 编译时注入 Git 版本信息
- `main.go`:添加 `GitVersion``GitCommit``BuildTime` 三个变量(由 `-ldflags -X` 注入)
- `main.go`:添加 `GET /api/version` 接口(无需认证,返回三个版本字段)
- `install.sh`:编译前读取 `git describe --tags``git rev-parse --short HEAD`、当前时间,组装 `LDFLAGS` 传入 `go build`
- 编译命令示例:`CGO_ENABLED=0 GOOS=linux go build -o OPSYS -ldflags="-s -w -X main.GitVersion=... -X main.GitCommit=... -X main.BuildTime=..." main.go`
## 移动端设置页 - 显示版本号 + 自动递增脚本
- 创建 `frontend/ops2_uniapp/bump-version.js`
- 读取 `manifest.json`(支持去除 JS 注释后再 `JSON.parse`
- `versionCode` +1`versionName` 自动递增 patch 位
- 用法:`node bump-version.js`(打包前手动执行)
- `pages/settings/settings.vue`
- 底部新增"关于"分组,显示版本号
- 真机端:`plus.runtime.version`
- H5 端:`fetch('/manifest.json')` + 去注释 + `JSON.parse`
- 样式补全 `cell-label`
## 移动端仓库 - 物品编辑页补充 quantity 字段
- `pages/warehouse/item-edit.vue`:参考 Web 端 `WarehouseItemEdit.vue`
- form 增加 `quantity: 1`
- 编号和备注之间添加 +/− 步进器 UI
- `fetchDetail` 回填 `quantity: item.Quantity ?? 1`
- 提交数据加入 `quantity: form.value.quantity > 0 ? form.value.quantity : 1`
- 删除调试 log,补步进器样式
## 移动端仓库 - 新增物品页面补充 quantity 字段
- `pages/warehouse/add-item.vue`:参考 Web 端 `WarehouseAddItem.vue`,补充 `quantity` 字段
- form 增加 `quantity: 1`(默认值 1
- 模板增加 +/ 步进器 UI
- 提交数据中加入 `quantity: form.value.quantity > 0 ? form.value.quantity : 1`
## 后端 - 根路由增加版本字段
- `routers/api.go`
- 添加包级变量 `GitVersion``GitCommit``BuildTime`
- `GET /api/` 响应新增 `version``gitCommit``buildTime` 三个字段
- `main.go``main()` 启动时将变量赋值给 `routers`
- `install.sh` 修复:`BUILD_TIME` 格式改 `YYYYMMDD_HHMMSS`(去空格,避免 ldflags 解析报错)
## Web 前端 - 版本定义 + Footer 显示
- `vite.config.js`:读取 `package.json``version`,通过 `define: { __APP_VERSION__ }` 注入全局常量
- `components/AppFooter.vue`
- script 中 `const version = __APP_VERSION__`
- 模板中版权行末尾显示 `v{{ version }}`(如 `v0.1.0`