Добавление PWA
This commit is contained in:
parent
682a5ecb13
commit
bfb684dded
12
install.sh
12
install.sh
|
|
@ -36,8 +36,16 @@ mkdir -p "$INIT_DIR"
|
|||
mkdir -p "/opt/etc/mihomo/profiles"
|
||||
mkdir -p "/opt/etc/mihomo/backup"
|
||||
|
||||
# 3. Скачивание файлов
|
||||
echo "[3/4] Скачивание файлов с сервера..."
|
||||
# Создаем директорию для PWA
|
||||
mkdir -p "/opt/etc/mihomo/public/icons"
|
||||
|
||||
# 3. Скачивание и копирование файлов
|
||||
echo "[3/4] Скачивание и копирование файлов..."
|
||||
|
||||
# Копируем локальные PWA файлы
|
||||
echo "Копирование PWA файлов..."
|
||||
cp -f public/manifest.json /opt/etc/mihomo/public/manifest.json
|
||||
cp -f public/icons/*.png /opt/etc/mihomo/public/icons/
|
||||
|
||||
# Скачиваем основной скрипт
|
||||
echo "Загрузка $PY_SCRIPT..."
|
||||
|
|
|
|||
|
|
@ -164,6 +164,8 @@ HTML_TEMPLATE = """<!DOCTYPE html>
|
|||
<meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
||||
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
|
||||
<title>Mihomo Editor v18.4</title>
|
||||
<link rel="manifest" href="/manifest.json">
|
||||
<link rel="apple-touch-icon" href="/icons/icon-192x192.png">
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.32.7/ace.js"></script>
|
||||
<style>
|
||||
:root {
|
||||
|
|
@ -777,6 +779,30 @@ class H(http.server.SimpleHTTPRequestHandler):
|
|||
pass # Silent fail to avoid crashing
|
||||
|
||||
def do_GET(s):
|
||||
if s.path == '/manifest.json':
|
||||
try:
|
||||
with open('public/manifest.json', 'rb') as f:
|
||||
s.send_response(200)
|
||||
s.send_header('Content-type', 'application/json')
|
||||
s.end_headers()
|
||||
s.wfile.write(f.read())
|
||||
except FileNotFoundError:
|
||||
s.send_error(404, "File not found")
|
||||
return
|
||||
|
||||
if s.path.startswith('/icons/'):
|
||||
try:
|
||||
# Sanitize path to prevent directory traversal
|
||||
safe_path = os.path.join('public', s.path[1:]).replace('\\\\', '/')
|
||||
with open(safe_path, 'rb') as f:
|
||||
s.send_response(200)
|
||||
s.send_header('Content-type', 'image/png')
|
||||
s.end_headers()
|
||||
s.wfile.write(f.read())
|
||||
except FileNotFoundError:
|
||||
s.send_error(404, "File not found")
|
||||
return
|
||||
|
||||
if s.path.startswith('/mihomo_panel/'):
|
||||
s.proxy_pass('GET')
|
||||
return
|
||||
|
|
|
|||
Binary file not shown.
|
After Width: | Height: | Size: 8.5 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 29 KiB |
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"name": "Mihomo Studio",
|
||||
"short_name": "Mihomo",
|
||||
"start_url": "/",
|
||||
"display": "standalone",
|
||||
"background_color": "#1a1a1a",
|
||||
"theme_color": "#1a1a1a",
|
||||
"description": "Mihomo Config Editor",
|
||||
"icons": [
|
||||
{
|
||||
"src": "/icons/icon-192x192.png",
|
||||
"sizes": "192x192",
|
||||
"type": "image/png"
|
||||
},
|
||||
{
|
||||
"src": "/icons/icon-512x512.png",
|
||||
"sizes": "512x512",
|
||||
"type": "image/png"
|
||||
}
|
||||
]
|
||||
}
|
||||
Loading…
Reference in New Issue