修复前端问题

This commit is contained in:
xhy 2025-04-04 18:07:48 +08:00
parent d064fdc1f9
commit dd77a24b48
15 changed files with 3210 additions and 7 deletions

2
.gitignore vendored
View File

@ -50,7 +50,7 @@ __pycache__/
# Distribution / packaging
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/

View File

@ -45,7 +45,10 @@ class MainApp:
)
parser.add_argument(
"--crawl", help="采集模式,根据域名批量采集 SURL多个域名可使用英文逗号分割也可通过 --crawl-file 传入文件",
"--crawl",
nargs="?",
const="",
help="采集模式,根据域名批量采集 SURL多个域名可使用英文逗号分割也可通过 --crawl-file 传入文件",
)
parser.add_argument(
"--crawl-file", help="目标域名文件,批量传入待采集的域名,每行一个"
@ -133,7 +136,7 @@ class MainApp:
signal.signal(signal.SIGINT, self.exit_handler)
# 启动所有的 engine
if self.args.crawl:
if self.args.crawl is not None:
self.crawl_engine = CrawlEngine()
self.crawl_engine.start()
logger.info("crawl 启动")

View File

@ -1,11 +1,25 @@
import os
import uvicorn
from fastapi import FastAPI
from fastapi import FastAPI, HTTPException
from fastapi.responses import FileResponse, Response
from loguru import logger
from starlette.staticfiles import StaticFiles
from starlette.types import Scope
from .controller.domain import router as domain_router
from .controller.report import router as report_router
from .controller.status import router as status_router
class SPAStaticFiles(StaticFiles):
async def get_response(self, path: str, scope: Scope) -> Response:
# 如果是前端路由,直接返回 index.html否则直接访问的时候会404
if path in ("domain", "url"):
return FileResponse(os.path.join(self.directory, "index.html"))
return await super().get_response(path, scope)
class WebApp:
def __init__(self):
@ -20,6 +34,9 @@ class WebApp:
app.include_router(report_router)
app.include_router(domain_router)
# 挂载前端文件
app.mount("/", SPAStaticFiles(directory="fe/dist", html=True), name="static")
# TODO 先写死,后面从配置文件里取
cfg = uvicorn.Config(app, host="127.0.0.1", port=3000)
server = uvicorn.Server(cfg)

2
fe/.gitignore vendored
View File

@ -9,7 +9,7 @@ lerna-debug.log*
node_modules
.DS_Store
dist
dist-ssr
coverage
*.local

2
fe/components.d.ts vendored
View File

@ -14,7 +14,6 @@ declare module 'vue' {
NButton: typeof import('naive-ui')['NButton']
NCard: typeof import('naive-ui')['NCard']
NCheckbox: typeof import('naive-ui')['NCheckbox']
NConfigProvider: typeof import('naive-ui')['NConfigProvider']
NDataTable: typeof import('naive-ui')['NDataTable']
NDialogProvider: typeof import('naive-ui')['NDialogProvider']
NDropdown: typeof import('naive-ui')['NDropdown']
@ -28,7 +27,6 @@ declare module 'vue' {
NPagination: typeof import('naive-ui')['NPagination']
NSelect: typeof import('naive-ui')['NSelect']
NSpace: typeof import('naive-ui')['NSpace']
NSwitch: typeof import('naive-ui')['NSwitch']
NTag: typeof import('naive-ui')['NTag']
NTooltip: typeof import('naive-ui')['NTooltip']
RouterLink: typeof import('vue-router')['RouterLink']

483
fe/dist/assets/DomainManager-2SUOMVR8.js vendored Normal file

File diff suppressed because one or more lines are too long

1525
fe/dist/assets/FormItem-DHmVxm6n.js vendored Normal file

File diff suppressed because one or more lines are too long

Binary file not shown.

Binary file not shown.

Binary file not shown.

1
fe/dist/assets/UrlManager-DG8i4_QJ.js vendored Normal file

File diff suppressed because one or more lines are too long

1
fe/dist/assets/index-Ca0u0JBQ.css vendored Normal file

File diff suppressed because one or more lines are too long

1161
fe/dist/assets/index-DnpM0Ntg.js vendored Normal file

File diff suppressed because one or more lines are too long

BIN
fe/dist/favicon.ico vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

14
fe/dist/index.html vendored Normal file
View File

@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="">
<head>
<meta charset="UTF-8">
<link rel="icon" href="/favicon.ico">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Baidu Reporter</title>
<script type="module" crossorigin src="/assets/index-DnpM0Ntg.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-Ca0u0JBQ.css">
</head>
<body>
<div id="app"></div>
</body>
</html>