Skip to content

Commit ed1c57c

Browse files
committed
pref: support pwa
1 parent 6889cc7 commit ed1c57c

13 files changed

+2227
-405
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ yarn-error.log
66
.DS_Store
77
src/temp.ts
88
dist
9-
.netlify/
9+
.netlify/
10+
dev-dist/

astro.config.mjs

+40-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
presetTypography
1212
} from "unocss"
1313
import solidJs from "@astrojs/solid-js"
14+
import AstroPWA from "@vite-pwa/astro"
1415

1516
const adapter = () => {
1617
if (process.env.VERCEL) {
@@ -42,7 +43,45 @@ export default defineConfig({
4243
presetIcons()
4344
]
4445
}),
45-
solidJs()
46+
solidJs(),
47+
AstroPWA({
48+
base: "/",
49+
scope: "/",
50+
includeAssets: ["favicon.svg"],
51+
manifest: {
52+
name: "ChatGPT",
53+
lang: "zh-cn",
54+
short_name: "ChatGPT",
55+
background_color: "#f6f8fa",
56+
theme_color: "#f6f8fa",
57+
icons: [
58+
{
59+
src: "192.png",
60+
sizes: "192x192",
61+
type: "image/png"
62+
},
63+
{
64+
src: "256.png",
65+
sizes: "256x256",
66+
type: "image/png"
67+
},
68+
{
69+
src: "512.png",
70+
sizes: "512x512",
71+
type: "image/png"
72+
},
73+
{
74+
src: "512.png",
75+
sizes: "512x512",
76+
type: "image/png"
77+
}
78+
]
79+
},
80+
workbox: {
81+
navigateFallback: "/404",
82+
globPatterns: ["**/*.{css,js,html,svg,png,ico,txt,astro}"]
83+
}
84+
})
4685
],
4786
output: "server",
4887
adapter: adapter()

package.json

+14-11
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,16 @@
1414
"lint": "eslint . --ext .ts",
1515
"prettier": "prettier --write ."
1616
},
17+
"simple-git-hooks": {
18+
"pre-commit": "pnpm exec lint-staged"
19+
},
20+
"lint-staged": {
21+
"src/**/*.{js,jsx,ts,tsx,json}": [
22+
"prettier --write",
23+
"eslint --cache --fix",
24+
"git add"
25+
]
26+
},
1727
"dependencies": {
1828
"@astrojs/cloudflare": "^6.2.1",
1929
"@astrojs/netlify": "2.0.0",
@@ -37,16 +47,6 @@
3747
"markdown-it-kbd": "^2.2.2",
3848
"solid-js": "^1.6.15"
3949
},
40-
"simple-git-hooks": {
41-
"pre-commit": "pnpm exec lint-staged"
42-
},
43-
"lint-staged": {
44-
"src/**/*.{js,jsx,ts,tsx,json}": [
45-
"prettier --write",
46-
"eslint --cache --fix",
47-
"git add"
48-
]
49-
},
5050
"devDependencies": {
5151
"@iconify-json/carbon": "^1.1.16",
5252
"@iconify-json/ri": "^1.1.5",
@@ -62,7 +62,10 @@
6262
"punycode": "^2.3.0",
6363
"simple-git-hooks": "^2.8.1",
6464
"typescript": "^5.0.2",
65-
"unocss": "^0.50.6"
65+
"unocss": "^0.50.6",
66+
"@vite-pwa/astro": "^0.0.5",
67+
"vite-plugin-pwa": "^0.14.4",
68+
"workbox-window": "^6.5.4"
6669
},
6770
"packageManager": "[email protected]",
6871
"engines": {

0 commit comments

Comments
 (0)