2023-08-13 13:12:29 +02:00
|
|
|
<!--
|
2024-02-13 16:59:27 +01:00
|
|
|
SPDX-FileCopyrightText: syuilo and misskey-project
|
2023-08-13 13:12:29 +02:00
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
-->
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<MkModal ref="modal" :zPriority="'middle'" @closed="$emit('closed')" @click="onBgClick">
|
|
|
|
<div ref="rootEl" :class="$style.root">
|
|
|
|
<div :class="$style.header">
|
|
|
|
<span :class="$style.icon">
|
2024-06-21 17:27:36 +02:00
|
|
|
<i v-if="announcement.icon === 'info'" class="ti ti-info-circle"></i>
|
2024-06-21 16:52:22 +02:00
|
|
|
<i v-else-if="announcement.icon === 'warning'" class="ti ti-alert-triangle" style="color: var(--warn);"></i>
|
2024-06-21 17:29:48 +02:00
|
|
|
<i v-else-if="announcement.icon === 'error'" class="ti ti-circle-x" style="color: var(--error);"></i>
|
|
|
|
<i v-else-if="announcement.icon === 'success'" class="ti ti-check" style="color: var(--success);"></i>
|
2023-08-13 13:12:29 +02:00
|
|
|
</span>
|
|
|
|
<span :class="$style.title">{{ announcement.title }}</span>
|
|
|
|
</div>
|
2024-06-07 12:01:49 +02:00
|
|
|
<div :class="$style.text"><Mfm :text="announcement.text" :isBlock="true" /></div>
|
2023-08-13 13:12:29 +02:00
|
|
|
<MkButton primary full @click="ok">{{ i18n.ts.ok }}</MkButton>
|
|
|
|
</div>
|
|
|
|
</MkModal>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
|
import { onMounted, shallowRef } from 'vue';
|
2023-09-04 06:33:38 +02:00
|
|
|
import * as Misskey from 'misskey-js';
|
2023-09-19 09:37:43 +02:00
|
|
|
import * as os from '@/os.js';
|
2024-01-04 10:32:46 +01:00
|
|
|
import { misskeyApi } from '@/scripts/misskey-api.js';
|
2023-08-13 13:12:29 +02:00
|
|
|
import MkModal from '@/components/MkModal.vue';
|
|
|
|
import MkButton from '@/components/MkButton.vue';
|
2023-09-19 09:37:43 +02:00
|
|
|
import { i18n } from '@/i18n.js';
|
|
|
|
import { $i, updateAccount } from '@/account.js';
|
2023-08-13 13:12:29 +02:00
|
|
|
|
|
|
|
const props = withDefaults(defineProps<{
|
2023-09-04 06:33:38 +02:00
|
|
|
announcement: Misskey.entities.Announcement;
|
2023-08-13 13:12:29 +02:00
|
|
|
}>(), {
|
|
|
|
});
|
|
|
|
|
|
|
|
const rootEl = shallowRef<HTMLDivElement>();
|
|
|
|
const modal = shallowRef<InstanceType<typeof MkModal>>();
|
|
|
|
|
|
|
|
async function ok() {
|
|
|
|
if (props.announcement.needConfirmationToRead) {
|
|
|
|
const confirm = await os.confirm({
|
|
|
|
type: 'question',
|
|
|
|
title: i18n.ts._announcement.readConfirmTitle,
|
2024-01-20 00:11:59 +01:00
|
|
|
text: i18n.tsx._announcement.readConfirmText({ title: props.announcement.title }),
|
2023-08-13 13:12:29 +02:00
|
|
|
});
|
|
|
|
if (confirm.canceled) return;
|
|
|
|
}
|
|
|
|
|
2024-01-30 11:53:53 +01:00
|
|
|
modal.value?.close();
|
2024-01-04 10:32:46 +01:00
|
|
|
misskeyApi('i/read-announcement', { announcementId: props.announcement.id });
|
2023-08-13 13:12:29 +02:00
|
|
|
updateAccount({
|
|
|
|
unreadAnnouncements: $i!.unreadAnnouncements.filter(a => a.id !== props.announcement.id),
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function onBgClick() {
|
2024-01-30 11:53:53 +01:00
|
|
|
rootEl.value?.animate([{
|
2023-08-13 13:12:29 +02:00
|
|
|
offset: 0,
|
|
|
|
transform: 'scale(1)',
|
|
|
|
}, {
|
|
|
|
offset: 0.5,
|
|
|
|
transform: 'scale(1.1)',
|
|
|
|
}, {
|
|
|
|
offset: 1,
|
|
|
|
transform: 'scale(1)',
|
|
|
|
}], {
|
|
|
|
duration: 100,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" module>
|
|
|
|
.root {
|
|
|
|
margin: auto;
|
|
|
|
position: relative;
|
|
|
|
padding: 32px;
|
|
|
|
min-width: 320px;
|
|
|
|
max-width: 480px;
|
|
|
|
box-sizing: border-box;
|
|
|
|
background: var(--panel);
|
|
|
|
border-radius: var(--radius);
|
|
|
|
}
|
|
|
|
|
|
|
|
.header {
|
|
|
|
font-size: 120%;
|
|
|
|
}
|
|
|
|
|
|
|
|
.icon {
|
|
|
|
margin-right: 0.5em;
|
|
|
|
}
|
|
|
|
|
|
|
|
.title {
|
|
|
|
font-weight: bold;
|
|
|
|
}
|
|
|
|
|
|
|
|
.text {
|
|
|
|
margin: 1em 0;
|
|
|
|
}
|
|
|
|
</style>
|