Files
crypto_monitor/scripts/sync_brand_icons.py
T
dekun 9f67de3677 refactor: 移除 gate_bot,统一为三所架构并更新文档
删除 crypto_monitor_gate_bot 目录,中控与子代理改为 binance/okx/gate 三账户;
文档与 UI 文案「四所」改为「三所」;新增清库前一次性配置备份脚本。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-04 22:00:08 +08:00

64 lines
1.8 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env python3
"""
将 brand/icons 同步到中控与各所 static/iconsChrome 快捷方式 / 标签页图标)。
用法(仓库根目录):
python scripts/generate_brand_icons.py
python scripts/sync_brand_icons.py
"""
from __future__ import annotations
import os
import shutil
REPO = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
SRC = os.path.join(REPO, "brand", "icons")
HUB_DEST = os.path.join(REPO, "manual_trading_hub", "static", "icons")
EXCHANGE_DIRS = (
"crypto_monitor_binance",
"crypto_monitor_okx",
"crypto_monitor_gate",
)
FILES = (
"icon.svg",
"favicon.ico",
"icon-16.png",
"icon-32.png",
"icon-192.png",
"icon-512.png",
"apple-touch-icon.png",
)
def sync_dir(dest: str, url_prefix: str, manifest_template: str) -> str:
if not os.path.isdir(SRC):
return f"SKIP {dest}: 请先运行 python scripts/generate_brand_icons.py"
os.makedirs(dest, exist_ok=True)
for name in FILES:
shutil.copy2(os.path.join(SRC, name), os.path.join(dest, name))
manifest_src = os.path.join(REPO, "brand", manifest_template)
if os.path.isfile(manifest_src):
with open(manifest_src, encoding="utf-8") as f:
text = f.read().replace("__ICON_PREFIX__", url_prefix)
with open(
os.path.join(dest, "manifest.webmanifest"),
"w",
encoding="utf-8",
newline="\n",
) as f:
f.write(text)
return f"DONE {dest}"
def main() -> None:
print(sync_dir(HUB_DEST, "/assets/icons", "manifest.webmanifest"))
for d in EXCHANGE_DIRS:
dest = os.path.join(REPO, d, "static", "icons")
print(sync_dir(dest, "/static/icons", "manifest.exchange.webmanifest"))
if __name__ == "__main__":
main()