fix: 控制台显示版本号 #59

This commit is contained in:
涵曦 2024-05-16 23:19:05 +00:00
parent abbc2f25bb
commit c2740533a8
5 changed files with 22 additions and 1 deletions

View File

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

View File

@ -0,0 +1 @@
__version__ = '0.1.29'

View File

@ -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():

View File

@ -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);
}

View File

@ -60,7 +60,7 @@
</style>
</head>
<body>
<h2>小爱音箱操控面板</h2>
<h2>小爱音箱操控面板<span id="version">(版本未知)</span></h2>
<hr>
<div id="cmds">
</div>