2020-01-29 20:37:25 +01:00
|
|
|
<template>
|
2021-10-24 17:13:54 +02:00
|
|
|
<MkSpacer :content-max="800">
|
2021-10-23 21:03:07 +02:00
|
|
|
<MkPagination :pagination="pagination" #default="{items}" class="ruryvtyk _content">
|
2021-10-24 17:13:54 +02:00
|
|
|
<section class="_card announcement" v-for="(announcement, i) in items" :key="announcement.id">
|
2021-10-23 21:03:07 +02:00
|
|
|
<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 class="_footer" v-if="$i && !announcement.isRead">
|
|
|
|
<MkButton @click="read(items, announcement, i)" primary><i class="fas fa-check"></i> {{ $ts.gotIt }}</MkButton>
|
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
</MkPagination>
|
2021-10-24 17:13:54 +02:00
|
|
|
</MkSpacer>
|
2020-01-29 20:37:25 +01:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2020-10-17 13:12:00 +02:00
|
|
|
import { defineComponent } from 'vue';
|
2021-03-23 09:30:14 +01:00
|
|
|
import MkPagination from '@client/components/ui/pagination.vue';
|
|
|
|
import MkButton from '@client/components/ui/button.vue';
|
|
|
|
import * as os from '@client/os';
|
2021-04-10 05:54:12 +02:00
|
|
|
import * as symbols from '@client/symbols';
|
2020-01-29 20:37:25 +01:00
|
|
|
|
2020-10-17 13:12:00 +02:00
|
|
|
export default defineComponent({
|
2020-01-29 20:37:25 +01:00
|
|
|
components: {
|
|
|
|
MkPagination,
|
|
|
|
MkButton
|
|
|
|
},
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
2021-04-10 05:54:12 +02:00
|
|
|
[symbols.PAGE_INFO]: {
|
2020-12-26 02:47:36 +01:00
|
|
|
title: this.$ts.announcements,
|
2021-10-03 16:51:54 +02:00
|
|
|
icon: 'fas fa-broadcast-tower',
|
|
|
|
bg: 'var(--bg)',
|
2020-10-17 13:12:00 +02:00
|
|
|
},
|
2020-01-29 20:37:25 +01:00
|
|
|
pagination: {
|
|
|
|
endpoint: 'announcements',
|
|
|
|
limit: 10,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
2020-08-01 03:02:03 +02:00
|
|
|
// TODO: これは実質的に親コンポーネントから子コンポーネントのプロパティを変更してるのでなんとかしたい
|
|
|
|
read(items, announcement, i) {
|
2020-10-17 13:12:00 +02:00
|
|
|
items[i] = {
|
2020-08-01 03:02:03 +02:00
|
|
|
...announcement,
|
|
|
|
isRead: true,
|
2020-10-17 13:12:00 +02:00
|
|
|
};
|
|
|
|
os.api('i/read-announcement', { announcementId: announcement.id });
|
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%;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|