mirror of
https://iceshrimp.dev/limepotato/jormungandr-bite.git
synced 2024-11-29 21:37:34 -07:00
feat: ✨ Swiper in notifs
This commit is contained in:
parent
d828274b74
commit
8c4061f375
3 changed files with 38 additions and 20 deletions
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "calckey",
|
"name": "calckey",
|
||||||
"version": "12.118.1-calc.2-beta.2-rc.12",
|
"version": "12.118.1-calc.2-beta.2-rc.13",
|
||||||
"codename": "aqua",
|
"codename": "aqua",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
|
|
@ -9,15 +9,25 @@
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
<MkSpacer :content-max="800">
|
<MkSpacer :content-max="800">
|
||||||
<div v-if="tab === 'all' || tab === 'unread'">
|
<swiper
|
||||||
<XNotifications class="notifications" :include-types="includeTypes" :unread-only="unreadOnly"/>
|
:modules="[Virtual]"
|
||||||
</div>
|
:space-between="20"
|
||||||
<div v-else-if="tab === 'mentions'">
|
:virtual="true"
|
||||||
|
@swiper="setSwiperRef"
|
||||||
|
>
|
||||||
|
<swiper-slide>
|
||||||
|
<XNotifications class="notifications" :include-types="includeTypes" :unread-only="false"/>
|
||||||
|
</swiper-slide>
|
||||||
|
<swiper-slide>
|
||||||
|
<XNotifications class="notifications" :include-types="includeTypes" :unread-only="true"/>
|
||||||
|
</swiper-slide>
|
||||||
|
<swiper-slide>
|
||||||
<XNotes :pagination="mentionsPagination"/>
|
<XNotes :pagination="mentionsPagination"/>
|
||||||
</div>
|
</swiper-slide>
|
||||||
<div v-else-if="tab === 'directNotes'">
|
<swiper-slide>
|
||||||
<XNotes :pagination="directNotesPagination"/>
|
<XNotes :pagination="directNotesPagination"/>
|
||||||
</div>
|
</swiper-slide>
|
||||||
|
</swiper>
|
||||||
</MkSpacer>
|
</MkSpacer>
|
||||||
</MkStickyContainer>
|
</MkStickyContainer>
|
||||||
</template>
|
</template>
|
||||||
|
@ -25,13 +35,16 @@
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed, ref } from 'vue';
|
import { computed, ref } from 'vue';
|
||||||
import { notificationTypes } from 'misskey-js';
|
import { notificationTypes } from 'misskey-js';
|
||||||
|
import { Virtual } from 'swiper';
|
||||||
|
import { Swiper, SwiperSlide } from 'swiper/vue';
|
||||||
import XNotifications from '@/components/MkNotifications.vue';
|
import XNotifications from '@/components/MkNotifications.vue';
|
||||||
import XNotes from '@/components/MkNotes.vue';
|
import XNotes from '@/components/MkNotes.vue';
|
||||||
import * as os from '@/os';
|
import * as os from '@/os';
|
||||||
import { i18n } from '@/i18n';
|
import { i18n } from '@/i18n';
|
||||||
import { definePageMetadata } from '@/scripts/page-metadata';
|
import { definePageMetadata } from '@/scripts/page-metadata';
|
||||||
import { deviceKind } from '@/scripts/device-kind';
|
import { deviceKind } from '@/scripts/device-kind';
|
||||||
|
import 'swiper/scss';
|
||||||
|
import 'swiper/scss/virtual';
|
||||||
let tab = $ref('all');
|
let tab = $ref('all');
|
||||||
let includeTypes = $ref<string[] | null>(null);
|
let includeTypes = $ref<string[] | null>(null);
|
||||||
let unreadOnly = $computed(() => tab === 'unread');
|
let unreadOnly = $computed(() => tab === 'unread');
|
||||||
|
@ -39,7 +52,7 @@ os.api('notifications/mark-all-as-read');
|
||||||
|
|
||||||
const MOBILE_THRESHOLD = 500;
|
const MOBILE_THRESHOLD = 500;
|
||||||
const isMobile = ref(
|
const isMobile = ref(
|
||||||
deviceKind === 'smartphone' || window.innerWidth <= MOBILE_THRESHOLD
|
deviceKind === 'smartphone' || window.innerWidth <= MOBILE_THRESHOLD,
|
||||||
);
|
);
|
||||||
window.addEventListener('resize', () => {
|
window.addEventListener('resize', () => {
|
||||||
isMobile.value =
|
isMobile.value =
|
||||||
|
@ -112,6 +125,16 @@ const headerTabs = $computed(() => [{
|
||||||
iconOnly: true,
|
iconOnly: true,
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
|
let swiperRef = null;
|
||||||
|
|
||||||
|
function setSwiperRef(swiper) {
|
||||||
|
swiperRef = swiper;
|
||||||
|
}
|
||||||
|
|
||||||
|
function syncSlide(index) {
|
||||||
|
swiperRef.slideTo(index);
|
||||||
|
}
|
||||||
|
|
||||||
definePageMetadata(computed(() => ({
|
definePageMetadata(computed(() => ({
|
||||||
title: i18n.ts.notifications,
|
title: i18n.ts.notifications,
|
||||||
icon: 'fas fa-bell',
|
icon: 'fas fa-bell',
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
</div> *v-else on next div* -->
|
</div> *v-else on next div* -->
|
||||||
<div class="tl _block">
|
<div class="tl _block">
|
||||||
<swiper
|
<swiper
|
||||||
:modules="[Pagination, Virtual]"
|
:modules="[Virtual]"
|
||||||
:space-between="20"
|
:space-between="20"
|
||||||
:virtual="true"
|
:virtual="true"
|
||||||
@swiper="setSwiperRef"
|
@swiper="setSwiperRef"
|
||||||
|
@ -66,7 +66,7 @@
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { defineAsyncComponent, computed, watch, ref } from 'vue';
|
import { defineAsyncComponent, computed, watch, ref } from 'vue';
|
||||||
import { Pagination, Virtual } from 'swiper';
|
import { Virtual } from 'swiper';
|
||||||
import { Swiper, SwiperSlide } from 'swiper/vue';
|
import { Swiper, SwiperSlide } from 'swiper/vue';
|
||||||
import XTimeline from '@/components/MkTimeline.vue';
|
import XTimeline from '@/components/MkTimeline.vue';
|
||||||
import XPostForm from '@/components/MkPostForm.vue';
|
import XPostForm from '@/components/MkPostForm.vue';
|
||||||
|
@ -79,7 +79,6 @@ import { $i } from '@/account';
|
||||||
import { definePageMetadata } from '@/scripts/page-metadata';
|
import { definePageMetadata } from '@/scripts/page-metadata';
|
||||||
import { deviceKind } from '@/scripts/device-kind';
|
import { deviceKind } from '@/scripts/device-kind';
|
||||||
import 'swiper/scss';
|
import 'swiper/scss';
|
||||||
import 'swiper/scss/pagination';
|
|
||||||
import 'swiper/scss/virtual';
|
import 'swiper/scss/virtual';
|
||||||
|
|
||||||
const XTutorial = defineAsyncComponent(() => import('./timeline.tutorial.vue'));
|
const XTutorial = defineAsyncComponent(() => import('./timeline.tutorial.vue'));
|
||||||
|
@ -128,11 +127,7 @@ const rootEl = $ref<HTMLElement>();
|
||||||
|
|
||||||
let queue = $ref(0);
|
let queue = $ref(0);
|
||||||
const src = $computed({
|
const src = $computed({
|
||||||
get: () => {
|
get: () => defaultStore.reactiveState.tl.value.src,
|
||||||
const lastSrc = defaultStore.reactiveState.tl.value.src;
|
|
||||||
syncSlide(timelines.indexOf(lastSrc));
|
|
||||||
return lastSrc;
|
|
||||||
},
|
|
||||||
set: (x) => {
|
set: (x) => {
|
||||||
saveSrc(x);
|
saveSrc(x);
|
||||||
syncSlide(timelines.indexOf(x));
|
syncSlide(timelines.indexOf(x));
|
||||||
|
|
Loading…
Reference in a new issue