add an achievement

This commit is contained in:
syuilo 2023-01-22 20:30:56 +09:00
parent ede96eca28
commit b906ff3fed
4 changed files with 19 additions and 1 deletions

View file

@ -1128,6 +1128,9 @@ _achievements:
_htl20npm: _htl20npm:
title: "流れるTL" title: "流れるTL"
description: "ホームタイムラインの流速が20npmを越す" description: "ホームタイムラインの流速が20npmを越す"
_viewInstanceChart:
title: "アナリスト"
description: "インスタンスのチャートを表示した"
_outputHelloWorldOnScratchpad: _outputHelloWorldOnScratchpad:
title: "Hello, world!" title: "Hello, world!"
description: "スクラッチパッドで hello world を出力した" description: "スクラッチパッドで hello world を出力した"

View file

@ -69,6 +69,7 @@ const ACHIEVEMENT_TYPES = [
'postedAt0min0sec', 'postedAt0min0sec',
'selfQuote', 'selfQuote',
'htl20npm', 'htl20npm',
'viewInstanceChart',
'outputHelloWorldOnScratchpad', 'outputHelloWorldOnScratchpad',
'open3windows', 'open3windows',
'driveFolderCircularReference', 'driveFolderCircularReference',

View file

@ -86,7 +86,7 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { ref, computed } from 'vue'; import { ref, computed, watch } from 'vue';
import XEmojis from './about.emojis.vue'; import XEmojis from './about.emojis.vue';
import XFederation from './about.federation.vue'; import XFederation from './about.federation.vue';
import { version, instanceName, host } from '@/config'; import { version, instanceName, host } from '@/config';
@ -100,6 +100,7 @@ import * as os from '@/os';
import number from '@/filters/number'; import number from '@/filters/number';
import { i18n } from '@/i18n'; import { i18n } from '@/i18n';
import { definePageMetadata } from '@/scripts/page-metadata'; import { definePageMetadata } from '@/scripts/page-metadata';
import { claimAchievement } from '@/scripts/achievements';
const props = withDefaults(defineProps<{ const props = withDefaults(defineProps<{
initialTab?: string; initialTab?: string;
@ -110,6 +111,12 @@ const props = withDefaults(defineProps<{
let stats = $ref(null); let stats = $ref(null);
let tab = $ref(props.initialTab); let tab = $ref(props.initialTab);
watch($$(tab), () => {
if (tab === 'charts') {
claimAchievement('viewInstanceChart');
}
});
const initStats = () => os.api('stats', { const initStats = () => os.api('stats', {
}).then((res) => { }).then((res) => {
stats = res; stats = res;

View file

@ -65,6 +65,7 @@ export const ACHIEVEMENT_TYPES = [
'postedAt0min0sec', 'postedAt0min0sec',
'selfQuote', 'selfQuote',
'htl20npm', 'htl20npm',
'viewInstanceChart',
'outputHelloWorldOnScratchpad', 'outputHelloWorldOnScratchpad',
'open3windows', 'open3windows',
'driveFolderCircularReference', 'driveFolderCircularReference',
@ -367,6 +368,11 @@ export const ACHIEVEMENT_BADGES = {
bg: 'linear-gradient(0deg, rgb(220 223 225), rgb(172 192 207))', bg: 'linear-gradient(0deg, rgb(220 223 225), rgb(172 192 207))',
frame: 'bronze', frame: 'bronze',
}, },
'viewInstanceChart': {
img: '/fluent-emoji/1f4ca.png',
bg: 'linear-gradient(0deg, rgb(58 231 198), rgb(37 194 255))',
frame: 'bronze',
},
'outputHelloWorldOnScratchpad': { 'outputHelloWorldOnScratchpad': {
img: '/fluent-emoji/1f530.png', img: '/fluent-emoji/1f530.png',
bg: 'linear-gradient(0deg, rgb(58 231 198), rgb(37 194 255))', bg: 'linear-gradient(0deg, rgb(58 231 198), rgb(37 194 255))',
@ -448,6 +454,7 @@ export const claimedAchievements: typeof ACHIEVEMENT_TYPES[number][] = ($i && $i
const claimingQueue = new Set<string>(); const claimingQueue = new Set<string>();
export async function claimAchievement(type: typeof ACHIEVEMENT_TYPES[number]) { export async function claimAchievement(type: typeof ACHIEVEMENT_TYPES[number]) {
if ($i == null) return;
if (claimedAchievements.includes(type)) return; if (claimedAchievements.includes(type)) return;
claimingQueue.add(type); claimingQueue.add(type);
claimedAchievements.push(type); claimedAchievements.push(type);