diff --git a/frontend/App.vue b/frontend/App.vue index f3e6ef5..44cccb2 100644 --- a/frontend/App.vue +++ b/frontend/App.vue @@ -160,7 +160,10 @@ // - _downloads/upgrade_*.{wgt,apk,ipa}:用户进入"存储空间 → 其他业务缓存"分类手动清 // 保留:upgrade-popup#cleanupAfterInstall(安装成功后自动清) - this.setPermissions(); + // 2026-08-03 注释:UniPush/系统首次启动自带通知权限弹窗, + // 这里再弹自定义的会跟系统弹窗冲突(Android 13+ 首次启动 areNotificationsEnabled=false + // 会抢先弹自定义框,盖过系统框)。如需恢复"用户拒绝后有去设置入口",取消注释即可。 + // this.setPermissions(); // #ifdef APP-PLUS // 冷启动 deep link:iOS UniversalLinks / Android App Links 通过 launchOptions 传入 @@ -452,104 +455,110 @@ // #endif }, - setPermissions() { - // #ifdef APP-PLUS - if (plus.os.name == "Android") { - // 判断是Android - var main = plus.android.runtimeMainActivity(); - var pkName = main.getPackageName(); - var uid = main.getApplicationInfo().plusGetAttribute("uid"); - var NotificationManagerCompat = plus.android.importClass( - "android.support.v4.app.NotificationManagerCompat", - ); - //android.support.v4升级为androidx - if (NotificationManagerCompat == null) { - NotificationManagerCompat = plus.android.importClass( - "androidx.core.app.NotificationManagerCompat", - ); - } - var areNotificationsEnabled = - NotificationManagerCompat.from(main).areNotificationsEnabled(); - // 未开通‘允许通知’权限,则弹窗提醒开通,并点击确认后,跳转到系统设置页面进行设置 - if (!areNotificationsEnabled) { - uni.showModal({ - title: "通知权限开启提醒", - content: "您还没有开启通知权限,无法接受到消息通知,请前往设置!", - showCancel: false, - confirmText: "去设置", - success: function(res) { - if (res.confirm) { - var Intent = plus.android.importClass("android.content.Intent"); - var Build = plus.android.importClass("android.os.Build"); - //android 8.0引导 - if (Build.VERSION.SDK_INT >= 26) { - var intent = new Intent( - "android.settings.APP_NOTIFICATION_SETTINGS", - ); - intent.putExtra("android.provider.extra.APP_PACKAGE", pkName); - } else if (Build.VERSION.SDK_INT >= 21) { - //android 5.0-7.0 - var intent = new Intent( - "android.settings.APP_NOTIFICATION_SETTINGS", - ); - intent.putExtra("app_package", pkName); - intent.putExtra("app_uid", uid); - } else { - //(<21)其他--跳转到该应用管理的详情页 - intent.setAction( - Settings.ACTION_APPLICATION_DETAILS_SETTINGS, - ); - var uri = Uri.fromParts( - "package", - mainActivity.getPackageName(), - null, - ); - intent.setData(uri); - } - // 跳转到该应用的系统通知设置页 - main.startActivity(intent); - } - }, - }); - } - } else if (plus.os.name == "iOS") { - // 判断是ISO - var isOn = undefined; - var types = 0; - var app = plus.ios.invoke("UIApplication", "sharedApplication"); - var settings = plus.ios.invoke(app, "currentUserNotificationSettings"); - if (settings) { - types = settings.plusGetAttribute("types"); - plus.ios.deleteObject(settings); - } else { - types = plus.ios.invoke(app, "enabledRemoteNotificationTypes"); - } - plus.ios.deleteObject(app); - isOn = 0 != types; - if (isOn == false) { - uni.showModal({ - title: "通知权限开启提醒", - content: "您还没有开启通知权限,无法接受到消息通知,请前往设置!", - showCancel: false, - confirmText: "去设置", - success: function(res) { - if (res.confirm) { - var app = plus.ios.invoke("UIApplication", "sharedApplication"); - var setting = plus.ios.invoke( - "NSURL", - "URLWithString:", - "app-settings:", - ); - plus.ios.invoke(app, "openURL:", setting); - plus.ios.deleteObject(setting); - plus.ios.deleteObject(app); - } - }, - }); - } - } - // #endif - }, + // ───────────────────────────────────────────────────────────── + // setPermissions() 已于 2026-08-03 整体注释: + // 首次启动 UniPush/系统自带通知权限弹窗,自定义弹窗会和系统弹窗冲突, + // Android 13+ 首次启动 areNotificationsEnabled=false 会抢先弹自定义框, + // 把系统框盖掉,用户会看到两个提示叠一起。需要时把整个方法取消注释恢复。 + // ───────────────────────────────────────────────────────────── + // setPermissions() { + // // #ifdef APP-PLUS + // if (plus.os.name == "Android") { + // // 判断是Android + // var main = plus.android.runtimeMainActivity(); + // var pkName = main.getPackageName(); + // var uid = main.getApplicationInfo().plusGetAttribute("uid"); + // var NotificationManagerCompat = plus.android.importClass( + // "android.support.v4.app.NotificationManagerCompat", + // ); + // //android.support.v4升级为androidx + // if (NotificationManagerCompat == null) { + // NotificationManagerCompat = plus.android.importClass( + // "androidx.core.app.NotificationManagerCompat", + // ); + // } + // var areNotificationsEnabled = + // NotificationManagerCompat.from(main).areNotificationsEnabled(); + // // 未开通‘允许通知’权限,则弹窗提醒开通,并点击确认后,跳转到系统设置页面进行设置 + // if (!areNotificationsEnabled) { + // uni.showModal({ + // title: "通知权限开启提醒", + // content: "您还没有开启通知权限,无法接受到消息通知,请前往设置!", + // showCancel: false, + // confirmText: "去设置", + // success: function(res) { + // if (res.confirm) { + // var Intent = plus.android.importClass("android.content.Intent"); + // var Build = plus.android.importClass("android.os.Build"); + // //android 8.0引导 + // if (Build.VERSION.SDK_INT >= 26) { + // var intent = new Intent( + // "android.settings.APP_NOTIFICATION_SETTINGS", + // ); + // intent.putExtra("android.provider.extra.APP_PACKAGE", pkName); + // } else if (Build.VERSION.SDK_INT >= 21) { + // //android 5.0-7.0 + // var intent = new Intent( + // "android.settings.APP_NOTIFICATION_SETTINGS", + // ); + // intent.putExtra("app_package", pkName); + // intent.putExtra("app_uid", uid); + // } else { + // //(<21)其他--跳转到该应用管理的详情页 + // intent.setAction( + // Settings.ACTION_APPLICATION_DETAILS_SETTINGS, + // ); + // var uri = Uri.fromParts( + // "package", + // mainActivity.getPackageName(), + // null, + // ); + // intent.setData(uri); + // } + // // 跳转到该应用的系统通知设置页 + // main.startActivity(intent); + // } + // }, + // }); + // } + // } else if (plus.os.name == "iOS") { + // // 判断是ISO + // var isOn = undefined; + // var types = 0; + // var app = plus.ios.invoke("UIApplication", "sharedApplication"); + // var settings = plus.ios.invoke(app, "currentUserNotificationSettings"); + // if (settings) { + // types = settings.plusGetAttribute("types"); + // plus.ios.deleteObject(settings); + // } else { + // types = plus.ios.invoke(app, "enabledRemoteNotificationTypes"); + // } + // plus.ios.deleteObject(app); + // isOn = 0 != types; + // if (isOn == false) { + // uni.showModal({ + // title: "通知权限开启提醒", + // content: "您还没有开启通知权限,无法接受到消息通知,请前往设置!", + // showCancel: false, + // confirmText: "去设置", + // success: function(res) { + // if (res.confirm) { + // var app = plus.ios.invoke("UIApplication", "sharedApplication"); + // var setting = plus.ios.invoke( + // "NSURL", + // "URLWithString:", + // "app-settings:", + // ); + // plus.ios.invoke(app, "openURL:", setting); + // plus.ios.deleteObject(setting); + // plus.ios.deleteObject(app); + // } + // }, + // }); + // } + // } + // // #endif + // }, }, }; diff --git a/frontend/pages/square/square.vue b/frontend/pages/square/square.vue index ca1b77c..3bd1c2d 100644 --- a/frontend/pages/square/square.vue +++ b/frontend/pages/square/square.vue @@ -125,6 +125,7 @@ import { useBanner } from "./composables/useBanner.js"; import { useBackgroundRefresh } from "@/composables/useBackgroundRefresh.js"; import { doubleTapLike } from "@/utils/likeHelper.js"; import { getPreloadApi } from "@/utils/preloadApi/index"; +import { invalidate } from "@/utils/preloadApi/core"; import checkUpdate from "@/uni_modules/uni-upgrade-center-app/utils/check-update"; @@ -198,9 +199,21 @@ const likingMap = ref({}); const outerScrollTop = ref(0); // 切 tab 时重置外层 scroll-view 的 scrollTop,避免残留滚动位置 -watch(activeContentTab, () => { +// ★ 2026-08-03:同时失效目标 tab 的预拉缓存。 +// 排行榜/灵感流是动态数据(点赞数等实时变化),而三个 tab 组件都用 v-if + usePreload, +// 组件重新挂载时 get() 会命中 5 分钟 TTL 的内存缓存,导致"切 tab 看到的一直是旧接口值"。 +// watch 默认 flush:'pre' 先于子组件挂载执行,这里 invalidate 掉目标 key, +// 组件挂载时 get() 缓存未命中 → 走真实接口(且只发一次请求,不会与组件自身 fetch 双发)。 +const TAB_PRELOAD_KEYS = { + xinghe: "ranking.xinghe", + xingbang: "ranking.xingbang", + guangchang: "inspiration.flow", +}; +watch(activeContentTab, (newTab) => { // 星河/星榜 时 scroll-y=false,但 scrollTop 残留可能导致显示异常 outerScrollTop.value = 0; + const preloadKey = TAB_PRELOAD_KEYS[newTab]; + if (preloadKey) invalidate(preloadKey); }); // 统一 scroll 处理:驱动 CreationGrid 切 fixed