feat: add brand icons for Chrome shortcuts and PWA manifest
Dark cyan-green candlestick icon for hub and four exchanges; generate/sync scripts and docs/shortcut-icon.md. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
将 brand/icons 同步到中控与各所 static/icons(Chrome 快捷方式 / 标签页图标)。
|
||||
|
||||
用法(仓库根目录):
|
||||
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",
|
||||
"crypto_monitor_gate_bot",
|
||||
)
|
||||
|
||||
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()
|
||||
Reference in New Issue
Block a user