refactor: 优化main.py,移除无效代码和浏览器自动打开功能
- 移除了`extra-hooks/__init__.py`中的注释,该文件现在为空。 - 在`main.py`中移除了未使用的导入语句和函数,以及启动浏览器的代码。 - 删除了`main.spec`文件,因为它是PyInstaller打包配置的一部分,现在的更改侧重于源代码的清理和优化。
This commit is contained in:
@@ -1 +0,0 @@
|
|||||||
# 用于build exe 使用
|
|
||||||
@@ -1,27 +1,13 @@
|
|||||||
import multiprocessing
|
import multiprocessing
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import time
|
|
||||||
import threading
|
|
||||||
import webbrowser
|
|
||||||
|
|
||||||
root_path = os.getcwd()
|
root_path = os.getcwd()
|
||||||
sys.path.append(root_path)
|
sys.path.append(root_path)
|
||||||
import uvicorn
|
import uvicorn
|
||||||
from pathlib import Path
|
|
||||||
from application.settings import LOGGING
|
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__':
|
if __name__ == '__main__':
|
||||||
multiprocessing.freeze_support()
|
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,
|
uvicorn.run("application.asgi:application", reload=False, host="0.0.0.0", port=8000, workers=4,
|
||||||
log_config=LOGGING)
|
log_config=LOGGING)
|
||||||
|
|||||||
@@ -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,
|
|
||||||
)
|
|
||||||
Reference in New Issue
Block a user