hippofish/packages/frontend/src/pages/my-antennas/index.vue

90 lines
2 KiB
Vue
Raw Normal View History

<!--
SPDX-FileCopyrightText: syuilo and other misskey contributors
SPDX-License-Identifier: AGPL-3.0-only
-->
2023-05-19 13:52:15 +02:00
<template>
<MkStickyContainer>
<template #header><MkPageHeader :actions="headerActions" :tabs="headerTabs"/></template>
2023-05-19 13:52:15 +02:00
<MkSpacer :contentMax="700">
<div>
<div v-if="antennas.length === 0" class="empty">
<div class="_fullinfo">
<img :src="infoImageUrl" class="_ghost"/>
<div>{{ i18n.ts.nothing }}</div>
</div>
</div>
<MkButton :link="true" to="/my/antennas/create" primary :class="$style.add"><i class="ti ti-plus"></i> {{ i18n.ts.add }}</MkButton>
<div v-if="antennas.length > 0" class="_gaps">
<MkA v-for="antenna in antennas" :key="antenna.id" :class="$style.antenna" :to="`/my/antennas/${antenna.id}`">
<div class="name">{{ antenna.name }}</div>
</MkA>
2023-05-19 13:52:15 +02:00
</div>
2021-12-02 12:09:12 +01:00
</div>
2023-05-19 13:52:15 +02:00
</MkSpacer>
</MkStickyContainer>
</template>
<script lang="ts" setup>
import MkButton from '@/components/MkButton.vue';
import { i18n } from '@/i18n';
import { definePageMetadata } from '@/scripts/page-metadata';
import { antennasCache } from '@/cache';
import { api } from '@/os';
import { onActivated } from 'vue';
import { infoImageUrl } from '@/instance';
const antennas = $computed(() => antennasCache.value.value ?? []);
function fetch() {
antennasCache.fetch(() => api('antennas/list'));
}
fetch();
const headerActions = $computed(() => [{
asFullButton: true,
icon: 'ti ti-refresh',
text: i18n.ts.reload,
handler: () => {
antennasCache.delete();
fetch();
},
}]);
const headerTabs = $computed(() => []);
definePageMetadata({
title: i18n.ts.manageAntennas,
icon: 'ti ti-antenna',
});
2021-08-07 10:55:16 +02:00
onActivated(() => {
antennasCache.fetch(() => api('antennas/list'));
});
</script>
2021-08-07 10:55:16 +02:00
<style lang="scss" module>
.add {
margin: 0 auto 16px auto;
}
2021-08-07 10:55:16 +02:00
.antenna {
display: block;
padding: 16px;
border: solid 1px var(--divider);
border-radius: 6px;
2021-08-07 10:55:16 +02:00
&:hover {
border: solid 1px var(--accent);
text-decoration: none;
2021-08-07 10:55:16 +02:00
}
}
.name {
font-weight: bold;
}
</style>