//子页返回触发
document.addEventListener('plusready', function () {
window.plus.key.addEventListener('backbutton', function () {
var webview = window.plus.webview.currentWebview();
webview.canBack(function (e) {
if (e.canBack) {
webview.back();
}
})
});
});
//在主页按返回按钮时触发
document.addEventListener('plusready', function () {
let time = null;
window.plus.key.addEventListener('backbutton', function () {
var webview = window.plus.webview.currentWebview();
webview.canBack(function (e) {
if (!e.canBack) {
if (!time) {
time = new Date().getTime();
window.plus.nativeUI.toast('再按一次退出应用');
setTimeout(function () {
time = null;
}, 1000);
} else {
if (new Date().getTime() - time < 1500) {
window.plus.runtime.quit();
}
}
}
})
});
});
App 更新问题:
/**
* 查询app最新版本
* @type {import("./types").Result<unknown, any[]>}
*/
const getNewAppVersionReq = useRequest(Api.getNewAppVersion, {
manual: true,
debounceWait: 500,
onSuccess(v) {
if (v.length>0){
const appVersion = v[0].appVersion
const url = v[0].appUrl
if (APP_VERSION !== appVersion){
Dialog.alert({
content: '检测到有最新版本(V'+ appVersion+'),请更新!',
confirmText:"立即更新",
onConfirm: () => {
window.location.href=url
},
})
}
}
}
})