From c3381d21ffb75b01a5c193b71cc30c193e564e5d Mon Sep 17 00:00:00 2001 From: wherewhere Date: Mon, 17 Jun 2024 17:33:27 +0800 Subject: [PATCH] =?UTF-8?q?Action=20=E4=BF=AE=E6=94=B9=20service-worker.js?= =?UTF-8?q?=20=E6=A0=B9=E8=B7=AF=E5=BE=84=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复 app.css 导入问题 --- .github/workflows/build-and-deploy.yml | 6 +++++- Wherlog/wwwroot/css/app.css | 2 +- Wherlog/wwwroot/index.html | 2 +- Wherlog/wwwroot/service-worker.published.js | 4 ++-- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index f0bb188..9d8d6bb 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -35,9 +35,13 @@ jobs: run: dotnet publish -c:Release -o:public # Changes the base-tag in index.html to match GitHub Pages repository subdirectory - - name: Change base-tag + - name: Change index.html base-tag run: sed -i 's///g' public/wwwroot/index.html + # Changes the base in service-worker.js to match GitHub Pages repository subdirectory + - name: Change service-worker.js base + run: sed -i 's/const base = "\/";/const base = "\/wherlog\/";/g' public/wwwroot/service-worker.js + # Copy index.html to 404.html to serve the same file when a file is not found - name: copy index.html to 404.html run: cp public/wwwroot/index.html public/wwwroot/404.html diff --git a/Wherlog/wwwroot/css/app.css b/Wherlog/wwwroot/css/app.css index b41a2c2..e32edeb 100644 --- a/Wherlog/wwwroot/css/app.css +++ b/Wherlog/wwwroot/css/app.css @@ -1,4 +1,4 @@ -@import '/_content/Microsoft.FluentUI.AspNetCore.Components/css/reboot.css'; +@import '../_content/Microsoft.FluentUI.AspNetCore.Components/css/reboot.css'; body { --body-font: "Segoe UI Variable", "Segoe UI", sans-serif; diff --git a/Wherlog/wwwroot/index.html b/Wherlog/wwwroot/index.html index df68a44..4b36713 100644 --- a/Wherlog/wwwroot/index.html +++ b/Wherlog/wwwroot/index.html @@ -18,7 +18,7 @@ - + diff --git a/Wherlog/wwwroot/service-worker.published.js b/Wherlog/wwwroot/service-worker.published.js index 1f7f543..0d4d905 100644 --- a/Wherlog/wwwroot/service-worker.published.js +++ b/Wherlog/wwwroot/service-worker.published.js @@ -16,7 +16,7 @@ const base = "/"; const baseUrl = new URL(base, self.origin); const manifestUrlList = self.assetsManifest.assets.map(asset => new URL(asset.url, baseUrl).href); -async function onInstall(event) { +async function onInstall(_) { console.info('Service worker: Install'); // Fetch and cache all matching items from the assets manifest @@ -27,7 +27,7 @@ async function onInstall(event) { await caches.open(cacheName).then(cache => cache.addAll(assetsRequests)); } -async function onActivate(event) { +async function onActivate(_) { console.info('Service worker: Activate'); // Delete unused caches