diff --git a/build/plugins/index.ts b/build/plugins/index.ts index 1b118010b..457a39041 100644 --- a/build/plugins/index.ts +++ b/build/plugins/index.ts @@ -2,7 +2,6 @@ import type { PluginOption } from 'vite'; import vue from '@vitejs/plugin-vue'; import vueJsx from '@vitejs/plugin-vue-jsx'; import unocss from '@unocss/vite'; -import { VitePWA } from 'vite-plugin-pwa'; import progress from 'vite-plugin-progress'; import routerPage from '@soybeanjs/router-page'; import html from './html'; @@ -10,6 +9,7 @@ import unplugin from './unplugin'; import mock from './mock'; import visualizer from './visualizer'; import compress from './compress'; +import pwa from './pwa'; /** * vite插件 @@ -19,13 +19,13 @@ export function setupVitePlugins(viteEnv: ImportMetaEnv): (PluginOption | Plugin const plugins = [ vue(), vueJsx(), - VitePWA(), html(viteEnv), ...unplugin(viteEnv), unocss(), mock, progress(), - routerPage() + routerPage(), + pwa() ]; if (viteEnv.VITE_VISUALIZER === 'Y') { diff --git a/build/plugins/pwa.ts b/build/plugins/pwa.ts new file mode 100644 index 000000000..25c9f9b7e --- /dev/null +++ b/build/plugins/pwa.ts @@ -0,0 +1,31 @@ +import { VitePWA } from 'vite-plugin-pwa'; + +export default function setupVitePwa() { + return VitePWA({ + registerType: 'autoUpdate', + includeAssets: ['favicon.ico'], + manifest: { + name: 'SoybeanAdmin', + short_name: 'SoybeanAdmin', + theme_color: '#fff', + icons: [ + { + src: '/logo.png', + sizes: '192x192', + type: 'image/png' + }, + { + src: '/logo.png', + sizes: '512x512', + type: 'image/png' + }, + { + src: '/logo.png', + sizes: '512x512', + type: 'image/png', + purpose: 'any maskable' + } + ] + } + }); +} diff --git a/public/logo.png b/public/logo.png new file mode 100644 index 000000000..b0dbadd8f Binary files /dev/null and b/public/logo.png differ