From 8747792a4baede381bcb0929f1144c47966dc167 Mon Sep 17 00:00:00 2001 From: shenlei Date: Mon, 20 Jul 2026 16:03:59 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=A0=B9=E6=8D=AE=E5=BA=94=E7=94=A8?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E8=87=AA=E5=8A=A8=E9=87=8D=E7=BD=AE=E6=9E=84?= =?UTF-8?q?=E5=BB=BA=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/routers/config.py | 20 ++++++++++---------- frontend/src/__tests__/ConfigView.test.js | 2 +- frontend/src/views/ConfigView.vue | 8 ++------ tests/test_api_config.py | 16 ++++++++++++++++ tests/test_security.py | 6 +++--- 5 files changed, 32 insertions(+), 20 deletions(-) diff --git a/backend/routers/config.py b/backend/routers/config.py index c18a33a..8ee8562 100644 --- a/backend/routers/config.py +++ b/backend/routers/config.py @@ -2,6 +2,7 @@ import asyncio import json import os +import re import shutil import zipfile from datetime import datetime @@ -501,19 +502,18 @@ async def get_versions(): @router.put("/versions") async def update_versions(data: dict): - """更新 App_Ver 和 Build_Ver""" + """更新 App_Ver,并将 Build_Ver 重置为对应的 .0。""" app_ver = data.get("app_ver", "").strip() - build_ver = data.get("build_ver", "").strip() + if not re.fullmatch(r"\d+\.\d+\.\d+", app_ver): + raise HTTPException(status_code=400, detail="App_Ver 必须为主版本.次版本.修订号,例如 2.196.0") - if not app_ver or not build_ver: - raise HTTPException(status_code=400, detail="版本号不能为空") - - config = load_config() - config["versions"] = { - "app_ver": app_ver, - "build_ver": build_ver, - } + build_ver = f"{app_ver}.0" async with _config_lock: + config = load_config() + config["versions"] = { + "app_ver": app_ver, + "build_ver": build_ver, + } save_config(config) return {"message": "版本号已更新", "app_ver": app_ver, "build_ver": build_ver} diff --git a/frontend/src/__tests__/ConfigView.test.js b/frontend/src/__tests__/ConfigView.test.js index 5c8dad1..a0cd825 100644 --- a/frontend/src/__tests__/ConfigView.test.js +++ b/frontend/src/__tests__/ConfigView.test.js @@ -181,6 +181,6 @@ describe('ConfigView.vue', () => { expect(wrapper.text()).toContain('应用版本号') expect(wrapper.text()).not.toContain('打包参数') - expect(wrapper.findAll('input').length).toBe(2) + expect(wrapper.findAll('input').length).toBe(1) }) }) diff --git a/frontend/src/views/ConfigView.vue b/frontend/src/views/ConfigView.vue index c10ce06..35052ae 100644 --- a/frontend/src/views/ConfigView.vue +++ b/frontend/src/views/ConfigView.vue @@ -273,11 +273,7 @@
格式:主版本.次版本.修订号
-
- - -
格式:主版本.次版本.修订号.构建号(App_Store 打包时构建号自动 +1)
-
+
保存后 Build_Ver 将自动重置为 App_Ver.0;App Store 打包时构建号自动 +1。