fix: resolve Feishin white screen boot crash by sanitizing Electron nativeTheme configuration
This commit is contained in:
parent
2609dcd854
commit
5cb7679b59
30
install.sh
30
install.sh
@ -440,26 +440,18 @@ if os.path.exists(var_app):
|
|||||||
|
|
||||||
for td in target_dirs:
|
for td in target_dirs:
|
||||||
if os.path.exists(td):
|
if os.path.exists(td):
|
||||||
# 1. Set preferences.json theme to defaultDark
|
# Clean up / sanitize invalid Electron theme strings in config.json, preferences.json, settings.json
|
||||||
pref_file = os.path.join(td, 'preferences.json')
|
for fn in ['config.json', 'preferences.json', 'settings.json']:
|
||||||
try:
|
fp = os.path.join(td, fn)
|
||||||
pdata = {}
|
if os.path.exists(fp):
|
||||||
if os.path.exists(pref_file):
|
|
||||||
with open(pref_file, 'r', encoding='utf-8') as f:
|
|
||||||
pdata = json.load(f)
|
|
||||||
pdata['theme'] = 'defaultDark'
|
|
||||||
with open(pref_file, 'w', encoding='utf-8') as f:
|
|
||||||
json.dump(pdata, f, indent=2)
|
|
||||||
except Exception: pass
|
|
||||||
|
|
||||||
# 2. Clean up corrupted config.json / settings.json
|
|
||||||
for bad in ['config.json', 'settings.json']:
|
|
||||||
bp = os.path.join(td, bad)
|
|
||||||
if os.path.exists(bp):
|
|
||||||
try:
|
try:
|
||||||
with open(bp, 'r', encoding='utf-8') as f: bd = json.load(f)
|
with open(fp, 'r', encoding='utf-8') as f: data = json.load(f)
|
||||||
if isinstance(bd, dict) and list(bd.keys()) == ['theme']:
|
if isinstance(data, dict):
|
||||||
os.remove(bp)
|
if list(data.keys()) == ['theme'] and data['theme'] not in ['dark', 'light', 'system', 'defaultDark', 'defaultLight']:
|
||||||
|
os.remove(fp)
|
||||||
|
elif 'theme' in data and data['theme'] not in ['dark', 'light', 'system', 'defaultDark', 'defaultLight']:
|
||||||
|
data['theme'] = 'dark'
|
||||||
|
with open(fp, 'w', encoding='utf-8') as f: json.dump(data, f, indent=2)
|
||||||
except Exception: pass
|
except Exception: pass
|
||||||
" 2>/dev/null || true
|
" 2>/dev/null || true
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1298,15 +1298,21 @@ def sync_feishin(bg, surface, current_line, fg, accent, sub_accent, is_dark, var
|
|||||||
with open(os.path.join(themes_dir, "quickshell.json"), 'w', encoding='utf-8') as f:
|
with open(os.path.join(themes_dir, "quickshell.json"), 'w', encoding='utf-8') as f:
|
||||||
json.dump(qs_json, f, indent=2)
|
json.dump(qs_json, f, indent=2)
|
||||||
|
|
||||||
# Repair/remove any corrupted config.json or settings.json files created by previous bad writes
|
# Ensure config.json, preferences.json, and settings.json maintain valid Electron themeSource ("dark" or "light")
|
||||||
for bad_file_name in ['config.json', 'settings.json']:
|
valid_electron_theme = "dark" if is_dark else "light"
|
||||||
bad_path = os.path.join(base_dir, bad_file_name)
|
for conf_file_name in ['config.json', 'preferences.json', 'settings.json']:
|
||||||
if os.path.exists(bad_path):
|
conf_path = os.path.join(base_dir, conf_file_name)
|
||||||
|
if os.path.exists(conf_path):
|
||||||
try:
|
try:
|
||||||
with open(bad_path, 'r', encoding='utf-8') as f:
|
with open(conf_path, 'r', encoding='utf-8') as f:
|
||||||
bad_data = json.load(f)
|
cdata = json.load(f)
|
||||||
if isinstance(bad_data, dict) and list(bad_data.keys()) == ['theme']:
|
if isinstance(cdata, dict):
|
||||||
os.remove(bad_path)
|
if list(cdata.keys()) == ['theme'] and cdata['theme'] not in ['dark', 'light', 'system', 'defaultDark', 'defaultLight']:
|
||||||
|
os.remove(conf_path)
|
||||||
|
elif 'theme' in cdata and cdata['theme'] not in ['dark', 'light', 'system', 'defaultDark', 'defaultLight']:
|
||||||
|
cdata['theme'] = valid_electron_theme
|
||||||
|
with open(conf_path, 'w', encoding='utf-8') as f:
|
||||||
|
json.dump(cdata, f, indent=2)
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
except Exception:
|
except Exception:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user