This commit is contained in:
+11
-2
@@ -9,7 +9,7 @@ from uuid import UUID
|
|||||||
|
|
||||||
from fastapi import Depends, FastAPI, HTTPException, Query, Request, Response
|
from fastapi import Depends, FastAPI, HTTPException, Query, Request, Response
|
||||||
from fastapi.openapi.docs import get_swagger_ui_html
|
from fastapi.openapi.docs import get_swagger_ui_html
|
||||||
from fastapi.responses import FileResponse, JSONResponse
|
from fastapi.responses import FileResponse, HTMLResponse, JSONResponse
|
||||||
from fastapi.staticfiles import StaticFiles
|
from fastapi.staticfiles import StaticFiles
|
||||||
from sqlalchemy import delete, exists, func, or_, select, update
|
from sqlalchemy import delete, exists, func, or_, select, update
|
||||||
from sqlalchemy.exc import IntegrityError
|
from sqlalchemy.exc import IntegrityError
|
||||||
@@ -786,6 +786,15 @@ if static_dir.exists():
|
|||||||
headers = {"Cache-Control": "no-cache, no-store, must-revalidate, max-age=0"}
|
headers = {"Cache-Control": "no-cache, no-store, must-revalidate, max-age=0"}
|
||||||
if target.is_file() and target.is_relative_to(root):
|
if target.is_file() and target.is_relative_to(root):
|
||||||
if target.name == "sw.js":
|
if target.name == "sw.js":
|
||||||
return FileResponse(target, headers=headers)
|
return HTMLResponse(
|
||||||
|
"self.addEventListener('install',()=>self.skipWaiting());"
|
||||||
|
"self.addEventListener('activate',e=>e.waitUntil("
|
||||||
|
"caches.keys().then(k=>Promise.all(k.map(x=>caches.delete(x))))"
|
||||||
|
".then(()=>self.registration.unregister())"
|
||||||
|
".then(()=>self.clients.matchAll({type:'window'}))"
|
||||||
|
".then(cs=>cs.forEach(c=>c.navigate(c.url)))));",
|
||||||
|
media_type="application/javascript",
|
||||||
|
headers=headers,
|
||||||
|
)
|
||||||
return FileResponse(target)
|
return FileResponse(target)
|
||||||
return FileResponse(root / "index.html", headers=headers)
|
return FileResponse(root / "index.html", headers=headers)
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ const loading = ref(false)
|
|||||||
const mobileSidebar = ref(false)
|
const mobileSidebar = ref(false)
|
||||||
const mobileDetail = ref(false)
|
const mobileDetail = ref(false)
|
||||||
const markdownPreview = ref(false)
|
const markdownPreview = ref(false)
|
||||||
const showCompleted = ref(false)
|
const showCompleted = ref(true)
|
||||||
const page = ref(1)
|
const page = ref(1)
|
||||||
const pageSize = 50
|
const pageSize = 50
|
||||||
const totalTasks = ref(0)
|
const totalTasks = ref(0)
|
||||||
|
|||||||
@@ -3,4 +3,9 @@ import App from './App.vue'
|
|||||||
import './style.css'
|
import './style.css'
|
||||||
|
|
||||||
createApp(App).mount('#app')
|
createApp(App).mount('#app')
|
||||||
if ('serviceWorker' in navigator && import.meta.env.PROD) navigator.serviceWorker.register('/sw.js')
|
if ('serviceWorker' in navigator && import.meta.env.PROD) {
|
||||||
|
navigator.serviceWorker.getRegistrations().then((registrations) => {
|
||||||
|
registrations.forEach((registration) => registration.unregister())
|
||||||
|
})
|
||||||
|
caches.keys().then((keys) => keys.forEach((key) => caches.delete(key)))
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user