fix: 兼容旧的setting.json文件中conf_path为空的情况

This commit is contained in:
涵曦 2024-07-17 02:20:02 +00:00
parent e5b32b2831
commit fb44f88df2
2 changed files with 6 additions and 3 deletions

View File

@ -22,7 +22,7 @@ def update_html_version(html_files, version):
:param version: 新的版本号字符串
"""
pattern = re.compile(r'(/static/.*(css|js))\?version=[^"]*"')
#pattern = re.compile(r'(/static/.*html)\?version=[^"]*"')
# pattern = re.compile(r'(/static/.*html)\?version=[^"]*"')
for html_file in html_files:
if not html_file.exists():
@ -32,8 +32,8 @@ def update_html_version(html_files, version):
html_content = html_file.read_text()
# 更新CSS和JS版本号
html_content = pattern.sub(fr'\g<1>?version={version}"', html_content)
#html_content = pattern.sub(fr'\g<1>"', html_content)
html_content = pattern.sub(rf'\g<1>?version={version}"', html_content)
# html_content = pattern.sub(fr'\g<1>"', html_content)
# 保存更改到HTML文件
html_file.write_text(html_content)

View File

@ -87,6 +87,9 @@ class XiaoMusic:
def init_config(self):
self.music_path = self.config.music_path
self.conf_path = self.config.conf_path
# 兼容旧配置空的情况
if not self.conf_path:
self.conf_path = "conf"
self.download_path = self.config.download_path
if not self.download_path:
self.download_path = self.music_path