This commit is contained in:
mattyatea 2023-10-13 07:26:27 +09:00
parent 79876ab3ac
commit 120efff6c1
5 changed files with 59 additions and 21 deletions

View File

@ -4,29 +4,35 @@ SPDX-License-Identifier: AGPL-3.0-only
--> -->
<template> <template>
<div> <div>
<div v-if="game.ready" :class="$style.game"> <div v-if="game.ready" :class="$style.game">
<div :class="$style.cps" class="">{{ number(cps) }}cps</div> <div :class="$style.cps" class="">{{ number(cps) }}cps</div>
<div :class="$style.count" class=""><i class="ti ti-cookie" style="font-size: 70%;"></i> {{ number(cookies) }}</div> <div :class="$style.count" class=""><img :class="[$style.icon,{[$style.dark]:darkMode}]" alt="Cosaque daihuku"
<button v-click-anime class="_button" @click="onClick"> src="https://media.discordapp.net/attachments/1153099592863334431/1162139796647448576/AfovawbDhjHYAAAAAElFTkSuQmCC.png"/>
<img src="/client-assets/cookie.png" :class="$style.img"> {{ number(cookies) }}
</button> </div>
<button v-click-anime class="_button" @click="onClick">
<img src="https://cdn.discordapp.com/attachments/1153099592863334431/1160169965568143391/dihk_cossack.gif"
:class="$style.img">
</button>
</div>
<div v-else>
<MkLoading/>
</div>
</div> </div>
<div v-else>
<MkLoading/>
</div>
</div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { computed, onMounted, onUnmounted } from 'vue'; import {computed, onMounted, onUnmounted} from 'vue';
import MkPlusOneEffect from '@/components/MkPlusOneEffect.vue'; import MkPlusOneEffect from '@/components/MkPlusOneEffect.vue';
import * as os from '@/os.js'; import * as os from '@/os.js';
import { useInterval } from '@/scripts/use-interval.js'; import {useInterval} from '@/scripts/use-interval.js';
import * as game from '@/scripts/clicker-game.js'; import * as game from '@/scripts/clicker-game.js';
import number from '@/filters/number.js'; import number from '@/filters/number.js';
import { claimAchievement } from '@/scripts/achievements.js'; import {claimAchievement} from '@/scripts/achievements.js';
import {defaultStore} from "@/store.js";
const darkMode = computed(defaultStore.makeGetterSetter('darkMode'));
const saveData = game.saveData; const saveData = game.saveData;
const cookies = computed(() => saveData.value?.cookies); const cookies = computed(() => saveData.value?.cookies);
let cps = $ref(0); let cps = $ref(0);
@ -35,7 +41,7 @@ let prevCookies = $ref(0);
function onClick(ev: MouseEvent) { function onClick(ev: MouseEvent) {
const x = ev.clientX; const x = ev.clientX;
const y = ev.clientY; const y = ev.clientY;
os.popup(MkPlusOneEffect, { x, y }, {}, 'end'); os.popup(MkPlusOneEffect, {x, y}, {}, 'end');
saveData.value!.cookies++; saveData.value!.cookies++;
saveData.value!.totalCookies++; saveData.value!.totalCookies++;
@ -92,4 +98,16 @@ onUnmounted(() => {
.img { .img {
max-width: 90px; max-width: 90px;
} }
$color-scheme: var(--color-scheme);
.icon {
width: 1.3em;
vertical-align: -24%;
}
.dark {
filter: invert(1);
}
</style> </style>

View File

@ -17,8 +17,8 @@ import MkClickerGame from '@/components/MkClickerGame.vue';
import { definePageMetadata } from '@/scripts/page-metadata.js'; import { definePageMetadata } from '@/scripts/page-metadata.js';
definePageMetadata({ definePageMetadata({
title: '🍪👈', title: '👈',
icon: 'ti ti-cookie', icon: 'ti ti-circle',
}); });
</script> </script>

View File

@ -272,6 +272,10 @@ export const defaultStore = markRaw(new Storage('base', {
where: 'device', where: 'device',
default: true, default: true,
}, },
gamingType: {
where: 'device',
default: 'dark',
},
bannerUrl:{ bannerUrl:{
where: 'device', where: 'device',
default: bannerDark default: bannerDark
@ -442,6 +446,7 @@ export const defaultStore = markRaw(new Storage('base', {
} }
})); }));
// TODO: 他のタブと永続化されたstateを同期 // TODO: 他のタブと永続化されたstateを同期
const PREFIX = 'miux:' as const; const PREFIX = 'miux:' as const;

View File

@ -60,8 +60,8 @@ export function openInstanceMenu(ev: MouseEvent) {
}, { }, {
type: 'link', type: 'link',
to: '/clicker', to: '/clicker',
text: '🍪👈', text: '👈',
icon: 'ti ti-cookie', icon: 'ti ti-circle',
}, ($i && ($i.isAdmin || $i.policies.canManageCustomEmojis)) ? { }, ($i && ($i.isAdmin || $i.policies.canManageCustomEmojis)) ? {
type: 'link', type: 'link',
to: '/custom-emojis-manager', to: '/custom-emojis-manager',

View File

@ -5,7 +5,8 @@ SPDX-License-Identifier: AGPL-3.0-only
<template> <template>
<MkContainer :showHeader="widgetProps.showHeader" class="mkw-clicker"> <MkContainer :showHeader="widgetProps.showHeader" class="mkw-clicker">
<template #icon><i class="ti ti-cookie"></i></template> <template #icon><img :class="[$style.icon,{[$style.dark]:darkMode}]" alt="Cosaque daihuku"
src="https://media.discordapp.net/attachments/1153099592863334431/1162139796647448576/AfovawbDhjHYAAAAAElFTkSuQmCC.png"/></template>
<template #header>Clicker</template> <template #header>Clicker</template>
<MkClickerGame/> <MkClickerGame/>
</MkContainer> </MkContainer>
@ -16,7 +17,9 @@ import { useWidgetPropsManager, Widget, WidgetComponentEmits, WidgetComponentExp
import { GetFormResultType } from '@/scripts/form.js'; import { GetFormResultType } from '@/scripts/form.js';
import MkContainer from '@/components/MkContainer.vue'; import MkContainer from '@/components/MkContainer.vue';
import MkClickerGame from '@/components/MkClickerGame.vue'; import MkClickerGame from '@/components/MkClickerGame.vue';
import {computed} from "vue";
import {defaultStore} from "@/store.js";
const darkMode = computed(defaultStore.makeGetterSetter('darkMode'));
const name = 'clicker'; const name = 'clicker';
const widgetPropsDef = { const widgetPropsDef = {
@ -43,3 +46,15 @@ defineExpose<WidgetComponentExpose>({
id: props.widget ? props.widget.id : null, id: props.widget ? props.widget.id : null,
}); });
</script> </script>
<style lang="scss" module>
.icon {
width: 1.3em;
vertical-align: -24%;
}
.dark {
filter: invert(1);
}
</style>