From 033fa1da1fb246f3ec4460909aa6b2a743fbf5fb Mon Sep 17 00:00:00 2001 From: xu_yanfeng Date: Sat, 18 Jan 2025 22:21:12 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=99=E6=9B=B4=E5=A4=9A=E7=9A=84=E5=B9=BF?= =?UTF-8?q?=E5=91=8A=E5=B1=95=E7=A4=BA=E6=9C=BA=E4=BC=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cc-inspector/src/scripts/inject-view/loader.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/cc-inspector/src/scripts/inject-view/loader.ts b/cc-inspector/src/scripts/inject-view/loader.ts index 5b42009..c0a56a0 100644 --- a/cc-inspector/src/scripts/inject-view/loader.ts +++ b/cc-inspector/src/scripts/inject-view/loader.ts @@ -56,6 +56,15 @@ export class AdData { * 底部广告多少秒滚动一次 */ scrollDuration: number = 3; + /** + * 将位置随机打乱,保证用户每次看到的插件数量不一样,提高转换率 + */ + randomIndex: boolean = false; + /** + * 展示的广告数量,-1为所有 + */ + showCount: number = -1; + data: Array = []; parse(data: AdData) { this.desc = data.desc; @@ -63,8 +72,17 @@ export class AdData { this.valid = !!data.valid; this.showDuration = data.showDuration || 10; this.scrollDuration = data.scrollDuration || 3; + this.randomIndex = !!data.randomIndex; + this.showCount = data.showCount || -1; + if (data.data) { + if (this.randomIndex) { + data.data.sort(() => Math.random() - 0.5); + } data.data.forEach((el) => { + if (this.showCount !== -1 && this.data.length >= this.showCount) { + return; + } const item = new AdItem().parse(el); if (!item.duration) { console.warn(`add failed, ad.duration is ${item.duration}, ${JSON.stringify(item)}`);