mirror of
https://github.com/dreamhunter2333/cloudflare_temp_email.git
synced 2026-09-04 23:17:34 +08:00
feat: ui (#79)
This commit is contained in:
+123
-37
@@ -1,7 +1,8 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { NSpace, NAlert, NSwitch, NCard, NInput, NInputGroupLabel } from 'naive-ui'
|
import { NSpace, NAlert, NSwitch, NCard, NInput, NInputGroupLabel } from 'naive-ui'
|
||||||
import { NButton, NLayout, NInputGroup, NModal, NSelect, NPagination } from 'naive-ui'
|
import { NButton, NLayout, NInputGroup, NModal, NSelect, NPagination } from 'naive-ui'
|
||||||
import { NList, NListItem, NThing, NTag, NIcon } from 'naive-ui'
|
import { NList, NListItem, NThing, NTag, NIcon, NSplit } from 'naive-ui'
|
||||||
|
import { NDrawer, NDrawerContent } from 'naive-ui'
|
||||||
import { watch, onMounted, ref } from "vue";
|
import { watch, onMounted, ref } from "vue";
|
||||||
import useClipboard from 'vue-clipboard3'
|
import useClipboard from 'vue-clipboard3'
|
||||||
import { useMessage } from 'naive-ui'
|
import { useMessage } from 'naive-ui'
|
||||||
@@ -9,9 +10,11 @@ import { useI18n } from 'vue-i18n'
|
|||||||
import { useGlobalState } from '../store'
|
import { useGlobalState } from '../store'
|
||||||
import { api } from '../api'
|
import { api } from '../api'
|
||||||
import { CloudDownloadRound } from '@vicons/material'
|
import { CloudDownloadRound } from '@vicons/material'
|
||||||
|
import { useIsMobile } from '../utils/composables'
|
||||||
|
|
||||||
const { toClipboard } = useClipboard()
|
const { toClipboard } = useClipboard()
|
||||||
const message = useMessage()
|
const message = useMessage()
|
||||||
|
const isMobile = useIsMobile()
|
||||||
|
|
||||||
const { jwt, settings, openSettings } = useGlobalState()
|
const { jwt, settings, openSettings } = useGlobalState()
|
||||||
const autoRefresh = ref(false)
|
const autoRefresh = ref(false)
|
||||||
@@ -47,6 +50,7 @@ const { t } = useI18n({
|
|||||||
password: 'Password',
|
password: 'Password',
|
||||||
passwordTip: 'Please copy the password and you can use it to login to your email account.',
|
passwordTip: 'Please copy the password and you can use it to login to your email account.',
|
||||||
attachments: 'Show Attachments',
|
attachments: 'Show Attachments',
|
||||||
|
pleaseSelectMail: "Please select a mail to view."
|
||||||
},
|
},
|
||||||
zh: {
|
zh: {
|
||||||
yourAddress: '你的邮箱地址是',
|
yourAddress: '你的邮箱地址是',
|
||||||
@@ -63,6 +67,7 @@ const { t } = useI18n({
|
|||||||
password: '密码',
|
password: '密码',
|
||||||
passwordTip: '请复制密码,你可以使用它登录你的邮箱。',
|
passwordTip: '请复制密码,你可以使用它登录你的邮箱。',
|
||||||
attachments: '查看附件',
|
attachments: '查看附件',
|
||||||
|
pleaseSelectMail: "请选择一封邮件查看。"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -134,6 +139,11 @@ const newEmail = async () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const curMail = ref(null);
|
||||||
|
const clickRow = async (row) => {
|
||||||
|
curMail.value = row;
|
||||||
|
};
|
||||||
|
|
||||||
const getAttachments = async (attachment_id) => {
|
const getAttachments = async (attachment_id) => {
|
||||||
try {
|
try {
|
||||||
const res = await api.fetch(
|
const res = await api.fetch(
|
||||||
@@ -173,56 +183,127 @@ onMounted(async () => {
|
|||||||
<n-alert :type='settings.address ? "info" : "warning"' show-icon>
|
<n-alert :type='settings.address ? "info" : "warning"' show-icon>
|
||||||
<span v-if="settings.address">
|
<span v-if="settings.address">
|
||||||
{{ t('yourAddress') }} <b>{{ settings.address }}</b>
|
{{ t('yourAddress') }} <b>{{ settings.address }}</b>
|
||||||
|
<n-button size="small" class="center" @click="showPassword = true" tertiary round type="primary">
|
||||||
|
{{ t('showPassword') }}
|
||||||
|
</n-button>
|
||||||
<n-button @click="copy" size="small" tertiary round type="primary">
|
<n-button @click="copy" size="small" tertiary round type="primary">
|
||||||
{{ t('copy') }}
|
{{ t('copy') }}
|
||||||
</n-button>
|
</n-button>
|
||||||
</span>
|
</span>
|
||||||
<span v-else>
|
<span v-else>
|
||||||
{{ t('pleaseGetNewEmail') }}
|
{{ t('pleaseGetNewEmail') }}
|
||||||
|
<n-button class="center" @click="showNewEmail = true" tertiary round type="primary">
|
||||||
|
{{ t('getNewEmail') }}
|
||||||
|
</n-button>
|
||||||
</span>
|
</span>
|
||||||
</n-alert>
|
</n-alert>
|
||||||
<n-button v-if="settings.address" class="center" @click="showPassword = true" tertiary round type="primary">
|
<n-split v-if="!isMobile" direction="horizontal" :max="0.75" :min="0.25" default-size="0.25">
|
||||||
{{ t('showPassword') }}
|
<template #1>
|
||||||
</n-button>
|
<div>
|
||||||
<n-button v-else class="center" @click="showNewEmail = true" tertiary round type="primary">
|
<div style="display: inline-block; margin-top: 10px; margin-bottom: 10px;">
|
||||||
{{ t('getNewEmail') }}
|
<n-pagination v-model:page="page" v-model:page-size="pageSize" :item-count="count" simple size="small" />
|
||||||
</n-button>
|
</div>
|
||||||
<n-switch v-model:value="autoRefresh">
|
<n-switch v-model:value="autoRefresh" size="small">
|
||||||
<template #checked>
|
<template #checked>
|
||||||
{{ t('autoRefresh') }}
|
{{ t('autoRefresh') }}
|
||||||
|
</template>
|
||||||
|
<template #unchecked>
|
||||||
|
{{ t('autoRefresh') }}
|
||||||
|
</template></n-switch>
|
||||||
|
<n-button class="center" @click="refresh" size="small" type="primary">
|
||||||
|
{{ t('refresh') }}
|
||||||
|
</n-button>
|
||||||
|
</div>
|
||||||
|
<div style="overflow: scroll; max-height: 80vh;">
|
||||||
|
<n-list hoverable clickable>
|
||||||
|
<n-list-item v-for="row in data" v-bind:key="row.id" @click="() => clickRow(row)">
|
||||||
|
<n-thing class="center" :title="row.subject" style="overflow: scroll">
|
||||||
|
<template #description>
|
||||||
|
<n-tag type="info">
|
||||||
|
ID: {{ row.id }}
|
||||||
|
</n-tag>
|
||||||
|
<div style="word-break: break-all; font-size: small;">
|
||||||
|
FROM: {{ row.source }}
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</n-thing>
|
||||||
|
</n-list-item>
|
||||||
|
</n-list>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<template #unchecked>
|
<template #2>
|
||||||
{{ t('autoRefresh') }}
|
<n-card v-if="curMail" :title="curMail.subject" style="overflow: scroll;">
|
||||||
</template></n-switch>
|
<n-tag type="info">
|
||||||
<n-button class="center" @click="refresh" round type="primary">
|
ID: {{ curMail.id }}
|
||||||
{{ t('refresh') }}
|
</n-tag>
|
||||||
</n-button>
|
<n-tag type="info">
|
||||||
<div>
|
FROM: {{ curMail.source }}
|
||||||
<div style="display: inline-block; margin-top: 10px; margin-bottom: 10px;">
|
</n-tag>
|
||||||
<n-pagination v-model:page="page" v-model:page-size="pageSize" :item-count="count" simple />
|
<n-space>
|
||||||
|
<n-button v-if="curMail.attachment_id" size="small" tertiary type="info"
|
||||||
|
@click="getAttachments(curMail.attachment_id)">
|
||||||
|
{{ t('attachments') }}
|
||||||
|
</n-button>
|
||||||
|
</n-space>
|
||||||
|
<div v-html="curMail.message" style="max-height: 100vh;"></div>
|
||||||
|
</n-card>
|
||||||
|
<n-card v-else>
|
||||||
|
{{ t('pleaseSelectMail') }}
|
||||||
|
</n-card>
|
||||||
|
</template>
|
||||||
|
</n-split>
|
||||||
|
<div v-else>
|
||||||
|
<div>
|
||||||
|
<div style="display: inline-block; margin-top: 10px; margin-bottom: 10px;">
|
||||||
|
<n-pagination v-model:page="page" v-model:page-size="pageSize" :item-count="count" simple size="small" />
|
||||||
|
</div>
|
||||||
|
<n-switch v-model:value="autoRefresh" size="small">
|
||||||
|
<template #checked>
|
||||||
|
{{ t('autoRefresh') }}
|
||||||
|
</template>
|
||||||
|
<template #unchecked>
|
||||||
|
{{ t('autoRefresh') }}
|
||||||
|
</template></n-switch>
|
||||||
|
<n-button class="center" @click="refresh" size="small" type="primary">
|
||||||
|
{{ t('refresh') }}
|
||||||
|
</n-button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div id="drawer-target" style="overflow: scroll; max-height: 80vh;">
|
||||||
<n-list hoverable clickable>
|
<n-list hoverable clickable>
|
||||||
<n-list-item v-for="row in data" v-bind:key="row.id">
|
<n-list-item v-for="row in data" v-bind:key="row.id" @click="() => clickRow(row)">
|
||||||
<n-thing class="center" :title="row.subject">
|
<n-thing class="center" :title="row.subject" style="overflow: scroll">
|
||||||
<template #description>
|
<template #description>
|
||||||
|
<n-tag type="info">
|
||||||
|
ID: {{ row.id }}
|
||||||
|
</n-tag>
|
||||||
|
<div style="word-break: break-all; font-size: small;">
|
||||||
|
FROM: {{ row.source }}
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</n-thing>
|
||||||
|
</n-list-item>
|
||||||
|
</n-list>
|
||||||
|
</div>
|
||||||
|
<n-drawer v-model:show="curMail" width="100%" :trap-focus="false" :block-scroll="false" to="#drawer-target">
|
||||||
|
<n-drawer-content :title="curMail.subject" closable>
|
||||||
|
<n-tag type="info">
|
||||||
|
ID: {{ curMail.id }}
|
||||||
|
</n-tag>
|
||||||
|
<n-tag type="info">
|
||||||
|
FROM: {{ curMail.source }}
|
||||||
|
</n-tag>
|
||||||
|
<n-card style="overflow: scroll;">
|
||||||
<n-space>
|
<n-space>
|
||||||
<n-tag type="info">
|
<n-button v-if="curMail.attachment_id" size="small" tertiary type="info"
|
||||||
FROM: {{ row.source }}
|
@click="getAttachments(curMail.attachment_id)">
|
||||||
</n-tag>
|
|
||||||
<n-tag type="info">
|
|
||||||
ID: {{ row.id }}
|
|
||||||
</n-tag>
|
|
||||||
<n-button v-if="row.attachment_id" size="small" tertiary type="info"
|
|
||||||
@click="getAttachments(row.attachment_id)">
|
|
||||||
{{ t('attachments') }}
|
{{ t('attachments') }}
|
||||||
</n-button>
|
</n-button>
|
||||||
</n-space>
|
</n-space>
|
||||||
</template>
|
<div v-html="curMail.message" style="max-height: 100vh;"></div>
|
||||||
<div v-html="row.message" style="max-height: 400px; overflow: auto; text-align: left;"></div>
|
</n-card>
|
||||||
</n-thing>
|
</n-drawer-content>
|
||||||
</n-list-item>
|
</n-drawer>
|
||||||
</n-list>
|
</div>
|
||||||
</n-layout>
|
</n-layout>
|
||||||
<n-modal v-model:show="showNewEmail" preset="dialog" title="Dialog">
|
<n-modal v-model:show="showNewEmail" preset="dialog" title="Dialog">
|
||||||
<template #header>
|
<template #header>
|
||||||
@@ -296,4 +377,9 @@ onMounted(async () => {
|
|||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.n-split {
|
||||||
|
overflow: scroll;
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user