(add) Notification test

This commit is contained in:
kakkokari-gtyih 2023-09-10 17:36:56 +09:00
parent fd7d7318a7
commit 9e95982f16
4 changed files with 31 additions and 0 deletions

3
locales/index.d.ts vendored
View File

@ -2132,6 +2132,9 @@ export interface Locale {
"unreadAntennaNote": string;
"emptyPushNotificationMessage": string;
"achievementEarned": string;
"testNotification": string;
"doTestNotification": string;
"notificationWillBeDisplayedLikeThis": string;
"_types": {
"all": string;
"follow": string;

View File

@ -2047,6 +2047,9 @@ _notification:
unreadAntennaNote: "アンテナ {name}"
emptyPushNotificationMessage: "プッシュ通知の更新をしました"
achievementEarned: "実績を獲得"
testNotification: "通知テスト"
doTestNotification: "通知をテストする"
notificationWillBeDisplayedLikeThis: "通知はこのように表示されます"
_types:
all: "すべて"

View File

@ -90,6 +90,8 @@ SPDX-License-Identifier: AGPL-3.0-only
<option value="vertical"><i class="ti ti-carousel-vertical"></i> {{ i18n.ts.vertical }}</option>
<option value="horizontal"><i class="ti ti-carousel-horizontal"></i> {{ i18n.ts.horizontal }}</option>
</MkRadios>
<MkButton @click="testNotification()">{{ i18n.ts._notification.doTestNotification }}</MkButton>
</div>
</FormSection>
@ -185,6 +187,7 @@ import { unisonReload } from '@/scripts/unison-reload';
import { i18n } from '@/i18n';
import { definePageMetadata } from '@/scripts/page-metadata';
import { miLocalStorage } from '@/local-storage';
import { infoImageUrl } from '@/instance';
const lang = ref(miLocalStorage.getItem('lang'));
const fontSize = ref(miLocalStorage.getItem('fontSize'));
@ -296,6 +299,14 @@ function removeEmojiIndex(lang: string) {
os.promiseDialog(main());
}
function testNotification(): void {
os.api('notifications/create', {
header: i18n.ts._notification.testNotification,
body: i18n.ts._notification.notificationWillBeDisplayedLikeThis,
icon: infoImageUrl.value,
});
}
const headerActions = $computed(() => []);
const headerTabs = $computed(() => []);

View File

@ -12,6 +12,11 @@ SPDX-License-Identifier: AGPL-3.0-only
<FormLink @click="readAllUnreadNotes">{{ i18n.ts.markAsReadAllUnreadNotes }}</FormLink>
</div>
</FormSection>
<FormSection>
<div class="_gaps_m">
<FormLink @click="testNotification">{{ i18n.ts._notification.doTestNotification }}</FormLink>
</div>
</FormSection>
<FormSection>
<template #label>{{ i18n.ts.pushNotification }}</template>
@ -41,6 +46,7 @@ import { i18n } from '@/i18n';
import { definePageMetadata } from '@/scripts/page-metadata';
import MkPushNotificationAllowButton from '@/components/MkPushNotificationAllowButton.vue';
import { notificationTypes } from '@/const';
import { infoImageUrl } from '@/instance';
let allowButton = $shallowRef<InstanceType<typeof MkPushNotificationAllowButton>>();
let pushRegistrationInServer = $computed(() => allowButton?.pushRegistrationInServer);
@ -83,6 +89,14 @@ function onChangeSendReadMessage(v: boolean) {
});
}
function testNotification(): void {
os.api('notifications/create', {
header: i18n.ts._notification.testNotification,
body: i18n.ts._notification.notificationWillBeDisplayedLikeThis,
icon: infoImageUrl.value,
});
}
const headerActions = $computed(() => []);
const headerTabs = $computed(() => []);