This commit is contained in:
syuilo 2025-08-26 14:22:53 +09:00
parent 05cc8047fa
commit d5475d1ff6
7 changed files with 16 additions and 15 deletions

View File

@ -52,7 +52,7 @@ import { prefer } from '@/preferences.js';
type Ad = (typeof instance)['ads'][number];
const props = defineProps<{
preferForms: string[];
preferForms?: string[];
specify?: Ad;
}>();
@ -71,7 +71,7 @@ const choseAd = (): Ad | null => {
ratio: 0,
} : ad);
let ads = allAds.filter(ad => props.preferForms.includes(ad.place));
let ads = props.preferForms ? allAds.filter(ad => props.preferForms!.includes(ad.place)) : allAds;
if (ads.length === 0) {
ads = allAds.filter(ad => ad.place === 'square');

View File

@ -140,15 +140,15 @@ function toggleDayOfWeek(ad, index) {
function add() {
ads.value.unshift({
id: null,
id: '',
memo: '',
place: 'square',
priority: 'middle',
ratio: 1,
url: '',
imageUrl: null,
expiresAt: null,
startsAt: null,
imageUrl: '',
expiresAt: new Date().toISOString(),
startsAt: new Date().toISOString(),
dayOfWeek: 0,
});
}
@ -160,7 +160,7 @@ function remove(ad) {
}).then(({ canceled }) => {
if (canceled) return;
ads.value = ads.value.filter(x => x !== ad);
if (ad.id == null) return;
if (ad.id === '') return;
os.apiWithDialog('admin/ad/delete', {
id: ad.id,
}).then(() => {
@ -170,7 +170,7 @@ function remove(ad) {
}
function save(ad) {
if (ad.id == null) {
if (ad.id === '') {
misskeyApi('admin/ad/create', {
...ad,
expiresAt: new Date(ad.expiresAt).getTime(),
@ -207,7 +207,7 @@ function save(ad) {
}
function more() {
misskeyApi('admin/ad/list', { untilId: ads.value.reduce((acc, ad) => ad.id != null ? ad : acc).id, publishing: publishing }).then(adsResponse => {
misskeyApi('admin/ad/list', { untilId: ads.value.reduce((acc, ad) => ad.id !== '' ? ad : acc).id, publishing: publishing }).then(adsResponse => {
if (adsResponse == null) return;
ads.value = ads.value.concat(adsResponse.map(r => {
const exdate = new Date(r.expiresAt);

View File

@ -75,14 +75,15 @@ onMounted(async () => {
if (!$i) return;
try {
session.value = await misskeyApi('auth/session/show', {
const result = await misskeyApi('auth/session/show', {
token: props.token,
});
session.value = result;
//
if (session.value.app.isAuthorized) {
if (result.app.isAuthorized) {
await misskeyApi('auth/accept', {
token: session.value.token,
token: result.token,
});
accepted();
} else {

View File

@ -312,6 +312,7 @@ const headerActions = computed(() => [{
handler: add,
}, {
icon: 'ti ti-dots',
text: i18n.ts.more,
handler: menu,
}]);

View File

@ -161,7 +161,7 @@ async function _fetch_() {
},
raw: res.data,
};
} catch (err) {
} catch (err: any) {
switch (err.message.toLowerCase()) {
case 'this theme is already installed':
errorKV.value = {

View File

@ -34,6 +34,7 @@ const props = defineProps<{
const password = ref('');
async function save() {
if (props.token == null) return;
await os.apiWithDialog('reset-password', {
token: props.token,
password: password.value,

View File

@ -159,8 +159,6 @@ SPDX-License-Identifier: AGPL-3.0-only
</div>
<div v-if="expandedBlockItems.includes(item.id)" :class="$style.userItemSub">
<div>Blocked at: <MkTime :time="item.createdAt" mode="detail"/></div>
<div v-if="item.expiresAt">Period: {{ new Date(item.expiresAt).toLocaleString() }}</div>
<div v-else>Period: {{ i18n.ts.indefinitely }}</div>
</div>
</div>
</div>