|
@@ -49,14 +49,17 @@ export default {
|
|
|
chromeVersion < 76 ||
|
|
|
this.done ||
|
|
|
!navigator.serviceWorker ||
|
|
|
- !navigator.serviceWorker.controller
|
|
|
+ !navigator.serviceWorker.controller ||
|
|
|
+ // 在某些情况下,caches 没有定义,这时候不做cache. 暂时注释
|
|
|
+ // !window.caches ||
|
|
|
+ this.downloadPercent === 100
|
|
|
);
|
|
|
},
|
|
|
},
|
|
|
async created() {
|
|
|
this.cacheInterval = setInterval(() => {
|
|
|
- if (!this.done) {
|
|
|
- caches
|
|
|
+ if (!this.done && window.caches) {
|
|
|
+ window.caches
|
|
|
.open("audios")
|
|
|
.then(caches => caches.match(this.src))
|
|
|
.then(e => e && (this.done = true));
|
|
@@ -71,6 +74,22 @@ export default {
|
|
|
);
|
|
|
};
|
|
|
navigator.serviceWorker.addEventListener("message", this.handleMSG);
|
|
|
+
|
|
|
+ let chromeVersion = window.navigator.userAgent
|
|
|
+ .split(" ")
|
|
|
+ .find(v => v.startsWith("Chrome/"));
|
|
|
+ if (chromeVersion) {
|
|
|
+ chromeVersion = +chromeVersion.replace("Chrome/", "").split(".")[0];
|
|
|
+ }
|
|
|
+ if (chromeVersion >= 76) {
|
|
|
+ if (!window.caches) {
|
|
|
+ window._hmt.push([
|
|
|
+ "_trackEvent",
|
|
|
+ "音频播放",
|
|
|
+ "chromeVersion >= 76 && window.caches 为空",
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+ }
|
|
|
},
|
|
|
beforeDestroy() {
|
|
|
clearInterval(this.cacheInterval);
|