1
0
mirror of https://github.com/misskey-dev/misskey synced 2024-11-25 07:37:13 +09:00

ユーザーの実績一覧を見れるように

This commit is contained in:
syuilo 2023-01-21 16:57:23 +09:00
parent 8dc0e0abbb
commit 3bf775c9a8
3 changed files with 68 additions and 6 deletions

View File

@ -15,7 +15,7 @@ import { definePageMetadata } from '@/scripts/page-metadata';
import { $i } from '@/account';
import { claimAchievement } from '@/scripts/achievements';
let timer;
let timer: number | null;
function viewAchievements3min() {
claimAchievement('viewAchievements3min');
@ -26,8 +26,10 @@ onMounted(() => {
});
onUnmounted(() => {
window.clearTimeout(timer);
timer = null;
if (timer != null) {
window.clearTimeout(timer);
timer = null;
}
});
onActivated(() => {
@ -35,8 +37,10 @@ onActivated(() => {
});
onDeactivated(() => {
window.clearTimeout(timer);
timer = null;
if (timer != null) {
window.clearTimeout(timer);
timer = null;
}
});
definePageMetadata({

View File

@ -0,0 +1,52 @@
<template>
<MkSpacer :content-max="1200">
<MkAchievements :user="user" :with-locked="false"/>
</MkSpacer>
</template>
<script lang="ts" setup>
import { onActivated, onDeactivated, onMounted, onUnmounted, ref } from 'vue';
import * as misskey from 'misskey-js';
import MkAchievements from '@/components/MkAchievements.vue';
import { i18n } from '@/i18n';
import { claimAchievement } from '@/scripts/achievements';
import { $i } from '@/account';
const props = defineProps<{
user: misskey.entities.User;
}>();
let timer: number | null;
function viewAchievements3min() {
if ($i && (props.user.id === $i.id)) {
claimAchievement('viewAchievements3min');
}
}
onMounted(() => {
if (timer == null) timer = window.setTimeout(viewAchievements3min, 1000 * 60 * 3);
});
onUnmounted(() => {
if (timer != null) {
window.clearTimeout(timer);
timer = null;
}
});
onActivated(() => {
if (timer == null) timer = window.setTimeout(viewAchievements3min, 1000 * 60 * 3);
});
onDeactivated(() => {
if (timer != null) {
window.clearTimeout(timer);
timer = null;
}
});
</script>
<style lang="scss" module>
</style>

View File

@ -6,6 +6,7 @@
<div v-if="user">
<XHome v-if="tab === 'home'" :user="user"/>
<XActivity v-else-if="tab === 'activity'" :user="user"/>
<XAchievements v-else-if="tab === 'achievements'" :user="user"/>
<XReactions v-else-if="tab === 'reactions'" :user="user"/>
<XClips v-else-if="tab === 'clips'" :user="user"/>
<XPages v-else-if="tab === 'pages'" :user="user"/>
@ -34,6 +35,7 @@ import { $i } from '@/account';
const XHome = defineAsyncComponent(() => import('./home.vue'));
const XActivity = defineAsyncComponent(() => import('./activity.vue'));
const XAchievements = defineAsyncComponent(() => import('./achievements.vue'));
const XReactions = defineAsyncComponent(() => import('./reactions.vue'));
const XClips = defineAsyncComponent(() => import('./clips.vue'));
const XPages = defineAsyncComponent(() => import('./pages.vue'));
@ -76,7 +78,11 @@ const headerTabs = $computed(() => user ? [{
key: 'activity',
title: i18n.ts.activity,
icon: 'ti ti-chart-line',
}, ...($i && ($i.id === user.id)) || user.publicReactions ? [{
}, ...(user.host == null ? [{
key: 'achievements',
title: i18n.ts.achievements,
icon: 'ti ti-military-award',
}] : []), ...($i && ($i.id === user.id)) || user.publicReactions ? [{
key: 'reactions',
title: i18n.ts.reaction,
icon: 'ti ti-mood-happy',