refactor: 将版本号注入移至构建配置

This commit is contained in:
dmy
2026-03-05 12:36:29 +08:00
parent 395d364a8f
commit 94080e71ae
6 changed files with 11 additions and 25 deletions

View File

@@ -1 +0,0 @@
1.0.18

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -1,4 +0,0 @@
version: 1.0.18
company_name: EGM
file_description: EGM Lightning Protection Calculator
product_name: Lightening

View File

@@ -1,6 +1,5 @@
#!/usr/bin/env python3
"""更新版本号脚本"""
import re
import sys
from pathlib import Path
@@ -20,22 +19,6 @@ def increment_version(version: str) -> str:
return version
def update_index_html(version: str):
"""更新 webui/index.html 中的标题版本号"""
index_file = Path(__file__).parent / "webui" / "index.html"
content = index_file.read_text(encoding="utf-8")
# 替换标题中的版本号
new_content = re.sub(
r"<title>EGM 输电线路绕击跳闸率计算( v[\d.]+)?</title>",
f"<title>EGM 输电线路绕击跳闸率计算 v{version}</title>",
content
)
index_file.write_text(new_content, encoding="utf-8")
print(f"Updated version in {index_file} to v{version}")
def update_version_file(version: str):
"""更新 VERSION 文件"""
version_file = Path(__file__).parent / "VERSION"
@@ -66,7 +49,6 @@ def main():
# 更新所有文件
update_version_file(new_version)
update_index_html(new_version)
create_metadata(new_version)
print(f"Version updated: {current_version} -> {new_version}")

View File

@@ -4,7 +4,7 @@
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>EGM 输电线路绕击跳闸率计算 v1.0.22</title>
<title>EGM 输电线路绕击跳闸率计算</title>
</head>
<body>
<div id="app"></div>

View File

@@ -15,7 +15,16 @@ export default defineConfig({
vue({
template: { transformAssetUrls }
}),
quasar()
quasar(),
{
name: 'html-version',
transformIndexHtml(html) {
return html.replace(
/<title>EGM 输电线路绕击跳闸率计算( v[\d.]+)?<\/title>/,
`<title>EGM 输电线路绕击跳闸率计算 v${version}</title>`
)
}
}
],
resolve: {
alias: {