From 269828c79edcab96f0e89a566e6d076c4f316494 Mon Sep 17 00:00:00 2001 From: MacRimi Date: Mon, 29 Sep 2025 18:16:01 +0200 Subject: [PATCH] Update AppImage --- AppImage/next.config.mjs | 2 +- AppImage/package.json | 3 ++- AppImage/scripts/build_appimage.sh | 30 ++++++++++-------------------- AppImage/scripts/flask_server.py | 22 ++++++++++++---------- 4 files changed, 25 insertions(+), 32 deletions(-) diff --git a/AppImage/next.config.mjs b/AppImage/next.config.mjs index 87f06dd..ce3a66c 100644 --- a/AppImage/next.config.mjs +++ b/AppImage/next.config.mjs @@ -1,6 +1,6 @@ /** @type {import('next').NextConfig} */ const nextConfig = { - output: 'standalone', + output: 'export', trailingSlash: true, eslint: { ignoreDuringBuilds: true, diff --git a/AppImage/package.json b/AppImage/package.json index edfc121..6060bc4 100644 --- a/AppImage/package.json +++ b/AppImage/package.json @@ -7,7 +7,8 @@ "dev": "next dev", "build": "next build", "start": "next start", - "lint": "next lint" + "lint": "next lint", + "export": "next build" }, "dependencies": { "@hookform/resolvers": "^3.10.0", diff --git a/AppImage/scripts/build_appimage.sh b/AppImage/scripts/build_appimage.sh index eaef42b..ec73a3b 100644 --- a/AppImage/scripts/build_appimage.sh +++ b/AppImage/scripts/build_appimage.sh @@ -48,17 +48,16 @@ if [ ! -d "node_modules" ]; then npm install fi -# Build Next.js application -echo "🏗️ Building Next.js application..." -npm run build +echo "🏗️ Building Next.js static export..." +npm run export -# Verify build was successful -if [ ! -d ".next" ]; then - echo "❌ Error: Next.js build failed - .next directory not found" +# Verify export was successful +if [ ! -d "out" ]; then + echo "❌ Error: Next.js export failed - out directory not found" exit 1 fi -echo "✅ Next.js build completed successfully" +echo "✅ Next.js static export completed successfully" # Return to script directory cd "$SCRIPT_DIR" @@ -193,24 +192,15 @@ chmod +x "$APP_DIR/usr/bin/translate_cli.py" # Copy Next.js build echo "📋 Copying web dashboard..." -if [ -d "$APPIMAGE_ROOT/.next" ]; then +if [ -d "$APPIMAGE_ROOT/out" ]; then mkdir -p "$APP_DIR/web" - cp -r "$APPIMAGE_ROOT/.next" "$APP_DIR/web/" + cp -r "$APPIMAGE_ROOT/out" "$APP_DIR/web/" cp -r "$APPIMAGE_ROOT/public" "$APP_DIR/web/" cp "$APPIMAGE_ROOT/package.json" "$APP_DIR/web/" - # Also try to create a static export if possible - cd "$APPIMAGE_ROOT" - if npm run export 2>/dev/null; then - echo "✅ Next.js static export created" - if [ -d "out" ]; then - cp -r "out" "$APP_DIR/web/" - fi - fi - - echo "✅ Next.js build copied successfully" + echo "✅ Next.js static export copied successfully" else - echo "❌ Error: Next.js build not found even after building" + echo "❌ Error: Next.js export not found even after building" exit 1 fi diff --git a/AppImage/scripts/flask_server.py b/AppImage/scripts/flask_server.py index 122421f..e20e1f3 100644 --- a/AppImage/scripts/flask_server.py +++ b/AppImage/scripts/flask_server.py @@ -23,13 +23,10 @@ CORS(app) # Enable CORS for Next.js frontend def serve_dashboard(): """Serve the main dashboard page from Next.js build""" try: - next_dir = os.path.join(os.path.dirname(__file__), '..', 'web', '.next') - - # Try to serve the Next.js built index page index_paths = [ - os.path.join(next_dir, 'server', 'app', 'page.html'), - os.path.join(next_dir, 'server', 'pages', 'index.html'), os.path.join(os.path.dirname(__file__), '..', 'web', 'out', 'index.html'), + os.path.join(os.path.dirname(__file__), '..', 'web', '.next', 'server', 'app', 'page.html'), + os.path.join(os.path.dirname(__file__), '..', 'web', '.next', 'server', 'pages', 'index.html'), os.path.join(os.path.dirname(__file__), '..', 'web', 'dist', 'index.html') ] @@ -130,9 +127,15 @@ def serve_sw(): def serve_next_static(filename): """Serve Next.js static files""" try: - next_static_dir = os.path.join(os.path.dirname(__file__), '..', 'web', '.next', 'static') - if os.path.exists(os.path.join(next_static_dir, filename)): - return send_from_directory(next_static_dir, filename) + static_paths = [ + os.path.join(os.path.dirname(__file__), '..', 'web', 'out', '_next'), + os.path.join(os.path.dirname(__file__), '..', 'web', '.next', 'static') + ] + + for static_dir in static_paths: + file_path = os.path.join(static_dir, filename) + if os.path.exists(file_path): + return send_file(file_path) return '', 404 except Exception as e: print(f"Error serving Next.js static file {filename}: {e}") @@ -142,11 +145,10 @@ def serve_next_static(filename): def serve_static_files(filename): """Serve static files (icons, etc.)""" try: - # Try Next.js public directory first public_paths = [ + os.path.join(os.path.dirname(__file__), '..', 'web', 'out'), os.path.join(os.path.dirname(__file__), '..', 'web', 'public'), os.path.join(os.path.dirname(__file__), '..', 'public'), - os.path.join(os.path.dirname(__file__), '..', 'web', 'out'), os.path.join(os.path.dirname(__file__), '..', 'web', '.next', 'static') ]