InboxMail.vue
4.4 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
<script setup lang="ts">
import type { Mail } from '~/types'
defineProps<{
mail: Mail
}>()
const emits = defineEmits(['close'])
const { locale, t } = useAppI18n()
const dropdownItems = computed(() => [[{
label: t('inbox.actions.markAsUnread'),
icon: 'i-lucide-check-circle'
}, {
label: t('inbox.actions.markAsImportant'),
icon: 'i-lucide-triangle-alert'
}], [{
label: t('inbox.actions.starThread'),
icon: 'i-lucide-star'
}, {
label: t('inbox.actions.muteThread'),
icon: 'i-lucide-circle-pause'
}]])
const toast = useToast()
const reply = ref('')
const loading = ref(false)
const dateFormatter = computed(() => {
return new Intl.DateTimeFormat(locale.value === 'zh-CN' ? 'zh-CN' : 'en-US', {
day: '2-digit',
month: 'short',
hour: '2-digit',
minute: '2-digit',
hour12: false
})
})
function onSubmit() {
loading.value = true
setTimeout(() => {
reply.value = ''
toast.add({
title: t('inbox.toast.sentTitle'),
description: t('inbox.toast.sentDescription'),
icon: 'i-lucide-check-circle',
color: 'success'
})
loading.value = false
}, 1000)
}
</script>
<template>
<UDashboardPanel id="inbox-2">
<UDashboardNavbar :title="mail.subject" :toggle="false">
<template #leading>
<UButton
icon="i-lucide-x"
color="neutral"
variant="ghost"
class="-ms-1.5"
@click="emits('close')"
/>
</template>
<template #right>
<UTooltip :text="t('inbox.actions.archive')">
<UButton
icon="i-lucide-inbox"
color="neutral"
variant="ghost"
/>
</UTooltip>
<UTooltip :text="t('inbox.actions.reply')">
<UButton icon="i-lucide-reply" color="neutral" variant="ghost" />
</UTooltip>
<UDropdownMenu :items="dropdownItems">
<UButton
icon="i-lucide-ellipsis-vertical"
color="neutral"
variant="ghost"
/>
</UDropdownMenu>
</template>
</UDashboardNavbar>
<div class="flex flex-col sm:flex-row justify-between gap-1 p-4 sm:px-6 border-b border-default">
<div class="flex items-start gap-4 sm:my-1.5">
<UAvatar
v-bind="mail.from.avatar"
:alt="mail.from.name"
size="3xl"
/>
<div class="min-w-0">
<p class="font-semibold text-highlighted">
{{ mail.from.name }}
</p>
<p class="text-muted">
{{ mail.from.email }}
</p>
</div>
</div>
<p class="max-sm:pl-16 text-muted text-sm sm:mt-2">
{{ dateFormatter.format(new Date(mail.date)) }}
</p>
</div>
<div class="flex-1 p-4 sm:p-6 overflow-y-auto">
<p class="whitespace-pre-wrap">
{{ mail.body }}
</p>
</div>
<div class="pb-4 px-4 sm:px-6 shrink-0">
<UCard variant="subtle" class="mt-auto" :ui="{ header: 'flex items-center gap-1.5 text-dimmed' }">
<template #header>
<UIcon name="i-lucide-reply" class="size-5" />
<span class="text-sm truncate">
{{ t('inbox.compose.replyTo', { name: mail.from.name, email: mail.from.email }) }}
</span>
</template>
<form @submit.prevent="onSubmit">
<UTextarea
v-model="reply"
color="neutral"
variant="none"
required
autoresize
:placeholder="t('inbox.compose.placeholder')"
:rows="4"
:disabled="loading"
class="w-full"
:ui="{ base: 'p-0 resize-none' }"
/>
<div class="flex items-center justify-between">
<UTooltip :text="t('inbox.actions.attachFile')">
<UButton
color="neutral"
variant="ghost"
icon="i-lucide-paperclip"
/>
</UTooltip>
<div class="flex items-center justify-end gap-2">
<UButton
color="neutral"
variant="ghost"
:label="t('common.saveDraft')"
/>
<UButton
type="submit"
color="neutral"
:loading="loading"
:label="t('common.send')"
icon="i-lucide-send"
/>
</div>
</div>
</form>
</UCard>
</div>
</UDashboardPanel>
</template>