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