自动化推广【约稿】
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div class="mail-container">
|
||||
<div class="mail-sidebar">
|
||||
<div class="p-10" style="padding-left: 0px;padding-right: 0px;">
|
||||
<div class="p-10">
|
||||
<div class="sidebar-top-actions">
|
||||
<el-button type="primary" icon="el-icon-plus" class="write-btn" @click="handleWrite">
|
||||
{{ $t('mailboxCollect.writeBtn') }}
|
||||
@@ -51,7 +51,13 @@
|
||||
<el-button icon="el-icon-refresh" circle :loading="syncLoading" @click="handleSyncInbox" style="margin-left: 10px;"></el-button>
|
||||
</div> -->
|
||||
|
||||
<div ref="listScrollArea" class="list-scroll-area" @scroll="onListScroll">
|
||||
<div
|
||||
ref="listScrollArea"
|
||||
class="list-scroll-area"
|
||||
@scroll="onListScroll"
|
||||
v-loading="inboxLoading"
|
||||
:element-loading-text="$t('mailboxCollect.loading')"
|
||||
>
|
||||
<template v-if="displayList.length > 0">
|
||||
<div
|
||||
v-for="item in displayList"
|
||||
@@ -137,11 +143,10 @@
|
||||
<el-table :data="accountList" v-loading="accountLoading" size="small">
|
||||
<el-table-column prop="smtp_user" :label="$t('mailboxCollect.accountColumn')" />
|
||||
<el-table-column prop="smtp_from_name" :label="$t('mailboxCollect.nameColumn')" />
|
||||
<el-table-column :label="$t('mailboxCollect.operation')" width="100">
|
||||
<el-table-column :label="$t('mailboxCollect.operation')" width="140">
|
||||
<template slot-scope="scope">
|
||||
<el-button type="primary" size="mini" @click="chooseAccount(scope.row)">
|
||||
{{ $t('mailboxCollect.useBtn') }}
|
||||
</el-button>
|
||||
<span v-if="isCurrentAccount(scope.row)" class="current-account-text">{{ $t('mailboxCollect.currentAccountText') }}</span>
|
||||
<el-button v-else type="primary" size="mini" @click="chooseAccount(scope.row)">{{ $t('mailboxCollect.switchColumn') }}</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
@@ -156,7 +161,7 @@ const API = {
|
||||
syncInbox: 'api/email_client/syncInbox',
|
||||
getAccounts: 'api/email_client/getAccounts',
|
||||
getOneEmail: 'api/email_client/getOneEmail',
|
||||
getAllJournal: 'api/Journal/getAllJournal',
|
||||
getAllJournal: 'api/Article/getJournal',
|
||||
};
|
||||
import MailDetail from '../../components/page/components/email/MailDetail.vue';
|
||||
export default {
|
||||
@@ -175,6 +180,7 @@ export default {
|
||||
inboxTotalPages: 1,
|
||||
inboxTotal: 0,
|
||||
inboxLoadingMore: false,
|
||||
inboxLoading: false,
|
||||
listWidth: 350,
|
||||
minWidth: 260,
|
||||
maxWidth: 600,
|
||||
@@ -198,6 +204,7 @@ export default {
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.loadJournals();
|
||||
this.initAccountSelection();
|
||||
},
|
||||
methods: {
|
||||
@@ -248,51 +255,32 @@ export default {
|
||||
// 3. 都没有则弹出选择账号弹窗
|
||||
this.openAccountDialog();
|
||||
},
|
||||
loadDefaultAccount() {
|
||||
this.$api.post(API.getAllJournal, {}).then(res => {
|
||||
const journals = (res && res.data && res.data.journals) || res.data || [];
|
||||
const list = (Array.isArray(journals) ? journals : []).map(i => ({
|
||||
journal_id: i.journal_id || i.id,
|
||||
title: i.title || i.name || ''
|
||||
}));
|
||||
this.journalList = list;
|
||||
if (!list.length) {
|
||||
this.openAccountDialog();
|
||||
return;
|
||||
}
|
||||
const firstJournalId = list[0].journal_id;
|
||||
this.accountJournalId = firstJournalId;
|
||||
this.accountLoading = true;
|
||||
this.$api.post(API.getAccounts, { journal_id: firstJournalId }).then(accRes => {
|
||||
this.accountLoading = false;
|
||||
const accounts = accRes && accRes.data ? accRes.data : [];
|
||||
if (Array.isArray(accounts) && accounts.length > 0) {
|
||||
this.selectedAccount = accounts[0];
|
||||
loadAccountById(jEmailId) {
|
||||
this.$api
|
||||
.post(API.getOneEmail, { j_email_id: jEmailId })
|
||||
.then(res => {
|
||||
const email = res && res.data ? res.data.email : null;
|
||||
if (res && res.code === 0 && email) {
|
||||
this.selectedAccount = email;
|
||||
this.fetchData();
|
||||
} else {
|
||||
this.accountList = accounts || [];
|
||||
this.openAccountDialog();
|
||||
return;
|
||||
}
|
||||
}).catch(() => {
|
||||
this.accountLoading = false;
|
||||
// 接口返回 null/非 0:回退到选择账号弹窗
|
||||
this.selectedAccount = null;
|
||||
this.openAccountDialog();
|
||||
})
|
||||
.catch(() => {
|
||||
// 请求失败:同样回退到选择账号弹窗
|
||||
this.selectedAccount = null;
|
||||
this.openAccountDialog();
|
||||
});
|
||||
}).catch(() => {
|
||||
this.openAccountDialog();
|
||||
});
|
||||
},
|
||||
loadAccountById(jEmailId) {
|
||||
this.$api.post(API.getOneEmail, { j_email_id: jEmailId }).then(res => {
|
||||
const email = res.data.email;
|
||||
if (res.code === 0 && email) {
|
||||
this.selectedAccount = email;
|
||||
this.fetchData();
|
||||
}
|
||||
}).catch(() => {});
|
||||
},
|
||||
openAccountDialog() {
|
||||
this.accountDialogVisible = true;
|
||||
this.loadJournals();
|
||||
// 期刊列表进入页面时已加载;仅在首次为空时补拉,避免每次切换账号都请求
|
||||
if (!this.journalList || this.journalList.length === 0) {
|
||||
this.loadJournals();
|
||||
}
|
||||
if (this.selectedAccount && this.selectedAccount.journal_id) {
|
||||
this.accountJournalId = this.selectedAccount.journal_id;
|
||||
this.loadAccountsForJournal(this.selectedAccount.journal_id);
|
||||
@@ -301,9 +289,9 @@ export default {
|
||||
loadJournals() {
|
||||
this.journalLoading = true;
|
||||
this.$api
|
||||
.post(API.getAllJournal, {})
|
||||
.post(API.getAllJournal, {username: localStorage.getItem('U_name')})
|
||||
.then(res => {
|
||||
this.journalList = (res.data.journals || res.data || []).map(i => ({
|
||||
this.journalList = (res || []).map(i => ({
|
||||
journal_id: i.journal_id || i.id,
|
||||
title: i.title || i.name || ''
|
||||
}));
|
||||
@@ -323,6 +311,10 @@ export default {
|
||||
this.accountList = res.data || [];
|
||||
});
|
||||
},
|
||||
isCurrentAccount(row) {
|
||||
if (!row || !this.selectedAccount) return false;
|
||||
return String(row.j_email_id || '') === String(this.selectedAccount.j_email_id || '');
|
||||
},
|
||||
chooseAccount(row) {
|
||||
this.selectedAccount = row;
|
||||
this.accountDialogVisible = false;
|
||||
@@ -354,6 +346,10 @@ export default {
|
||||
const isFirstPage = page === 1 || page == null;
|
||||
if (isFirstPage) {
|
||||
this.inboxPage = 1;
|
||||
// 首次拉取:显示加载中
|
||||
this.inboxLoading = true;
|
||||
// 避免复用旧列表造成“先空后满”的闪烁
|
||||
this.tableData_in = [];
|
||||
}
|
||||
const params = {
|
||||
j_email_id: this.selectedAccount.j_email_id,
|
||||
@@ -390,8 +386,10 @@ export default {
|
||||
this.inboxTotal = data.total != null ? Number(data.total) : this.tableData_in.length;
|
||||
this.queryIn.num = this.inboxTotal;
|
||||
this.inboxLoadingMore = false;
|
||||
if (isFirstPage) this.inboxLoading = false;
|
||||
}).catch(() => {
|
||||
this.inboxLoadingMore = false;
|
||||
if (isFirstPage) this.inboxLoading = false;
|
||||
});
|
||||
},
|
||||
switchFolder(f) { this.currentFolder = f; this.activeMailId = null; },
|
||||
@@ -447,9 +445,8 @@ export default {
|
||||
|
||||
// 提取日期信息用于比较
|
||||
const dateYear = date.getFullYear();
|
||||
const dateMonth = date.getMonth() + 1;
|
||||
const dateDay = date.getDate();
|
||||
const nowYear = now.getFullYear();
|
||||
const lang = localStorage.getItem('langs') === 'zh' ? 'zh-CN' : 'en-US';
|
||||
|
||||
// 获取昨天日期
|
||||
const yesterday = new Date(now);
|
||||
@@ -469,15 +466,17 @@ export default {
|
||||
|
||||
// 2. 如果是昨天:只显示 "昨天"
|
||||
if (date.toDateString() === yesterday.toDateString()) {
|
||||
return '昨天';
|
||||
return this.$t('mailboxCollect.yesterday');
|
||||
}
|
||||
|
||||
// 3. 如果是今年(非今天/昨天):显示 "月-日",如 "3月8日"
|
||||
// 3. 如果是今年(非今天/昨天):按语言显示月日
|
||||
if (dateYear === nowYear) {
|
||||
return `${dateMonth}月${dateDay}日`;
|
||||
return new Intl.DateTimeFormat(lang, { month: 'short', day: 'numeric' }).format(date);
|
||||
}
|
||||
|
||||
// 4. 如果是往年:显示完整年月日,如 "2025-12-05"
|
||||
const dateMonth = date.getMonth() + 1;
|
||||
const dateDay = date.getDate();
|
||||
const fullMonth = dateMonth.toString().padStart(2, '0');
|
||||
const fullDay = dateDay.toString().padStart(2, '0');
|
||||
return `${dateYear}-${fullMonth}-${fullDay}`;
|
||||
@@ -486,10 +485,7 @@ export default {
|
||||
handleWrite() {
|
||||
if (!this.selectedAccount) return;
|
||||
this.$router.push(
|
||||
'/mailboxSend?journal_id=' +
|
||||
this.selectedAccount.journal_id +
|
||||
'&j_email_id=' +
|
||||
this.selectedAccount.j_email_id
|
||||
'/mailboxSend'
|
||||
);
|
||||
},
|
||||
handleSearch() { this.fetchData(1); },
|
||||
@@ -502,7 +498,7 @@ export default {
|
||||
this.fetchData(this.inboxPage + 1);
|
||||
}
|
||||
},
|
||||
notImplemented() { this.$message.info('开发中...'); }
|
||||
notImplemented() { this.$message.info(this.$t('mailboxCollect.featureDev')); }
|
||||
}
|
||||
};
|
||||
</script>
|
||||
@@ -517,7 +513,7 @@ export default {
|
||||
|
||||
/* 1. 左侧栏 */
|
||||
.mail-sidebar {
|
||||
width: 220px;
|
||||
width: 240px;
|
||||
background-color: #f8f9fa;
|
||||
border-right: 1px solid #eaeaea;
|
||||
flex-shrink: 0;
|
||||
@@ -526,9 +522,9 @@ export default {
|
||||
}
|
||||
.p-10 { padding: 10px; }
|
||||
.p-20 { padding: 20px; }
|
||||
.sidebar-top-actions { display: flex; gap: 10px; }
|
||||
.write-btn { flex: 1; width: auto; border-radius: 8px; font-weight: bold;padding-left: 0px;padding-right: 0px; }
|
||||
.receive-btn { flex: 1; width: auto; border-radius: 8px; font-weight: bold;margin-left: 0px;padding-left: 0px;padding-right: 0px; }
|
||||
.sidebar-top-actions { display: flex; gap: 10px; padding: 0 6px; }
|
||||
.write-btn { flex: 1; width: auto; border-radius: 8px; font-weight: bold; padding-left: 10px; padding-right: 10px; }
|
||||
.receive-btn { flex: 1; width: auto; border-radius: 8px; font-weight: bold; margin-left: 0px; padding-left: 10px; padding-right: 10px; }
|
||||
.folder-list { list-style: none; padding: 0; margin: 0; flex: 1; }
|
||||
.folder-list li {
|
||||
padding: 12px 20px;
|
||||
@@ -538,7 +534,7 @@ export default {
|
||||
align-items: center;
|
||||
}
|
||||
.folder-list li i { margin-right: 12px; font-size: 18px; }
|
||||
.folder-list li.active { background: #edeef0; color: #006699; font-weight: bold; border-right: 3px solid #006699; }
|
||||
.folder-list li.active { background: #edeef0; color: #006699; font-weight: bold; border-left: 3px solid #006699; }
|
||||
.badge { margin-left: auto; background: #ddd; padding: 2px 8px; border-radius: 10px; font-size: 12px; }
|
||||
|
||||
.sidebar-footer { padding: 10px 0px; border-top: 1px solid #eee; background: #f8f9fa; }
|
||||
@@ -573,13 +569,15 @@ export default {
|
||||
.mail-excerpt { font-size: 12px; color: #606266; margin: 0; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
|
||||
.load-more-tip { text-align: center; padding: 12px; font-size: 12px; color: #909399; }
|
||||
.load-more-tip.no-more { color: #c0c4cc; }
|
||||
.current-account-text { color: #006699; font-size: 12px; }
|
||||
|
||||
/* 拖拽条 */
|
||||
.list-resizer { width: 4px; cursor: col-resize; border-left: 1px solid #eaeaea; transition: background 0.2s; }
|
||||
.list-resizer:hover { background: #409eff; }
|
||||
|
||||
/* 3. 右侧详情 */
|
||||
.mail-content-panel { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
|
||||
.mail-content-panel { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
|
||||
.mail-page { flex: 1; min-height: 0; overflow-y: auto; }
|
||||
.detail-toolbar { padding: 10px 20px; border-bottom: 1px solid #eee; display: flex; justify-content: space-between; }
|
||||
.detail-content { padding: 30px 40px; overflow-y: auto; }
|
||||
.mail-title { font-size: 24px; margin-bottom: 20px; }
|
||||
|
||||
Reference in New Issue
Block a user