perf: 邮箱目录

dev/ckeditor
Lei OT 4 months ago
parent d55d55a3aa
commit 01dbcabdd7

@ -168,7 +168,7 @@ export const getEmailDirAction = async (params = { opi_sn: '' }) => {
const mailboxSort = result //.sort(sortBy('MDR_Order'));
let tree = buildTree(mailboxSort, { key: 'VKey', parent: 'VParent', name: 'VName', iconIndex: 'ImageIndex', rootKeys: [1], ignoreKeys: [-227001, -227002] })
tree = tree.filter((ele) => ele.key !== 1)
return errcode === 0 ? tree : [];
return errcode === 0 ? { [`${params.opi_sn}`]: tree } : { [`${params.opi_sn}`]: [] }
};
export const getTodoOrdersAction = async (params) => {
const opi_arr = params.opisn.split(',')
@ -204,7 +204,8 @@ export const getTodoOrdersAction = async (params) => {
{},
)
const { errcode, result } = await fetchJSON(`${API_HOST}/getwlorder`, params)
const _result_unique = uniqWith(result, (a, b) => a.COLI_SN === b.COLI_SN)
// 取后一个状态, 因此翻转两次
const _result_unique = uniqWith(result.reverse(), (a, b) => a.COLI_SN === b.COLI_SN).reverse();
const orderList = errcode === 0 ? _result_unique : []
const byOPI = groupBy(orderList, 'OPI_SN')
const byState = Object.keys(byOPI).reduce((acc, key) => {
@ -274,8 +275,12 @@ export const getTodoOrdersAction = async (params) => {
* @param {string} params.userIdStr - 用户ID字符串默认为空
*/
export const getRootMailboxDirAction = async ({ opi_sn = 0, userIdStr = '' } = {}) => {
const [stickyTree, mailboxDir] = await Promise.all([getTodoOrdersAction({ opisn: userIdStr || String(opi_sn), otype: 'today' }), getEmailDirAction({ opi_sn: opi_sn })])
const rootTree = Object.keys(stickyTree).map((opi) => ({ key: Number(opi), tree: [...stickyTree[opi], ...mailboxDir] }))
const [stickyTree, ...mailboxDir] = await Promise.all([
getTodoOrdersAction({ opisn: userIdStr || String(opi_sn), otype: 'today' }),
...(userIdStr.split(',').map(_opi => getEmailDirAction({ opi_sn: _opi }))),
])
const mailboxDirByOPI = mailboxDir.reduce((a, c) => ({...a, ...c}), {});
const rootTree = Object.keys(stickyTree).map((opi) => ({ key: Number(opi), tree: [...stickyTree[opi], ...(mailboxDirByOPI?.[opi] || [])] }))
writeIndexDB(rootTree, 'dirs', 'mailbox')
const _mapped = groupBy(rootTree, 'key')
return _mapped[opi_sn]?.[0]?.tree || []

@ -123,7 +123,7 @@ const emailSlice = (set, get) => ({
createIndexedDBStore(['dirs', 'maillist', 'mailinfo', 'draft'], 'mailbox')
setCurrentMailboxOPI(opi_sn)
setCurrentMailboxDEI(dei_sn)
getOPIEmailDir(userId, userIdStr)
getOPIEmailDir(opi_sn, userIdStr)
// 登录后, 执行一下清除缓存
clean7DaysMailboxLog();
},

Loading…
Cancel
Save