From 14514c97c694b59ea4774520f8eb6457ec718722 Mon Sep 17 00:00:00 2001 From: zanllp Date: Wed, 21 Aug 2024 22:52:15 +0800 Subject: [PATCH] releases/1.1.0 --- scripts/iib/api.py | 8 +++++--- scripts/iib/tool.py | 12 +++++++++++- vue/src-tauri/tauri.conf.json | 2 +- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/scripts/iib/api.py b/scripts/iib/api.py index 1760f29b..df40e714 100644 --- a/scripts/iib/api.py +++ b/scripts/iib/api.py @@ -36,7 +36,7 @@ get_current_commit_hash, get_current_tag, get_file_info_by_path, - get_frame_at_second + get_data_file_path ) from fastapi import FastAPI, HTTPException, Header, Response from fastapi.staticfiles import StaticFiles @@ -73,7 +73,9 @@ except Exception as e: logger.error(e) -index_html_path = os.path.normpath(os.path.join(__file__, "../","vue/dist/index.html")) if is_exe_ver else os.path.join(cwd, "vue/dist/index.html") # 在app.py也被使用 +print(f"data_file_path:{get_data_file_path()}") + +index_html_path = get_data_file_path("vue/dist/index.html") if is_exe_ver else os.path.join(cwd, "vue/dist/index.html") # 在app.py也被使用 send_img_path = {"value": ""} @@ -746,7 +748,7 @@ def index_bd(): return Response(content=content, media_type="text/html") return FileResponse(index_html_path) - static_dir = os.path.normpath(os.path.join(__file__, "../","vue/dist")) if is_exe_ver else f"{cwd}/vue/dist" + static_dir = get_data_file_path("vue/dist") if is_exe_ver else f"{cwd}/vue/dist" @app.get(api_base + "/fe-static/{file_path:path}") async def serve_static_file(file_path: str): file_full_path = f"{static_dir}/{file_path}" diff --git a/scripts/iib/tool.py b/scripts/iib/tool.py index c632e4e0..23519239 100644 --- a/scripts/iib/tool.py +++ b/scripts/iib/tool.py @@ -723,4 +723,14 @@ def get_frame_at_second(video_path, second): container.seek(frame_container_pts, backward=True, stream=container.streams.video[0]) frame = next(container.decode(video=0)) - return frame \ No newline at end of file + return frame + +def get_data_file_path(filename): + if hasattr(sys, '_MEIPASS'): + # Running in a PyInstaller bundle + base_path = os.path.join(sys._MEIPASS) + else: + # Running in a normal Python environment + base_path = os.path.join(os.path.dirname(__file__)) + + return os.path.normpath(os.path.join(base_path, filename)) \ No newline at end of file diff --git a/vue/src-tauri/tauri.conf.json b/vue/src-tauri/tauri.conf.json index 0a7335ab..4576f5af 100644 --- a/vue/src-tauri/tauri.conf.json +++ b/vue/src-tauri/tauri.conf.json @@ -8,7 +8,7 @@ }, "package": { "productName": "Infinite Image Browsing", - "version": "1.0.0" + "version": "1.1.0" }, "tauri": { "allowlist": {