diff --git a/mihomo_editor.py b/mihomo_editor.py index 24ff17e..226054f 100644 --- a/mihomo_editor.py +++ b/mihomo_editor.py @@ -316,6 +316,7 @@ button:hover{filter:brightness(1.1)}
+
@@ -431,6 +432,30 @@ function delProf() { }); } +function downloadProf() { + var sel = document.getElementById('prof-sel'); + if (!sel.value) return; + var name = sel.value; + var params = new URLSearchParams(); + params.append('act', 'get_prof_content'); + params.append('name', name); + fetch('/', { method: 'POST', body: params }) + .then(r => r.json()) + .then(d => { + if (d.error) { + alert(d.error); + } else { + var a = document.createElement('a'); + a.href = 'data:text/yaml;charset=utf-8,' + encodeURIComponent(d.content); + a.download = name + '.yaml'; + document.body.appendChild(a); + a.click(); + document.body.removeChild(a); + showToast('📄 Загрузка началась'); + } + }); +} + function fmtLog(raw) { if(!raw) return "Log empty"; return raw.split('\\n').map(l => { @@ -753,6 +778,17 @@ class H(http.server.SimpleHTTPRequestHandler): s.wfile.write(json.dumps({'error': 'File not found'}).encode('utf-8')) return + if a == 'get_prof_content': + n = p.get('name') + target = os.path.join(PROFILES_DIR, n + ".yaml") + if os.path.exists(target): + with open(target, 'r', encoding='utf-8') as f: + content = f.read() + s.wfile.write(json.dumps({'status': 'ok', 'content': content}).encode('utf-8')) + else: + s.wfile.write(json.dumps({'error': 'Profile not found'}).encode('utf-8')) + return + # --- EXISTING ACTIONS --- if a == 'parse':