增加pwa判断环境
This commit is contained in:
parent
3cd673b9af
commit
41ba52032d
|
@ -144,6 +144,14 @@ const webpackConfig = merge(baseWebpackConfig, {
|
||||||
from: path.resolve(__dirname, '../static'),
|
from: path.resolve(__dirname, '../static'),
|
||||||
to: config.build.assetsSubDirectory,
|
to: config.build.assetsSubDirectory,
|
||||||
ignore: ['.*']
|
ignore: ['.*']
|
||||||
|
},
|
||||||
|
{
|
||||||
|
from: path.resolve(__dirname, '../sw.js'),
|
||||||
|
to: config.build.assetsSubDirectory
|
||||||
|
},
|
||||||
|
{
|
||||||
|
from: path.resolve(__dirname, '../manifest.json'),
|
||||||
|
to: config.build.assetsSubDirectory
|
||||||
}
|
}
|
||||||
])
|
])
|
||||||
]
|
]
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||||
<link rel="manifest" href="./manifest.json">
|
<link rel="manifest" href="<%= htmlWebpackPlugin.options.path %>/manifest.json">
|
||||||
<meta name="renderer" content="webkit">
|
<meta name="renderer" content="webkit">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
|
||||||
<title>vue-element-admin</title>
|
<title>vue-element-admin</title>
|
||||||
|
@ -15,7 +15,7 @@
|
||||||
</body>
|
</body>
|
||||||
<script>
|
<script>
|
||||||
if ('serviceWorker' in navigator) {
|
if ('serviceWorker' in navigator) {
|
||||||
navigator.serviceWorker.register('sw.js').then(function(registration) {
|
navigator.serviceWorker.register('<%= htmlWebpackPlugin.options.path %>/sw.js').then(function(registration) {
|
||||||
// Registration Success
|
// Registration Success
|
||||||
console.log('[serviceWorker]: registration successful with scope: ', registration.scope)
|
console.log('[serviceWorker]: registration successful with scope: ', registration.scope)
|
||||||
}).catch(function(err) {
|
}).catch(function(err) {
|
||||||
|
|
|
@ -3,12 +3,12 @@
|
||||||
"short_name": "VEAPWA",
|
"short_name": "VEAPWA",
|
||||||
"icons": [
|
"icons": [
|
||||||
{
|
{
|
||||||
"src": "./build/logo.png",
|
"src": "../favicon.ico",
|
||||||
"sizes": "200x200",
|
"sizes": "128x128",
|
||||||
"type": "image/png"
|
"type": "image/png"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"start_url": "http://localhost:9527",
|
"start_url": "/PWA/",
|
||||||
"display": "standalone",
|
"display": "standalone",
|
||||||
"background_color": "#2d3a4b",
|
"background_color": "#2d3a4b",
|
||||||
"theme_color": "#3d5165"
|
"theme_color": "#3d5165"
|
||||||
|
|
14
sw.js
14
sw.js
|
@ -4,12 +4,18 @@
|
||||||
const version = '2.0.0'
|
const version = '2.0.0'
|
||||||
const CACHE = version + '::PWAsite'
|
const CACHE = version + '::PWAsite'
|
||||||
const offlineURL = '/offline/'
|
const offlineURL = '/offline/'
|
||||||
const installFilesEssential = [
|
const installFilesEssential = process.env.NODE_ENV === 'production' ? [
|
||||||
|
'/',
|
||||||
|
'../static/manifest.json',
|
||||||
|
'../static/css/*',
|
||||||
|
'../static/img/*',
|
||||||
|
'../static/js/*',
|
||||||
|
'../static/fonts/*',
|
||||||
|
'../static/tinymce4.7.5/*',
|
||||||
|
'../static/js/*'
|
||||||
|
].concat(offlineURL) : [
|
||||||
'/',
|
'/',
|
||||||
'./static/tinymce4.7.5/*',
|
'./static/tinymce4.7.5/*',
|
||||||
// './dist/css/*',
|
|
||||||
// './dist/fonts/*',
|
|
||||||
// './dist/img/*',
|
|
||||||
'./manifest.json',
|
'./manifest.json',
|
||||||
'./build/logo.png'
|
'./build/logo.png'
|
||||||
].concat(offlineURL)
|
].concat(offlineURL)
|
||||||
|
|
Loading…
Reference in New Issue