refactor: 优化main.py,移除无效代码和浏览器自动打开功能

- 移除了`extra-hooks/__init__.py`中的注释,该文件现在为空。
- 在`main.py`中移除了未使用的导入语句和函数,以及启动浏览器的代码。
- 删除了`main.spec`文件,因为它是PyInstaller打包配置的一部分,现在的更改侧重于源代码的清理和优化。
This commit is contained in:
李强
2024-06-21 07:36:31 +08:00
parent 60ca268851
commit f34b7967d5
3 changed files with 0 additions and 98 deletions

View File

@@ -1 +0,0 @@
# 用于build exe 使用

View File

@@ -1,27 +1,13 @@
import multiprocessing
import os
import sys
import time
import threading
import webbrowser
root_path = os.getcwd()
sys.path.append(root_path)
import uvicorn
from pathlib import Path
from application.settings import LOGGING
BASE_DIR = Path(__file__).resolve().parent.parent
url = "http://127.0.0.1:8000/web/"
def open_browser_after_delay(url, delay):
time.sleep(delay)
webbrowser.open(url)
if __name__ == '__main__':
multiprocessing.freeze_support()
threading.Thread(target=open_browser_after_delay, args=(url, 3)).start()
uvicorn.run("application.asgi:application", reload=False, host="0.0.0.0", port=8000, workers=4,
log_config=LOGGING)

View File

@@ -1,83 +0,0 @@
# -*- mode: python ; coding: utf-8 -*-
a = Analysis(
['main.py'],
pathex=['./'],
binaries=[],
datas=[
('./static', 'static'),
('./static/captcha/fonts', 'captcha/fonts'),
('./templates', 'templates'),
('./dvadmin/system/util', 'dvadmin/system/util'),
('./plugins/__init__.py', 'plugins/__init__.py'),
('./db.sqlite3', './'),
],
hiddenimports=[
"django",
"testfixtures",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"django_comment_migrate",
"rest_framework",
"django_filters",
"corsheaders", # 注册跨域app
"drf_yasg",
"captcha",
"channels",
"dvadmin.system",
"plugins.gla",
"testfixtures",
"application.asgi",
"dvadmin.utils.middleware",
"whitenoise",
"whitenoise.middleware",
"whitenoise.storage",
"dvadmin.utils.pagination",
"dvadmin.utils.exception",
"rest_framework_simplejwt.state",
],
hookspath=['./extra-hooks'],
hooksconfig={},
runtime_hooks=[],
excludes=[],
noarchive=False,
optimize=0,
)
pyz = PYZ(a.pure)
exe = EXE(
pyz,
a.scripts,
[],
exclude_binaries=True,
name='main',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
console=False,
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
)
coll = COLLECT(
exe,
a.binaries,
a.datas,
strip=False,
upx=True,
upx_exclude=[],
name='main',
)
app = BUNDLE(
coll,
name='main.app',
icon=None,
bundle_identifier=None,
)