From c2740533a88a43e4701a0e0a9463a64e87ca00b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B6=B5=E6=9B=A6?= Date: Thu, 16 May 2024 23:19:05 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=8E=A7=E5=88=B6=E5=8F=B0=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E7=89=88=E6=9C=AC=E5=8F=B7=20#59?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- newversion.sh | 3 +++ xiaomusic/__init__.py | 1 + xiaomusic/httpserver.py | 10 ++++++++++ xiaomusic/static/app.js | 7 +++++++ xiaomusic/static/index.html | 2 +- 5 files changed, 22 insertions(+), 1 deletion(-) diff --git a/newversion.sh b/newversion.sh index 2ef9f88..026579b 100755 --- a/newversion.sh +++ b/newversion.sh @@ -3,6 +3,7 @@ set -e version_file=./pyproject.toml +init_file=./xiaomusic/__init__.py # 获取当前版本号 current_version=$(grep -oE "version = \"[0-9]+\.[0-9]+\.[0-9]+\"" $version_file | cut -d'"' -f2) echo "当前版本号: "$current_version @@ -24,11 +25,13 @@ new_version="$major.$minor.$patch" # 将新版本号写入文件 sed -i "s/version.*/version = \"$new_version\"/g" $version_file +sed -i "s/__version__.*/__version__ = \"$new_version\"/g" $init_file echo "新版本号:$new_version" git diff git add $version_file +git add $init_file git commit -m "new version v$new_version" git tag v$new_version git push -u origin main --tags diff --git a/xiaomusic/__init__.py b/xiaomusic/__init__.py index e69de29..e23e22c 100644 --- a/xiaomusic/__init__.py +++ b/xiaomusic/__init__.py @@ -0,0 +1 @@ +__version__ = '0.1.29' diff --git a/xiaomusic/httpserver.py b/xiaomusic/httpserver.py index 88bb1e1..cfd47ad 100644 --- a/xiaomusic/httpserver.py +++ b/xiaomusic/httpserver.py @@ -9,6 +9,10 @@ from xiaomusic.config import ( KEY_WORD_DICT, ) +from xiaomusic import ( + __version__, +) + app = Flask(__name__) host = "0.0.0.0" port = 8090 @@ -21,6 +25,12 @@ log = None def allcmds(): return KEY_WORD_DICT +@app.route("/getversion", methods=["GET"]) +def getversion(): + log.debug("getversion %s", __version__) + return { + "version": __version__, + } @app.route("/getvolume", methods=["GET"]) def getvolume(): diff --git a/xiaomusic/static/app.js b/xiaomusic/static/app.js index 2bd0fe6..9f33310 100644 --- a/xiaomusic/static/app.js +++ b/xiaomusic/static/app.js @@ -20,6 +20,13 @@ $(function(){ $("#volume").val(data.volume); }); + // 拉取版本 + $.get("/getversion", function(data, status) { + console.log(data, status, data["version"]); + $("#version").text(`(${data.version})`); + }); + + function append_op_button_name(name) { append_op_button(name, name); } diff --git a/xiaomusic/static/index.html b/xiaomusic/static/index.html index 5448f10..39eebe0 100644 --- a/xiaomusic/static/index.html +++ b/xiaomusic/static/index.html @@ -60,7 +60,7 @@ -

小爱音箱操控面板

+

小爱音箱操控面板(版本未知)