feat: 修改应用公告显示频率

main
jcgitadmin 2026-07-12 13:56:08 +08:00
parent 68b4b50d42
commit 07f5070145
2 changed files with 32 additions and 20 deletions

View File

@ -377,10 +377,12 @@ const api = {
},
getAppUpgrade(){
return service.get('/app/upgrade').then(res=>{
if(!res.upgrade || !res.content || res.id == LocalStorage.getItem('upgradeId')){
const t = new Date().getTime()
if(!res.upgrade || !res.content || (res.id == LocalStorage.getItem('upgradeId') && t - (this._upgradeTime || 0) < 60 * 60 * 1000)){
return Promise.reject(false)
}
LocalStorage.set('upgradeId',res.id)
this._upgradeTime = t
return res
})
},
@ -443,13 +445,6 @@ export default boot(({ app, router, store, urlPath, redirect }) => {
return Promise.reject(err);
});
api.getAppUpgrade().then(res=>{
Dialog.create({
title: res.title||'系统提示',
message: res.content,
})
})
let refreshTimer = null
function clearRefreshTimer() {
if(refreshTimer) {

View File

@ -1,6 +1,6 @@
// import something here
import { boot } from "quasar/wrappers";
import { Platform, Dialog,openURL,Loading,Notify } from "quasar";
import { Platform, Dialog, openURL,Loading,Notify } from "quasar";
import { api } from "./axios";
import { requestNotifyPermission } from "src/utils/mobile";
@ -112,25 +112,42 @@ function checkUpdate() {
// console.info(e.message);
// });
}
// 检查系统公告
function checkUpgradgeNotice() {
api.getAppUpgrade().then(res=>{
Dialog.create({
title: res.title||'系统提示',
message: res.content,
})
})
}
function onResume(){
checkUpgradgeNotice();
if (
checkUpdate.lastestCheckTime &&
new Date().getTime() - checkUpdate.lastestCheckTime > 60 * 60000
) {
checkUpdate();
}
}
// document.addEventListener("pause", onPause, false);
document.addEventListener(
"resume",
function () {
if (
checkUpdate.lastestCheckTime &&
new Date().getTime() - checkUpdate.lastestCheckTime > 60 * 60000
) {
checkUpdate();
document.addEventListener("resume", onResume, false);
document.addEventListener('visibilitychange', function() {
if (document.visibilityState === 'visible') {
onResume();
}
},
false
);
});
window.addEventListener("cordovacallbackerror", function (event) {
// event.error contains the original error object
console.error(event);
});
export default boot(({ app, router, store, urlPath, redirect }) => {
checkUpgradgeNotice();
app.provide('checkUpdate',function(){
checkUpdate().catch(e=>{
Notify.create(e.message)