feat: 主动收邮件

2.0/email-builder
Lei OT 11 months ago
parent c52db468d3
commit 09125b32ac

@ -29,7 +29,7 @@ export const postSendEmail = async (body) => {
attaList.forEach(function (item) {
formData.append('attachment', item);
});
const {result} = await postForm(`${EMAIL_HOST}/sendmail`, formData);
const { result } = await postForm(`${EMAIL_HOST}/sendmail`, formData);
return result;
};
@ -54,3 +54,36 @@ export const getEmailDetailAction = async (param) => {
const { result } = await fetchJSON(`${EMAIL_HOST}/getmail`, param);
return { info: result.MailInfo?.[0] || {}, content: result.MailContent || '', attachments: result?.AttachList || [] };
}
/**
* 主动收邮件
* @param {object} { opi_sn, mai_sn }
* @ignore 用下面的接口代替, 收所有账户
*/
export const getEmailFetchAction = async (param) => {
const { result } = await fetchJSON(`${EMAIL_HOST}/email_fetch`, param);
return result;
};
/**
* 主动收邮件, 所有账户
* @param {object} { opi_sn, mai_sn }
*/
export const getAllEmailFetchAction = async (emailList) => {
try {
const promises = emailList.map((eaccount) => fetchJSON(`${EMAIL_HOST}/email_fetch`, {
opi_sn: eaccount.opi_sn,
mat_sn: eaccount.mat_sn,
// 以下是废弃的参数
externalid: 0,
actionid: 0,
token: 0,
}))
const result = await Promise.all(promises);
return result;
} catch (error) {
console.error('Error:', error);
throw error;
}
};

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M20 7.23792L12.0718 14.338L4 7.21594V19H13V21H3C2.44772 21 2 20.5523 2 20V4C2 3.44772 2.44772 3 3 3H21C21.5523 3 22 3.44772 22 4V12H20V7.23792ZM19.501 5H4.51146L12.0619 11.662L19.501 5ZM20 18H23L19 22L15 18H18V14H20V18Z"></path></svg>

After

Width:  |  Height:  |  Size: 323 B

@ -12,6 +12,7 @@ import SendPlaneFillSVG from '@/assets/icons/send-plane-fill.svg?react';
import SendPlaneLineSVG from '@/assets/icons/send-plane-line.svg?react';
import ResendLineSVG from '@/assets/icons/reset-left-line.svg?react';
import EditLineSVG from '@/assets/icons/quill-pen-line.svg?react';
import MailDownloadLineSVG from '@/assets/icons/mail-download-line.svg?react';
export const ReplyIcon = (props) => <Icon component={ReplyLineSVG} {...props} />;
@ -25,6 +26,7 @@ export const SendPlaneFillIcon = (props) => <Icon component={SendPlaneFillSVG} {
export const SendPlaneLineIcon = (props) => <Icon component={SendPlaneLineSVG} {...props} />;
export const ResendIcon = (props) => <Icon component={ResendLineSVG} {...props} />;
export const EditIcon = (props) => <Icon component={EditLineSVG} {...props} />;
export const MailDownloadIcon = (props) => <Icon component={MailDownloadLineSVG} {...props} />;
const WABSvg = () => (
<svg viewBox='0 0 32 32' xmlns='http://www.w3.org/2000/svg' width='16' height='16'>

@ -19,7 +19,7 @@ const TagColorStyle = (tag) => {
const EmailDetail = ({ open, setOpen, emailMsg, ...props }) => {
console.log('emailDetail', emailMsg);
// console.log('emailDetail', emailMsg);
const { conversationid, order_opi } = emailMsg
const { mai_sn, id } = emailMsg.msgOrigin?.email || emailMsg.msgOrigin || {} // todo: , id,

@ -0,0 +1,30 @@
import { createContext, useEffect, useState } from 'react'
import { App, Tooltip, Button } from 'antd'
import { PlusOutlined, LoadingOutlined, HistoryOutlined, FireOutlined, AudioTwoTone } from '@ant-design/icons'
import { getEmailFetchAction, getAllEmailFetchAction } from '@/actions/EmailActions'
import useAuthStore from '@/stores/AuthStore'
import { MailDownloadIcon } from '@/components/Icons'
const EmailFetch = ({ ...props }) => {
const { message } = App.useApp()
const { userId, emailList } = useAuthStore((state) => state.loginUser)
const [getEmailLoading, setEmailLoading] = useState(false)
const [fetchingText, setFetchingText] = useState('收邮件')
const handleGetEmail = async () => {
setEmailLoading(true)
// const ret = await getEmailFetchAction({ ...{}, opi_sn: userId })
const ret = await getAllEmailFetchAction(emailList)
// setFetchingText('...');
setEmailLoading(false)
message.info('正在接收邮件...') // .info
}
return (
<>
<Tooltip key={'email-fetch'} title={fetchingText}>
<Button type='text' onClick={handleGetEmail} icon={getEmailLoading ? <LoadingOutlined className='text-indigo-500' /> : <MailDownloadIcon className='text-indigo-500' />} />
</Tooltip>
</>
)
}
export default EmailFetch

@ -13,6 +13,7 @@ import ChatListFilter from './Components/ChatListFilter';
import useStyleStore from '@/stores/StyleStore';
import dayjs from 'dayjs';
import { DATETIME_FORMAT } from '@/config';
import EmailFetch from './Components/EmailFetch';
/**
* []
@ -259,6 +260,7 @@ const Conversations = () => {
// addonBefore={<FilterOutlined />}
// enterButton={'Filter'}
/>
<EmailFetch />
<Tooltip key={'conversation-list'} title={activeList ? '隐藏会话' : '活跃会话'}>
<Button onClick={toggleClosedConversationsList} icon={activeList ? <HistoryOutlined className='text-neutral-500' /> : <FireOutlined className=' text-orange-500' />} type='text' />
</Tooltip>

Loading…
Cancel
Save