diff --git a/frontend/package.json b/frontend/package.json index 0c8a246..2a7b5a1 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -7,10 +7,12 @@ "build": "vue-cli-service build" }, "dependencies": { - "vue": "^3.5.18", - "axios": "^1.11.0" + "axios": "^1.11.0", + "register-service-worker": "^1.7.2", + "vue": "^3.5.18" }, "devDependencies": { + "@vue/cli-plugin-pwa": "~5.0.0", "@vue/cli-service": "~5.0.8" } } diff --git a/frontend/public/icons/icon.svg b/frontend/public/icons/icon.svg new file mode 100644 index 0000000..7ed7559 --- /dev/null +++ b/frontend/public/icons/icon.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/frontend/public/index.html b/frontend/public/index.html index b523ada..4af8dd9 100644 --- a/frontend/public/index.html +++ b/frontend/public/index.html @@ -5,6 +5,9 @@ + + + 临时邮件 diff --git a/frontend/public/manifest.json b/frontend/public/manifest.json new file mode 100644 index 0000000..f52103f --- /dev/null +++ b/frontend/public/manifest.json @@ -0,0 +1,15 @@ +{ + "name": "Email Unlimit", + "short_name": "EmailUnlimit", + "icons": [ + { + "src": "icons/icon.svg", + "sizes": "any", + "type": "image/png" + } + ], + "start_url": "/", + "display": "standalone", + "background_color": "#ffffff", + "theme_color": "#000000" +} \ No newline at end of file diff --git a/frontend/public/robots.txt b/frontend/public/robots.txt new file mode 100644 index 0000000..eb05362 --- /dev/null +++ b/frontend/public/robots.txt @@ -0,0 +1,2 @@ +User-agent: * +Disallow: diff --git a/frontend/src/main.js b/frontend/src/main.js index e4be44b..b57c9ab 100644 --- a/frontend/src/main.js +++ b/frontend/src/main.js @@ -1,5 +1,6 @@ import { createApp } from 'vue' import App from './App.vue' import './assets/main.css' // 引入新的全局样式文件 +import './registerServiceWorker' createApp(App).mount('#app') \ No newline at end of file diff --git a/frontend/src/registerServiceWorker.js b/frontend/src/registerServiceWorker.js new file mode 100644 index 0000000..76cede0 --- /dev/null +++ b/frontend/src/registerServiceWorker.js @@ -0,0 +1,32 @@ +/* eslint-disable no-console */ + +import { register } from 'register-service-worker' + +if (process.env.NODE_ENV === 'production') { + register(`${process.env.BASE_URL}service-worker.js`, { + ready () { + console.log( + 'App is being served from cache by a service worker.\n' + + 'For more details, visit https://goo.gl/AFskqB' + ) + }, + registered () { + console.log('Service worker has been registered.') + }, + cached () { + console.log('Content has been cached for offline use.') + }, + updatefound () { + console.log('New content is downloading.') + }, + updated () { + console.log('New content is available; please refresh.') + }, + offline () { + console.log('No internet connection found. App is running in offline mode.') + }, + error (error) { + console.error('Error during service worker registration:', error) + } + }) +} diff --git a/frontend/vue.config.js b/frontend/vue.config.js index 7dc6ac0..0b7e6a8 100644 --- a/frontend/vue.config.js +++ b/frontend/vue.config.js @@ -1,6 +1,21 @@ const { defineConfig } = require('@vue/cli-service') module.exports = defineConfig({ - transpileDependencies: true + transpileDependencies: true, // devServer 代理配置已移除,所有代理均由外部 Nginx 处理。 + pwa: { + name: 'EmailUnlimit', + themeColor: '#000000', + msTileColor: '#000000', + appleMobileWebAppCapable: 'yes', + appleMobileWebAppStatusBarStyle: 'black', + + // 配置 workbox-webpack-plugin + workboxPluginMode: 'GenerateSW', + workboxOptions: { + // swSrc is required in InjectManifest mode. + // swSrc: 'dev/sw.js', + // ...other Workbox options... + } + } }) \ No newline at end of file