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