mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-05-21 01:45:33 +02:00
refactor(frontend): improve pagination implementation
This commit is contained in:
@@ -5,7 +5,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
<template>
|
||||
<div class="_gaps_m">
|
||||
<FormPagination ref="list" :pagination="pagination">
|
||||
<MkPagination :paginator="paginator">
|
||||
<template #empty><MkResult type="empty"/></template>
|
||||
<template #default="{items}">
|
||||
<div class="_gaps">
|
||||
@@ -44,35 +44,33 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||
</MkFolder>
|
||||
</div>
|
||||
</template>
|
||||
</FormPagination>
|
||||
</MkPagination>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, computed, useTemplateRef } from 'vue';
|
||||
import { ref, computed, markRaw } from 'vue';
|
||||
import * as Misskey from 'misskey-js';
|
||||
import FormPagination from '@/components/MkPagination.vue';
|
||||
import MkPagination from '@/components/MkPagination.vue';
|
||||
import { misskeyApi } from '@/utility/misskey-api.js';
|
||||
import { i18n } from '@/i18n.js';
|
||||
import { definePage } from '@/page.js';
|
||||
import MkKeyValue from '@/components/MkKeyValue.vue';
|
||||
import MkButton from '@/components/MkButton.vue';
|
||||
import MkFolder from '@/components/MkFolder.vue';
|
||||
import { Paginator } from '@/utility/paginator.js';
|
||||
|
||||
const list = useTemplateRef('list');
|
||||
|
||||
const pagination = {
|
||||
endpoint: 'i/apps' as const,
|
||||
const paginator = markRaw(new Paginator('i/apps', {
|
||||
limit: 100,
|
||||
noPaging: true,
|
||||
params: {
|
||||
sort: '+lastUsedAt',
|
||||
},
|
||||
};
|
||||
}));
|
||||
|
||||
function revoke(token) {
|
||||
misskeyApi('i/revoke-token', { tokenId: token.id }).then(() => {
|
||||
list.value?.paginator.reload();
|
||||
paginator.reload();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||
<MkFolder :defaultOpen="true">
|
||||
<template #label>{{ i18n.ts.manage }}</template>
|
||||
|
||||
<MkPagination :pagination="pagination" withControl>
|
||||
<MkPagination :paginator="paginator" withControl>
|
||||
<template #default="{items}">
|
||||
<div class="_gaps">
|
||||
<FormLink v-for="webhook in items" :key="webhook.id" :to="`/settings/webhook/edit/${webhook.id}`">
|
||||
@@ -61,7 +61,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed, ref, defineAsyncComponent } from 'vue';
|
||||
import { computed, ref, defineAsyncComponent, markRaw } from 'vue';
|
||||
import MkPagination from '@/components/MkPagination.vue';
|
||||
import FormSection from '@/components/form/section.vue';
|
||||
import FormLink from '@/components/form/link.vue';
|
||||
@@ -72,14 +72,14 @@ import * as os from '@/os.js';
|
||||
import { misskeyApi } from '@/utility/misskey-api.js';
|
||||
import MkButton from '@/components/MkButton.vue';
|
||||
import MkFolder from '@/components/MkFolder.vue';
|
||||
import { Paginator } from '@/utility/paginator.js';
|
||||
|
||||
const isDesktop = ref(window.innerWidth >= 1100);
|
||||
|
||||
const pagination = {
|
||||
endpoint: 'i/webhooks/list' as const,
|
||||
const paginator = markRaw(new Paginator('i/webhooks/list', {
|
||||
limit: 100,
|
||||
noPaging: true,
|
||||
};
|
||||
}));
|
||||
|
||||
async function generateToken() {
|
||||
const { dispose } = await os.popupAsyncWithDialog(import('@/components/MkTokenGenerateWindow.vue').then(x => x.default), {}, {
|
||||
|
||||
@@ -10,7 +10,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||
<option v-for="x in sortOptions" :key="x.value" :value="x.value">{{ x.displayName }}</option>
|
||||
</MkSelect>
|
||||
<div v-if="!fetching">
|
||||
<MkPagination v-slot="{items}" :pagination="pagination">
|
||||
<MkPagination v-slot="{items}" :paginator="paginator">
|
||||
<div class="_gaps">
|
||||
<div
|
||||
v-for="file in items" :key="file.id"
|
||||
@@ -48,9 +48,9 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import type { StyleValue } from 'vue';
|
||||
import { computed, markRaw, ref, watch } from 'vue';
|
||||
import tinycolor from 'tinycolor2';
|
||||
import type { StyleValue } from 'vue';
|
||||
import * as os from '@/os.js';
|
||||
import { misskeyApi } from '@/utility/misskey-api.js';
|
||||
import MkPagination from '@/components/MkPagination.vue';
|
||||
@@ -60,13 +60,13 @@ import bytes from '@/filters/bytes.js';
|
||||
import { definePage } from '@/page.js';
|
||||
import MkSelect from '@/components/MkSelect.vue';
|
||||
import { getDriveFileMenu } from '@/utility/get-drive-file-menu.js';
|
||||
import { Paginator } from '@/utility/paginator.js';
|
||||
|
||||
const sortMode = ref('+size');
|
||||
const pagination = {
|
||||
endpoint: 'drive/files' as const,
|
||||
const paginator = markRaw(new Paginator('drive/files', {
|
||||
limit: 10,
|
||||
params: computed(() => ({ sort: sortMode.value })),
|
||||
};
|
||||
computedParams: computed(() => ({ sort: sortMode.value })),
|
||||
}));
|
||||
|
||||
const sortOptions = [
|
||||
{ value: 'sizeDesc', displayName: i18n.ts._drivecleaner.orderBySizeDesc },
|
||||
|
||||
@@ -80,7 +80,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||
<template #icon><i class="ti ti-repeat-off"></i></template>
|
||||
<template #label><SearchLabel>{{ i18n.ts.mutedUsers }} ({{ i18n.ts.renote }})</SearchLabel></template>
|
||||
|
||||
<MkPagination :pagination="renoteMutingPagination" withControl>
|
||||
<MkPagination :paginator="renoteMutingPaginator" withControl>
|
||||
<template #empty><MkResult type="empty" :text="i18n.ts.noUsers"/></template>
|
||||
|
||||
<template #default="{ items }">
|
||||
@@ -111,7 +111,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||
<template #icon><i class="ti ti-eye-off"></i></template>
|
||||
<template #label>{{ i18n.ts.mutedUsers }}</template>
|
||||
|
||||
<MkPagination :pagination="mutingPagination" withControl>
|
||||
<MkPagination :paginator="mutingPaginator" withControl>
|
||||
<template #empty><MkResult type="empty" :text="i18n.ts.noUsers"/></template>
|
||||
|
||||
<template #default="{ items }">
|
||||
@@ -144,7 +144,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||
<template #icon><i class="ti ti-ban"></i></template>
|
||||
<template #label>{{ i18n.ts.blockedUsers }}</template>
|
||||
|
||||
<MkPagination :pagination="blockingPagination" withControl>
|
||||
<MkPagination :paginator="blockingPaginator" withControl>
|
||||
<template #empty><MkResult type="empty" :text="i18n.ts.noUsers"/></template>
|
||||
|
||||
<template #default="{ items }">
|
||||
@@ -174,7 +174,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, computed, watch } from 'vue';
|
||||
import { ref, computed, watch, markRaw } from 'vue';
|
||||
import XEmojiMute from './mute-block.emoji-mute.vue';
|
||||
import XInstanceMute from './mute-block.instance-mute.vue';
|
||||
import XWordMute from './mute-block.word-mute.vue';
|
||||
@@ -192,23 +192,21 @@ import MkSwitch from '@/components/MkSwitch.vue';
|
||||
import { reloadAsk } from '@/utility/reload-ask.js';
|
||||
import { prefer } from '@/preferences.js';
|
||||
import MkFeatureBanner from '@/components/MkFeatureBanner.vue';
|
||||
import { Paginator } from '@/utility/paginator.js';
|
||||
|
||||
const $i = ensureSignin();
|
||||
|
||||
const renoteMutingPagination = {
|
||||
endpoint: 'renote-mute/list' as const,
|
||||
const renoteMutingPaginator = markRaw(new Paginator('renote-mute/list', {
|
||||
limit: 10,
|
||||
};
|
||||
}));
|
||||
|
||||
const mutingPagination = {
|
||||
endpoint: 'mute/list' as const,
|
||||
const mutingPaginator = markRaw(new Paginator('mute/list', {
|
||||
limit: 10,
|
||||
};
|
||||
}));
|
||||
|
||||
const blockingPagination = {
|
||||
endpoint: 'blocking/list' as const,
|
||||
const blockingPaginator = markRaw(new Paginator('blocking/list', {
|
||||
limit: 10,
|
||||
};
|
||||
}));
|
||||
|
||||
const expandedRenoteMuteItems = ref([]);
|
||||
const expandedMuteItems = ref([]);
|
||||
|
||||
@@ -26,7 +26,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
<FormSection>
|
||||
<template #label>{{ i18n.ts.signinHistory }}</template>
|
||||
<MkPagination :pagination="pagination" disableAutoLoad withControl>
|
||||
<MkPagination :paginator="paginator" withControl>
|
||||
<template #default="{items}">
|
||||
<div>
|
||||
<div v-for="item in items" :key="item.id" v-panel class="timnmucd">
|
||||
@@ -53,7 +53,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed } from 'vue';
|
||||
import { computed, markRaw } from 'vue';
|
||||
import X2fa from './2fa.vue';
|
||||
import FormSection from '@/components/form/section.vue';
|
||||
import FormSlot from '@/components/form/slot.vue';
|
||||
@@ -64,11 +64,11 @@ import { misskeyApi } from '@/utility/misskey-api.js';
|
||||
import { i18n } from '@/i18n.js';
|
||||
import { definePage } from '@/page.js';
|
||||
import MkFeatureBanner from '@/components/MkFeatureBanner.vue';
|
||||
import { Paginator } from '@/utility/paginator.js';
|
||||
|
||||
const pagination = {
|
||||
endpoint: 'i/signin-history' as const,
|
||||
const paginator = markRaw(new Paginator('i/signin-history', {
|
||||
limit: 5,
|
||||
};
|
||||
}));
|
||||
|
||||
async function change() {
|
||||
const { canceled: canceled2, result: newPassword } = await os.inputText({
|
||||
|
||||
Reference in New Issue
Block a user