1
0
mirror of https://github.com/MisskeyIO/misskey synced 2024-12-23 11:08:22 +09:00
MisskeyIO/packages/frontend/src/pages/my-clips/index.vue

101 lines
2.1 KiB
Vue
Raw Normal View History

2022-07-20 22:24:26 +09:00
<template>
<MkStickyContainer>
<template #header><MkPageHeader :actions="headerActions" :tabs="headerTabs"/></template>
2022-07-20 22:24:26 +09:00
<MkSpacer :content-max="700">
<div class="qtcaoidl">
<MkButton primary class="add" @click="create"><i class="ti ti-plus"></i> {{ i18n.ts.add }}</MkButton>
2020-11-15 12:04:54 +09:00
2022-07-20 22:24:26 +09:00
<MkPagination v-slot="{items}" ref="pagingComponent" :pagination="pagination" class="list">
<MkA v-for="item in items" :key="item.id" :to="`/clips/${item.id}`" class="item _panel _gap">
<b>{{ item.name }}</b>
<div v-if="item.description" class="description">{{ item.description }}</div>
</MkA>
</MkPagination>
</div>
</MkSpacer>
</MkStickyContainer>
2020-11-15 12:04:54 +09:00
</template>
<script lang="ts" setup>
import { } from 'vue';
import MkPagination from '@/components/MkPagination.vue';
import MkButton from '@/components/MkButton.vue';
2021-11-12 02:02:25 +09:00
import * as os from '@/os';
import { i18n } from '@/i18n';
import { definePageMetadata } from '@/scripts/page-metadata';
2020-11-15 12:04:54 +09:00
const pagination = {
endpoint: 'clips/list' as const,
limit: 10,
};
2020-11-15 12:04:54 +09:00
const pagingComponent = $ref<InstanceType<typeof MkPagination>>();
2020-11-15 12:04:54 +09:00
async function create() {
const { canceled, result } = await os.form(i18n.ts.createNewClip, {
name: {
type: 'string',
label: i18n.ts.name,
2020-11-15 12:04:54 +09:00
},
description: {
type: 'string',
required: false,
multiline: true,
label: i18n.ts.description,
2020-11-15 12:04:54 +09:00
},
isPublic: {
type: 'boolean',
label: i18n.ts.public,
default: false,
},
});
if (canceled) return;
os.apiWithDialog('clips/create', result);
pagingComponent.reload();
}
function onClipCreated() {
pagingComponent.reload();
}
2020-11-15 12:04:54 +09:00
function onClipDeleted() {
pagingComponent.reload();
}
const headerActions = $computed(() => []);
const headerTabs = $computed(() => []);
definePageMetadata({
title: i18n.ts.clip,
icon: 'ti ti-paperclip',
action: {
icon: 'ti ti-plus',
handler: create,
},
2020-11-15 12:04:54 +09:00
});
</script>
2020-11-15 12:34:47 +09:00
<style lang="scss" scoped>
2020-11-15 12:34:47 +09:00
.qtcaoidl {
> .add {
margin: 0 auto 16px auto;
}
2021-12-02 20:09:12 +09:00
> .list {
> .item {
display: block;
padding: 16px;
2020-11-15 12:34:47 +09:00
2021-12-02 20:09:12 +09:00
> .description {
margin-top: 8px;
padding-top: 8px;
border-top: solid 0.5px var(--divider);
2020-11-15 12:34:47 +09:00
}
}
}
}
</style>