@hlw-uni/mp-vue 2.3.0 → 2.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -11
- package/dist/index.mjs +1 -11
- package/package.json +1 -1
- package/src/utils/ad/index.ts +4 -10
package/dist/index.js
CHANGED
|
@@ -411,17 +411,7 @@ var __publicField = (obj, key, value) => {
|
|
|
411
411
|
return current;
|
|
412
412
|
}
|
|
413
413
|
function destroyRewardAd(adId) {
|
|
414
|
-
|
|
415
|
-
const ad = adInstances.get(adId);
|
|
416
|
-
if (ad) {
|
|
417
|
-
try {
|
|
418
|
-
(_a = ad.destroy) == null ? void 0 : _a.call(ad);
|
|
419
|
-
console.log(`[Ad] Rewarded video destroyed: ${adId}`);
|
|
420
|
-
} catch (e) {
|
|
421
|
-
console.error("[Ad] Rewarded video destroy error:", e);
|
|
422
|
-
}
|
|
423
|
-
adInstances.delete(adId);
|
|
424
|
-
}
|
|
414
|
+
adInstances.delete(adId);
|
|
425
415
|
if (activeRewardId === adId) {
|
|
426
416
|
activeRewardId = "";
|
|
427
417
|
rewardCallback = void 0;
|
package/dist/index.mjs
CHANGED
|
@@ -410,17 +410,7 @@ function showRewardAd(onShowSuccess) {
|
|
|
410
410
|
return current;
|
|
411
411
|
}
|
|
412
412
|
function destroyRewardAd(adId) {
|
|
413
|
-
|
|
414
|
-
const ad = adInstances.get(adId);
|
|
415
|
-
if (ad) {
|
|
416
|
-
try {
|
|
417
|
-
(_a = ad.destroy) == null ? void 0 : _a.call(ad);
|
|
418
|
-
console.log(`[Ad] Rewarded video destroyed: ${adId}`);
|
|
419
|
-
} catch (e) {
|
|
420
|
-
console.error("[Ad] Rewarded video destroy error:", e);
|
|
421
|
-
}
|
|
422
|
-
adInstances.delete(adId);
|
|
423
|
-
}
|
|
413
|
+
adInstances.delete(adId);
|
|
424
414
|
if (activeRewardId === adId) {
|
|
425
415
|
activeRewardId = "";
|
|
426
416
|
rewardCallback = void 0;
|
package/package.json
CHANGED
package/src/utils/ad/index.ts
CHANGED
|
@@ -202,16 +202,10 @@ export function showRewardAd(onShowSuccess?: () => void): Promise<AdRes> {
|
|
|
202
202
|
* @param adId 广告单元 ID
|
|
203
203
|
*/
|
|
204
204
|
export function destroyRewardAd(adId: string) {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
console.log(`[Ad] Rewarded video destroyed: ${adId}`);
|
|
210
|
-
} catch (e) {
|
|
211
|
-
console.error("[Ad] Rewarded video destroy error:", e);
|
|
212
|
-
}
|
|
213
|
-
adInstances.delete(adId);
|
|
214
|
-
}
|
|
205
|
+
// 仅从本地缓存 Map 中移除该广告单元的实例引用,并清理相关状态,严禁调用 ad.destroy()
|
|
206
|
+
// 因为微信小程序的 wx.createRewardedVideoAd 在整个应用生命周期中为全局单例,
|
|
207
|
+
// 一旦销毁 (destroy) 后,后续再次 create 该广告位 ID 将永远返回已销毁的实例,导致报错 "video-ad has been destroyed"
|
|
208
|
+
adInstances.delete(adId);
|
|
215
209
|
if (activeRewardId === adId) {
|
|
216
210
|
activeRewardId = "";
|
|
217
211
|
rewardCallback = undefined;
|