From 2c699235f782c77850a398df5251d9cfb9f9e5bd Mon Sep 17 00:00:00 2001 From: Petro1990 Date: Mon, 24 Nov 2025 22:41:06 +0300 Subject: [PATCH] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=BA=D0=BD=D0=BE=D0=BF=D0=BA=D0=B8=20"?= =?UTF-8?q?=D0=9F=D0=B0=D0=BD=D0=B5=D0=BB=D1=8C"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mihomo_editor.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) 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':