Skip to content

feat: support PWA #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Mar 1, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor: 简化配置
  • Loading branch information
pany-ang committed Mar 1, 2025
commit 72a9ebefadd67da878490bb91cb47628d447179e
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Common
dist
dev-dist
node_modules
.eslintcache
vite.config.*.timestamp*
Expand Down
7 changes: 3 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@
name="viewport"
content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no, viewport-fit=cover"
/>
<meta name="description" content="A crafted mobile template" />
<meta name="theme-color" content="#ffffff" />
<link rel="apple-touch-icon" href="/apple-touch-icon.png" />
<link rel="icon" href="/favicon.png" type="image/png" />
<link rel="stylesheet" href="/app-loading.css" />
<title>%VITE_APP_TITLE%</title>
<link rel="apple-touch-icon" href="/apple-touch-icon.png" sizes="180x180" />
<!-- 必须和 manifest 中的 theme_color 保持一致 -->
<meta name="theme-color" content="#1989fa" />
</head>

<body ontouchstart>
<div id="app">
<div id="app-loading"></div>
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
"vant": "4.9.17",
"vconsole": "3.15.1",
"vue": "3.5.13",
"vue-router": "4.5.0",
"workbox-window": "7.3.0"
"vue-router": "4.5.0"
},
"devDependencies": {
"@antfu/eslint-config": "4.3.0",
Expand Down
3 changes: 0 additions & 3 deletions pnpm-lock.yaml

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

Binary file modified public/apple-touch-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/pwa-192x192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/pwa-512x512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions public/robota.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
User-agent: *
Allow: /
5 changes: 0 additions & 5 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/* eslint-disable perfectionist/sort-imports */

// pwa
import { registerSW } from "virtual:pwa-register"
// core
import { pinia } from "@/pinia"
import { router } from "@/router"
Expand All @@ -15,9 +13,6 @@ import "nprogress/nprogress.css"
import "@@/assets/styles/index.css"
import "virtual:uno.css"

// 自动安装新的 Service Worker,更新缓存并刷新页面
registerSW({ immediate: true })

// 创建应用实例
const app = createApp(App)

Expand Down
1 change: 0 additions & 1 deletion src/vite-env.d.ts

This file was deleted.

2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"@@/*": ["src/common/*"]
},
"resolveJsonModule": true,
"types": ["vite/client"],
"types": ["vite/client", "vite-plugin-pwa/client"],
// 允许导入 .ts .mts .tsx 拓展名的文件
"allowImportingTsExtensions": true,
// 允许 JS
Expand Down
16 changes: 6 additions & 10 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,14 @@ export default defineConfig(({ mode }) => {
dts: "types/auto/components.d.ts",
resolvers: [VantResolver()]
}),
// PWA
VitePWA({
registerType: "autoUpdate",
includeAssets: ["favicon.png"],
includeAssets: ["favicon.png", "apple-touch-icon.png"],
manifest: {
name: "MOBVUE",
short_name: "MOBVUE",
description: "A crafted mobile template / vue mobile / vue h5 / vue vant / vue web app",
theme_color: "#1989fa",
name: "MobVue",
short_name: "MobVue",
description: "A crafted mobile template",
theme_color: "#ffffff",
icons: [
{
src: "pwa-192x192.png",
Expand All @@ -149,10 +149,6 @@ export default defineConfig(({ mode }) => {
purpose: ["any", "maskable"]
}
]
},
devOptions: {
enabled: true,
type: "module"
}
})
],
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy