feat:更新版本记录

This commit is contained in:
2026-06-23 13:29:38 +08:00
parent 90fc557ac8
commit ab8e8371cf
4 changed files with 52 additions and 8 deletions
+17 -4
View File
@@ -62,7 +62,7 @@
const shouldUseUpdateOverlay = (title) => {
const text = String(title || '');
if (!text) return false;
if (/下载|安装|更新/.test(text) && (/%/.test(text) || /下载中|安装中/.test(text))) {
if (/下载|安装|更新/.test(text) && (/%/.test(text) || /下载中|安装中|正在下载|正在安装|正在更新/.test(text))) {
return true;
}
return false;
@@ -86,18 +86,31 @@
return true;
};
if (!uni.__updateToastPatched && typeof uni.showToast === 'function') {
const originalShowToast = uni.showToast;
uni.showToast = (options = {}) => {
const title =
typeof options === 'string' ? options : (options?.title ?? '');
if ((uni.__hotUpdateInFlight || uni.__hotUpdatePendingProgress || uni.__updateProgressShown) && shouldUseUpdateOverlay(title)) {
return;
}
return originalShowToast.call(uni, options);
};
uni.__updateToastPatched = true;
}
uni.showLoading = (options = {}) => {
const title = options?.title ?? '';
if (shouldUseUpdateOverlay(title) && canEmit()) {
if (shouldUseUpdateOverlay(title) && (uni.__hotUpdateInFlight || uni.__hotUpdatePendingProgress || canEmit())) {
const parsed = parseTitleToProgress(title);
if (!uni.__updateProgressShown) {
if (!uni.__updateProgressShown && canEmit()) {
uni.__updateProgressShown = true;
emitProgress({
type: 'show',
text: parsed.text || '下载中...'
});
}
if (parsed.percent !== null) {
if (parsed.percent !== null && canEmit()) {
emitProgress({
type: 'set',
percent: parsed.percent,