yumechi-no-kuni/packages/frontend/src/pages/announcements.vue

77 lines
1.9 KiB
Vue
Raw Normal View History

<template>
<MkStickyContainer>
<template #header><MkPageHeader :actions="headerActions" :tabs="headerTabs"/></template>
<MkSpacer :content-max="800">
2023-01-05 22:40:17 -06:00
<MkPagination v-slot="{items}" :pagination="pagination" class="ruryvtyk _gaps_m">
2023-01-05 18:41:14 -06:00
<section v-for="(announcement, i) in items" :key="announcement.id" class="announcement _panel">
<div class="header"><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>
2023-01-05 18:41:14 -06:00
<div v-if="$i && !announcement.isRead" class="footer">
<MkButton primary @click="read(items, announcement, i)"><i class="ti ti-check"></i> {{ $ts.gotIt }}</MkButton>
</div>
</section>
</MkPagination>
</MkSpacer>
</MkStickyContainer>
</template>
<script lang="ts" setup>
import { } from 'vue';
import MkPagination from '@/components/MkPagination.vue';
import MkButton from '@/components/MkButton.vue';
2021-11-11 11:02:25 -06:00
import * as os from '@/os';
import { i18n } from '@/i18n';
import { definePageMetadata } from '@/scripts/page-metadata';
const pagination = {
endpoint: 'announcements' as const,
limit: 10,
};
// TODO: これは実質的に親コンポーネントから子コンポーネントのプロパティを変更してるのでなんとかしたい
function read(items, announcement, i) {
items[i] = {
...announcement,
isRead: true,
};
os.api('i/read-announcement', { announcementId: announcement.id });
}
const headerActions = $computed(() => []);
const headerTabs = $computed(() => []);
definePageMetadata({
title: i18n.ts.announcements,
icon: 'ti ti-speakerphone',
});
</script>
<style lang="scss" scoped>
.ruryvtyk {
> .announcement {
2023-01-07 04:57:48 -06:00
padding: 16px;
2023-01-05 18:41:14 -06:00
> .header {
2023-01-07 04:57:48 -06:00
margin-bottom: 16px;
2023-01-05 18:41:14 -06:00
font-weight: bold;
2021-10-24 10:13:54 -05:00
}
2023-01-05 18:41:14 -06:00
> .content {
> img {
display: block;
max-height: 300px;
max-width: 100%;
}
}
2023-01-05 18:41:14 -06:00
> .footer {
2023-01-07 04:57:48 -06:00
margin-top: 16px;
2023-01-05 18:41:14 -06:00
}
}
}
</style>