添加版本检查代码, 流程管理页面空数据处理
This commit is contained in:
@@ -389,3 +389,33 @@ export const getDay = (option?: { value: number; unit: 'day' | 'month' | 'year'
|
||||
const { value = 0, unit = 'day' } = option || {};
|
||||
return dayjs().subtract(value, unit).format('YYYY-MM-DD');
|
||||
};
|
||||
|
||||
/**
|
||||
* 监听向微信后台请求检查更新结果事件
|
||||
*/
|
||||
export const updateVersion = () => {
|
||||
const updateManager = wx.getUpdateManager();
|
||||
// 监听向微信后台请求检查更新结果事件
|
||||
updateManager.onCheckForUpdate((res) => {
|
||||
if (res.hasUpdate) {
|
||||
// 监听小程序有版本更新事件
|
||||
updateManager.onUpdateReady(() => {
|
||||
wx.showModal({
|
||||
title: '更新提示',
|
||||
content: '新版本已经准备好,是否重启当前应用?',
|
||||
success(res) {
|
||||
if (res.confirm) {
|
||||
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
|
||||
updateManager.applyUpdate();
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
// 监听小程序更新失败事件
|
||||
updateManager.onUpdateFailed(function () {
|
||||
wx.showModal({ title: '发现新版本', content: '请删除当前小程序,重新搜索打开...' });
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user