杂务:更新 YumiNail 工作区
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
|
||||
|
||||
def apply_nav_fallback(text: str) -> str:
|
||||
return (
|
||||
text
|
||||
.replace('color="#2d2430"', 'color="{{navThemeColor || \'#4A443F\'}}"')
|
||||
.replace('color="#1f1b17"', 'color="{{navThemeColor || \'#4A443F\'}}"')
|
||||
.replace('background="{{navThemeBackground || \'#FFF7F9\'}}"', 'background="{{navThemeBackground || \'#FDFBF9\'}}"')
|
||||
.replace('background="{{navThemeBackground || \'#FFF8F4\'}}"', 'background="{{navThemeBackground || \'#FDFBF9\'}}"')
|
||||
.replace('background="#fff7f8"', 'background="{{navThemeBackground || \'#FDFBF9\'}}"')
|
||||
)
|
||||
|
||||
|
||||
TRACKED_RESTORE = [
|
||||
"WeChatProgram/pages/coupons/index.wxml",
|
||||
"WeChatProgram/pages/index/index.wxml",
|
||||
"WeChatProgram/pages/notifications/index.wxml",
|
||||
"WeChatProgram/pages/product-detail/index.wxml",
|
||||
"WeChatProgram/pages/settings/index.wxml",
|
||||
"WeChatProgram/pages/vip-center/index.wxml",
|
||||
"WeChatProgram/pages/wishlist/index.wxml",
|
||||
]
|
||||
|
||||
for relative_path in TRACKED_RESTORE:
|
||||
content = subprocess.check_output(["git", "show", f"HEAD:{relative_path}"], cwd=ROOT)
|
||||
text = content.decode("utf-8")
|
||||
(ROOT / relative_path).write_text(apply_nav_fallback(text), encoding="utf-8")
|
||||
|
||||
|
||||
UNTRACKED_CONVERT = [
|
||||
"WeChatProgram/pages/account-settings/index.wxml",
|
||||
"WeChatProgram/pages/after-sale-apply/index.wxml",
|
||||
"WeChatProgram/pages/after-sales/index.wxml",
|
||||
"WeChatProgram/pages/artist-calendar/index.wxml",
|
||||
"WeChatProgram/pages/artist-orders/index.wxml",
|
||||
"WeChatProgram/pages/help/index.wxml",
|
||||
"WeChatProgram/pages/order-detail/index.wxml",
|
||||
"WeChatProgram/pages/password-settings/index.wxml",
|
||||
"WeChatProgram/pages/service-progress/index.wxml",
|
||||
]
|
||||
|
||||
for relative_path in UNTRACKED_CONVERT:
|
||||
path = ROOT / relative_path
|
||||
if not path.exists():
|
||||
continue
|
||||
text = path.read_text(encoding="utf-8-sig", errors="replace")
|
||||
try:
|
||||
fixed = text.encode("gb18030").decode("utf-8")
|
||||
except UnicodeDecodeError:
|
||||
fixed = text.encode("gb18030").decode("utf-8", errors="replace")
|
||||
path.write_text(apply_nav_fallback(fixed), encoding="utf-8")
|
||||
Reference in New Issue
Block a user