新增邮件发送和管理员功能
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div class="account-box">
|
||||
<div class="head-opt">
|
||||
<Icon v-if="settingStore.settings.addEmail === 0" class="icon" icon="ion:add-outline" width="23" height="23" @click="add" />
|
||||
<div class="head-opt" >
|
||||
<Icon v-if="settingStore.settings.addEmail === 0" v-perm="'account:add'" class="icon" icon="ion:add-outline" width="23" height="23" @click="add" />
|
||||
<Icon class="icon" icon="ion:reload" width="18" height="18" @click="refresh" />
|
||||
</div>
|
||||
<el-scrollbar class="scrollbar">
|
||||
@@ -15,7 +15,7 @@
|
||||
<Icon icon="eva:email-fill" width="22" height="22" color="#fbbd08" />
|
||||
</div>
|
||||
<div class="settings" @click.stop>
|
||||
<Icon v-if="item.accountId === userStore.user.accountId" icon="fluent:settings-24-filled" width="20" height="20" color="#909399" />
|
||||
<Icon v-if="item.accountId === userStore.user.accountId || !hasPerm('account:delete')" icon="fluent:settings-24-filled" width="20" height="20" color="#909399" />
|
||||
<el-dropdown v-else >
|
||||
<Icon icon="fluent:settings-24-filled" width="20" height="20" color="#909399" />
|
||||
<template #dropdown >
|
||||
@@ -68,7 +68,6 @@
|
||||
|
||||
</el-scrollbar>
|
||||
<el-dialog v-model="showAdd" title="添加邮箱" >
|
||||
<form>
|
||||
<div class="container">
|
||||
<el-input v-model="addForm.email" type="text" placeholder="邮箱" autocomplete="off">
|
||||
<template #append>
|
||||
@@ -97,7 +96,6 @@
|
||||
>添加
|
||||
</el-button>
|
||||
</div>
|
||||
</form>
|
||||
<div
|
||||
class="add-email-turnstile"
|
||||
:class="verifyShow ? 'turnstile-show' : 'turnstile-hide'"
|
||||
@@ -116,6 +114,7 @@ import {isEmail} from "@/utils/verify-utils.js";
|
||||
import {useSettingStore} from "@/store/setting.js";
|
||||
import {useAccountStore} from "@/store/account.js";
|
||||
import {useUserStore} from "@/store/user.js";
|
||||
import hasPerm from "@/utils/perm.js";
|
||||
|
||||
const userStore = useUserStore();
|
||||
const accountStore = useAccountStore();
|
||||
@@ -136,12 +135,15 @@ const addForm = reactive({
|
||||
})
|
||||
const queryParams = {
|
||||
accountId: 0,
|
||||
size: 12
|
||||
size: 20
|
||||
}
|
||||
|
||||
const mySelect = ref()
|
||||
|
||||
getAccountList()
|
||||
if (hasPerm('account:query')) {
|
||||
getAccountList()
|
||||
}
|
||||
|
||||
|
||||
const openSelect = () => {
|
||||
mySelect.value.toggleMenu()
|
||||
@@ -192,6 +194,7 @@ function refresh() {
|
||||
}
|
||||
function changeAccount(account) {
|
||||
accountStore.currentAccountId = account.accountId
|
||||
accountStore.currentAccount = account
|
||||
}
|
||||
|
||||
function add() {
|
||||
@@ -270,6 +273,7 @@ function submit() {
|
||||
type: "success",
|
||||
plain: true
|
||||
})
|
||||
userStore.refreshUserInfo()
|
||||
}).catch(res => {
|
||||
if (res.code === 400) {
|
||||
verifyToken = ''
|
||||
@@ -292,12 +296,13 @@ function submit() {
|
||||
align-items: center;
|
||||
height: 38px;
|
||||
box-shadow: inset 0 -1px 0 0 rgba(100, 121, 143, 0.12);
|
||||
padding-left: 10px;
|
||||
padding-right: 10px;
|
||||
.icon{
|
||||
cursor: pointer;
|
||||
margin-left: 10px;
|
||||
}
|
||||
.icon:nth-child(2) {
|
||||
margin-left: 20px;
|
||||
margin-left: 15px;
|
||||
}
|
||||
}
|
||||
.scrollbar {
|
||||
@@ -364,6 +369,7 @@ function submit() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.setting-icon {
|
||||
position: relative;
|
||||
top: 6px;
|
||||
@@ -392,6 +398,11 @@ function submit() {
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
:deep(.el-pagination .el-select) {
|
||||
width: 100px;
|
||||
background: #FFF;
|
||||
}
|
||||
|
||||
.add-email-turnstile {
|
||||
margin-top: 15px;
|
||||
}
|
||||
|
||||
@@ -6,22 +6,45 @@
|
||||
<div>{{settingStore.settings.title}}</div>
|
||||
</div>
|
||||
<el-menu :collapse="false" text-color="#fff" active-text-color="#fff" style="margin-top: 10px">
|
||||
<el-menu-item @click="router.push('/email')" index="email"
|
||||
<el-menu-item @click="router.push({name: 'email'})" index="email"
|
||||
:class="route.meta.name === 'email' ? 'choose-item' : ''">
|
||||
<Icon icon="hugeicons:mailbox-01" width="20" height="20" />
|
||||
<span class="menu-name" style="margin-left: 21px">收件箱</span>
|
||||
</el-menu-item>
|
||||
<el-menu-item @click="router.push('/star')" index="star"
|
||||
<el-menu-item @click="router.push({name: 'send'})" index="send"
|
||||
:class="route.meta.name === 'send' ? 'choose-item' : ''">
|
||||
<Icon icon="cil:send" width="20" height="20" />
|
||||
<span class="menu-name" style="margin-left: 21px">已发送</span>
|
||||
</el-menu-item>
|
||||
<el-menu-item @click="router.push({name: 'star'})" index="star"
|
||||
:class="route.meta.name === 'star' ? 'choose-item' : ''">
|
||||
<Icon icon="solar:star-line-duotone" width="20" height="20" />
|
||||
<span class="menu-name" style="margin-left: 20px">星标邮件</span>
|
||||
</el-menu-item>
|
||||
<el-menu-item @click="router.push('/setting')" index="setting"
|
||||
<el-menu-item @click="router.push({name: 'setting'})" index="setting"
|
||||
:class="route.meta.name === 'setting' ? 'choose-item' : ''">
|
||||
<Icon icon="fluent:settings-48-regular" width="20" height="20" />
|
||||
<span class="menu-name" style="margin-left: 20px">个人设置</span>
|
||||
</el-menu-item>
|
||||
<el-menu-item @click="router.push('/sys-setting')" index="sys-setting" v-if="userStore.user.type === 0"
|
||||
<div class="manage-title" v-perm="['user:query','role:query','setting:query']">
|
||||
<div>管理</div>
|
||||
</div>
|
||||
<el-menu-item @click="router.push({name: 'user'})" index="setting" v-perm="'user:query'"
|
||||
:class="route.meta.name === 'user' ? 'choose-item' : ''">
|
||||
<Icon icon="iconoir:user" width="24" height="24" />
|
||||
<span class="menu-name" style="margin-left: 16px">用户列表</span>
|
||||
</el-menu-item>
|
||||
<el-menu-item @click="router.push({name: 'sys-email'})" index="sys-email" v-perm="'sys-email:query'"
|
||||
:class="route.meta.name === 'sys-email' ? 'choose-item' : ''">
|
||||
<Icon icon="fluent:mail-list-28-regular" width="22" height="22" />
|
||||
<span class="menu-name" style="margin-left: 18px">邮件列表</span>
|
||||
</el-menu-item>
|
||||
<el-menu-item @click="router.push({name: 'role'})" index="setting" v-perm="'role:query'"
|
||||
:class="route.meta.name === 'role' ? 'choose-item' : ''">
|
||||
<Icon icon="hugeicons:key-02" width="22" height="22" />
|
||||
<span class="menu-name" style="margin-left: 18px">权限控制</span>
|
||||
</el-menu-item>
|
||||
<el-menu-item @click="router.push({name: 'sys-setting'})" index="sys-setting" v-perm="'setting:query'"
|
||||
:class="route.meta.name === 'sys-setting' ? 'choose-item' : ''">
|
||||
<Icon icon="eos-icons:system-ok-outlined" width="18" height="18" />
|
||||
<span class="menu-name" style="margin-left: 23px">系统设置</span>
|
||||
@@ -37,15 +60,14 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {useUserStore} from "@/store/user.js";
|
||||
import router from "@/router/index.js";
|
||||
import { useRoute } from "vue-router";
|
||||
import {Icon} from "@iconify/vue";
|
||||
import {useSettingStore} from "@/store/setting.js";
|
||||
|
||||
const settingStore = useSettingStore();
|
||||
const userStore = useUserStore();
|
||||
const route = useRoute();
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@@ -63,7 +85,6 @@ const route = useRoute();
|
||||
gap: 5px;
|
||||
color: #ffffff;
|
||||
background: linear-gradient(135deg, #1890ff, #1c6dd0);
|
||||
box-shadow: 0 0 12px rgba(24, 144, 255, 0.6), 0 0 20px rgba(24, 144, 255, 0.4);
|
||||
transition: all 0.3s ease;
|
||||
|
||||
:deep(.el-icon) {
|
||||
@@ -81,6 +102,11 @@ const route = useRoute();
|
||||
}
|
||||
|
||||
|
||||
.manage-title {
|
||||
margin-top: 10px;
|
||||
padding-left: 20px;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.el-menu-item {
|
||||
margin: 5px 10px !important;
|
||||
@@ -122,7 +148,7 @@ const route = useRoute();
|
||||
border-right: 0;
|
||||
width: 250px;
|
||||
@media (max-width: 1199px) {
|
||||
width: 200px;
|
||||
width: 230px;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,7 +158,7 @@ const route = useRoute();
|
||||
}
|
||||
|
||||
.scroll {
|
||||
box-shadow: 6px 0 20px rgba(0, 21, 41, 0.35);
|
||||
|
||||
}
|
||||
|
||||
.github {
|
||||
|
||||
@@ -1,12 +1,19 @@
|
||||
<template>
|
||||
<div class="header">
|
||||
<div class="btn">
|
||||
<div class="header-btn">
|
||||
<hanburger @click="changeAside"></hanburger>
|
||||
<span class="breadcrumb-item">{{ route.meta.title }}</span>
|
||||
</div>
|
||||
<div class="writer-box" @click="openSend">
|
||||
<div class="writer" >
|
||||
<Icon icon="material-symbols:edit-outline-sharp" width="22" height="22" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="toolbar">
|
||||
<div class="email">{{ userStore.user.email }}</div>
|
||||
<el-dropdown>
|
||||
<div class="email">
|
||||
<span>{{ userStore.user.email }}</span>
|
||||
</div>
|
||||
<el-dropdown :teleported="false" popper-class="detail-dropdown" >
|
||||
<div class="avatar">
|
||||
<div class="avatar-text">
|
||||
<div>{{ formatName(userStore.user.email) }}</div>
|
||||
@@ -14,14 +21,38 @@
|
||||
<Icon class="setting-icon" icon="mingcute:down-small-fill" width="24" height="24" />
|
||||
</div>
|
||||
<template #dropdown>
|
||||
<el-dropdown-menu>
|
||||
<el-dropdown-item @click="router.push('/setting')">
|
||||
个人设置
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item @click="clickLogout">
|
||||
退出登录
|
||||
</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
<div class="user-details">
|
||||
<div class="details-avatar">
|
||||
{{ formatName(userStore.user.email) }}
|
||||
</div>
|
||||
<div class="detail-email">
|
||||
{{ userStore.user.email }}
|
||||
</div>
|
||||
<div class="detail-user-type">
|
||||
<el-tag type="warning">{{userStore.user.role.name}}</el-tag>
|
||||
</div>
|
||||
<div class="action-info">
|
||||
<div>
|
||||
<span style="margin-right: 10px">邮件发送 :</span>
|
||||
<span style="margin-right: 10px">邮箱添加 :</span>
|
||||
</div>
|
||||
<div>
|
||||
<div>
|
||||
<span v-if="sendCount !== null" style="margin-right: 5px">{{ sendCount }}</span>
|
||||
<el-tag v-if="!hasPerm('email:send')" type="warning">{{sendType}}</el-tag>
|
||||
<el-tag v-else type="success">{{sendType}}</el-tag>
|
||||
</div>
|
||||
<div>
|
||||
<span v-if="accountCount && hasPerm('account:add')" style="margin-right: 5px">{{ accountCount }}个</span>
|
||||
<el-tag v-if="!accountCount && hasPerm('account:add')" type="success">无限制</el-tag>
|
||||
<el-tag v-if="!hasPerm('account:add')" type="warning">无权限</el-tag>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="logout">
|
||||
<el-button type="primary" :loading="logoutLoading" @click="clickLogout">退出</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</el-dropdown>
|
||||
</div>
|
||||
@@ -36,18 +67,58 @@ import {Icon} from "@iconify/vue";
|
||||
import {useUiStore} from "@/store/ui.js";
|
||||
import {useUserStore} from "@/store/user.js";
|
||||
import { useRoute } from "vue-router";
|
||||
import {computed, ref} from "vue";
|
||||
import hasPerm from "@/utils/perm.js";
|
||||
|
||||
const route = useRoute();
|
||||
const userStore = useUserStore();
|
||||
const uiStore = useUiStore();
|
||||
const logoutLoading = ref(false)
|
||||
|
||||
const accountCount = computed(() => {
|
||||
return userStore.user.role.accountCount
|
||||
})
|
||||
|
||||
const sendType = computed(() => {
|
||||
|
||||
if (!hasPerm('email:send')) {
|
||||
return '无权限'
|
||||
}
|
||||
if (userStore.user.role.sendType === 'day') {
|
||||
return '每天'
|
||||
}
|
||||
if (userStore.user.role.sendType === 'count') {
|
||||
return '次数'
|
||||
}
|
||||
})
|
||||
|
||||
const sendCount = computed(() => {
|
||||
|
||||
if (!hasPerm('email:send')) {
|
||||
return null
|
||||
}
|
||||
|
||||
if (!userStore.user.role.sendCount) {
|
||||
return '无限制'
|
||||
}
|
||||
return userStore.user.sendCount + '/' + userStore.user.role.sendCount
|
||||
})
|
||||
|
||||
function openSend() {
|
||||
uiStore.writerRef.open()
|
||||
}
|
||||
|
||||
function changeAside() {
|
||||
uiStore.asideShow = !uiStore.asideShow
|
||||
}
|
||||
|
||||
function clickLogout() {
|
||||
logoutLoading.value = true
|
||||
logout().then(() => {
|
||||
localStorage.removeItem("token")
|
||||
router.push('/login')
|
||||
}).finally(() => {
|
||||
logoutLoading.value = false
|
||||
})
|
||||
}
|
||||
|
||||
@@ -61,7 +132,7 @@ function formatName(email) {
|
||||
|
||||
.breadcrumb-item {
|
||||
font-weight: bold;
|
||||
font-size: 16px;
|
||||
font-size: 14px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
@@ -71,16 +142,113 @@ function formatName(email) {
|
||||
bottom: 10px;
|
||||
}
|
||||
|
||||
:deep(.el-popper.is-pure) {
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.user-details {
|
||||
width: 250px;
|
||||
font-size: 14px;
|
||||
color: #333;
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
justify-items: center;
|
||||
|
||||
.detail-user-type {
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.action-info {
|
||||
width: 100%;
|
||||
display: grid;
|
||||
grid-template-columns: auto auto;
|
||||
margin-top: 10px;
|
||||
>div:first-child {
|
||||
display: grid;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
}
|
||||
>div:last-child {
|
||||
display: grid;
|
||||
gap: 10px;
|
||||
text-align: center;
|
||||
>div {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.detail-email {
|
||||
padding-left: 20px;
|
||||
padding-right: 20px;
|
||||
margin-top: 10px;
|
||||
width: 250px;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
text-align: center;
|
||||
}
|
||||
.logout {
|
||||
margin-top: 20px;
|
||||
width: 100%;
|
||||
padding-left: 10px;
|
||||
padding-right: 10px;
|
||||
padding-bottom: 10px;
|
||||
.el-button {
|
||||
height: 26px;
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
.details-avatar {
|
||||
margin-top: 20px;
|
||||
height: 45px;
|
||||
width: 45px;
|
||||
border: 1px solid #ccc;
|
||||
font-size: 18px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border-radius: 8px;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
.header {
|
||||
text-align: right;
|
||||
font-size: 12px;
|
||||
display: grid;
|
||||
height: 100%;
|
||||
gap: 10px;
|
||||
grid-template-columns: auto 1fr;
|
||||
grid-template-columns: auto auto 1fr;
|
||||
}
|
||||
|
||||
.btn {
|
||||
.writer-box {
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-left: 5px;
|
||||
.writer {
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
border-radius: 50%;
|
||||
color: #ffffff;
|
||||
background: linear-gradient(135deg, #1890ff, #1c6dd0);
|
||||
transition: all 0.3s ease;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
.writer-text {
|
||||
margin-left: 15px;
|
||||
font-size: 14px;
|
||||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.header-btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
height: 100%;
|
||||
@@ -102,12 +270,13 @@ function formatName(email) {
|
||||
text-overflow: ellipsis;
|
||||
font-weight: bold;
|
||||
width: 100%;
|
||||
|
||||
}
|
||||
|
||||
.avatar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
cursor: pointer;
|
||||
.avatar-text {
|
||||
height: 30px;
|
||||
width: 30px;
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
:class="(uiStore.asideShow && isMobile)? 'overlay-show':'overlay-hide'"
|
||||
@click="uiStore.asideShow = false"
|
||||
></div>
|
||||
|
||||
<el-container class="main-container">
|
||||
<el-main>
|
||||
<el-header>
|
||||
@@ -19,6 +18,7 @@
|
||||
</el-main>
|
||||
</el-container>
|
||||
</el-container>
|
||||
<writer ref="writerRef" />
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
@@ -27,17 +27,20 @@ import Header from '@/layout/header/index.vue'
|
||||
import Main from '@/layout/main/index.vue'
|
||||
import { ref, onMounted, onBeforeUnmount } from 'vue'
|
||||
import {useUiStore} from "@/store/ui.js";
|
||||
import writer from '@/layout/write/index.vue'
|
||||
|
||||
const uiStore = useUiStore();
|
||||
const isMobile = ref(window.innerWidth < 768)
|
||||
|
||||
|
||||
const writerRef = ref({})
|
||||
const isMobile = ref(window.innerWidth < 992)
|
||||
const handleResize = () => {
|
||||
isMobile.value = window.innerWidth < 768
|
||||
uiStore.asideShow = window.innerWidth >= 992;
|
||||
isMobile.value = window.innerWidth < 992
|
||||
uiStore.asideShow = window.innerWidth >= 991;
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
|
||||
uiStore.writerRef = writerRef
|
||||
|
||||
window.addEventListener('resize', handleResize)
|
||||
handleResize()
|
||||
})
|
||||
@@ -58,10 +61,12 @@ onBeforeUnmount(() => {
|
||||
}
|
||||
|
||||
.aside-show {
|
||||
-webkit-box-shadow: 3px 0 5px rgba(0, 21, 41, .35);
|
||||
box-shadow: 3px 0 5px rgba(0, 21, 41, 0.35);
|
||||
transform: translateX(0);
|
||||
transition: all 100ms ease;
|
||||
z-index: 101;
|
||||
@media (max-width: 767px) {
|
||||
@media (max-width: 991px) {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<template>
|
||||
<div :class=" accountShow ? 'main-box-show' : 'main-box-hide'">
|
||||
<div :class="accountShow ? 'block-show' : 'block-hide'" @click="uiStore.accountShow = false"></div>
|
||||
<account :class="accountShow ? 'show' : 'hide'" />
|
||||
<div :class="accountShow && hasPerm('account:query') ? 'main-box-show' : 'main-box-hide'">
|
||||
<div :class="accountShow && hasPerm('account:query') ? 'block-show' : 'block-hide'" @click="uiStore.accountShow = false"></div>
|
||||
<account :class="accountShow && hasPerm('account:query') ? 'show' : 'hide'" />
|
||||
<router-view class="main-view" v-slot="{ Component,route }">
|
||||
<keep-alive :include="['email','sys-setting','star']">
|
||||
<keep-alive :include="['email','sys-email','send','sys-setting','star','user','role']">
|
||||
<component :is="Component" :key="route.name"/>
|
||||
</keep-alive>
|
||||
</router-view>
|
||||
@@ -15,6 +15,7 @@ import {useUiStore} from "@/store/ui.js";
|
||||
import {useSettingStore} from "@/store/setting.js";
|
||||
import {computed, onBeforeUnmount, onMounted} from "vue";
|
||||
import { useRoute } from 'vue-router'
|
||||
import hasPerm from "@/utils/perm.js";
|
||||
|
||||
const props = defineProps({
|
||||
openSend: Function
|
||||
@@ -39,10 +40,10 @@ onBeforeUnmount(() => {
|
||||
})
|
||||
|
||||
const handleResize = () => {
|
||||
if (['content','email'].includes(route.meta.name)) {
|
||||
if (['content','email','send'].includes(route.meta.name)) {
|
||||
if (innerWidth !== window.innerWidth) {
|
||||
innerWidth = window.innerWidth;
|
||||
uiStore.accountShow = window.innerWidth >= 768;
|
||||
uiStore.accountShow = window.innerWidth >= 767;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -77,7 +78,7 @@ const handleResize = () => {
|
||||
@media (max-width: 767px) {
|
||||
position: fixed;
|
||||
z-index: 100;
|
||||
width: 199px;
|
||||
width: 229px;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,8 +87,8 @@ const handleResize = () => {
|
||||
position: fixed;
|
||||
transform: translateX(-100%);
|
||||
opacity: 0;
|
||||
@media (max-width: 767px) {
|
||||
width: 199px;
|
||||
@media (max-width: 991px) {
|
||||
width: 229px;
|
||||
z-index: 100;
|
||||
}
|
||||
}
|
||||
@@ -96,10 +97,13 @@ const handleResize = () => {
|
||||
.main-box-show {
|
||||
display: grid;
|
||||
grid-template-columns: 250px 1fr;
|
||||
height: calc(100% - 60px);
|
||||
@media (max-width: 1200px) {
|
||||
grid-template-columns: 229px 1fr;
|
||||
}
|
||||
@media (max-width: 767px) {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
height: calc(100% - 60px);
|
||||
}
|
||||
|
||||
.main-box-hide {
|
||||
|
||||
378
mail-vue/src/layout/write/index.vue
Normal file
378
mail-vue/src/layout/write/index.vue
Normal file
@@ -0,0 +1,378 @@
|
||||
<template>
|
||||
<div class="send" v-show="show">
|
||||
<div class="write-box">
|
||||
<div class="title">
|
||||
<div class="title-left">
|
||||
<span class="title-text">写邮件</span>
|
||||
</div>
|
||||
<div @click="close" style="cursor: pointer;">
|
||||
<Icon icon="material-symbols-light:close-rounded" width="22" height="22"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="container">
|
||||
<el-input v-model="form.sendEmail" disabled placeholder="">
|
||||
<template #prefix>
|
||||
<div class="item-title">发件人 :</div>
|
||||
</template>
|
||||
</el-input>
|
||||
<el-input v-model="form.receiveEmail" placeholder="收件人邮箱地址">
|
||||
<template #prefix>
|
||||
<div class="item-title">收件人 :</div>
|
||||
</template>
|
||||
</el-input>
|
||||
<el-input v-model="form.name" placeholder="发件人名字,不填则默认使用邮箱名">
|
||||
<template #prefix>
|
||||
<div class="item-title">名字 :</div>
|
||||
</template>
|
||||
</el-input>
|
||||
<el-input v-model="form.subject" placeholder="邮件主题">
|
||||
<template #prefix>
|
||||
<div class="item-title">主题 :</div>
|
||||
</template>
|
||||
</el-input>
|
||||
<tinyEditor ref="editor" @change="change"/>
|
||||
<div class="button-item">
|
||||
<div class="att-add" @click="chooseFile">
|
||||
<Icon icon="iconamoon:attachment-fill" width="26" height="26"/>
|
||||
</div>
|
||||
<div class="att-clear" @click="clearContent">
|
||||
<Icon icon="icon-park-outline:clear-format" width="26" height="26"/>
|
||||
</div>
|
||||
<div class="att-list">
|
||||
<div class="att-item" v-for="(item,index) in form.attachments" :key="index">
|
||||
<Icon :icon="getIconByName(item.filename)" width="20" height="20"/>
|
||||
<span class="att-filename">{{ item.filename }}</span>
|
||||
<span class="att-size">{{ formatBytes(item.size) }}</span>
|
||||
<Icon style="cursor: pointer;" icon="material-symbols-light:close-rounded" @click="delAtt(index)"
|
||||
width="22" height="22"/>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<el-button type="primary" @click="sendEmail">发送</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script setup>
|
||||
import tinyEditor from '@/components/tiny-editor/index.vue'
|
||||
import {h, onMounted, onUnmounted, reactive, ref} from "vue";
|
||||
import {Icon} from "@iconify/vue";
|
||||
import {useUserStore} from "@/store/user.js";
|
||||
import {emailSend} from "@/request/email.js";
|
||||
import {isEmail} from "@/utils/verify-utils.js";
|
||||
import {ElMessage, ElMessageBox, ElNotification} from "element-plus";
|
||||
import {useAccountStore} from "@/store/account.js";
|
||||
import {useEmailStore} from "@/store/email.js";
|
||||
import {fileToBase64, formatBytes} from "@/utils/file-utils.js";
|
||||
import {getIconByName} from "@/utils/icon-utils.js";
|
||||
import sendPercent from "@/components/send-percent/index.vue"
|
||||
import hasPerm from "@/utils/perm.js";
|
||||
|
||||
defineExpose({
|
||||
open
|
||||
})
|
||||
|
||||
const emailStore = useEmailStore();
|
||||
const accountStore = useAccountStore()
|
||||
const editor = ref({})
|
||||
const userStore = useUserStore();
|
||||
const show = ref(false);
|
||||
const percent = ref(0)
|
||||
let percentMessage = null
|
||||
let sending = false
|
||||
const form = reactive({
|
||||
sendEmail: '',
|
||||
receiveEmail: '',
|
||||
accountId: -1,
|
||||
name: '',
|
||||
subject: '',
|
||||
content: '',
|
||||
text: '',
|
||||
attachments: []
|
||||
})
|
||||
|
||||
function clearContent() {
|
||||
ElMessageBox.confirm('确定要清空邮件吗?', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
resetForm()
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
function delAtt(index) {
|
||||
form.attachments.splice(index, 1);
|
||||
}
|
||||
|
||||
function chooseFile() {
|
||||
const doc = document.createElement("input")
|
||||
doc.setAttribute("type", "file")
|
||||
doc.click()
|
||||
doc.onchange = async (e) => {
|
||||
|
||||
const file = e.target.files[0]
|
||||
const size = file.size
|
||||
const filename = file.name
|
||||
const contentType = file.type
|
||||
|
||||
const TotalSize = form.attachments.reduce((acc, item) => acc + item.size, 0);
|
||||
if ((TotalSize + size) > 29360128) {
|
||||
ElMessage({
|
||||
message: '附件文件大小限制28mb',
|
||||
type: 'error',
|
||||
plain: true,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
const content = await fileToBase64(file)
|
||||
form.attachments.push({content, filename, size, contentType})
|
||||
}
|
||||
}
|
||||
|
||||
async function sendEmail() {
|
||||
|
||||
if (!form.receiveEmail) {
|
||||
ElMessage({
|
||||
message: '收件人邮箱地址不能为空',
|
||||
type: 'error',
|
||||
plain: true,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if (!isEmail(form.receiveEmail)) {
|
||||
ElMessage({
|
||||
message: '请输入正确的收件人邮箱',
|
||||
type: 'error',
|
||||
plain: true,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if (!form.subject) {
|
||||
ElMessage({
|
||||
message: '主题不能为空',
|
||||
type: 'error',
|
||||
plain: true,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if (!form.content) {
|
||||
ElMessage({
|
||||
message: '正文不能为空',
|
||||
type: 'error',
|
||||
plain: true,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if (sending) {
|
||||
ElMessage({
|
||||
message: '邮件正在发送中',
|
||||
type: 'error',
|
||||
plain: true,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
percentMessage = ElMessage({
|
||||
message: () => h(sendPercent, { value: percent.value }),
|
||||
dangerouslyUseHTMLString: true,
|
||||
plain: true,
|
||||
duration: 0,
|
||||
customClass: 'message-bottom'
|
||||
})
|
||||
|
||||
sending = true
|
||||
close()
|
||||
emailSend(form, (e) => {
|
||||
percent.value = Math.round((e.loaded * 98) / e.total)
|
||||
}).then(email => {
|
||||
emailStore.sendScroll?.addItem(email)
|
||||
resetForm()
|
||||
show.value = false
|
||||
ElNotification({
|
||||
title: '邮件已发送',
|
||||
type: "success",
|
||||
message: h('span', { style: 'color: teal' }, email.subject),
|
||||
position: 'bottom-right'
|
||||
})
|
||||
userStore.refreshUserInfo();
|
||||
}).catch((e) => {
|
||||
ElNotification({
|
||||
title: '发送失败',
|
||||
type: e.code === 403 ? 'warning' : 'error',
|
||||
message: h('span', { style: 'color: teal' }, e.message),
|
||||
position: 'bottom-right'
|
||||
})
|
||||
}).finally(() => {
|
||||
percentMessage.close()
|
||||
percent.value = 0
|
||||
sending = false
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
function resetForm() {
|
||||
form.receiveEmail = ''
|
||||
form.name = ''
|
||||
form.subject = ''
|
||||
form.content = ''
|
||||
form.attachments = []
|
||||
editor.value.clearEditor()
|
||||
}
|
||||
|
||||
function change(content, text) {
|
||||
form.content = content;
|
||||
form.text = text
|
||||
}
|
||||
|
||||
function open() {
|
||||
if (!accountStore.currentAccount.email) {
|
||||
form.sendEmail = userStore.user.email;
|
||||
form.accountId = userStore.user.accountId;
|
||||
} else {
|
||||
form.sendEmail = accountStore.currentAccount.email;
|
||||
form.accountId = accountStore.currentAccount.accountId;
|
||||
}
|
||||
show.value = true;
|
||||
}
|
||||
|
||||
const handleKeyDown = (event) => {
|
||||
if (event.key === 'Escape') {
|
||||
close()
|
||||
}
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
window.addEventListener('keydown', handleKeyDown);
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
window.removeEventListener('keydown', handleKeyDown);
|
||||
});
|
||||
|
||||
function close() {
|
||||
show.value = false;
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.send {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
.write-box {
|
||||
background: #FFFFFF;
|
||||
width: 900px;
|
||||
box-shadow: var(--el-box-shadow-light);
|
||||
border: 1px solid var(--el-border-color-light);
|
||||
transition: var(--el-transition-duration);
|
||||
padding: 15px;
|
||||
border-radius: 8px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@media (max-width: 991px) {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
@media (min-width: 992px) {
|
||||
height: min(800px, calc(100vh - 60px));
|
||||
}
|
||||
|
||||
.title {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 10px;
|
||||
.title-left {
|
||||
align-items: center;
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
}
|
||||
.title-text {
|
||||
font-weight: bold;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
div {
|
||||
display: flex;
|
||||
}
|
||||
}
|
||||
|
||||
.container {
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 15px;
|
||||
|
||||
.item-title {
|
||||
color: #333;
|
||||
margin-right: 8px;
|
||||
}
|
||||
|
||||
.button-item {
|
||||
display: grid;
|
||||
grid-template-columns: auto auto 1fr auto;
|
||||
|
||||
.att-add {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.att-clear {
|
||||
cursor: pointer;
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
.att-list {
|
||||
display: grid;
|
||||
gap: 5px;
|
||||
grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
|
||||
padding-left: 10px;
|
||||
padding-right: 10px;
|
||||
max-height: 110px;
|
||||
overflow-y: auto;
|
||||
@media (max-width: 450px) {
|
||||
grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
|
||||
}
|
||||
|
||||
.att-item {
|
||||
display: grid;
|
||||
grid-template-columns: auto 1fr auto auto;
|
||||
gap: 5px;
|
||||
height: 32px;
|
||||
font-size: 14px;
|
||||
border: 1px solid var(--el-border-color-light);
|
||||
padding: 5px 5px;
|
||||
border-radius: 4px;
|
||||
|
||||
.att-filename {
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
overflow: hidden;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
.icon {
|
||||
cursor: pointer;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user