Skip to content

Commit a048875

Browse files
feat: Front-end and back-end integration
1 parent 8376995 commit a048875

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

backend/common/utils/whitelist.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from typing import List, Pattern
44
from common.core.config import settings
55
wlist = [
6+
"/",
67
"/docs",
78
"/login/*",
89
"*.json",

backend/main.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1+
from fastapi.responses import FileResponse
12
from fastapi.staticfiles import StaticFiles
23
import sentry_sdk
3-
from fastapi import FastAPI
4+
from fastapi import FastAPI, Path
45
from fastapi.routing import APIRoute
56
from starlette.middleware.cors import CORSMiddleware
67
from apps.api import api_router
78
from apps.system.middleware.auth import TokenMiddleware
89
from common.core.config import settings
910

1011
def custom_generate_unique_id(route: APIRoute) -> str:
11-
return f"{route.tags[0]}-{route.name}"
12+
tag = route.tags[0] if route.tags and len(route.tags) > 0 else ""
13+
return f"{tag}-{route.name}"
1214

1315

1416
if settings.SENTRY_DSN and settings.ENVIRONMENT != "local":
@@ -32,7 +34,11 @@ def custom_generate_unique_id(route: APIRoute) -> str:
3234

3335
app.add_middleware(TokenMiddleware)
3436
app.include_router(api_router, prefix=settings.API_V1_STR)
35-
app.mount("/", StaticFiles(directory='../frontend/dist'), name="static")
37+
app.mount("/static", StaticFiles(directory='../frontend/dist'), name="static")
38+
39+
@app.get("/", include_in_schema=False)
40+
async def read_index():
41+
return FileResponse(path="../frontend/dist/index.html")
3642
if __name__ == "__main__":
3743
import uvicorn
3844
uvicorn.run("main:app", host="0.0.0.0", port=8000, reload=True)

frontend/src/router/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createRouter, createWebHistory } from 'vue-router'
1+
import { createRouter, createWebHashHistory } from 'vue-router'
22

33
import Layout from '@/components/layout/index.vue'
44
import login from '@/views/login/index.vue'
@@ -8,7 +8,7 @@ import dashboard from '@/views/dashboard/index.vue'
88
import setting from '@/views/setting/index.vue'
99
import { watchRouter } from './watch'
1010
const router = createRouter({
11-
history: createWebHistory(),
11+
history: createWebHashHistory(),
1212
routes: [
1313
{
1414
path: '/login',

0 commit comments

Comments
 (0)