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 @@ -

小爱音箱操控面板

+

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