2025-12-05 02:12:33 +00:00
|
|
|
<!-- eslint-disable vue/multi-word-component-names -->
|
2023-09-07 00:41:38 +00:00
|
|
|
<template>
|
2025-12-05 02:12:33 +00:00
|
|
|
<MultiModal @handle="on_modal_handle" />
|
2023-09-07 00:41:38 +00:00
|
|
|
|
2025-12-05 02:12:33 +00:00
|
|
|
<BulmaToast @handle="on_toast_handle" class="content">
|
2023-11-11 01:22:30 +00:00
|
|
|
<p>
|
|
|
|
|
Du hast noch keine Türchen geöffnet, vielleicht gibt es ein Anzeigeproblem
|
|
|
|
|
in Deinem Webbrowser?
|
|
|
|
|
</p>
|
|
|
|
|
<div class="level">
|
|
|
|
|
<div class="level-item">
|
|
|
|
|
<BulmaButton
|
|
|
|
|
class="is-success"
|
|
|
|
|
text="Türchen anzeigen"
|
|
|
|
|
@click.left="
|
|
|
|
|
store.is_touch_device = true;
|
|
|
|
|
toast?.hide();
|
|
|
|
|
"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="level-item">
|
|
|
|
|
<BulmaButton
|
|
|
|
|
class="is-danger"
|
|
|
|
|
text="Ich möchte selbst suchen"
|
|
|
|
|
@click.left="toast?.hide()"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</BulmaToast>
|
|
|
|
|
|
2023-09-09 23:52:58 +00:00
|
|
|
<figure>
|
|
|
|
|
<div class="image is-unselectable">
|
2025-12-05 02:12:33 +00:00
|
|
|
<img :src="ensure_loaded(store.background_image).data_url" />
|
2023-09-09 23:52:58 +00:00
|
|
|
<ThouCanvas>
|
|
|
|
|
<CalendarDoor
|
|
|
|
|
v-for="(door, index) in doors"
|
|
|
|
|
:key="`door-${index}`"
|
|
|
|
|
:door="door"
|
2023-11-01 23:58:09 +00:00
|
|
|
:visible="store.is_touch_device"
|
2025-12-05 02:12:33 +00:00
|
|
|
:title="name_door(door.day)"
|
2023-10-27 15:37:21 +00:00
|
|
|
@click="door_click(door.day)"
|
2023-11-21 22:33:11 +00:00
|
|
|
style="cursor: pointer"
|
2023-09-09 23:52:58 +00:00
|
|
|
/>
|
|
|
|
|
</ThouCanvas>
|
|
|
|
|
</div>
|
2023-09-09 23:08:43 +00:00
|
|
|
</figure>
|
2023-09-07 00:41:38 +00:00
|
|
|
</template>
|
|
|
|
|
|
2025-11-30 18:09:08 +00:00
|
|
|
<script setup lang="ts">
|
2024-08-26 14:14:07 +00:00
|
|
|
import { API } from "@/lib/api";
|
|
|
|
|
import { APIError } from "@/lib/api_error";
|
2025-12-05 02:12:33 +00:00
|
|
|
import { ensure_loaded, name_door } from "@/lib/helpers";
|
2024-08-26 14:14:07 +00:00
|
|
|
import { ImageData } from "@/lib/model";
|
2025-12-07 03:28:00 +00:00
|
|
|
import { VueDoor } from "@/lib/rects/door";
|
2024-08-23 16:38:04 +00:00
|
|
|
import { advent22Store } from "@/lib/store";
|
2023-09-07 00:41:38 +00:00
|
|
|
|
2025-12-05 02:12:33 +00:00
|
|
|
import { onBeforeUnmount } from "vue";
|
|
|
|
|
import MultiModal, { HMultiModal } from "./MultiModal.vue";
|
2023-10-27 14:40:25 +00:00
|
|
|
import BulmaButton from "./bulma/Button.vue";
|
2025-12-05 02:12:33 +00:00
|
|
|
import BulmaToast, { HBulmaToast } from "./bulma/Toast.vue";
|
2023-09-07 02:08:56 +00:00
|
|
|
import CalendarDoor from "./calendar/CalendarDoor.vue";
|
|
|
|
|
import ThouCanvas from "./calendar/ThouCanvas.vue";
|
2023-09-07 00:41:38 +00:00
|
|
|
|
2025-12-05 02:12:33 +00:00
|
|
|
defineProps<{
|
2025-12-07 03:28:00 +00:00
|
|
|
doors: VueDoor[];
|
2025-12-05 02:12:33 +00:00
|
|
|
}>();
|
2023-09-07 00:41:38 +00:00
|
|
|
|
2025-12-05 02:12:33 +00:00
|
|
|
const store = advent22Store();
|
2023-11-11 01:22:30 +00:00
|
|
|
|
2025-12-05 02:12:33 +00:00
|
|
|
let modal: HMultiModal | undefined;
|
|
|
|
|
let toast: HBulmaToast | undefined;
|
|
|
|
|
let toast_timeout: number | undefined;
|
2023-11-11 01:22:30 +00:00
|
|
|
|
2025-12-05 02:12:33 +00:00
|
|
|
function on_modal_handle(handle: HMultiModal) {
|
|
|
|
|
modal = handle;
|
|
|
|
|
}
|
2023-11-11 01:22:30 +00:00
|
|
|
|
2025-12-05 02:12:33 +00:00
|
|
|
function on_toast_handle(handle: HBulmaToast) {
|
|
|
|
|
toast = handle;
|
2023-11-11 01:22:30 +00:00
|
|
|
|
2025-12-05 02:12:33 +00:00
|
|
|
if (store.is_touch_device) return;
|
2023-11-11 01:22:30 +00:00
|
|
|
|
2025-12-05 02:12:33 +00:00
|
|
|
store.when_initialized(() => {
|
2025-12-07 03:28:00 +00:00
|
|
|
toast_timeout = window.setTimeout(() => {
|
2025-12-05 02:12:33 +00:00
|
|
|
if (store.user_doors.length === 0) return;
|
|
|
|
|
if (store.is_touch_device) return;
|
2023-09-07 00:41:38 +00:00
|
|
|
|
2025-12-05 02:12:33 +00:00
|
|
|
toast!.show({ duration: 600000, type: "is-warning" });
|
|
|
|
|
}, 10e3);
|
|
|
|
|
});
|
|
|
|
|
}
|
2023-11-11 01:47:54 +00:00
|
|
|
|
2025-12-05 02:12:33 +00:00
|
|
|
async function door_click(day: number) {
|
2025-12-07 03:28:00 +00:00
|
|
|
window.clearTimeout(toast_timeout);
|
2025-12-05 02:12:33 +00:00
|
|
|
toast?.hide();
|
2024-08-26 14:14:07 +00:00
|
|
|
|
2025-12-05 02:12:33 +00:00
|
|
|
if (modal === undefined) return;
|
|
|
|
|
modal.show_loading();
|
2024-08-26 14:14:07 +00:00
|
|
|
|
2025-12-05 02:12:33 +00:00
|
|
|
try {
|
|
|
|
|
const day_image = await API.request<ImageData>(`user/image_${day}`);
|
|
|
|
|
modal.show_image(day_image.data_url, name_door(day));
|
|
|
|
|
} catch (error) {
|
|
|
|
|
APIError.alert(error);
|
|
|
|
|
modal.hide();
|
2024-08-26 14:14:07 +00:00
|
|
|
}
|
2023-09-07 00:41:38 +00:00
|
|
|
}
|
2025-12-05 02:12:33 +00:00
|
|
|
|
|
|
|
|
onBeforeUnmount(() => toast?.hide());
|
2023-09-07 00:41:38 +00:00
|
|
|
</script>
|