-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
print.vue
65 lines (60 loc) · 1.62 KB
/
print.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<script setup lang="ts">
import { computed } from 'vue'
import { useStyleTag } from '@vueuse/core'
import { useHead } from '@unhead/vue'
import { configs, themeVars } from '../../env'
import { rawRoutes, total } from '../../logic/nav'
import NoteDisplay from '../../internals/NoteDisplay.vue'
useStyleTag(`
@page {
size: A4;
margin-top: 1.5cm;
margin-bottom: 1cm;
}
* {
-webkit-print-color-adjust: exact;
}
html,
html body,
html #app,
html #page-root {
height: auto;
overflow: auto !important;
}
`)
useHead({
title: `Notes - ${configs.title}`,
})
const slidesWithNote = computed(() => rawRoutes
.map(route => route.meta?.slide)
.filter(slide => slide !== undefined && slide.noteHTML !== ''))
</script>
<template>
<div id="page-root" :style="themeVars">
<div class="m-4">
<div class="mb-10">
<h1 class="text-4xl font-bold mt-2">
{{ configs.title }}
</h1>
<div class="opacity-50">
{{ new Date().toLocaleString() }}
</div>
</div>
<div v-for="(slide, index) of slidesWithNote" :key="index" class="flex flex-col gap-4 break-inside-avoid-page">
<div>
<h2 class="text-lg">
<div class="font-bold flex gap-2">
<div class="opacity-50">
{{ slide?.no }}/{{ total }}
</div>
{{ slide?.title }}
<div class="flex-auto" />
</div>
</h2>
<NoteDisplay :note-html="slide!.noteHTML" class="max-w-full" />
</div>
<hr v-if="index < slidesWithNote.length - 1" class="border-gray-400/50 mb-8">
</div>
</div>
</div>
</template>