2020-01-29 20:37:25 +01:00
|
|
|
<template>
|
2023-04-08 02:01:42 +02:00
|
|
|
<MkStickyContainer>
|
|
|
|
<template #header
|
|
|
|
><MkPageHeader :actions="headerActions" :tabs="headerTabs"
|
|
|
|
/></template>
|
|
|
|
<MkSpacer :content-max="800">
|
|
|
|
<MkPagination
|
|
|
|
v-slot="{ items }"
|
|
|
|
:pagination="pagination"
|
|
|
|
class="ruryvtyk _content"
|
|
|
|
>
|
|
|
|
<section
|
|
|
|
v-for="(announcement, i) in items"
|
|
|
|
:key="announcement.id"
|
|
|
|
class="_card announcement"
|
|
|
|
>
|
|
|
|
<div class="_title">
|
|
|
|
<span v-if="$i && !announcement.isRead">🆕 </span
|
|
|
|
>{{ announcement.title }}
|
|
|
|
</div>
|
|
|
|
<div class="_content">
|
|
|
|
<Mfm :text="announcement.text" />
|
|
|
|
<img
|
|
|
|
v-if="announcement.imageUrl"
|
|
|
|
:src="announcement.imageUrl"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<div v-if="$i && !announcement.isRead" class="_footer">
|
|
|
|
<MkButton primary @click="read(items, announcement, i)"
|
|
|
|
><i class="ph-check ph-bold ph-lg"></i>
|
|
|
|
{{ i18n.ts.gotIt }}</MkButton
|
|
|
|
>
|
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
</MkPagination>
|
|
|
|
</MkSpacer>
|
|
|
|
</MkStickyContainer>
|
2020-01-29 20:37:25 +01:00
|
|
|
</template>
|
|
|
|
|
2022-06-20 10:38:49 +02:00
|
|
|
<script lang="ts" setup>
|
2023-04-08 02:01:42 +02:00
|
|
|
import {} from "vue";
|
|
|
|
import MkPagination from "@/components/MkPagination.vue";
|
|
|
|
import MkButton from "@/components/MkButton.vue";
|
|
|
|
import * as os from "@/os";
|
|
|
|
import { i18n } from "@/i18n";
|
|
|
|
import { definePageMetadata } from "@/scripts/page-metadata";
|
2020-01-29 20:37:25 +01:00
|
|
|
|
2022-06-20 10:38:49 +02:00
|
|
|
const pagination = {
|
2023-04-08 02:01:42 +02:00
|
|
|
endpoint: "announcements" as const,
|
2022-06-20 10:38:49 +02:00
|
|
|
limit: 10,
|
|
|
|
};
|
2020-01-29 20:37:25 +01:00
|
|
|
|
2022-06-20 10:38:49 +02:00
|
|
|
// TODO: これは実質的に親コンポーネントから子コンポーネントのプロパティを変更してるのでなんとかしたい
|
|
|
|
function read(items, announcement, i) {
|
|
|
|
items[i] = {
|
|
|
|
...announcement,
|
|
|
|
isRead: true,
|
|
|
|
};
|
2023-04-08 02:01:42 +02:00
|
|
|
os.api("i/read-announcement", { announcementId: announcement.id });
|
2022-06-20 10:38:49 +02:00
|
|
|
}
|
2020-01-29 20:37:25 +01:00
|
|
|
|
2022-06-20 10:38:49 +02:00
|
|
|
const headerActions = $computed(() => []);
|
|
|
|
|
|
|
|
const headerTabs = $computed(() => []);
|
|
|
|
|
|
|
|
definePageMetadata({
|
|
|
|
title: i18n.ts.announcements,
|
2023-04-08 02:01:42 +02:00
|
|
|
icon: "ph-megaphone-simple ph-bold ph-lg",
|
2020-01-29 20:37:25 +01:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.ruryvtyk {
|
|
|
|
> .announcement {
|
2021-10-24 17:13:54 +02:00
|
|
|
&:not(:last-child) {
|
|
|
|
margin-bottom: var(--margin);
|
|
|
|
}
|
|
|
|
|
2020-01-29 20:37:25 +01:00
|
|
|
> ._content {
|
|
|
|
> img {
|
|
|
|
display: block;
|
|
|
|
max-height: 300px;
|
|
|
|
max-width: 100%;
|
2023-04-17 04:04:28 +02:00
|
|
|
border-radius: 10px;
|
|
|
|
margin-top: 1rem;
|
2020-01-29 20:37:25 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|