diff --git a/modules/functions/settings/save_load_settings.py b/modules/functions/settings/save_load_settings.py index 5411af8..b41837f 100644 --- a/modules/functions/settings/save_load_settings.py +++ b/modules/functions/settings/save_load_settings.py @@ -41,8 +41,12 @@ def load_settings() -> Settings: # 加载 的函数 with open("settings.json", 'r', encoding="utf-8") as f: try: settings = json.load(f, object_hook=dict2class) # 尝试转换 json 为 dict + path = "" if not os.path.exists(settings.lyric_path): # 检测输出文件夹,若文件夹不存在则在启动时创建 - os.mkdir(settings.lyric_path) + for i in settings.lyric_path.split("/"): + path += i + "/" + if not os.path.exists(path): + os.mkdir(path) return settings except json.decoder.JSONDecodeError or KeyError: # 如果检测到文件无法读取,将会删除设置文件并重新创建 print("设置文件损坏,重新创建...") diff --git a/modules/submenus/settings.py b/modules/submenus/settings.py index 32bb8ee..d80fabd 100644 --- a/modules/submenus/settings.py +++ b/modules/submenus/settings.py @@ -1,7 +1,7 @@ """集合设置参数""" import os -from colorama import Fore +from colorama import Fore, Style from modules.utils.clear_screen import cls_stay from modules.utils.inputs import rinput, cinput from modules.functions.settings.save_load_settings import save_settings @@ -86,8 +86,11 @@ def __remove_output_files(self): def __set_lyric_path(self): cls_stay(self, "[设置菜单 - 保存路径]") - print("允许使用相对路径和绝对路径,默认为\"./out/\"\n请*不要*使用反斜杠来确保通用性\n" - "当前值:%s\n留空回车取消当前设置\n请输入新的歌词保存路径:" % self.settings.lyric_path) + print(f"""允许使用相对路径和绝对路径,默认为"./out/" +请{Fore.RED}*不要*{Style.RESET_ALL}使用{Fore.BLUE}反斜杠{Style.RESET_ALL}来确保通用性 +当前值:{Fore.GREEN}{self.settings.lyric_path}{Style.RESET_ALL} +留空回车取消当前设置 +请输入新的歌词保存路径:""") r = cinput() if not r: input("输入为空!\n按回车继续...") diff --git a/modules/utils/bar.py b/modules/utils/bar.py index 82d9fa9..5b28e49 100644 --- a/modules/utils/bar.py +++ b/modules/utils/bar.py @@ -11,9 +11,9 @@ class CompactBar(Bar): def print_onto_bar(self, message: str): """在进度条的上方打印消息,进度条保持在下方""" # 光标移动到行首,并通过打印空格清空残留的进度条 ↓ - print(f"\x1b[{get_terminal_size().columns}D{(get_terminal_size().columns - 1) * ' '}" - # 光标移动到该行的首部(\x1b[nD, n为前移个数),将需要的信息打印出来,再将光标移动到下一行 ↓ - f"\x1b[{get_terminal_size().columns}D" + message) + print(f"\033[{get_terminal_size().columns}D{(get_terminal_size().columns - 1) * ' '}" + # 光标移动到该行的首部(\033[nD, n为前移个数),将需要的信息打印出来,再将光标移动到下一行 ↓ + f"\033[{get_terminal_size().columns}D" + message) self.update() # 更新进度条 def writeln(self, line, shorten=False):