修改新增加文件数量的查询功能
This commit is contained in:
@ -26,17 +26,17 @@ def get_base_path():
|
||||
|
||||
|
||||
def get_static_path():
|
||||
"""获取 Vue 静态资源 dist 的路径"""
|
||||
"""获取 Vue 静态资源 web_dist 的路径"""
|
||||
if getattr(sys, 'frozen', False):
|
||||
# PyInstaller 打包时,资源文件会被解压到 sys._MEIPASS 临时目录
|
||||
# 我们需要在打包命令中指定 --add-data "dist;dist"
|
||||
return os.path.join(sys._MEIPASS, 'dist')
|
||||
# 我们需要在打包命令中指定 --add-data "web_dist;web_dist"
|
||||
return os.path.join(sys._MEIPASS, 'web_dist')
|
||||
# 开发环境
|
||||
return os.path.join(os.path.dirname(os.path.abspath(__file__)), 'dist')
|
||||
return os.path.join(os.path.dirname(os.path.abspath(__file__)), 'web_dist')
|
||||
|
||||
|
||||
# --- Flask 初始化 ---
|
||||
# static_folder 指向 Vue 打包后的 dist 目录
|
||||
# static_folder 指向 Vue 打包后的 web_dist 目录
|
||||
# static_url_path='' 表示静态文件不需要 /static 前缀
|
||||
dist_folder = get_static_path()
|
||||
app = Flask(__name__, static_folder=dist_folder, static_url_path='')
|
||||
@ -303,7 +303,7 @@ def serve_index():
|
||||
|
||||
@app.route('/<path:path>')
|
||||
def serve_static_files(path):
|
||||
# 尝试在 dist 目录寻找文件 (css, js, icons)
|
||||
# 尝试在 web_dist 目录寻找文件 (css, js, icons)
|
||||
file_path = os.path.join(app.static_folder, path)
|
||||
if os.path.exists(file_path):
|
||||
return send_from_directory(app.static_folder, path)
|
||||
@ -323,5 +323,5 @@ if __name__ == "__main__":
|
||||
scheduler.start()
|
||||
# Host='0.0.0.0' 允许外部IP访问
|
||||
# Port=5000 (确保 Windows 防火墙开放了此端口)
|
||||
print("应用正在启动... 请确保 dist 文件夹与脚本/exe 同级或已被打包")
|
||||
print("应用正在启动... 请确保 web_dist 文件夹与脚本/exe 同级或已被打包")
|
||||
app.run(host='0.0.0.0', port=5000, debug=False, use_reloader=False)
|
||||
|
||||
Reference in New Issue
Block a user