fix mobile countdown show
This commit is contained in:
parent
9f30853ded
commit
129b3916ab
@ -75,8 +75,7 @@
|
|||||||
<h1>
|
<h1>
|
||||||
RSS Reader
|
RSS Reader
|
||||||
<< if gt .AutoUpdatePush 0 >>
|
<< if gt .AutoUpdatePush 0 >>
|
||||||
<br/>
|
<span v-show="isPc"><br/>{{ countdown }} s</span>
|
||||||
<span>{{ countdown }} s</span>
|
|
||||||
<< end >>
|
<< end >>
|
||||||
</h1>
|
</h1>
|
||||||
</el-header>
|
</el-header>
|
||||||
@ -157,18 +156,19 @@
|
|||||||
showSEOFlag: true,
|
showSEOFlag: true,
|
||||||
fullscreenLoading: true,
|
fullscreenLoading: true,
|
||||||
countdown: 60,
|
countdown: 60,
|
||||||
|
isPc: true,
|
||||||
autoUpdatePush: << .AutoUpdatePush >>,
|
autoUpdatePush: << .AutoUpdatePush >>,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
async created() {
|
async created() {
|
||||||
this.fullscreenLoading = false;
|
this.fullscreenLoading = false;
|
||||||
|
// 使用媒体查询判断设备类型
|
||||||
|
this.isPc = !window.matchMedia('(max-width: 767px)').matches;
|
||||||
},
|
},
|
||||||
async mounted() {
|
async mounted() {
|
||||||
const protocol = window.location.protocol === 'https:' ? 'wss://' : 'ws://';
|
const protocol = window.location.protocol === 'https:' ? 'wss://' : 'ws://';
|
||||||
const connect = () => {
|
const connect = () => {
|
||||||
const socket = new WebSocket(protocol + window.location.host + "/ws");
|
const socket = new WebSocket(protocol + window.location.host + "/ws");
|
||||||
// 使用媒体查询判断设备类型
|
|
||||||
const isMobile = window.matchMedia('(max-width: 767px)').matches;
|
|
||||||
socket.onmessage = event => {
|
socket.onmessage = event => {
|
||||||
const feed = JSON.parse(event.data);
|
const feed = JSON.parse(event.data);
|
||||||
const existingFeed = this.feeds.find(f => f.link === feed.link);
|
const existingFeed = this.feeds.find(f => f.link === feed.link);
|
||||||
@ -189,7 +189,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
socket.onclose = event => {
|
socket.onclose = event => {
|
||||||
if (!isMobile && this.autoUpdatePush > 0) {
|
if (this.isPc && this.autoUpdatePush > 0) {
|
||||||
console.log("WebSocket closed. Reconnecting...");
|
console.log("WebSocket closed. Reconnecting...");
|
||||||
setInterval(reloadHtml, 3000);
|
setInterval(reloadHtml, 3000);
|
||||||
}
|
}
|
||||||
@ -202,7 +202,7 @@
|
|||||||
reloadHtml()
|
reloadHtml()
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if (!isMobile && this.autoUpdatePush > 0) {
|
if (this.isPc && this.autoUpdatePush > 0) {
|
||||||
setInterval(sendHeartbeat, 60000);
|
setInterval(sendHeartbeat, 60000);
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
if (this.countdown > 0) {
|
if (this.countdown > 0) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user