2017-03-11 23:55:01 +00:00
|
|
|
if (process.BROWSER_BUILD && process.env.NODE_ENV === 'production') {
|
|
|
|
require('offline-plugin/runtime').install()
|
2017-03-12 00:13:34 +00:00
|
|
|
window.onNuxtReady((app) => {
|
|
|
|
if ('serviceWorker' in navigator) {
|
|
|
|
if (navigator.serviceWorker.controller) {} else {
|
|
|
|
navigator.serviceWorker.register('/_nuxt/tcmpsw.js', {scope: '/'}).then(function(res) {
|
|
|
|
console.log('sw loaded...')
|
|
|
|
}).catch(function(err) {
|
|
|
|
console.log(err);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
} else if (window.applicationCache) {
|
|
|
|
// register appcache code
|
|
|
|
var iframe = document.createElement('iframe');
|
|
|
|
iframe.style.display = "none";
|
|
|
|
iframe.src = '/_nuxt/appcache/manifest.html';
|
|
|
|
document.body.appendChild(iframe);
|
|
|
|
}
|
|
|
|
})
|
2017-03-11 23:55:01 +00:00
|
|
|
}
|