fix(assets): fix sw-update-notification display and PWA guard conditions

- Change sw-toast default from `display: flex` to `display: none` with proper CSS discrete transition
- Add `display: flex` in `.visible` state and `allow-discrete` transition for display property
- Restore production-only guard for SW notification and webmanifest templates
- Fix PWA config enable to always be true when template is rendered
- Fix extra space in head/index.html conditional
This commit is contained in:
Cell
2026-07-13 16:50:10 +08:00
parent 874337f7d1
commit 405024989c
6 changed files with 8 additions and 6 deletions
+1 -1
View File
@@ -300,7 +300,7 @@
{{- $swBuildCtx := dict "mainCSSURL" $mainCSS.RelPermalink "mainJSURL" $mainJS.RelPermalink "offlineURL" $offlineURL "relURL" (relURL "") "version" (hugo.Store.Get "version") "Page" . -}}
{{- $serviceWorker := resources.Get "js/service-worker.template.js" | resources.ExecuteAsTemplate "js/service-worker.template.js" $swBuildCtx -}}
{{- $serviceWorker = dict "Resource" $serviceWorker "Build" (dict "targetPath" "sw.js") "Fingerprint" $fingerprint | partial "function/js-build.html" -}}
{{- $config = dict "PWA" (dict "enable" .Site.Params.app.pwa "serviceWorkerURL" $serviceWorker.RelPermalink) | merge $config -}}
{{- $config = dict "PWA" (dict "enable" true "serviceWorkerURL" $serviceWorker.RelPermalink) | merge $config -}}
{{- end -}}
{{- /* Auto Bookmark */ -}}
+1 -1
View File
@@ -98,7 +98,7 @@
{{- /* Alternative output formats (Atom, RSS, manifest etc.) */ -}}
{{- range .AlternativeOutputFormats -}}
{{- if (eq .Name "manifest") | and (not $.Site.Params.app.pwa) -}}
{{- if (eq .Name "manifest") | and (not $.Site.Params.app.pwa) -}}
{{- continue -}}
{{- end -}}
<link rel="{{ .Rel }}" type="{{ .MediaType.Type }}" href="{{ .Permalink | safeURL }}">
+1 -1
View File
@@ -129,7 +129,7 @@
{{- end -}}
{{- /* Service Worker Update Notification */ -}}
{{- if .Site.Params.app.pwa -}}
{{- if not hugo.IsServer | and hugo.IsProduction | and .Site.Params.app.pwa -}}
<div class="sw-update-notification">
<div class="sw-update-content">
<p class="sw-update-title">{{ T "serviceWorker.updateTitle" }}</p>
+1 -1
View File
@@ -1,4 +1,4 @@
{{- hugo.Store.Set "version" "v1.0.0-mriu2jcf" -}}
{{- hugo.Store.Set "version" "v1.0.0-mrizf1fk" -}}
{{- .Store.Set "this" dict -}}
{{- partial "init/detection-env.html" . -}}