Skip to content

Commit

Permalink
🐛 修复PWA未正常注册的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
pecasha committed Apr 4, 2024
1 parent c607643 commit 6ffab99
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@ jobs:
- name: Authenticate With Tencent Cloud CLI
run: tccli configure set secretId $SECRET_ID secretKey $SECRET_KEY
- name: Purge Tencent Cloud CDN Cache
run: tccli cdn PurgeUrlsCache --Urls "$(echo '["${{ vars.WEBSITE_DOMAIN }}"]')"
run: tccli cdn PurgeUrlsCache --Urls "$(echo '${{ vars.DEPLOY_CDN_PURGE_URLS }}')"
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"tailwindcss": "^3.4.3",
"tslib": "^2.6.2",
"typescript": "^5.4.3",
"vite": "^5.2.7"
"vite": "^5.2.7",
"vite-plugin-pwa": "^0.19.7"
}
}
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion src/app.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import "vite-plugin-pwa/info";
import "vite-plugin-pwa/svelte";

declare global {
namespace App {
Expand Down
2 changes: 1 addition & 1 deletion src/app.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html lang="zh-cmn-Hans-CN" ondragstart="return false">
<head>
<meta charset="utf-8"/>
<link rel="icon" href="%sveltekit.assets%/favicon.png"/>
<link rel="icon" href="%sveltekit.assets%/favicon.ico"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<meta name="renderer" content="webkit"/>
Expand Down
4 changes: 3 additions & 1 deletion src/routes/+layout.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<slot></slot>
<main>
<slot />
</main>

<svelte:head>
{@html webManifestLink}
Expand Down
2 changes: 1 addition & 1 deletion src/routes/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="page">
<header>
<div class="logo">
<img src="/favicon.png"
<img src="/logo.png"
alt="中国大面值邮票图鉴">
<section>
<h1>中国大面值邮票图鉴</h1>
Expand Down
Binary file added static/favicon.ico
Binary file not shown.
File renamed without changes
23 changes: 20 additions & 3 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,28 @@ export default defineConfig({
SvelteKitPWA({
registerType: "autoUpdate",
includeAssets: [
"favicon.png"
"favicon.ico",
"logo.png"
],
workbox: {
globIgnores: [
"**/images/*.{png,jpg,jpeg,webp,gif}"
],
globPatterns: [
"**/*.{jpg,png}"
"client/**/*.{js,css,ico,png}"
],
runtimeCaching: [
{
urlPattern: /\.(?:png|jpg|jpeg|webp|gif)$/i,
handler: "CacheFirst",
options: {
cacheName: "images-cache",
expiration: {
maxEntries: 1000,
maxAgeSeconds: 604_800
}
}
}
]
},
manifest: {
Expand All @@ -26,7 +43,7 @@ export default defineConfig({
orientation: "landscape-primary",
icons: [
{
src: "favicon.png",
src: "logo.png",
sizes: "128x128",
type: "image/png"
}
Expand Down

0 comments on commit 6ffab99

Please sign in to comment.