mirror of
https://codeberg.org/yeentown/barkey.git
synced 2025-10-25 18:54:52 +00:00
# Conflicts: # .github/workflows/api-misskey-js.yml # .github/workflows/changelog-check.yml # .github/workflows/check-misskey-js-autogen.yml # .github/workflows/get-api-diff.yml # .github/workflows/lint.yml # .github/workflows/locale.yml # .github/workflows/on-release-created.yml # .github/workflows/storybook.yml # .github/workflows/test-backend.yml # .github/workflows/test-federation.yml # .github/workflows/test-frontend.yml # .github/workflows/test-misskey-js.yml # .github/workflows/test-production.yml # .github/workflows/validate-api-json.yml # package.json # packages/backend/package.json # packages/backend/src/server/api/ApiCallService.ts # packages/backend/src/server/api/endpoints/drive/files/create.ts # packages/frontend-shared/js/url.ts # packages/frontend/package.json # packages/frontend/src/components/MkFileCaptionEditWindow.vue # packages/frontend/src/components/MkInfo.vue # packages/frontend/src/components/MkLink.vue # packages/frontend/src/components/MkNote.vue # packages/frontend/src/components/MkNotes.vue # packages/frontend/src/components/MkPageWindow.vue # packages/frontend/src/components/MkReactionsViewer.vue # packages/frontend/src/components/MkTimeline.vue # packages/frontend/src/components/MkUrlPreview.vue # packages/frontend/src/components/MkUserPopup.vue # packages/frontend/src/components/global/MkPageHeader.vue # packages/frontend/src/components/global/MkUrl.vue # packages/frontend/src/components/global/PageWithHeader.vue # packages/frontend/src/pages/about-misskey.vue # packages/frontend/src/pages/announcements.vue # packages/frontend/src/pages/antenna-timeline.vue # packages/frontend/src/pages/channel.vue # packages/frontend/src/pages/instance-info.vue # packages/frontend/src/pages/note.vue # packages/frontend/src/pages/page.vue # packages/frontend/src/pages/role.vue # packages/frontend/src/pages/tag.vue # packages/frontend/src/pages/timeline.vue # packages/frontend/src/pages/user-list-timeline.vue # packages/frontend/src/pages/user/followers.vue # packages/frontend/src/pages/user/following.vue # packages/frontend/src/pages/user/home.vue # packages/frontend/src/pages/user/index.vue # packages/frontend/src/ui/deck.vue # packages/misskey-js/generator/package.json # pnpm-lock.yaml # scripts/changelog-checker/package-lock.json # scripts/changelog-checker/package.json
118 lines
3.5 KiB
Vue
118 lines
3.5 KiB
Vue
<!--
|
|
SPDX-FileCopyrightText: syuilo and misskey-project
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
-->
|
|
|
|
<template>
|
|
<PageWithHeader>
|
|
<div v-if="!instance.disableRegistration || !($i && ($i.isAdmin || $i.policies.canInvite))" class="_spacer" style="--MI_SPACER-w: 1200px;">
|
|
<div :class="$style.root">
|
|
<img :class="$style.img" :src="serverErrorImageUrl" draggable="false"/>
|
|
<div :class="$style.text">
|
|
<i class="ti ti-alert-triangle"></i>
|
|
{{ i18n.ts.nothing }}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div v-else class="_spacer" style="--MI_SPACER-w: 800px;">
|
|
<div class="_gaps_m" style="text-align: center;">
|
|
<div v-if="resetCycle && inviteLimit">{{ i18n.tsx.inviteLimitResetCycle({ time: resetCycle, limit: inviteLimit }) }}</div>
|
|
<MkButton inline primary rounded :disabled="currentInviteLimit !== null && currentInviteLimit <= 0" @click="create"><i class="ti ti-user-plus"></i> {{ i18n.ts.createInviteCode }}</MkButton>
|
|
<div v-if="currentInviteLimit !== null">{{ i18n.tsx.createLimitRemaining({ limit: currentInviteLimit }) }}</div>
|
|
|
|
<MkPagination ref="pagingComponent" :pagination="pagination">
|
|
<template #default="{ items }">
|
|
<div class="_gaps_s">
|
|
<MkInviteCode v-for="item in (items as Misskey.entities.InviteCode[])" :key="item.id" :invite="item" :onDeleted="deleted"/>
|
|
</div>
|
|
</template>
|
|
</MkPagination>
|
|
</div>
|
|
</div>
|
|
</PageWithHeader>
|
|
</template>
|
|
|
|
<script lang="ts" setup>
|
|
import { computed, ref, useTemplateRef } from 'vue';
|
|
import * as Misskey from 'misskey-js';
|
|
import type { Paging } from '@/components/MkPagination.vue';
|
|
import { i18n } from '@/i18n.js';
|
|
import * as os from '@/os.js';
|
|
import { misskeyApi } from '@/utility/misskey-api.js';
|
|
import MkButton from '@/components/MkButton.vue';
|
|
import MkPagination from '@/components/MkPagination.vue';
|
|
import MkInviteCode from '@/components/MkInviteCode.vue';
|
|
import { definePage } from '@/page.js';
|
|
import { serverErrorImageUrl, instance } from '@/instance.js';
|
|
import { $i } from '@/i.js';
|
|
|
|
const pagingComponent = useTemplateRef('pagingComponent');
|
|
const currentInviteLimit = ref<null | number>(null);
|
|
const inviteLimit = (($i != null && $i.policies.inviteLimit) || (($i == null && instance.policies.inviteLimit))) as number;
|
|
const inviteLimitCycle = (($i != null && $i.policies.inviteLimitCycle) || ($i == null && instance.policies.inviteLimitCycle)) as number;
|
|
|
|
const pagination: Paging = {
|
|
endpoint: 'invite/list' as const,
|
|
limit: 10,
|
|
};
|
|
|
|
const resetCycle = computed<null | string>(() => {
|
|
if (!inviteLimitCycle) return null;
|
|
|
|
const minutes = inviteLimitCycle;
|
|
if (minutes < 60) return minutes + i18n.ts._time.minute;
|
|
const hours = Math.floor(minutes / 60);
|
|
if (hours < 24) return hours + i18n.ts._time.hour;
|
|
return Math.floor(hours / 24) + i18n.ts._time.day;
|
|
});
|
|
|
|
async function create() {
|
|
const ticket = await misskeyApi('invite/create');
|
|
os.alert({
|
|
type: 'success',
|
|
title: i18n.ts.inviteCodeCreated,
|
|
text: ticket.code,
|
|
});
|
|
|
|
pagingComponent.value?.prepend(ticket);
|
|
update();
|
|
}
|
|
|
|
function deleted(id: string) {
|
|
if (pagingComponent.value) {
|
|
pagingComponent.value.items.delete(id);
|
|
}
|
|
update();
|
|
}
|
|
|
|
async function update() {
|
|
currentInviteLimit.value = (await misskeyApi('invite/limit')).remaining;
|
|
}
|
|
|
|
update();
|
|
|
|
definePage(() => ({
|
|
title: i18n.ts.invite,
|
|
icon: 'ti ti-user-plus',
|
|
}));
|
|
</script>
|
|
|
|
<style lang="scss" module>
|
|
.root {
|
|
padding: 32px;
|
|
text-align: center;
|
|
align-items: center;
|
|
}
|
|
|
|
.text {
|
|
margin: 0 0 8px 0;
|
|
}
|
|
|
|
.img {
|
|
vertical-align: bottom;
|
|
width: 128px;
|
|
height: 128px;
|
|
margin-bottom: 16px;
|
|
border-radius: var(--MI-radius-md);
|
|
}
|
|
</style>
|