fix: restore Feishin window dimension persistence and default to 1280x800

This commit is contained in:
Sho 2026-08-02 15:03:56 +09:00
parent 360f96c653
commit 7e815d4a51
2 changed files with 25 additions and 2 deletions

View File

@ -440,17 +440,25 @@ if os.path.exists(var_app):
for td in target_dirs:
if os.path.exists(td):
# Clean up / sanitize invalid Electron theme strings in config.json, preferences.json, settings.json
# Clean up / sanitize invalid Electron theme strings and ensure comfortable window bounds
for fn in ['config.json', 'preferences.json', 'settings.json']:
fp = os.path.join(td, fn)
if os.path.exists(fp):
try:
with open(fp, 'r', encoding='utf-8') as f: data = json.load(f)
if isinstance(data, dict):
mod = False
if list(data.keys()) == ['theme'] and data['theme'] not in ['dark', 'light', 'system', 'defaultDark', 'defaultLight']:
os.remove(fp)
continue
elif 'theme' in data and data['theme'] not in ['dark', 'light', 'system', 'defaultDark', 'defaultLight']:
data['theme'] = 'dark'
mod = True
bounds = data.get('bounds', {})
if isinstance(bounds, dict) and (bounds.get('width', 0) < 1000 or bounds.get('height', 0) < 700):
data['bounds'] = {'x': bounds.get('x', 50), 'y': bounds.get('y', 50), 'width': 1280, 'height': 800}
mod = True
if mod:
with open(fp, 'w', encoding='utf-8') as f: json.dump(data, f, indent=2)
except Exception: pass
" 2>/dev/null || true

View File

@ -1298,7 +1298,7 @@ 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:
json.dump(qs_json, f, indent=2)
# Ensure config.json, preferences.json, and settings.json maintain valid Electron themeSource ("dark" or "light")
# Ensure config.json, preferences.json, and settings.json maintain valid Electron themeSource ("dark" or "light") and comfortable window bounds
valid_electron_theme = "dark" if is_dark else "light"
for conf_file_name in ['config.json', 'preferences.json', 'settings.json']:
conf_path = os.path.join(base_dir, conf_file_name)
@ -1307,10 +1307,25 @@ def sync_feishin(bg, surface, current_line, fg, accent, sub_accent, is_dark, var
with open(conf_path, 'r', encoding='utf-8') as f:
cdata = json.load(f)
if isinstance(cdata, dict):
modified = False
if list(cdata.keys()) == ['theme'] and cdata['theme'] not in ['dark', 'light', 'system', 'defaultDark', 'defaultLight']:
os.remove(conf_path)
continue
elif 'theme' in cdata and cdata['theme'] not in ['dark', 'light', 'system', 'defaultDark', 'defaultLight']:
cdata['theme'] = valid_electron_theme
modified = True
bounds = cdata.get('bounds', {})
if isinstance(bounds, dict) and (bounds.get('width', 0) < 1000 or bounds.get('height', 0) < 700):
cdata['bounds'] = {
'x': bounds.get('x', 50),
'y': bounds.get('y', 50),
'width': 1280,
'height': 800
}
modified = True
if modified:
with open(conf_path, 'w', encoding='utf-8') as f:
json.dump(cdata, f, indent=2)
except Exception: