mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-26 02:13:09 +02:00
c1019a006b
* (add) 横スワイプでタブを切り替える機能 * Change Changelog * y方向の移動が一定量を超えたらスワイプを中断するように * Update swipe distance thresholds * Remove console.log * adjust threshold * rename, use v-model * fix * Update MkHorizontalSwipe.vue Co-authored-by: syuilo <Syuilotan@yahoo.co.jp> * use css module --------- Co-authored-by: syuilo <Syuilotan@yahoo.co.jp>
119 lines
2.9 KiB
Vue
119 lines
2.9 KiB
Vue
<!--
|
|
SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
-->
|
|
|
|
<template>
|
|
<MkStickyContainer>
|
|
<template #header><MkPageHeader v-model:tab="tab" :actions="headerActions" :tabs="headerTabs"/></template>
|
|
<MkSpacer :contentMax="700">
|
|
<MkHorizontalSwipe v-model:tab="tab" :tabs="headerTabs">
|
|
<div v-if="tab === 'my'" key="my" class="_gaps">
|
|
<MkButton primary rounded class="add" @click="create"><i class="ti ti-plus"></i> {{ i18n.ts.add }}</MkButton>
|
|
|
|
<MkPagination v-slot="{items}" ref="pagingComponent" :pagination="pagination" class="_gaps">
|
|
<MkA v-for="item in items" :key="item.id" :to="`/clips/${item.id}`">
|
|
<MkClipPreview :clip="item"/>
|
|
</MkA>
|
|
</MkPagination>
|
|
</div>
|
|
<div v-else-if="tab === 'favorites'" key="favorites" class="_gaps">
|
|
<MkA v-for="item in favorites" :key="item.id" :to="`/clips/${item.id}`">
|
|
<MkClipPreview :clip="item"/>
|
|
</MkA>
|
|
</div>
|
|
</MkHorizontalSwipe>
|
|
</MkSpacer>
|
|
</MkStickyContainer>
|
|
</template>
|
|
|
|
<script lang="ts" setup>
|
|
import { watch, ref, shallowRef, computed } from 'vue';
|
|
import * as Misskey from 'misskey-js';
|
|
import MkPagination from '@/components/MkPagination.vue';
|
|
import MkButton from '@/components/MkButton.vue';
|
|
import MkClipPreview from '@/components/MkClipPreview.vue';
|
|
import * as os from '@/os.js';
|
|
import { misskeyApi } from '@/scripts/misskey-api.js';
|
|
import { i18n } from '@/i18n.js';
|
|
import { definePageMetadata } from '@/scripts/page-metadata.js';
|
|
import { clipsCache } from '@/cache.js';
|
|
import MkHorizontalSwipe from '@/components/MkHorizontalSwipe.vue';
|
|
|
|
const pagination = {
|
|
endpoint: 'clips/list' as const,
|
|
noPaging: true,
|
|
limit: 10,
|
|
};
|
|
|
|
const tab = ref('my');
|
|
|
|
const favorites = ref<Misskey.entities.Clip[] | null>(null);
|
|
|
|
const pagingComponent = shallowRef<InstanceType<typeof MkPagination>>();
|
|
|
|
watch(tab, async () => {
|
|
favorites.value = await misskeyApi('clips/my-favorites');
|
|
});
|
|
|
|
async function create() {
|
|
const { canceled, result } = await os.form(i18n.ts.createNewClip, {
|
|
name: {
|
|
type: 'string',
|
|
label: i18n.ts.name,
|
|
},
|
|
description: {
|
|
type: 'string',
|
|
required: false,
|
|
multiline: true,
|
|
treatAsMfm: true,
|
|
label: i18n.ts.description,
|
|
},
|
|
isPublic: {
|
|
type: 'boolean',
|
|
label: i18n.ts.public,
|
|
default: false,
|
|
},
|
|
});
|
|
if (canceled) return;
|
|
|
|
os.apiWithDialog('clips/create', result);
|
|
|
|
clipsCache.delete();
|
|
|
|
pagingComponent.value.reload();
|
|
}
|
|
|
|
function onClipCreated() {
|
|
pagingComponent.value.reload();
|
|
}
|
|
|
|
function onClipDeleted() {
|
|
pagingComponent.value.reload();
|
|
}
|
|
|
|
const headerActions = computed(() => []);
|
|
|
|
const headerTabs = computed(() => [{
|
|
key: 'my',
|
|
title: i18n.ts.myClips,
|
|
icon: 'ti ti-paperclip',
|
|
}, {
|
|
key: 'favorites',
|
|
title: i18n.ts.favorites,
|
|
icon: 'ti ti-heart',
|
|
}]);
|
|
|
|
definePageMetadata({
|
|
title: i18n.ts.clip,
|
|
icon: 'ti ti-paperclip',
|
|
action: {
|
|
icon: 'ti ti-plus',
|
|
handler: create,
|
|
},
|
|
});
|
|
</script>
|
|
|
|
<style lang="scss" module>
|
|
|
|
</style>
|