Skip to content

Commit

Permalink
fix: pwa 还是先 autoUpdate 吧
Browse files Browse the repository at this point in the history
  • Loading branch information
adams549659584 committed May 30, 2023
1 parent da33467 commit 538d8a4
Show file tree
Hide file tree
Showing 11 changed files with 722 additions and 691 deletions.
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "go-proxy-bingai",
"version": "1.8.4",
"version": "1.8.5",
"private": true,
"scripts": {
"dev": "vite",
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/App.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<script setup lang="ts">
import { NMessageProvider, NConfigProvider, type GlobalThemeOverrides, NDialogProvider } from 'naive-ui';
import { RouterView } from 'vue-router';
import ReloadPWA from '@/components/ReloadPWA/ReloadPWA.vue';
const themeOverrides: GlobalThemeOverrides = {
common: {
Expand All @@ -17,7 +16,6 @@ const themeOverrides: GlobalThemeOverrides = {
<NConfigProvider :theme-overrides="themeOverrides">
<NDialogProvider>
<NMessageProvider>
<ReloadPWA />
<RouterView />
</NMessageProvider>
</NDialogProvider>
Expand Down
50 changes: 42 additions & 8 deletions frontend/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ const __APP_INFO__ = {

const initPwaOptions = (env: Record<string, string>) => {
const pwaOptions: Partial<VitePWAOptions> = {
srcDir: 'src',
filename: 'sw.ts',
// srcDir: 'src',
// filename: 'sw.ts',
includeAssets: ['img/logo.svg'],
manifest: {
name: 'BingAI',
Expand Down Expand Up @@ -45,14 +45,48 @@ const initPwaOptions = (env: Record<string, string>) => {
// enabled: true,
// type: 'module',
// },
strategies: 'injectManifest',
workbox: {
cleanupOutdatedCaches: true,
clientsClaim: true,
skipWaiting: true,
},
// strategies: 'injectManifest',
// workbox: {
// cleanupOutdatedCaches: true,
// clientsClaim: true,
// skipWaiting: true,
// },
// 取消注册服务工作进程
// selfDestroying: true,
registerType: 'autoUpdate',
workbox: {
globPatterns: ['**/*.{js,css,html,ico,png,svg}'],
runtimeCaching: [
{
urlPattern: /(.*?)\.(js|css|ts)/, // js /css /ts静态资源缓存
handler: 'StaleWhileRevalidate',
options: {
cacheName: 'BingAI-assets',
expiration: {
maxEntries: 100,
maxAgeSeconds: 60 * 60 * 24 * 7,
},
cacheableResponse: {
statuses: [0, 200],
},
},
},
{
urlPattern: /(.*?)\.(png|jpe?g|svg|gif|bmp|psd|tiff|tga|eps|ico)/, // 图片缓存
handler: 'CacheFirst',
options: {
cacheName: 'BingAI-images',
expiration: {
maxEntries: 100,
maxAgeSeconds: 60 * 60 * 24 * 7,
},
cacheableResponse: {
statuses: [0, 200],
},
},
},
],
},
};
return pwaOptions;
};
Expand Down
651 changes: 651 additions & 0 deletions web/assets/index-36027b8d.js

Large diffs are not rendered by default.

651 changes: 0 additions & 651 deletions web/assets/index-4cac3f94.js

This file was deleted.

46 changes: 23 additions & 23 deletions web/assets/index-58dc3d18.js → web/assets/index-5d6cbc08.js

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions web/assets/workbox-window.prod.es5-08b2315b.js

This file was deleted.

4 changes: 2 additions & 2 deletions web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@
<script src="/web/js/bing/chat/global.js"></script>
<script src="/web/js/bing/chat/amd.js"></script>
<script src="/web/js/bing/chat/config.js"></script>
<script type="module" crossorigin src="/web/assets/index-4cac3f94.js"></script>
<script type="module" crossorigin src="/web/assets/index-36027b8d.js"></script>
<link rel="stylesheet" href="/web/assets/index-4b631cfd.css">
<link rel="manifest" href="/web/manifest.webmanifest"></head>
<link rel="manifest" href="/web/manifest.webmanifest"><script id="vite-plugin-pwa:register-sw" src="/web/registerSW.js"></script></head>

<body>
<div id="b_sydHeadBg"></div>
Expand Down
1 change: 1 addition & 0 deletions web/registerSW.js

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

3 changes: 1 addition & 2 deletions web/sw.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions web/workbox-9d4bbdea.js

Large diffs are not rendered by default.

1 comment on commit 538d8a4

@vercel
Copy link

@vercel vercel bot commented on 538d8a4 May 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.