From 475ec245280e6cc13c9c363ed50ca3f090222d01 Mon Sep 17 00:00:00 2001 From: MaysWind Date: Sun, 9 Jul 2023 13:20:24 +0800 Subject: [PATCH] desktop page supports service worker --- cmd/webserver.go | 8 +++++++- src/DesktopApp.vue | 9 +++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/cmd/webserver.go b/cmd/webserver.go index b9f1a85a..b2ec53ac 100644 --- a/cmd/webserver.go +++ b/cmd/webserver.go @@ -74,6 +74,8 @@ func startWebServer(c *cli.Context) error { gin.SetMode(gin.ReleaseMode) } + workboxFileNames := utils.ListFileNamesWithPrefixAndSuffix(config.StaticRootPath, "workbox-", ".js") + router := gin.New() router.Use(bindMiddleware(middlewares.Recovery)) @@ -119,7 +121,6 @@ func startWebServer(c *cli.Context) error { router.StaticFile("/mobile/manifest.json", filepath.Join(config.StaticRootPath, "manifest.json")) router.StaticFile("/mobile/sw.js", filepath.Join(config.StaticRootPath, "sw.js")) - workboxFileNames := utils.ListFileNamesWithPrefixAndSuffix(config.StaticRootPath, "workbox-", ".js") for i := 0; i < len(workboxFileNames); i++ { router.StaticFile("/mobile/"+workboxFileNames[i], filepath.Join(config.StaticRootPath, workboxFileNames[i])) } @@ -137,6 +138,11 @@ func startWebServer(c *cli.Context) error { router.StaticFile("/desktop/favicon.png", filepath.Join(config.StaticRootPath, "favicon.png")) router.StaticFile("/desktop/touchicon.png", filepath.Join(config.StaticRootPath, "touchicon.png")) router.StaticFile("/desktop/manifest.json", filepath.Join(config.StaticRootPath, "manifest.json")) + router.StaticFile("/desktop/sw.js", filepath.Join(config.StaticRootPath, "sw.js")) + + for i := 0; i < len(workboxFileNames); i++ { + router.StaticFile("/desktop/"+workboxFileNames[i], filepath.Join(config.StaticRootPath, workboxFileNames[i])) + } router.GET("/healthz.json", bindApi(api.Healths.HealthStatusHandler)) diff --git a/src/DesktopApp.vue b/src/DesktopApp.vue index 36d5486f..ff8a7bed 100644 --- a/src/DesktopApp.vue +++ b/src/DesktopApp.vue @@ -7,6 +7,7 @@