enhance(AD): 表示される広告の選定条件を変更、縦に長いタイプを設定できるように (MisskeyIO#293)
This commit is contained in:
parent
44c10ea991
commit
8a8196aa09
@ -178,6 +178,7 @@ export const meta = {
|
|||||||
place: {
|
place: {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
optional: false, nullable: false,
|
optional: false, nullable: false,
|
||||||
|
enum: ['square', 'horizontal', 'horizontal-big', 'vertical'],
|
||||||
},
|
},
|
||||||
ratio: {
|
ratio: {
|
||||||
type: 'number',
|
type: 'number',
|
||||||
|
@ -95,7 +95,7 @@ export default defineComponent({
|
|||||||
if (props.ad && item._shouldInsertAd_) {
|
if (props.ad && item._shouldInsertAd_) {
|
||||||
return [h(MkAd, {
|
return [h(MkAd, {
|
||||||
key: item.id + ':ad',
|
key: item.id + ':ad',
|
||||||
prefer: ['horizontal', 'horizontal-big'],
|
prefer: [],
|
||||||
}), el];
|
}), el];
|
||||||
} else {
|
} else {
|
||||||
return el;
|
return el;
|
||||||
|
@ -63,24 +63,28 @@ const choseAd = (): Ad | null => {
|
|||||||
ratio: 0,
|
ratio: 0,
|
||||||
} : ad);
|
} : ad);
|
||||||
|
|
||||||
let ads = allAds.filter(ad => props.prefer.includes(ad.place));
|
const valuableAds = allAds.filter(ad => ad.ratio !== 0);
|
||||||
|
const lowPriorityAds = allAds.filter(ad => ad.ratio === 0);
|
||||||
|
|
||||||
if (ads.length === 0) {
|
let ads: Ad[];
|
||||||
ads = allAds.filter(ad => ad.place === 'square');
|
const preferredAds = valuableAds.filter(ad => props.prefer.includes(ad.place));
|
||||||
|
if (preferredAds.length !== 0) {
|
||||||
|
ads = preferredAds;
|
||||||
|
} else {
|
||||||
|
ads = lowPriorityAds.filter(ad => props.prefer.includes(ad.place));
|
||||||
}
|
}
|
||||||
|
|
||||||
const lowPriorityAds = ads.filter(ad => ad.ratio === 0);
|
|
||||||
ads = ads.filter(ad => ad.ratio !== 0);
|
|
||||||
|
|
||||||
if (ads.length === 0) {
|
if (ads.length === 0) {
|
||||||
if (lowPriorityAds.length !== 0) {
|
const nonPreferredAds = valuableAds.filter(ad => !props.prefer.includes(ad.place));
|
||||||
return lowPriorityAds[Math.floor(Math.random() * lowPriorityAds.length)];
|
if (nonPreferredAds.length !== 0) {
|
||||||
|
ads = nonPreferredAds;
|
||||||
} else {
|
} else {
|
||||||
return null;
|
ads = lowPriorityAds.filter(ad => !props.prefer.includes(ad.place));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const totalFactor = ads.reduce((a, b) => a + b.ratio, 0);
|
const totalFactor = ads.reduce((a, b) => a + b.ratio, 0);
|
||||||
|
if (totalFactor === 0) return ads[Math.floor(Math.random() * ads.length)];
|
||||||
const r = Math.random() * totalFactor;
|
const r = Math.random() * totalFactor;
|
||||||
|
|
||||||
let stackedFactor = 0;
|
let stackedFactor = 0;
|
||||||
@ -148,7 +152,8 @@ function reduceFrequency(): void {
|
|||||||
&.form_vertical {
|
&.form_vertical {
|
||||||
> .link,
|
> .link,
|
||||||
> .link > .img {
|
> .link > .img {
|
||||||
max-width: min(100px, 100%);
|
max-width: min(300px, 100%);
|
||||||
|
max-height: 450px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||||||
<option value="square">square</option>
|
<option value="square">square</option>
|
||||||
<option value="horizontal">horizontal</option>
|
<option value="horizontal">horizontal</option>
|
||||||
<option value="horizontal-big">horizontal-big</option>
|
<option value="horizontal-big">horizontal-big</option>
|
||||||
|
<option value="vertical">vertical</option>
|
||||||
</MkRadios>
|
</MkRadios>
|
||||||
<!--
|
<!--
|
||||||
<div style="margin: 32px 0;">
|
<div style="margin: 32px 0;">
|
||||||
|
@ -47,7 +47,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<MkA v-if="$i && $i.id === flash.userId" :to="`/play/${flash.id}/edit`" style="color: var(--accent);">{{ i18n.ts._play.editThisPage }}</MkA>
|
<MkA v-if="$i && $i.id === flash.userId" :to="`/play/${flash.id}/edit`" style="color: var(--accent);">{{ i18n.ts._play.editThisPage }}</MkA>
|
||||||
<MkAd :prefer="['horizontal', 'horizontal-big']"/>
|
<MkAd :prefer="['square', 'horizontal', 'horizontal-big']"/>
|
||||||
</div>
|
</div>
|
||||||
<MkError v-else-if="error" @retry="fetchPage()"/>
|
<MkError v-else-if="error" @retry="fetchPage()"/>
|
||||||
<MkLoading v-else/>
|
<MkLoading v-else/>
|
||||||
|
@ -42,7 +42,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||||||
<MkFollowButton v-if="!$i || $i.id != post.user.id" v-model:user="post.user" :inline="true" :transparent="false" :full="true" large class="koudoku"/>
|
<MkFollowButton v-if="!$i || $i.id != post.user.id" v-model:user="post.user" :inline="true" :transparent="false" :full="true" large class="koudoku"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<MkAd :prefer="['horizontal', 'horizontal-big']"/>
|
<MkAd :prefer="['square', 'horizontal', 'horizontal-big']"/>
|
||||||
<MkContainer :max-height="300" :foldable="true" class="other">
|
<MkContainer :max-height="300" :foldable="true" class="other">
|
||||||
<template #icon><i class="ti ti-clock"></i></template>
|
<template #icon><i class="ti ti-clock"></i></template>
|
||||||
<template #header>{{ i18n.ts.recentPosts }}</template>
|
<template #header>{{ i18n.ts.recentPosts }}</template>
|
||||||
|
@ -59,7 +59,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||||||
<div><i class="ti ti-clock"></i> {{ i18n.ts.createdAt }}: <MkTime :time="page.createdAt" mode="detail"/></div>
|
<div><i class="ti ti-clock"></i> {{ i18n.ts.createdAt }}: <MkTime :time="page.createdAt" mode="detail"/></div>
|
||||||
<div v-if="page.createdAt != page.updatedAt"><i class="ti ti-clock"></i> {{ i18n.ts.updatedAt }}: <MkTime :time="page.updatedAt" mode="detail"/></div>
|
<div v-if="page.createdAt != page.updatedAt"><i class="ti ti-clock"></i> {{ i18n.ts.updatedAt }}: <MkTime :time="page.updatedAt" mode="detail"/></div>
|
||||||
</div>
|
</div>
|
||||||
<MkAd :prefer="['horizontal', 'horizontal-big']"/>
|
<MkAd :prefer="['square', 'horizontal', 'horizontal-big']"/>
|
||||||
<MkContainer :max-height="300" :foldable="true" class="other">
|
<MkContainer :max-height="300" :foldable="true" class="other">
|
||||||
<template #icon><i class="ti ti-clock"></i></template>
|
<template #icon><i class="ti ti-clock"></i></template>
|
||||||
<template #header>{{ i18n.ts.recentPosts }}</template>
|
<template #header>{{ i18n.ts.recentPosts }}</template>
|
||||||
|
@ -19119,7 +19119,7 @@ export type operations = {
|
|||||||
notFoundImageUrl: string | null;
|
notFoundImageUrl: string | null;
|
||||||
iconUrl: string | null;
|
iconUrl: string | null;
|
||||||
maxNoteTextLength: number;
|
maxNoteTextLength: number;
|
||||||
ads: {
|
ads: ({
|
||||||
/**
|
/**
|
||||||
* Format: id
|
* Format: id
|
||||||
* @example xxxxxxxxxx
|
* @example xxxxxxxxxx
|
||||||
@ -19127,12 +19127,13 @@ export type operations = {
|
|||||||
id: string;
|
id: string;
|
||||||
/** Format: url */
|
/** Format: url */
|
||||||
url: string;
|
url: string;
|
||||||
place: string;
|
/** @enum {string} */
|
||||||
|
place: 'square' | 'horizontal' | 'horizontal-big' | 'vertical';
|
||||||
ratio: number;
|
ratio: number;
|
||||||
/** Format: url */
|
/** Format: url */
|
||||||
imageUrl: string;
|
imageUrl: string;
|
||||||
dayOfWeek: number;
|
dayOfWeek: number;
|
||||||
}[];
|
})[];
|
||||||
/** @default 0 */
|
/** @default 0 */
|
||||||
notesPerOneAd: number;
|
notesPerOneAd: number;
|
||||||
/** @example false */
|
/** @example false */
|
||||||
|
Loading…
Reference in New Issue
Block a user