新增邮件群发和数据可视化

This commit is contained in:
eoao
2025-06-17 09:20:00 +08:00
parent ea309f9171
commit 605829f180
65 changed files with 2352 additions and 900 deletions

View File

@@ -1,7 +1,7 @@
<template>
<div class="account-box">
<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 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,12 +15,12 @@
<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 || !hasPerm('account:delete')" icon="fluent:settings-24-filled" width="20" height="20" color="#909399" />
<el-dropdown v-else >
<el-dropdown>
<Icon icon="fluent:settings-24-filled" width="20" height="20" color="#909399" />
<template #dropdown >
<el-dropdown-menu>
<el-dropdown-item @click="remove(item)">删除</el-dropdown-item>
<el-dropdown-item @click="openSetName(item)">改名</el-dropdown-item>
<el-dropdown-item v-if="item.accountId !== userStore.user.accountId && hasPerm('account:delete')" @click="remove(item)">删除</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
@@ -69,7 +69,7 @@
</el-scrollbar>
<el-dialog v-model="showAdd" title="添加邮箱" >
<div class="container">
<el-input v-model="addForm.email" type="text" placeholder="邮箱" autocomplete="off">
<el-input v-model="addForm.email" ref="addRef" type="text" placeholder="邮箱" autocomplete="off">
<template #append>
<div @click.stop="openSelect">
<el-select
@@ -103,13 +103,21 @@
data-callback="onTurnstileSuccess"
></div>
</el-dialog>
<el-dialog v-model="setNameShow" title="修改名字" >
<div class="container">
<el-input v-model="accountName" type="text" placeholder="名字" autocomplete="off">
</el-input>
<el-button class="btn" type="primary" @click="setName" :loading="setNameLoading"
>保存
</el-button>
</div>
</el-dialog>
</div>
</template>
<script setup>
import {Icon} from "@iconify/vue";
import {nextTick, reactive, ref} from "vue";
import {accountList, accountAdd, accountDelete} from "@/request/account.js";
import {ElMessage, ElMessageBox} from "element-plus";
import {nextTick, reactive, ref, watch} from "vue";
import {accountList, accountAdd, accountDelete, accountSetName} from "@/request/account.js";
import {isEmail} from "@/utils/verify-utils.js";
import {useSettingStore} from "@/store/setting.js";
import {useAccountStore} from "@/store/account.js";
@@ -127,6 +135,11 @@ const noLoading = ref(false)
const loading = ref(false)
const followLoading = ref(false);
const verifyShow = ref(false)
const setNameShow = ref(false)
const setNameLoading = ref(false)
const accountName = ref(null)
const addRef = ref({})
let account = null
let turnstileId = null
let verifyToken = ''
const addForm = reactive({
@@ -144,6 +157,10 @@ if (hasPerm('account:query')) {
getAccountList()
}
watch(() => accountStore.changeUserAccountName, () => {
accounts[0].name = accountStore.changeUserAccountName
})
const openSelect = () => {
mySelect.value.toggleMenu()
@@ -156,6 +173,49 @@ window.onTurnstileSuccess = (token) => {
},1500)
};
function setName() {
let name = accountName.value
if (name === account.name) {
setNameShow.value = false
return
}
if (!name) {
ElMessage({
message: '用户名不能为空',
type: 'error',
plain: true,
})
return;
}
setNameLoading.value = true
accountSetName(account.accountId,name).then(() => {
account.name = name
setNameShow.value = false
if (account.accountId === userStore.user.accountId) {
userStore.user.name = name
}
ElMessage({
message: "保存成功",
type: "success",
plain: true
})
}).finally(()=> {
setNameLoading.value = false
})
}
function openSetName (accountItem) {
accountName.value = accountItem.name
account = accountItem
setNameShow.value = true
}
function itemBg(accountId) {
return accountStore.currentAccountId === accountId ? 'item-choose' : ''
}
@@ -199,6 +259,9 @@ function changeAccount(account) {
function add() {
showAdd.value = true
setTimeout(() => {
addRef.value.focus()
},100)
}
function getAccountList() {

View File

@@ -26,9 +26,14 @@
<Icon icon="fluent:settings-48-regular" width="20" height="20" />
<span class="menu-name" style="margin-left: 20px">个人设置</span>
</el-menu-item>
<div class="manage-title" v-perm="['user:query','role:query','setting:query']">
<div class="manage-title" v-perm="['user:query','role:query','setting:query','analysis:query']">
<div>管理</div>
</div>
<el-menu-item @click="router.push({name: 'analysis'})" index="analysis" v-perm="'analysis:query'"
:class="route.meta.name === 'analysis' ? 'choose-item' : ''">
<Icon icon="fluent:data-pie-20-regular" width="24" height="24" />
<span class="menu-name" style="margin-left: 16px">分析页</span>
</el-menu-item>
<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" />
@@ -70,7 +75,7 @@ const route = useRoute();
.title {
margin: 15px 10px;
height: 45px;
border-radius: 8px;
border-radius: 6px;
display: flex;
position: relative;
font-size: 16px;

View File

@@ -25,6 +25,9 @@
<div class="details-avatar">
{{ formatName(userStore.user.email) }}
</div>
<div class="user-name">
{{userStore.user.name}}
</div>
<div class="detail-email">
{{ userStore.user.email }}
</div>
@@ -43,9 +46,10 @@
<el-tag v-else >{{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')" >无限制</el-tag>
<el-tag v-if="!hasPerm('account:add')" ></el-tag>
<el-tag v-if="settingStore.settings.manyEmail || settingStore.settings.addEmail" >已关闭</el-tag>
<span v-else-if="accountCount && hasPerm('account:add')" style="margin-right: 5px">{{ accountCount }}</span>
<el-tag v-else-if="!accountCount && hasPerm('account:add')" >无限</el-tag>
<el-tag v-else-if="!hasPerm('account:add')" >无权限</el-tag>
</div>
</div>
</div>
@@ -55,6 +59,9 @@
</div>
</template>
</el-dropdown>
<div class="full" @click="full">
<Icon icon="iconamoon:screen-full-light" width="22" height="22" />
</div>
</div>
</div>
</template>
@@ -68,9 +75,12 @@ import {useUiStore} from "@/store/ui.js";
import {useUserStore} from "@/store/user.js";
import { useRoute } from "vue-router";
import {computed, ref} from "vue";
import {useSettingStore} from "@/store/setting.js";
import hasPerm from "@/utils/perm.js";
import screenfull from "screenfull";
const route = useRoute();
const settingStore = useSettingStore();
const userStore = useUserStore();
const uiStore = useUiStore();
const logoutLoading = ref(false)
@@ -131,6 +141,10 @@ function formatName(email) {
return email[0]?.toUpperCase() || ''
}
function full() {
screenfull.toggle();
}
</script>
<style lang="scss" scoped>
@@ -141,14 +155,8 @@ function formatName(email) {
white-space: nowrap;
}
.setting-icon {
margin-right: 10px;
position: relative;
bottom: 10px;
}
:deep(.el-popper.is-pure) {
border-radius: 10px;
border-radius: 6px;
}
.user-details {
@@ -158,7 +166,17 @@ function formatName(email) {
display: grid;
grid-template-columns: 1fr;
justify-items: center;
.user-name {
font-weight: bold;
margin-top: 10px;
padding-left: 20px;
padding-right: 20px;
width: 250px;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
text-align: center;
}
.detail-user-type {
margin-top: 10px;
}
@@ -187,12 +205,12 @@ function formatName(email) {
.detail-email {
padding-left: 20px;
padding-right: 20px;
margin-top: 10px;
width: 250px;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
text-align: center;
color: #5c5958;
}
.logout {
margin-top: 20px;
@@ -201,7 +219,7 @@ function formatName(email) {
padding-right: 10px;
padding-bottom: 10px;
.el-button {
border-radius: 8px;
border-radius: 6px;
height: 28px;
width: 100%;
}
@@ -264,9 +282,21 @@ function formatName(email) {
.toolbar {
display: grid;
grid-template-columns: 1fr auto;
grid-template-columns: 1fr auto auto;
margin-left: auto;
gap: 10px;
@media (max-width: 1024px) {
grid-template-columns: 1fr auto;
}
.full {
display: flex;
align-items: center;
justify-content: center;
padding-right: 10px;
cursor: pointer;
@media (max-width: 1024px) {
display: none;
}
}
.email {
align-self: center;
font-size: 14px;
@@ -276,13 +306,13 @@ function formatName(email) {
text-overflow: ellipsis;
font-weight: bold;
width: 100%;
}
.avatar {
display: flex;
align-items: center;
cursor: pointer;
margin-left: 10px;
.avatar-text {
height: 30px;
width: 30px;
@@ -296,6 +326,11 @@ function formatName(email) {
.setting-icon {
position: relative;
top: 0;
margin-right: 5px;
bottom: 10px;
@media (max-width: 1024px) {
margin-right: 10px;
}
}
}

View File

@@ -31,10 +31,10 @@ import writer from '@/layout/write/index.vue'
const uiStore = useUiStore();
const writerRef = ref({})
const isMobile = ref(window.innerWidth < 1024)
const isMobile = ref(window.innerWidth < 1025)
const handleResize = () => {
isMobile.value = window.innerWidth < 1024
uiStore.asideShow = window.innerWidth >= 1024;
isMobile.value = window.innerWidth < 1025
uiStore.asideShow = window.innerWidth > 1024;
}
onMounted(() => {
@@ -66,7 +66,7 @@ onBeforeUnmount(() => {
transform: translateX(0);
transition: all 100ms ease;
z-index: 101;
@media (max-width: 1024px) {
@media (max-width: 1025px) {
position: fixed;
top: 0;
left: 0;

View File

@@ -3,7 +3,7 @@
<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-email','send','sys-setting','star','user','role']">
<keep-alive :include="['email','sys-email','send','sys-setting','star','user','role','analysis']">
<component :is="Component" :key="route.name"/>
</keep-alive>
</router-view>

View File

@@ -3,40 +3,38 @@
<div class="write-box">
<div class="title">
<div class="title-left">
<span class="title-text">写邮件</span>
<span class="title-text">
<Icon icon="hugeicons:quill-write-01" width="28" height="28" />
</span>
<span class="sender">发件人:</span>
<span class="sender-name">{{form.name}}</span>
<span class="send-email"><{{form.sendEmail}}></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="">
<el-input-tag @add-tag="addTagChange" tag-type="primary" size="default" v-model="form.receiveEmail" placeholder="多邮个箱用, 分开 example1.com,example2.com" >
<template #prefix>
<div class="item-title">件人 :</div>
<div class="item-title">件人 </div>
</template>
<template #suffix>
<span class="distribute" :class="form.manyType ? 'checked' : ''" @click.stop="checkDistribute" >分别发送</span>
</template>
</el-input-tag>
<el-input v-model="form.subject" 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"/>
<tinyEditor :def-value="defValue" ref="editor" @change="change"/>
<div class="button-item">
<div class="att-add" @click="chooseFile">
<Icon icon="iconamoon:attachment-fill" width="26" height="26"/>
<Icon icon="iconamoon:attachment-fill" width="24" height="24"/>
</div>
<div class="att-clear" @click="clearContent">
<Icon icon="icon-park-outline:clear-format" width="26" height="26"/>
<Icon icon="icon-park-outline:clear-format" width="24" height="24 "/>
</div>
<div class="att-list">
<div class="att-item" v-for="(item,index) in form.attachments" :key="index">
@@ -48,7 +46,8 @@
</div>
</div>
<div>
<el-button type="primary" @click="sendEmail">发送</el-button>
<el-button type="primary" @click="sendEmail" v-if="form.sendType === 'reply'">回复</el-button>
<el-button type="primary" @click="sendEmail" v-else >发送</el-button>
</div>
</div>
</div>
@@ -62,15 +61,16 @@ 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 {formatDetailDate} from "@/utils/day.js";
defineExpose({
open
open,
openReply
})
const emailStore = useEmailStore();
@@ -81,17 +81,43 @@ const show = ref(false);
const percent = ref(0)
let percentMessage = null
let sending = false
const defValue = ref('')
const form = reactive({
sendEmail: '',
receiveEmail: '',
receiveEmail: [],
accountId: -1,
manyType: null,
name: '',
subject: '',
content: '',
sendType: '',
text: '',
emailId: 0,
attachments: []
})
function addTagChange(val) {
const emails = Array.from(new Set(
val.split(/[,]/).map(item => item.trim()).filter(item => item)
));
form.receiveEmail.splice(form.receiveEmail.length - 1, 1)
emails.forEach(email => {
if (isEmail(email) && !form.receiveEmail.includes(email)) {
form.receiveEmail.push(email)
}
})
}
function checkDistribute() {
form.manyType = form.manyType ? null : 'divide'
}
function clearContent() {
ElMessageBox.confirm('确定要清空邮件吗?', {
confirmButtonText: '确定',
@@ -135,7 +161,7 @@ function chooseFile() {
async function sendEmail() {
if (!form.receiveEmail) {
if (form.receiveEmail.length === 0) {
ElMessage({
message: '收件人邮箱地址不能为空',
type: 'error',
@@ -144,15 +170,6 @@ async function sendEmail() {
return
}
if (!isEmail(form.receiveEmail)) {
ElMessage({
message: '请输入正确的收件人邮箱',
type: 'error',
plain: true,
})
return
}
if (!form.subject) {
ElMessage({
message: '主题不能为空',
@@ -171,6 +188,15 @@ async function sendEmail() {
return
}
if (form.manyType === 'divide' && form.attachments.length > 0) {
ElMessage({
message: '分别发送暂时不支持附件',
type: 'error',
plain: true,
})
return
}
if (sending) {
ElMessage({
message: '邮件正在发送中',
@@ -192,8 +218,11 @@ async function sendEmail() {
close()
emailSend(form, (e) => {
percent.value = Math.round((e.loaded * 98) / e.total)
}).then(email => {
emailStore.sendScroll?.addItem(email)
}).then(emailList => {
const email = emailList[0]
emailList.forEach(item => {
emailStore.sendScroll?.addItem(item)
})
resetForm()
show.value = false
ElNotification({
@@ -219,11 +248,13 @@ async function sendEmail() {
function resetForm() {
form.receiveEmail = ''
form.name = ''
form.receiveEmail = []
form.subject = ''
form.content = ''
form.manyType = null
form.attachments = []
form.sendType = null
form.emailId = 0
editor.value.clearEditor()
}
@@ -232,15 +263,45 @@ function change(content, text) {
form.text = text
}
function openReply(email) {
resetForm();
email.subject = email.subject || ''
form.receiveEmail.push(email.sendEmail)
form.subject = (email.subject.startsWith('Re:') || email.subject.startsWith('回复:')) ? email.subject : 'Re: ' + email.subject
form.sendType = 'reply'
form.emailId = email.emailId
defValue.value = ''
setTimeout(() => {
defValue.value = `
<div></div>
<div>
<br>
${ formatDetailDate(email.createTime) }${email.name} &lt${email.sendEmail}&gt 来信:
</div>
<blockquote style="margin: 0 0 0 0.8ex;border-left: 1px solid rgb(204,204,204);padding-left: 1ex;">${email.content}</blockquote>`
open()
})
}
function open() {
if (!accountStore.currentAccount.email) {
form.sendEmail = userStore.user.email;
form.accountId = userStore.user.accountId;
form.name = userStore.user.name;
} else {
form.sendEmail = accountStore.currentAccount.email;
form.accountId = accountStore.currentAccount.accountId;
form.name = accountStore.currentAccount.name;
}
show.value = true;
editor.value.focus()
}
const handleKeyDown = (event) => {
@@ -276,22 +337,24 @@ function close() {
.write-box {
background: #FFFFFF;
width: 902px;
width: min(1200px,calc(100% - 80px));
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;
display: grid;
grid-template-rows: auto 1fr;
overflow: hidden;
@media (max-width: 1024px) {
width: 100%;
height: 100%;
border-radius: 0;
padding-top: 10px;
}
@media (min-width: 1024px) {
height: min(750px, calc(100vh - 60px));
@media (min-width: 1025px) {
height: min(800px, calc(100vh - 60px));
}
.title {
@@ -300,28 +363,63 @@ function close() {
margin-bottom: 10px;
.title-left {
align-items: center;
display: flex;
gap: 10px;
display: grid;
grid-template-columns: auto auto auto 1fr;
}
.title-text {
}
.sender {
margin-left: 8px;
}
.sender-name {
margin-left: 8px;
font-weight: bold;
font-size: 16px;
}
.send-email {
color: #999896;
margin-left: 5px;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
}
div {
display: flex;
align-items: center;
}
}
.container {
height: 100%;
display: flex;
flex-direction: column;
display: grid;
grid-template-rows: auto auto 1fr auto;
gap: 15px;
.distribute {
color: var(--el-color-info);
background: var(--el-color-info-light-9);
border: var(--el-color-info-light-8);
border-radius: 4px;
font-size: 12px;
padding: 0 5px;
}
.distribute.checked {
background: var(--el-color-primary-light-9);
color: var(--el-color-primary) !important;
border-radius: 4px;
}
.distribute:hover {
background: var(--el-color-primary-light-9);
color: var(--el-color-primary) !important;
border-radius: 4px;
}
.item-title {
color: #333;
margin-right: 8px;
}
.button-item {
@@ -371,6 +469,11 @@ function close() {
}
}
:deep(.el-input-tag__suffix) {
padding-right: 4px;
}
.icon {
cursor: pointer;
}