[U] Wrap into uv tool.

This commit is contained in:
2026-03-20 20:19:33 +08:00
parent db20b739cd
commit ca9e32763e
14 changed files with 844 additions and 433 deletions

View File

@@ -191,13 +191,13 @@ def setup_cloudflare(api_token, zone_id):
config.set('cdn.cloudflare.zone_id', zone_id)
config.save()
click.echo("Cloudflare配置已更新")
click.echo("Cloudflare配置已更新")
click.echo(f" API Token: {api_token[:10]}...")
click.echo(f" Zone ID: {zone_id}")
click.echo("\n💡 提示: 配置已保存到配置文件,无需重复设置环境变量")
click.echo("\n提示: 配置已保存到配置文件,无需重复设置环境变量")
except Exception as e:
click.echo(f"设置Cloudflare配置失败: {e}")
click.echo(f"设置Cloudflare配置失败: {e}")
return 1
@@ -224,9 +224,9 @@ def set_config(key, value):
config.set(key, value)
config.save()
click.echo(f"配置已更新: {key} = {value}")
click.echo(f"配置已更新: {key} = {value}")
except Exception as e:
click.echo(f"设置配置失败: {e}")
click.echo(f"设置配置失败: {e}")
return 1

View File

@@ -35,7 +35,7 @@ class DisplayManager:
for key, data in differences.items():
storage_value = str(data["storage"])
cdn_value = str(data["cdn"])
status = "不同" if data["different"] else "一致"
status = "不同" if data["different"] else "一致"
# 截断过长的值
if len(storage_value) > truncate_length:
@@ -88,16 +88,16 @@ class DisplayManager:
differences = sum(1 for data in result["differences"].values()
if data["different"])
status = "正常" if differences == 0 else f"⚠️ {differences} 项不同"
status = "正常" if differences == 0 else f"警告: {differences} 项不同"
self.console.print(
f" {platform.title()}: {status} "
f"(存储: {storage_keys}项, CDN: {cdn_keys}项)"
)
else:
self.console.print(f" {platform.title()}: 失败")
self.console.print(f" {platform.title()}: 失败")
else:
self.console.print(f" {platform.title()}: ⚠️ 未检查")
self.console.print(f" {platform.title()}: 未检查")
def display_error(self, message: str):
"""显示错误信息"""
@@ -113,4 +113,4 @@ class DisplayManager:
def display_success(self, message: str):
"""显示成功信息"""
self.console.print(f"[bold green]成功: {message}[/bold green]")
self.console.print(f"[bold green]成功: {message}[/bold green]")

View File

@@ -214,7 +214,7 @@ class ForceUpdateCommand:
update_version: str, update_ver_value: str):
"""显示成功结果"""
self.display_manager.display_success(
f"强制更新成功完成\n"
f"强制更新成功完成\n"
f" 平台: {platform}\n"
f" 目标版本: {target_version}\n"
f" 更新版本: {update_version}\n"
@@ -224,7 +224,7 @@ class ForceUpdateCommand:
def _display_config_comparison(self, platform: str, target_version: str,
original_config: Dict, updated_config: Dict):
"""显示配置对比"""
self.display_manager.display_info(f"\n📋 配置变更对比 (平台: {platform}, 版本: {target_version})")
self.display_manager.display_info(f"\n配置变更对比 (平台: {platform}, 版本: {target_version})")
# 创建对比表格
from rich.table import Table
@@ -263,6 +263,6 @@ class ForceUpdateCommand:
# 显示警告信息
self.display_manager.display_warning(
"⚠️ 注意: 强制更新会立即影响使用该版本的应用,"
"注意: 强制更新会立即影响使用该版本的应用,"
"请确保所有相关方已了解此变更。"
)

View File

@@ -238,11 +238,11 @@ class SuggestUpdateCommand:
updated_value = updated_config.get(key, "N/A")
if key == "Ver_New":
status = "🆕 新增"
status = "新增"
elif original_value != updated_value:
status = "🔄 修改"
status = "修改"
else:
status = "不变"
status = "不变"
# 格式化显示值
original_display = str(original_value)
@@ -266,7 +266,7 @@ class SuggestUpdateCommand:
unchanged_items = total_items - new_items - modified_items
self.display_manager.display_info(
f"\n📈 统计信息:\n"
f"\n统计信息:\n"
f" 总配置项: {total_items}\n"
f" 新增项: {new_items}\n"
f" 修改项: {modified_items}\n"

View File

@@ -54,7 +54,7 @@ def save_encrypted_config(config_data, file_path):
with open(file_path, 'w', encoding='utf-8') as f:
f.write(encrypted_content)
console.print(f"[green]加密配置文件已保存到: {file_path}[/green]")
console.print(f"[green]加密配置文件已保存到: {file_path}[/green]")
return True
except Exception as e:
console.print(f"[red]错误: 无法保存文件 {file_path}: {str(e)}[/red]")
@@ -62,14 +62,14 @@ def save_encrypted_config(config_data, file_path):
def main():
console.print(Panel("🔐 Config Encryptor Tool", expand=False, border_style="bold blue"))
console.print(Panel("Config Encryptor Tool", expand=False, border_style="bold blue"))
# Get input file path
while True:
input_file = input("请输入要读取的原始配置文件路径 (如: config.json): ").strip()
if input_file and os.path.exists(input_file):
break
console.print("[red]文件不存在,请重新输入[/red]")
console.print("[red]文件不存在,请重新输入[/red]")
# Load the raw config file
console.print(f"[blue]正在读取配置文件: {input_file}[/blue]")
@@ -77,10 +77,10 @@ def main():
if config_data is None:
return 1
console.print("[green]配置文件读取成功[/green]")
console.print("[green]配置文件读取成功[/green]")
# Display the config content
console.print(Panel("原始配置内容", title="📄 原始配置", border_style="cyan"))
console.print(Panel("原始配置内容", title="原始配置", border_style="cyan"))
console.print(Syntax(json.dumps(config_data, ensure_ascii=False, indent=2), "json", theme="monokai"))
# Get output file path
@@ -92,7 +92,7 @@ def main():
# Save the encrypted config
console.print(f"[blue]正在加密并保存配置文件: {output_file}[/blue]")
if save_encrypted_config(config_data, output_file):
console.print(Panel("🎉 配置文件加密完成!", expand=False, border_style="bold green"))
console.print(Panel("配置文件加密完成", expand=False, border_style="bold green"))
return 0
else:
return 1
@@ -102,8 +102,8 @@ if __name__ == "__main__":
try:
sys.exit(main())
except KeyboardInterrupt:
print("\n\n👋 已取消操作")
print("\n\n已取消操作")
sys.exit(0)
except Exception as e:
print(f"\n程序执行出错: {str(e)}")
print(f"\n程序执行出错: {str(e)}")
sys.exit(1)