增加版本显示
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
# 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`
|
||||
@@ -7,9 +7,23 @@ LOG_PATH="/var/log/$APP_NAME"
|
||||
|
||||
echo "正在安装 $APP_NAME..."
|
||||
|
||||
# 获取 git 版本信息
|
||||
GIT_VERSION=$(git describe --tags --always --dirty 2>/dev/null || git rev-parse --short HEAD 2>/dev/null || echo "unknown")
|
||||
GIT_COMMIT=$(git rev-parse --short HEAD 2>/dev/null || echo "unknown")
|
||||
BUILD_TIME=$(date '+%Y-%m-%d %H:%M:%S')
|
||||
|
||||
echo " Git Version : $GIT_VERSION"
|
||||
echo " Git Commit : $GIT_COMMIT"
|
||||
echo " Build Time : $BUILD_TIME"
|
||||
|
||||
LDFLAGS="-s -w"
|
||||
LDFLAGS="$LDFLAGS -X main.GitVersion=$GIT_VERSION"
|
||||
LDFLAGS="$LDFLAGS -X main.GitCommit=$GIT_COMMIT"
|
||||
LDFLAGS="$LDFLAGS -X main.BuildTime=$BUILD_TIME"
|
||||
|
||||
# 编译应用
|
||||
echo "编译应用..."
|
||||
CGO_ENABLED=0 GOOS=linux go build -o $APP_NAME -ldflags="-s -w" main.go
|
||||
CGO_ENABLED=0 GOOS=linux go build -o $APP_NAME -ldflags="$LDFLAGS" main.go
|
||||
|
||||
# 先停止服务
|
||||
sudo systemctl stop $APP_NAME
|
||||
|
||||
@@ -12,6 +12,13 @@ import (
|
||||
"github.com/goccy/go-yaml"
|
||||
)
|
||||
|
||||
// 由 install.sh 编译时通过 -ldflags -X 注入
|
||||
var (
|
||||
GitVersion = "dev"
|
||||
GitCommit = "unknown"
|
||||
BuildTime = "unknown"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
||||
fmt.Println("OPS Backend Service started")
|
||||
@@ -101,6 +108,11 @@ func main() {
|
||||
c.Abort()
|
||||
})
|
||||
|
||||
// 将编译注入的版本信息传给 routers 包
|
||||
routers.GitVersion = GitVersion
|
||||
routers.GitCommit = GitCommit
|
||||
routers.BuildTime = BuildTime
|
||||
|
||||
// API路由
|
||||
routers.ApiRoot(r.Group("/api"))
|
||||
|
||||
|
||||
@@ -10,6 +10,13 @@ import (
|
||||
|
||||
var ErrorCode map[string]interface{}
|
||||
|
||||
// 版本信息,由 main.go 在启动前赋值(值来自 -ldflags 注入)
|
||||
var (
|
||||
GitVersion = "dev"
|
||||
GitCommit = "unknown"
|
||||
BuildTime = "unknown"
|
||||
)
|
||||
|
||||
func init() {
|
||||
//读取默认配置
|
||||
fmt.Println("尝试读取错误码文件")
|
||||
@@ -60,6 +67,9 @@ func ApiRoot(r *gin.RouterGroup) {
|
||||
r.GET("/", func(ctx *gin.Context) {
|
||||
ReturnJson(ctx, "apiOK", gin.H{
|
||||
"isOpsApiRoot": true,
|
||||
"version": GitVersion,
|
||||
"gitCommit": GitCommit,
|
||||
"buildTime": BuildTime,
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
+1
-1
Submodule frontend/ops2_uniapp updated: 93359a1bd3...1d1a4f3670
Reference in New Issue
Block a user