Compare commits
2 Commits
c6c262169d
...
3f53a6c7d0
| Author | SHA1 | Date | |
|---|---|---|---|
| 3f53a6c7d0 | |||
| 7d3e6654fd |
@@ -181,6 +181,8 @@ export default {
|
||||
localStorage.removeItem('journalTypeData');
|
||||
localStorage.removeItem('journalTypeDataAll');
|
||||
localStorage.removeItem('opMedicalListData');
|
||||
localStorage.removeItem('mailboxCollect_j_email_id');
|
||||
localStorage.removeItem('mailboxCollect_journal_id');
|
||||
this.$router.push('/login');
|
||||
}
|
||||
},
|
||||
|
||||
@@ -179,6 +179,8 @@ export default {
|
||||
localStorage.removeItem('journalTypeData');
|
||||
localStorage.removeItem('journalTypeDataAll');
|
||||
localStorage.removeItem('opMedicalListData');
|
||||
localStorage.removeItem('mailboxCollect_j_email_id');
|
||||
localStorage.removeItem('mailboxCollect_journal_id');
|
||||
this.$router.push('/login');
|
||||
}
|
||||
},
|
||||
|
||||
@@ -157,9 +157,18 @@
|
||||
<el-submenu index="mailboxManagement">
|
||||
<template slot="title"> <i class="el-icon-message"></i> {{ $t('sidebar.promotionManagement') }} </template>
|
||||
|
||||
<el-menu-item index="expertDatabase">
|
||||
{{ $t('sidebar.expertDatabase') }}
|
||||
</el-menu-item>
|
||||
<el-submenu index="expertDatabaseSub">
|
||||
<template slot="title">
|
||||
{{ $t('sidebar.expertDatabase') }}
|
||||
</template>
|
||||
<el-menu-item index="expertDatabase">
|
||||
{{ $t('sidebar.expertList') }}
|
||||
</el-menu-item>
|
||||
<el-menu-item index="crawlTaskMonitor">
|
||||
{{ $t('sidebar.crawlTasks') }}
|
||||
</el-menu-item>
|
||||
|
||||
</el-submenu>
|
||||
|
||||
<el-menu-item index="mailboxConfig">
|
||||
{{ $t('sidebar.mailboxManagement') }}
|
||||
@@ -181,9 +190,6 @@
|
||||
<el-menu-item index="RejectedArticles">
|
||||
{{ $t('sidebar.ReArticles') }}
|
||||
</el-menu-item>
|
||||
<el-menu-item index="scholarCrawlers">
|
||||
{{ $t('sidebar.scholarCrawlers') }}
|
||||
</el-menu-item>
|
||||
<!-- <el-menu-item index="1" key="1"> -->
|
||||
<a href="http://master.tmrjournals.com" target="_blank" class="linkBar"> Management System </a>
|
||||
<!-- </el-menu-item> -->
|
||||
|
||||
@@ -276,7 +276,11 @@ const en = {
|
||||
mailboxManagement: 'Mailbox Management',
|
||||
mailboxConfig: 'Mailbox Management',
|
||||
scholarCrawlers: 'Scholar Crawlers',
|
||||
crawlerKeywords: 'Crawl Keywords',
|
||||
expertDatabase: 'Expert Database',
|
||||
keywordManagement: 'Keyword Management',
|
||||
crawlTasks: 'Crawl Tasks',
|
||||
expertList: 'Expert List',
|
||||
autoPromotion: 'Auto Promotion',
|
||||
ReArticles: 'Rejected Manuscripts', // 被拒稿件
|
||||
editorialBoard: 'Boss System',
|
||||
@@ -294,6 +298,7 @@ const en = {
|
||||
expertDatabase: {
|
||||
fieldSelectPlaceholder: 'Please select field',
|
||||
keywordPlaceholder: 'Name / Email / Affiliation',
|
||||
fieldPlaceholder: 'Please enter field',
|
||||
searchBtn: 'Search',
|
||||
resetBtn: 'Reset',
|
||||
downloadExcelBtn: 'Download Excel',
|
||||
@@ -310,7 +315,7 @@ const en = {
|
||||
emailLabel: 'Email:',
|
||||
acquisitionTimeLabel: 'Acquisition Time:'
|
||||
},
|
||||
exportWarn: 'Please select a research area or enter a keyword before exporting.',
|
||||
exportWarn: 'Please select a research area, enter a keyword, or enter a field before exporting.',
|
||||
exportFailed: 'Export failed'
|
||||
},
|
||||
mailboxConfig: {
|
||||
@@ -530,7 +535,134 @@ colTitle: 'Template title',
|
||||
loadingMore: 'Loading more...',
|
||||
noMore: 'No more',
|
||||
yesterday: 'Yesterday',
|
||||
selectAccountTip: 'Please select an email account first.'
|
||||
selectAccountTip: 'Please select an email account first.',
|
||||
attachmentCount: ' attachment(s)',
|
||||
downloadFail: 'Download failed',
|
||||
accountNotBelong: 'This account does not belong to you. Please select another one.',
|
||||
totalAttachments: '{count} attachment(s) in total',
|
||||
etcSuffix: '... etc.',
|
||||
viewAttachments: 'View attachments',
|
||||
newMailArrived: '{count} new mail(s) received, click to view',
|
||||
downloadAllZip: 'Download all',
|
||||
packingAttachments: 'Packing attachments, please wait...',
|
||||
downloadBtn: 'Download',
|
||||
printBtn: 'Print',
|
||||
previewNotSupported: 'This file format cannot be previewed online',
|
||||
downloadToView: 'Download to view locally',
|
||||
},
|
||||
crawlerKeywords: {
|
||||
pageTitle: 'Keyword Configuration',
|
||||
pageDesc: 'Manage core search terms for discovering experts.',
|
||||
exportData: 'Export Data',
|
||||
startCrawl: 'Start Crawl',
|
||||
inputPlaceholder: 'Enter new keyword, e.g. deep learning, semiconductor expert...',
|
||||
addKeyword: 'Add Keyword',
|
||||
searchPlaceholder: 'Search keywords...',
|
||||
searchBtn: 'Search',
|
||||
totalCount: '{count} keyword(s) in total',
|
||||
colKeyword: 'Keyword',
|
||||
colCategory: 'Category',
|
||||
colStatus: 'Status',
|
||||
colExpertCount: 'Expert Count',
|
||||
colLastCrawl: 'Last Crawl',
|
||||
colAction: 'Action',
|
||||
save: 'Save',
|
||||
cancel: 'Cancel',
|
||||
stateRunning: 'Running',
|
||||
statePaused: 'Paused',
|
||||
stateError: 'Error',
|
||||
stateDone: 'Done',
|
||||
emptyKeywordWarn: 'Please enter a keyword',
|
||||
addSuccess: 'Added successfully',
|
||||
addFail: 'Failed to add',
|
||||
updateSuccess: 'Updated successfully',
|
||||
updateFail: 'Failed to update',
|
||||
deleteConfirm: 'Are you sure to delete this keyword? This action cannot be undone.',
|
||||
confirmTitle: 'Confirm',
|
||||
deleteSuccess: 'Deleted successfully',
|
||||
deleteFail: 'Failed to delete',
|
||||
refreshSuccess: 'Refreshed successfully',
|
||||
refreshFail: 'Failed to refresh',
|
||||
crawlStarted: 'Crawl task started',
|
||||
crawlFail: 'Failed to start crawl',
|
||||
exportFail: 'Failed to export',
|
||||
},
|
||||
crawlTask: {
|
||||
pageTitle: 'Task Monitor',
|
||||
pageDesc: 'View currently running and completed crawl tasks.',
|
||||
exportData: 'Export Data',
|
||||
startCrawl: 'Start Crawl',
|
||||
searchPlaceholder: 'Search by keyword...',
|
||||
searchBtn: 'Search',
|
||||
allKeywords: 'All Keywords',
|
||||
enabled: 'Enabled',
|
||||
disabled: 'Disabled',
|
||||
allStatus: 'All Status',
|
||||
statusCrawling: 'Crawling',
|
||||
statusDone: 'Done',
|
||||
statusPaused: 'Paused',
|
||||
statusError: 'Error',
|
||||
source: 'Source',
|
||||
startTime: 'Start Time',
|
||||
endTime: 'End Time',
|
||||
progress: 'Progress',
|
||||
totalPages: 'Total Pages',
|
||||
crawledPages: 'Crawled Pages',
|
||||
expertCountLabel: 'Experts Stored',
|
||||
expertCount: 'Expert Count',
|
||||
created: 'Created',
|
||||
completed: 'Completed',
|
||||
updated: 'Updated',
|
||||
viewDetail: 'View Detail',
|
||||
viewLogs: 'View Logs',
|
||||
pause: 'Pause',
|
||||
resume: 'Resume',
|
||||
restart: 'Restart',
|
||||
delete: 'Delete',
|
||||
deleteConfirm: 'Are you sure to delete this task? This cannot be undone.',
|
||||
confirmTitle: 'Confirm',
|
||||
confirmOk: 'OK',
|
||||
confirmCancel: 'Cancel',
|
||||
operationSuccess: 'Operation succeeded',
|
||||
operationFail: 'Operation failed',
|
||||
operationRetry: 'Operation failed, please try again later',
|
||||
crawlStarted: 'Crawl task started',
|
||||
crawlFail: 'Failed to start crawl',
|
||||
exportFail: 'Failed to export',
|
||||
detailTitle: 'Task Detail',
|
||||
basicInfo: 'Basic Information',
|
||||
taskName: 'Task Name',
|
||||
status: 'Status',
|
||||
resultSummary: 'Result Summary',
|
||||
totalFound: 'Total Found',
|
||||
newAdded: 'New Added',
|
||||
duplicates: 'Duplicates',
|
||||
failed: 'Failed',
|
||||
logsTitle: 'Run Logs',
|
||||
noLogs: 'No logs yet',
|
||||
noData: 'No tasks',
|
||||
emptyResult: 'No matching task records found',
|
||||
addKeyword: 'Add Keyword',
|
||||
keyword: 'Keyword',
|
||||
keywordPlaceholder: 'Enter keyword, e.g.: Infectious Diseases',
|
||||
runOnce: 'Single Crawl',
|
||||
runOnceBtn: 'Single Crawl',
|
||||
runOnceLoading: 'Crawling...',
|
||||
yes: 'Yes',
|
||||
no: 'No',
|
||||
cancel: 'Cancel',
|
||||
confirm: 'OK',
|
||||
enterKeyword: 'Please enter a keyword',
|
||||
addKeywordSuccess: 'Keyword added successfully',
|
||||
addKeywordFailed: 'Failed to add keyword',
|
||||
runOnceSuccess: 'Single crawl triggered',
|
||||
runOnceFailed: 'Failed to trigger single crawl',
|
||||
disabledMsg: 'Disabled',
|
||||
enabledMsg: 'Enabled',
|
||||
pauseFailed: 'Failed to pause',
|
||||
resumeFailed: 'Failed to resume',
|
||||
missingKeyword: 'Missing keyword, cannot perform single crawl',
|
||||
restartSuccess: 'Sync restarted (local mock)',
|
||||
},
|
||||
mailboxSend: {
|
||||
title: 'Write mail',
|
||||
@@ -904,6 +1036,16 @@ colTitle: 'Template title',
|
||||
styleName: 'Style Name',
|
||||
defaultStyle: 'Default',
|
||||
changeTemplate: 'Change Template',
|
||||
selectPromotionFields: 'Select Promotion Fields',
|
||||
choosePromotionFields: 'Choose Fields',
|
||||
selectedCount: 'Selected {count}',
|
||||
selectAll: 'Select All',
|
||||
clearAll: 'Clear All',
|
||||
selectPromotionFieldsTip: 'Multiple selection supported; leave empty for no field restriction.',
|
||||
fieldSearchPlaceholder: 'Search promotion fields',
|
||||
noFieldMatch: 'No matching fields',
|
||||
confirm: 'Confirm',
|
||||
fieldsSaved: 'Promotion fields saved',
|
||||
confirmAndEnable: 'Confirm and Enable',
|
||||
onlySaveConfig: 'Save configuration only',
|
||||
enableNowNextDay: 'Enable auto promotion now (starts next day)'
|
||||
|
||||
@@ -264,7 +264,11 @@ const zh = {
|
||||
|
||||
|
||||
scholarCrawlers: '学者数据库',
|
||||
crawlerKeywords: '抓取关键词配置',
|
||||
expertDatabase: '专家库',
|
||||
keywordManagement: '关键词管理',
|
||||
crawlTasks: '抓取任务',
|
||||
expertList: '专家列表',
|
||||
autoPromotion: '自动推广',
|
||||
ReArticles: '被拒稿件', // 被拒稿件
|
||||
editorialBoard: '编委管理',
|
||||
@@ -283,6 +287,7 @@ const zh = {
|
||||
expertDatabase: {
|
||||
fieldSelectPlaceholder: '请选择研究领域',
|
||||
keywordPlaceholder: '姓名 / 邮箱 / 单位',
|
||||
fieldPlaceholder: '请输入领域 field',
|
||||
searchBtn: '搜索',
|
||||
resetBtn: '重置',
|
||||
downloadExcelBtn: '下载 Excel',
|
||||
@@ -299,7 +304,7 @@ const zh = {
|
||||
emailLabel: '邮箱:',
|
||||
acquisitionTimeLabel: '采集时间:'
|
||||
},
|
||||
exportWarn: '请选择研究领域或输入关键词后再导出。',
|
||||
exportWarn: '请选择研究领域或输入关键词或领域 field 后再导出。',
|
||||
exportFailed: '导出失败'
|
||||
},
|
||||
mailboxConfig: {
|
||||
@@ -520,6 +525,133 @@ const zh = {
|
||||
noMore: '没有更多了',
|
||||
yesterday: '昨天',
|
||||
selectAccountTip: '请先选择一个邮箱账号.',
|
||||
attachmentCount: '个附件',
|
||||
downloadFail: '下载失败',
|
||||
accountNotBelong: '该邮箱账号不属于当前用户,请重新选择',
|
||||
totalAttachments: '共{count}个附件',
|
||||
etcSuffix: '... 等',
|
||||
viewAttachments: '查看附件',
|
||||
newMailArrived: '收到 {count} 封新邮件,点击查看',
|
||||
downloadAllZip: '打包下载',
|
||||
packingAttachments: '正在打包附件,请稍后...',
|
||||
downloadBtn: '下载',
|
||||
printBtn: '打印',
|
||||
previewNotSupported: '该文件格式无法在线预览',
|
||||
downloadToView: '下载到本地查看',
|
||||
},
|
||||
crawlerKeywords: {
|
||||
pageTitle: '关键词配置',
|
||||
pageDesc: '管理用于发现专家的核心搜索词。',
|
||||
exportData: '导出数据',
|
||||
startCrawl: '开始抓取',
|
||||
inputPlaceholder: '输入新关键词,例如:深度学习、半导体专家...',
|
||||
addKeyword: '添加关键词',
|
||||
searchPlaceholder: '搜索关键词...',
|
||||
searchBtn: '搜索',
|
||||
totalCount: '共 {count} 个词条',
|
||||
colKeyword: '关键词',
|
||||
colCategory: '分类',
|
||||
colStatus: '状态',
|
||||
colExpertCount: '专家数量',
|
||||
colLastCrawl: '最后抓取',
|
||||
colAction: '操作',
|
||||
save: '保存',
|
||||
cancel: '取消',
|
||||
stateRunning: '运行中',
|
||||
statePaused: '已暂停',
|
||||
stateError: '异常',
|
||||
stateDone: '已完成',
|
||||
emptyKeywordWarn: '请输入关键词',
|
||||
addSuccess: '添加成功',
|
||||
addFail: '添加失败',
|
||||
updateSuccess: '更新成功',
|
||||
updateFail: '更新失败',
|
||||
deleteConfirm: '确定删除该关键词吗?删除后无法恢复。',
|
||||
confirmTitle: '提示',
|
||||
deleteSuccess: '删除成功',
|
||||
deleteFail: '删除失败',
|
||||
refreshSuccess: '刷新成功',
|
||||
refreshFail: '刷新失败',
|
||||
crawlStarted: '抓取任务已启动',
|
||||
crawlFail: '启动抓取失败',
|
||||
exportFail: '导出失败',
|
||||
},
|
||||
crawlTask: {
|
||||
pageTitle: '任务监控',
|
||||
pageDesc: '查看当前正在运行和已完成的抓取任务。',
|
||||
exportData: '导出数据',
|
||||
startCrawl: '开始抓取',
|
||||
searchPlaceholder: '按关键词搜索...',
|
||||
searchBtn: '搜索',
|
||||
allKeywords: '全部关键词',
|
||||
enabled: '启用',
|
||||
disabled: '停用',
|
||||
allStatus: '全部状态',
|
||||
statusCrawling: '抓取中',
|
||||
statusDone: '已完成',
|
||||
statusPaused: '已暂停',
|
||||
statusError: '异常',
|
||||
source: '来源',
|
||||
startTime: '开始时间',
|
||||
endTime: '结束时间',
|
||||
progress: '进度',
|
||||
totalPages: '总页数',
|
||||
crawledPages: '已抓取页数',
|
||||
expertCountLabel: '入库专家数',
|
||||
expertCount: '专家数量',
|
||||
created: '创建',
|
||||
completed: '完成',
|
||||
updated: '更新',
|
||||
viewDetail: '查看详情',
|
||||
viewLogs: '查看日志',
|
||||
pause: '暂停',
|
||||
resume: '继续',
|
||||
restart: '重新抓取',
|
||||
delete: '删除',
|
||||
deleteConfirm: '确定删除该任务吗?删除后无法恢复。',
|
||||
confirmTitle: '提示',
|
||||
confirmOk: '确定',
|
||||
confirmCancel: '取消',
|
||||
operationSuccess: '操作成功',
|
||||
operationFail: '操作失败',
|
||||
operationRetry: '操作失败,请稍后重试',
|
||||
crawlStarted: '抓取任务已启动',
|
||||
crawlFail: '启动抓取失败',
|
||||
exportFail: '导出失败',
|
||||
detailTitle: '任务详情',
|
||||
basicInfo: '基本信息',
|
||||
taskName: '任务名称',
|
||||
status: '状态',
|
||||
resultSummary: '抓取结果',
|
||||
totalFound: '发现总数',
|
||||
newAdded: '新增',
|
||||
duplicates: '重复',
|
||||
failed: '失败',
|
||||
logsTitle: '运行日志',
|
||||
noLogs: '暂无日志',
|
||||
noData: '暂无任务',
|
||||
emptyResult: '未发现匹配的任务记录',
|
||||
addKeyword: '新建关键词',
|
||||
keyword: '关键词',
|
||||
keywordPlaceholder: '请输入关键词,如:Infectious Diseases',
|
||||
runOnce: '单次抓取',
|
||||
runOnceBtn: '单次抓取',
|
||||
runOnceLoading: '抓取中...',
|
||||
yes: '是',
|
||||
no: '否',
|
||||
cancel: '取消',
|
||||
confirm: '确定',
|
||||
enterKeyword: '请输入关键词',
|
||||
addKeywordSuccess: '新增关键词成功',
|
||||
addKeywordFailed: '新增关键词失败',
|
||||
runOnceSuccess: '已触发单次抓取',
|
||||
runOnceFailed: '单次抓取触发失败',
|
||||
disabledMsg: '已停用',
|
||||
enabledMsg: '已启用',
|
||||
pauseFailed: '暂停失败',
|
||||
resumeFailed: '恢复失败',
|
||||
missingKeyword: '缺少关键词,无法执行单次抓取',
|
||||
restartSuccess: '已重启同步(本地模拟)',
|
||||
},
|
||||
mailboxSend: {
|
||||
title: '写邮件',
|
||||
@@ -889,6 +1021,16 @@ const zh = {
|
||||
styleName: '风格名称',
|
||||
defaultStyle: '默认风格',
|
||||
changeTemplate: '更换模版',
|
||||
selectPromotionFields: '选择推广领域',
|
||||
choosePromotionFields: '选择领域',
|
||||
selectedCount: '已选 {count} 项',
|
||||
selectAll: '全选',
|
||||
clearAll: '取消全选',
|
||||
selectPromotionFieldsTip: '可多选;未选择则不限制推广领域。',
|
||||
fieldSearchPlaceholder: '搜索推广领域',
|
||||
noFieldMatch: '没有匹配的领域',
|
||||
confirm: '确定',
|
||||
fieldsSaved: '推广领域已保存',
|
||||
confirmAndEnable: '确认并开启',
|
||||
onlySaveConfig: '仅保存配置',
|
||||
enableNowNextDay: '立即激活自动推广(次日开始自动推广)'
|
||||
|
||||
@@ -98,6 +98,10 @@
|
||||
:visible.sync="showWizardDialog"
|
||||
:config="wizardConfig"
|
||||
:wizardStartDate.sync="wizardStartDate"
|
||||
:selectedFieldIds.sync="selectedFieldIds"
|
||||
:availableFields="availableFields"
|
||||
:fieldsLoading="fieldsLoading"
|
||||
:fieldsSaving="fieldsSaving"
|
||||
:currentJournalName="wizardJournal ? wizardJournal.title : ''"
|
||||
:selectedTemplateThumbHtml="selectedTemplateThumbHtml"
|
||||
:selectedTemplateName="selectedTemplateName"
|
||||
@@ -105,6 +109,7 @@
|
||||
:saving="saving"
|
||||
:title="`${$t('autoPromotion.journalManage')}: ${wizardJournal ? wizardJournal.title : ''}`"
|
||||
@open-template-selector="openTemplateSelector"
|
||||
@confirm-fields="savePromotionFieldsNow"
|
||||
@cancel="showWizardDialog = false"
|
||||
@confirm="saveWizardConfig"
|
||||
/>
|
||||
@@ -150,6 +155,10 @@ export default {
|
||||
selectedTemplateThumbHtml: '',
|
||||
selectedTemplateName: '',
|
||||
selectedStyleName: '',
|
||||
selectedFieldIds: [],
|
||||
availableFields: [],
|
||||
fieldsLoading: false,
|
||||
fieldsSaving: false,
|
||||
templateDialogInitialStyleId: '',
|
||||
templateDialogInitialTemplateId: '',
|
||||
templateNameMap: {},
|
||||
@@ -306,6 +315,81 @@ export default {
|
||||
? this.$t('autoPromotion.goManagePlan')
|
||||
: this.$t('autoPromotion.startPlan');
|
||||
},
|
||||
findArray(obj) {
|
||||
if (Array.isArray(obj)) return obj;
|
||||
if (!obj || typeof obj !== 'object') return null;
|
||||
const keys = ['list', 'fields', 'rows', 'items', 'data', 'result'];
|
||||
for (const k of keys) {
|
||||
if (Array.isArray(obj[k])) return obj[k];
|
||||
}
|
||||
const values = Object.values(obj);
|
||||
if (values.length && Array.isArray(values[0])) return values[0];
|
||||
return null;
|
||||
},
|
||||
async loadPromotionFields(journalId) {
|
||||
this.fieldsLoading = true;
|
||||
this.availableFields = [];
|
||||
this.selectedFieldIds = [];
|
||||
try {
|
||||
const availableRes = await this.$api.post('api/email_client/getAvailableFields', { journal_id: String(journalId) });
|
||||
console.log('[getAvailableFields] raw response:', JSON.stringify(availableRes));
|
||||
|
||||
const availablePayload = (availableRes && availableRes.data) || availableRes || {};
|
||||
let availableArr = this.findArray(availablePayload);
|
||||
if (!availableArr) {
|
||||
availableArr = Array.isArray(availablePayload) ? availablePayload : [];
|
||||
}
|
||||
|
||||
this.availableFields = availableArr.map((item, idx) => {
|
||||
const id = item.expert_fetch_id || item.fetch_id || item.id || item.field_id || (idx + 1);
|
||||
const label = item.field || item.title || item.name || item.label || String(id);
|
||||
return { id: String(id), label };
|
||||
});
|
||||
console.log('[getAvailableFields] parsed fields:', this.availableFields.length, this.availableFields.slice(0, 3));
|
||||
} catch (e) {
|
||||
console.error('[getAvailableFields] error:', e);
|
||||
this.availableFields = [];
|
||||
}
|
||||
|
||||
try {
|
||||
const selectedRes = await this.$api.post('api/email_client/getJournalPromotionFields', { journal_id: String(journalId) });
|
||||
console.log('[getJournalPromotionFields] raw response:', JSON.stringify(selectedRes));
|
||||
|
||||
const selectedPayload = (selectedRes && selectedRes.data) || selectedRes || {};
|
||||
let selectedArr = this.findArray(selectedPayload);
|
||||
|
||||
if (selectedArr) {
|
||||
this.selectedFieldIds = selectedArr.map((it) => {
|
||||
return String(it.expert_fetch_id || it.fetch_id || it.id || it.field_id || it);
|
||||
});
|
||||
} else if (typeof selectedPayload === 'string') {
|
||||
this.selectedFieldIds = selectedPayload.split(',').map((s) => s.trim()).filter(Boolean);
|
||||
} else if (typeof selectedPayload.fetch_ids === 'string') {
|
||||
this.selectedFieldIds = selectedPayload.fetch_ids.split(',').map((s) => s.trim()).filter(Boolean);
|
||||
}
|
||||
console.log('[getJournalPromotionFields] parsed selected:', this.selectedFieldIds);
|
||||
} catch (e) {
|
||||
console.error('[getJournalPromotionFields] error:', e);
|
||||
this.selectedFieldIds = [];
|
||||
}
|
||||
|
||||
this.fieldsLoading = false;
|
||||
},
|
||||
async savePromotionFieldsNow() {
|
||||
if (!this.wizardJournal || !this.wizardJournal.journal_id) return;
|
||||
this.fieldsSaving = true;
|
||||
try {
|
||||
await this.$api.post('api/email_client/setJournalPromotionFields', {
|
||||
journal_id: String(this.wizardJournal.journal_id),
|
||||
fetch_ids: (this.selectedFieldIds || []).join(',')
|
||||
});
|
||||
this.$message.success(this.$t('autoPromotion.fieldsSaved'));
|
||||
} catch (e) {
|
||||
this.$message.error(this.$t('autoPromotion.saveFailed'));
|
||||
} finally {
|
||||
this.fieldsSaving = false;
|
||||
}
|
||||
},
|
||||
|
||||
async handleSolicitAction(journal) {
|
||||
if (!this.isSolicitConfigured(journal)) {
|
||||
@@ -344,7 +428,7 @@ export default {
|
||||
this.openDetail(journal);
|
||||
},
|
||||
|
||||
openWizardForJournal(journal) {
|
||||
async openWizardForJournal(journal) {
|
||||
this.wizardJournal = journal;
|
||||
const s = journal.solicit || {};
|
||||
this.wizardConfig = {
|
||||
@@ -355,6 +439,11 @@ export default {
|
||||
this.selectedTemplateName = s.templateName || '';
|
||||
this.selectedStyleName = s.styleName || '';
|
||||
this.selectedTemplateThumbHtml = `<div style="zoom:0.18; pointer-events:none; user-select:none;">${s.html || ''}</div>`;
|
||||
this.selectedFieldIds = [];
|
||||
this.availableFields = [];
|
||||
if (journal && journal.journal_id) {
|
||||
await this.loadPromotionFields(journal.journal_id);
|
||||
}
|
||||
this.showWizardDialog = true;
|
||||
},
|
||||
|
||||
@@ -387,6 +476,10 @@ export default {
|
||||
start_promotion: this.wizardConfig.enabled ? '1' : '0',
|
||||
user_id: userId
|
||||
});
|
||||
await this.$api.post('api/email_client/setJournalPromotionFields', {
|
||||
journal_id: String(this.wizardJournal.journal_id),
|
||||
fetch_ids: (this.selectedFieldIds || []).join(',')
|
||||
});
|
||||
await this.refreshJournalByDetail(this.wizardJournal);
|
||||
this.$message.success(this.$t('autoPromotion.configSaved'));
|
||||
this.showWizardDialog = false;
|
||||
@@ -445,7 +538,7 @@ export default {
|
||||
.journal-info { display: flex; align-items: center; }
|
||||
.icon-box { width: 28px; height: 28px; background: #edf5ff; border-radius: 4px; display: flex; align-items: center; justify-content: center; margin-right: 10px; }
|
||||
.icon-box i { color: #409eff; font-size: 14px; }
|
||||
.journal-name { font-size: 16px; font-weight: 600; color: #1f2d3d; }
|
||||
.journal-name { font-size: 14px; font-weight: 600; color: #1f2d3d; }
|
||||
.module-wrapper { display: grid; grid-template-columns: 1fr; }
|
||||
.module-card { border-radius: 6px; padding: 14px; display: flex; flex-direction: column; min-height: 160px; border: 1px solid transparent; }
|
||||
.is-solicit-active { background: #f4f9ff; border-color: #e1eeff; }
|
||||
|
||||
@@ -40,6 +40,10 @@
|
||||
mode="inline"
|
||||
:config="config"
|
||||
:wizardStartDate.sync="wizardStartDate"
|
||||
:selectedFieldIds.sync="selectedFieldIds"
|
||||
:availableFields="availableFields"
|
||||
:fieldsLoading="fieldsLoading"
|
||||
:fieldsSaving="fieldsSaving"
|
||||
:currentJournalName="currentJournalName"
|
||||
:selectedTemplateThumbHtml="selectedTemplateThumbHtml"
|
||||
:selectedTemplateName="selectedTemplateName"
|
||||
@@ -47,6 +51,7 @@
|
||||
:saving="saving"
|
||||
:title="$t('autoPromotion.title')"
|
||||
@open-template-selector="showTemplateDialog = true"
|
||||
@confirm-fields="savePromotionFieldsNow"
|
||||
@confirm="completeInitialization"
|
||||
/>
|
||||
</el-card>
|
||||
@@ -204,6 +209,10 @@
|
||||
:visible.sync="showWizardDialog"
|
||||
:config="config"
|
||||
:wizardStartDate.sync="wizardStartDate"
|
||||
:selectedFieldIds.sync="selectedFieldIds"
|
||||
:availableFields="availableFields"
|
||||
:fieldsLoading="fieldsLoading"
|
||||
:fieldsSaving="fieldsSaving"
|
||||
:currentJournalName="currentJournalName"
|
||||
:selectedTemplateThumbHtml="selectedTemplateThumbHtml"
|
||||
:selectedTemplateName="selectedTemplateName"
|
||||
@@ -211,6 +220,7 @@
|
||||
:saving="saving"
|
||||
:title="$t('autoPromotion.title')"
|
||||
@open-template-selector="showTemplateDialog = true"
|
||||
@confirm-fields="savePromotionFieldsNow"
|
||||
@cancel="showWizardDialog = false"
|
||||
@confirm="completeInitialization"
|
||||
/>
|
||||
@@ -328,6 +338,10 @@ export default {
|
||||
templateDialogInitialStyleId: '',
|
||||
templateDialogInitialTemplateId: '',
|
||||
togglingTaskId: '',
|
||||
selectedFieldIds: [],
|
||||
availableFields: [],
|
||||
fieldsLoading: false,
|
||||
fieldsSaving: false,
|
||||
previewForm: {
|
||||
id: '',
|
||||
email: '',
|
||||
@@ -453,6 +467,9 @@ export default {
|
||||
this.loading = true;
|
||||
try {
|
||||
await this.fetchJournalDetail();
|
||||
if (this.selectedJournalId) {
|
||||
this.loadPromotionFields(this.selectedJournalId);
|
||||
}
|
||||
if (this.config.initialized) {
|
||||
await this.fetchTemplates();
|
||||
await this.fetchList();
|
||||
@@ -524,13 +541,74 @@ export default {
|
||||
},
|
||||
|
||||
// 打开向导弹窗:用于“修改期刊自动推广配置”
|
||||
openWizardDialog() {
|
||||
this.showWizardDialog = true;
|
||||
findArray(obj) {
|
||||
if (Array.isArray(obj)) return obj;
|
||||
if (!obj || typeof obj !== 'object') return null;
|
||||
const keys = ['list', 'fields', 'rows', 'items', 'data', 'result'];
|
||||
for (const k of keys) {
|
||||
if (Array.isArray(obj[k])) return obj[k];
|
||||
}
|
||||
const values = Object.values(obj);
|
||||
if (values.length && Array.isArray(values[0])) return values[0];
|
||||
return null;
|
||||
},
|
||||
async loadPromotionFields(journalId) {
|
||||
this.fieldsLoading = true;
|
||||
this.availableFields = [];
|
||||
this.selectedFieldIds = [];
|
||||
try {
|
||||
const availableRes = await this.$api.post('api/email_client/getAvailableFields', { journal_id: String(journalId) });
|
||||
const availablePayload = (availableRes && availableRes.data) || availableRes || {};
|
||||
let availableArr = this.findArray(availablePayload);
|
||||
if (!availableArr) availableArr = Array.isArray(availablePayload) ? availablePayload : [];
|
||||
this.availableFields = availableArr.map((item, idx) => {
|
||||
const id = item.expert_fetch_id || item.fetch_id || item.id || item.field_id || (idx + 1);
|
||||
const label = item.field || item.title || item.name || item.label || String(id);
|
||||
return { id: String(id), label };
|
||||
});
|
||||
} catch (e) {
|
||||
this.availableFields = [];
|
||||
}
|
||||
try {
|
||||
const selectedRes = await this.$api.post('api/email_client/getJournalPromotionFields', { journal_id: String(journalId) });
|
||||
const selectedPayload = (selectedRes && selectedRes.data) || selectedRes || {};
|
||||
let selectedArr = this.findArray(selectedPayload);
|
||||
if (selectedArr) {
|
||||
this.selectedFieldIds = selectedArr.map((it) => String(it.expert_fetch_id || it.fetch_id || it.id || it.field_id || it));
|
||||
} else if (typeof selectedPayload === 'string') {
|
||||
this.selectedFieldIds = selectedPayload.split(',').map((s) => s.trim()).filter(Boolean);
|
||||
} else if (typeof selectedPayload.fetch_ids === 'string') {
|
||||
this.selectedFieldIds = selectedPayload.fetch_ids.split(',').map((s) => s.trim()).filter(Boolean);
|
||||
}
|
||||
} catch (e) {
|
||||
this.selectedFieldIds = [];
|
||||
}
|
||||
this.fieldsLoading = false;
|
||||
},
|
||||
async savePromotionFieldsNow() {
|
||||
if (!this.selectedJournalId) return;
|
||||
this.fieldsSaving = true;
|
||||
try {
|
||||
await this.$api.post('api/email_client/setJournalPromotionFields', {
|
||||
journal_id: String(this.selectedJournalId),
|
||||
fetch_ids: (this.selectedFieldIds || []).join(',')
|
||||
});
|
||||
this.$message.success(this.$t('autoPromotion.fieldsSaved'));
|
||||
} catch (e) {
|
||||
this.$message.error(this.$t('autoPromotion.saveFailed'));
|
||||
} finally {
|
||||
this.fieldsSaving = false;
|
||||
}
|
||||
},
|
||||
async openWizardDialog() {
|
||||
this.wizardStep = 0;
|
||||
// 尽量从已加载的 config 里取开始日期(没有就保持空)
|
||||
if (this.config && this.config.start_date) {
|
||||
this.wizardStartDate = this.config.start_date;
|
||||
}
|
||||
if (this.selectedJournalId) {
|
||||
await this.loadPromotionFields(this.selectedJournalId);
|
||||
}
|
||||
this.showWizardDialog = true;
|
||||
},
|
||||
|
||||
// 切换期刊逻辑
|
||||
@@ -622,10 +700,14 @@ export default {
|
||||
default_style_id: String(this.config.defaultStyleId || ''),
|
||||
start_promotion: this.config.enabled ? '1' : '0'
|
||||
};
|
||||
this.config.initialized = true; // 切换到管理模式
|
||||
this.config.initialized = true;
|
||||
this.showWizardDialog = false;
|
||||
this.fetchList();
|
||||
await this.$api.post(API.saveConfig, payload);
|
||||
await this.$api.post('api/email_client/setJournalPromotionFields', {
|
||||
journal_id: String(this.selectedJournalId || ''),
|
||||
fetch_ids: (this.selectedFieldIds || []).join(',')
|
||||
});
|
||||
this.$message.success(this.$t('autoPromotionLogs.configUpdated'));
|
||||
} finally {
|
||||
this.saving = false;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
v-if="mode === 'dialog'"
|
||||
:visible.sync="dialogVisible"
|
||||
:close-on-click-modal="false"
|
||||
width="1000px"
|
||||
width="1200px"
|
||||
top="5vh"
|
||||
destroy-on-close
|
||||
:title="title"
|
||||
@@ -16,7 +16,12 @@
|
||||
:selectedTemplateThumbHtml="selectedTemplateThumbHtml"
|
||||
:selectedTemplateName="selectedTemplateName"
|
||||
:selectedStyleName="selectedStyleName"
|
||||
:availableFields="availableFields"
|
||||
:fieldsLoading="fieldsLoading"
|
||||
:fieldsSaving="fieldsSaving"
|
||||
:selectedFieldIds.sync="selectedFieldIdsProxy"
|
||||
@open-template-selector="emitOpenTemplateSelector"
|
||||
@confirm-fields="emitConfirmFields"
|
||||
@update:wizardStartDate="onWizardStartDateUpdate"
|
||||
/>
|
||||
|
||||
@@ -43,7 +48,12 @@
|
||||
:selectedTemplateThumbHtml="selectedTemplateThumbHtml"
|
||||
:selectedTemplateName="selectedTemplateName"
|
||||
:selectedStyleName="selectedStyleName"
|
||||
:availableFields="availableFields"
|
||||
:fieldsLoading="fieldsLoading"
|
||||
:fieldsSaving="fieldsSaving"
|
||||
:selectedFieldIds.sync="selectedFieldIdsProxy"
|
||||
@open-template-selector="emitOpenTemplateSelector"
|
||||
@confirm-fields="emitConfirmFields"
|
||||
@update:wizardStartDate="onWizardStartDateUpdate"
|
||||
/>
|
||||
<div class="dialog-footer">
|
||||
@@ -77,7 +87,11 @@ export default {
|
||||
selectedTemplateThumbHtml: { type: String, default: '' },
|
||||
selectedTemplateName: { type: String, default: '' },
|
||||
selectedStyleName: { type: String, default: '' },
|
||||
saving: { type: Boolean, default: false }
|
||||
saving: { type: Boolean, default: false },
|
||||
availableFields: { type: Array, default: () => [] },
|
||||
fieldsLoading: { type: Boolean, default: false },
|
||||
fieldsSaving: { type: Boolean, default: false },
|
||||
selectedFieldIds: { type: Array, default: () => [] }
|
||||
},
|
||||
computed: {
|
||||
dialogVisible: {
|
||||
@@ -96,6 +110,14 @@ export default {
|
||||
this.$emit('update:wizardStartDate', val);
|
||||
}
|
||||
},
|
||||
selectedFieldIdsProxy: {
|
||||
get() {
|
||||
return this.selectedFieldIds;
|
||||
},
|
||||
set(val) {
|
||||
this.$emit('update:selectedFieldIds', val);
|
||||
}
|
||||
},
|
||||
canConfirm() {
|
||||
const id = this.config && this.config.defaultTemplateId != null ? String(this.config.defaultTemplateId) : '';
|
||||
return id !== '' && id !== '0';
|
||||
@@ -105,6 +127,9 @@ export default {
|
||||
emitOpenTemplateSelector() {
|
||||
this.$emit('open-template-selector');
|
||||
},
|
||||
emitConfirmFields() {
|
||||
this.$emit('confirm-fields');
|
||||
},
|
||||
onWizardStartDateUpdate(val) {
|
||||
// 由内容组件回传日期,继续走父组件的 .sync 链路
|
||||
this.wizardStartDateProxy = val;
|
||||
|
||||
@@ -76,7 +76,34 @@
|
||||
|
||||
<section class="form-section">
|
||||
<h4 class="section-title">
|
||||
<i class="el-icon-finished"></i> 2. {{ $t('autoPromotion.confirmAndEnable') }}
|
||||
<i class="el-icon-collection-tag"></i> 2. {{ $t('autoPromotion.selectPromotionFields') }}
|
||||
<span class="selected-count">
|
||||
{{ $t('autoPromotion.selectedCount', { count: selectedFieldIdsProxy.length }) }}
|
||||
</span>
|
||||
<el-button
|
||||
size="small"
|
||||
type="primary"
|
||||
plain
|
||||
icon="el-icon-edit-outline"
|
||||
class="section-action-btn"
|
||||
@click="fieldDialogVisible = true"
|
||||
>
|
||||
{{ $t('autoPromotion.choosePromotionFields') }}
|
||||
</el-button>
|
||||
</h4>
|
||||
<div class="status-confirm-box">
|
||||
<div v-if="selectedFieldLabels.length" class="selected-tags">
|
||||
<el-tag v-for="label in selectedFieldLabels" :key="label" size="mini" type="info" effect="plain">{{ label }}</el-tag>
|
||||
</div>
|
||||
<div class="field-tip">{{ $t('autoPromotion.selectPromotionFieldsTip') }}</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<el-divider></el-divider>
|
||||
|
||||
<section class="form-section">
|
||||
<h4 class="section-title">
|
||||
<i class="el-icon-finished"></i> 3. {{ $t('autoPromotion.confirmAndEnable') }}
|
||||
</h4>
|
||||
|
||||
<div class="status-confirm-box">
|
||||
@@ -88,19 +115,64 @@
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<el-dialog
|
||||
:title="$t('autoPromotion.selectPromotionFields')"
|
||||
:visible.sync="fieldDialogVisible"
|
||||
width="1200px"
|
||||
append-to-body
|
||||
:close-on-click-modal="false"
|
||||
>
|
||||
<div class="field-dialog-toolbar">
|
||||
<el-input
|
||||
v-model="fieldSearchText"
|
||||
size="small"
|
||||
clearable
|
||||
class="field-search-input"
|
||||
prefix-icon="el-icon-search"
|
||||
:placeholder="$t('autoPromotion.fieldSearchPlaceholder')"
|
||||
/>
|
||||
<el-button size="mini" @click="selectAllFields">{{ $t('autoPromotion.selectAll') }}</el-button>
|
||||
<el-button size="mini" @click="clearAllFields">{{ $t('autoPromotion.clearAll') }}</el-button>
|
||||
</div>
|
||||
<div class="field-dialog-body" v-loading="fieldsLoading">
|
||||
<el-checkbox-group v-model="selectedFieldIdsProxy" class="field-check-group">
|
||||
<el-checkbox v-for="f in sortedFilteredFields" :key="String(f.id)" :label="String(f.id)">
|
||||
{{ f.label }}
|
||||
</el-checkbox>
|
||||
</el-checkbox-group>
|
||||
<div v-if="!fieldsLoading && sortedFilteredFields.length === 0" class="field-empty-tip">
|
||||
{{ $t('autoPromotion.noFieldMatch') }}
|
||||
</div>
|
||||
</div>
|
||||
<span slot="footer">
|
||||
<el-button size="small" @click="fieldDialogVisible = false">{{ $t('autoPromotion.cancel') }}</el-button>
|
||||
<el-button size="small" type="primary" :loading="fieldsSaving" @click="emitConfirmFields">{{ $t('autoPromotion.confirm') }}</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'AutoPromotionWizardContent',
|
||||
data() {
|
||||
return {
|
||||
fieldSearchText: '',
|
||||
fieldDialogVisible: false
|
||||
};
|
||||
},
|
||||
props: {
|
||||
config: { type: Object, required: true },
|
||||
wizardStartDate: { type: [String, Date], default: '' },
|
||||
currentJournalName: { type: String, default: '' },
|
||||
selectedTemplateThumbHtml: { type: String, default: '' },
|
||||
selectedTemplateName: { type: String, default: '' },
|
||||
selectedStyleName: { type: String, default: '' }
|
||||
selectedStyleName: { type: String, default: '' },
|
||||
availableFields: { type: Array, default: () => [] },
|
||||
fieldsLoading: { type: Boolean, default: false },
|
||||
fieldsSaving: { type: Boolean, default: false },
|
||||
selectedFieldIds: { type: Array, default: () => [] }
|
||||
},
|
||||
computed: {
|
||||
hasSelectedTemplate() {
|
||||
@@ -109,11 +181,44 @@ export default {
|
||||
},
|
||||
displayTemplateName() {
|
||||
return this.selectedTemplateName || (this.hasSelectedTemplate ? String(this.config.defaultTemplateId) : '');
|
||||
},
|
||||
selectedFieldIdsProxy: {
|
||||
get() {
|
||||
return this.selectedFieldIds;
|
||||
},
|
||||
set(val) {
|
||||
this.$emit('update:selectedFieldIds', val);
|
||||
}
|
||||
},
|
||||
sortedFilteredFields() {
|
||||
const kw = (this.fieldSearchText || '').trim().toLowerCase();
|
||||
const list = (this.availableFields || []).filter((item) => {
|
||||
if (!kw) return true;
|
||||
return String(item.label || '').toLowerCase().includes(kw);
|
||||
});
|
||||
return list.slice().sort((a, b) => String(a.label || '').localeCompare(String(b.label || '')));
|
||||
},
|
||||
selectedFieldLabels() {
|
||||
const map = {};
|
||||
(this.availableFields || []).forEach((i) => { map[String(i.id)] = i.label; });
|
||||
return (this.selectedFieldIdsProxy || [])
|
||||
.map((id) => map[String(id)])
|
||||
.filter(Boolean);
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
emitOpenTemplateSelector() {
|
||||
this.$emit('open-template-selector');
|
||||
},
|
||||
selectAllFields() {
|
||||
this.selectedFieldIdsProxy = (this.availableFields || []).map((f) => String(f.id));
|
||||
},
|
||||
clearAllFields() {
|
||||
this.selectedFieldIdsProxy = [];
|
||||
},
|
||||
emitConfirmFields() {
|
||||
this.$emit('confirm-fields');
|
||||
this.fieldDialogVisible = false;
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -192,6 +297,9 @@ export default {
|
||||
color: #409EFF;
|
||||
font-size: 18px;
|
||||
}
|
||||
.section-action-btn {
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
/* 优化后的模板选择框 */
|
||||
.template-placeholder.mini-mode {
|
||||
@@ -406,5 +514,58 @@ export default {
|
||||
display: flex;
|
||||
gap: 30px;
|
||||
}
|
||||
.field-check-group {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, minmax(180px, 1fr));
|
||||
gap: 8px 14px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.field-dialog-toolbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
.field-search-input {
|
||||
width: 320px;
|
||||
}
|
||||
.field-choose-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.selected-count {
|
||||
font-size: 13px;
|
||||
color: #606266;
|
||||
margin-left: auto;
|
||||
margin-right: 10px;
|
||||
}
|
||||
.selected-tags {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.field-dialog-body {
|
||||
max-height: none;
|
||||
overflow: visible;
|
||||
}
|
||||
.field-empty-tip {
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
.field-check-group >>> .el-checkbox {
|
||||
margin-right: 0;
|
||||
line-height: 20px;
|
||||
}
|
||||
.field-check-group >>> .el-checkbox__label {
|
||||
font-size: 13px;
|
||||
}
|
||||
.field-tip {
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
237
src/components/page/components/email/FilePreviewDialog.vue
Normal file
237
src/components/page/components/email/FilePreviewDialog.vue
Normal file
@@ -0,0 +1,237 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
:visible.sync="visible"
|
||||
fullscreen
|
||||
append-to-body
|
||||
:show-close="false"
|
||||
custom-class="mail-preview-dialog"
|
||||
>
|
||||
<div slot="title" class="preview-navbar">
|
||||
<div class="navbar-left">
|
||||
<div class="file-icon-box" :class="getFileTypeClass(file.name)">
|
||||
<i :class="getFileIcon(file.name)"></i>
|
||||
</div>
|
||||
<span class="file-name" :title="file.name">{{ file.name }}</span>
|
||||
</div>
|
||||
|
||||
<div class="navbar-right">
|
||||
<div class="action-item" @click="handleDownload" :title="$t('mailboxCollect.downloadBtn')">
|
||||
<i class="el-icon-download"></i>
|
||||
</div>
|
||||
<div class="action-item" @click="handlePrint" v-if="isPdf" :title="$t('mailboxCollect.printBtn')">
|
||||
<i class="el-icon-printer"></i>
|
||||
</div>
|
||||
<div class="nav-divider"></div>
|
||||
<div class="action-item close-btn" @click="visible = false">
|
||||
<i class="el-icon-close"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="preview-body" v-loading="loading" element-loading-background="rgba(0, 0, 0, 0.7)">
|
||||
<iframe
|
||||
v-if="previewUrl"
|
||||
:src="previewUrl"
|
||||
class="preview-iframe"
|
||||
frameborder="0"
|
||||
@load="loading = false"
|
||||
></iframe>
|
||||
|
||||
<div v-else-if="isImage" class="image-viewer">
|
||||
<img :src="rawUrl" alt="preview" @load="loading = false" />
|
||||
</div>
|
||||
|
||||
<div v-else-if="!loading" class="error-state">
|
||||
<el-empty :description="$t('mailboxCollect.previewNotSupported')">
|
||||
<el-button type="primary" size="small" @click="handleDownload">{{ $t('mailboxCollect.downloadToView') }}</el-button>
|
||||
</el-empty>
|
||||
</div>
|
||||
</div>
|
||||
</el-dialog>
|
||||
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'FilePreviewDialog',
|
||||
data() {
|
||||
return {
|
||||
visible: false,
|
||||
loading: false,
|
||||
file: {},
|
||||
rawUrl: '', // 原始地址
|
||||
previewUrl: '', // 拼接后的预览地址
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
fileExt() {
|
||||
return this.file.name ? this.file.name.split('.').pop().toLowerCase() : '';
|
||||
},
|
||||
isImage() {
|
||||
return ['png', 'jpg', 'jpeg', 'gif', 'bmp'].includes(this.fileExt);
|
||||
},
|
||||
isPdf() {
|
||||
return this.fileExt === 'pdf';
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
/**
|
||||
* 父组件调用此方法打开弹窗
|
||||
* @param file 附件对象 {name: '', ...}
|
||||
* @param url 文件的公网绝对路径
|
||||
*/
|
||||
init(file, url) {
|
||||
this.file = file;
|
||||
this.rawUrl = url;
|
||||
this.loading = true;
|
||||
this.visible = true;
|
||||
|
||||
const ext = this.fileExt;
|
||||
|
||||
// 策略选择
|
||||
if (['doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx'].includes(ext)) {
|
||||
// Office系列:使用微软接口
|
||||
this.previewUrl = `https://view.officeapps.live.com/op/view.aspx?src=${url}`;
|
||||
} else if (['pdf', 'txt'].includes(ext) || this.isImage) {
|
||||
// 浏览器原生支持
|
||||
this.previewUrl = url;
|
||||
} else {
|
||||
this.previewUrl = '';
|
||||
this.loading = false;
|
||||
}
|
||||
},
|
||||
handleDownload() {
|
||||
this.$emit('download', this.file);
|
||||
},
|
||||
handlePrint() {
|
||||
window.print();
|
||||
},
|
||||
// 复用你之前的图标逻辑
|
||||
getFileIcon(name) {
|
||||
if (!name) return 'el-icon-files';
|
||||
var ext = name.split('.').pop().toLowerCase();
|
||||
if (['doc', 'docx'].includes(ext)) return 'el-icon-document';
|
||||
if (['jpg', 'png', 'jpeg'].includes(ext)) return 'el-icon-picture';
|
||||
return 'el-icon-files';
|
||||
},
|
||||
getFileTypeClass(name) {
|
||||
if (!name) return 'default';
|
||||
var ext = name.split('.').pop().toLowerCase();
|
||||
if (['doc', 'docx'].includes(ext)) return 'word';
|
||||
if (['jpg', 'png', 'jpeg'].includes(ext)) return 'img';
|
||||
return 'default';
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="css">
|
||||
/* 弹窗全屏覆盖与背景 */
|
||||
.mail-preview-dialog {
|
||||
background: #000 !important;
|
||||
}
|
||||
.mail-preview-dialog .el-dialog__header {
|
||||
padding: 0;
|
||||
}
|
||||
.mail-preview-dialog .el-dialog__body {
|
||||
padding: 0;
|
||||
height: calc(100vh - 56px);
|
||||
background: #333;
|
||||
}
|
||||
|
||||
/* 顶部导航栏 */
|
||||
.preview-navbar {
|
||||
height: 56px;
|
||||
background: #1a1a1a;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 0 20px;
|
||||
}
|
||||
|
||||
.navbar-left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
color: #fff;
|
||||
max-width: 70%;
|
||||
}
|
||||
|
||||
.file-icon-box {
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
border-radius: 4px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-right: 12px;
|
||||
font-size: 18px;
|
||||
}
|
||||
.file-icon-box.word { background: #0052d9; }
|
||||
.file-icon-box.img { background: #e34d59; }
|
||||
.file-icon-box.default { background: #737b85; }
|
||||
|
||||
.navbar-left .file-name {
|
||||
font-size: 16px;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
/* 右侧操作栏 */
|
||||
.navbar-right {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.action-item {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: #ccc;
|
||||
cursor: pointer;
|
||||
font-size: 20px;
|
||||
transition: all 0.2s;
|
||||
border-radius: 4px;
|
||||
}
|
||||
.action-item:hover {
|
||||
background: #333;
|
||||
color: #fff;
|
||||
}
|
||||
.close-btn:hover {
|
||||
background: #e34d59;
|
||||
}
|
||||
|
||||
.nav-divider {
|
||||
width: 1px;
|
||||
height: 20px;
|
||||
background: #444;
|
||||
margin: 0 10px;
|
||||
}
|
||||
|
||||
/* 内容区域 */
|
||||
.preview-body {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
.preview-iframe {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: #fff;
|
||||
}
|
||||
.image-viewer {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 100%;
|
||||
}
|
||||
.image-viewer img {
|
||||
max-width: 90%;
|
||||
max-height: 90%;
|
||||
box-shadow: 0 0 20px rgba(0,0,0,0.5);
|
||||
}
|
||||
.error-state {
|
||||
padding-top: 100px;
|
||||
}
|
||||
</style>
|
||||
@@ -1,164 +1,354 @@
|
||||
<template>
|
||||
<div class="mail-detail-container">
|
||||
<div class="detail-toolbar">
|
||||
<div class="toolbar-left">
|
||||
<h1 class="mail-subject-top">{{ $t('mailboxCollect.subject') }}:{{ mailData.subject }}</h1>
|
||||
</div>
|
||||
<div class="toolbar-right">
|
||||
<!-- <i class="el-icon-star-off action-icon"></i> -->
|
||||
<i class="el-icon-close action-icon" @click="$emit('close')"></i>
|
||||
<div class="detail-toolbar">
|
||||
<div class="toolbar-left">
|
||||
<h1 class="mail-subject-top">{{ $t('mailboxCollect.subject') }}:{{ mailData.subject }}</h1>
|
||||
</div>
|
||||
<div class="toolbar-right">
|
||||
<!-- <i class="el-icon-star-off action-icon"></i> -->
|
||||
<i class="el-icon-close action-icon" @click="$emit('close')"></i>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="detail-scroll-content">
|
||||
<div class="mail-header-info">
|
||||
<el-avatar :size="40" class="sender-avatar">{{ (mailData.from_name || 'U')[0] }}</el-avatar>
|
||||
<div class="info-main">
|
||||
<div class="first-line">
|
||||
<span class="sender-name">{{ mailData.from_name }}</span>
|
||||
<span class="sender-email"><{{ mailData.from_email }}></span>
|
||||
<span class="send-time">{{ formatDisplayTime(mailData.email_date) }}</span>
|
||||
|
||||
<span
|
||||
class="detail-toggle"
|
||||
@click="isDetailExpanded = !isDetailExpanded"
|
||||
v-if="mailData.to_list && mailData.to_list.length > 0"
|
||||
>
|
||||
{{ isDetailExpanded ? '收起' : '详情' }}
|
||||
<i :class="isDetailExpanded ? 'el-icon-arrow-up' : 'el-icon-arrow-down'"></i>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div v-if="isDetailExpanded" class="expanded-info">
|
||||
<div class="info-row">
|
||||
<span class="label">收件人:</span>
|
||||
<div class="recipient-tags">
|
||||
<el-tag v-for="(to, index) in mailData.to_list" :key="'to-' + index" size="mini" type="info">{{
|
||||
to.name || to.email
|
||||
}}</el-tag>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="mailData.cc_list && mailData.cc_list.length" class="info-row">
|
||||
<span class="label">抄送:</span>
|
||||
<div class="recipient-tags">
|
||||
<el-tag
|
||||
v-for="(cc, index) in mailData.cc_list"
|
||||
:key="'cc-' + index"
|
||||
size="mini"
|
||||
type="warning"
|
||||
effect="plain"
|
||||
>{{ cc.name || cc.email }}</el-tag
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-else class="simple-info" v-if="mailData.to_list && mailData.to_list.length > 0">
|
||||
发送给
|
||||
{{ mailData.to_list && mailData.to_list[0] ? mailData.to_list[0].name || mailData.to_list[0].email : '' }} 等{{
|
||||
mailData.to_list.length
|
||||
}}人
|
||||
</div>
|
||||
<div v-if="mailData.attachments && mailData.attachments.length" class="attachment-brief-bar">
|
||||
<span class="brief-info">
|
||||
{{ $t('mailboxCollect.totalAttachments', { count: mailData.attachments.length }) }}(
|
||||
<i class="el-icon-document" style="color: #409EFF;"></i>
|
||||
<span class="first-file-name">{{ mailData.attachments[0].name }}{{ mailData.attachments.length > 1 ? $t('mailboxCollect.etcSuffix') : '' }}</span>
|
||||
)
|
||||
|
||||
</span>
|
||||
<el-link type="primary" :underline="false" @click="scrollToAttachments" class="jump-link">
|
||||
{{ $t('mailboxCollect.viewAttachments') }}
|
||||
</el-link>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mail-body-content" v-html="mailData.content_html"></div>
|
||||
|
||||
<div v-if="mailData.attachments && mailData.attachments.length" class="attachment-section">
|
||||
<div class="attachment-header">
|
||||
<div class="header-left">
|
||||
<span>{{ mailData.attachments.length }}{{ $t('mailboxCollect.attachmentCount') }} ({{ totalAttachmentSize }})</span>
|
||||
<span class="divider">|</span>
|
||||
<span class="download-all" @click="downloadAll">
|
||||
<template v-if="packingAll"><i class="el-icon-loading"></i> {{ $t('mailboxCollect.packingAttachments') }}</template>
|
||||
<template v-else>{{ $t('mailboxCollect.downloadAllZip') }}</template>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="attachment-list">
|
||||
<div v-for="(file, index) in mailData.attachments" :key="index" class="attachment-card">
|
||||
<div class="file-icon" :class="getFileTypeClass(file.name)">
|
||||
<i :class="getFileIcon(file.name)"></i>
|
||||
</div>
|
||||
|
||||
<div class="detail-scroll-content">
|
||||
<div class="mail-header-info">
|
||||
<el-avatar :size="40" class="sender-avatar">{{ (mailData.from_name || 'U')[0] }}</el-avatar>
|
||||
<div class="info-main">
|
||||
<div class="first-line">
|
||||
<span class="sender-name">{{ mailData.from_name }}</span>
|
||||
<span class="sender-email"><{{ mailData.from_email }}></span>
|
||||
<span class="send-time">{{ formatDisplayTime(mailData.email_date) }}</span>
|
||||
<span class="detail-toggle" @click="isDetailExpanded = !isDetailExpanded" v-if="mailData.to_list&&mailData.to_list.length>0">
|
||||
{{ isDetailExpanded ? '收起' : '详情' }} <i :class="isDetailExpanded ? 'el-icon-arrow-up' : 'el-icon-arrow-down'"></i>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div v-if="isDetailExpanded" class="expanded-info">
|
||||
<div class="info-row">
|
||||
<span class="label">收件人:</span>
|
||||
<div class="recipient-tags">
|
||||
<el-tag v-for="(to, index) in mailData.to_list" :key="'to-'+index" size="mini" type="info">{{ to.name || to.email }}</el-tag>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="mailData.cc_list && mailData.cc_list.length" class="info-row">
|
||||
<span class="label">抄送:</span>
|
||||
<div class="recipient-tags">
|
||||
<el-tag v-for="(cc, index) in mailData.cc_list" :key="'cc-'+index" size="mini" type="warning" effect="plain">{{ cc.name || cc.email }}</el-tag>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-else class="simple-info" v-if="mailData.to_list&&mailData.to_list.length>0">
|
||||
发送给 {{ mailData.to_list && mailData.to_list[0] ? (mailData.to_list[0].name || mailData.to_list[0].email) : '' }} 等{{ mailData.to_list.length }}人
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mail-body-content" v-html="mailData.content_html"></div>
|
||||
|
||||
<div v-if="mailData.attachments && mailData.attachments.length" class="attachment-section">
|
||||
<div class="attachment-header">
|
||||
<span>{{ mailData.attachments.length }}个附件 ({{ totalAttachmentSize }})</span>
|
||||
<el-button type="text" size="small">打包下载</el-button>
|
||||
<span class="security-tip"><i class="el-icon-success"></i> 附件中未发现病毒</span>
|
||||
</div>
|
||||
<div class="attachment-list">
|
||||
<div v-for="(file, index) in mailData.attachments" :key="index" class="attachment-card">
|
||||
<div class="file-icon">
|
||||
<i :class="getFileIcon(file.name)"></i>
|
||||
</div>
|
||||
<div class="file-info">
|
||||
<div class="file-name" :title="file.name">{{ file.name }}</div>
|
||||
<div class="file-size">{{ file.size }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="file-info">
|
||||
<div class="file-name" :title="file.name">{{ file.name }}</div>
|
||||
<div class="file-size-row">
|
||||
<span class="file-size">{{ formatFileSize(file.size) }}</span>
|
||||
<span class="file-actions">
|
||||
<!-- <i class="el-icon-view" title="预览" @click.stop="previewAttachment(file)"></i> -->
|
||||
<i
|
||||
:class="downloadingIndex === index ? 'el-icon-loading' : 'el-icon-download'"
|
||||
:title="downloadingIndex === index ? '' : '下载'"
|
||||
@click.stop="downloadAttachment(file, index)"
|
||||
></i>
|
||||
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<file-preview-dialog
|
||||
ref="previewDialog"
|
||||
@download="downloadAttachment"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Common from '@/components/common/common';
|
||||
import JSZip from 'jszip';
|
||||
import { saveAs } from 'file-saver';
|
||||
import FilePreviewDialog from './FilePreviewDialog.vue';
|
||||
export default {
|
||||
components: {
|
||||
FilePreviewDialog
|
||||
},
|
||||
name: 'MailDetail',
|
||||
props: {
|
||||
mailData: {
|
||||
type: Object,
|
||||
default: () => ({
|
||||
subject: '',
|
||||
from_name: '',
|
||||
from_email: '',
|
||||
send_time: '',
|
||||
to_list: [],
|
||||
cc_list: [],
|
||||
content: '',
|
||||
attachments: []
|
||||
})
|
||||
}
|
||||
mailData: {
|
||||
type: Object,
|
||||
default: () => ({
|
||||
subject: '',
|
||||
from_name: '',
|
||||
from_email: '',
|
||||
send_time: '',
|
||||
to_list: [],
|
||||
cc_list: [],
|
||||
content: '',
|
||||
attachments: []
|
||||
})
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
isDetailExpanded: false
|
||||
};
|
||||
return {
|
||||
mediaUrl: Common.mediaUrl,
|
||||
isDetailExpanded: false,
|
||||
downloadingIndex: -1,
|
||||
packingAll: false
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
totalAttachmentSize() {
|
||||
// 简单模拟计算总量,实际可根据逻辑累加
|
||||
return "11MB";
|
||||
}
|
||||
totalAttachmentSize() {
|
||||
if (!this.mailData.attachments || !this.mailData.attachments.length) return '0B';
|
||||
const total = this.mailData.attachments.reduce((sum, f) => sum + (Number(f.size) || 0), 0);
|
||||
return this.formatFileSize(total);
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
formatDisplayTime(timestamp) {
|
||||
if (!timestamp) return '';
|
||||
|
||||
// 1. 处理 10 位秒级时间戳,转为毫秒并实例化 Date 对象
|
||||
const date = new Date(Number(timestamp) * 1000);
|
||||
const now = new Date();
|
||||
|
||||
// 提取日期信息用于比较
|
||||
const dateYear = date.getFullYear();
|
||||
const nowYear = now.getFullYear();
|
||||
const lang = localStorage.getItem('langs') === 'zh' ? 'zh-CN' : 'en-US';
|
||||
|
||||
// 获取昨天日期
|
||||
const yesterday = new Date(now);
|
||||
yesterday.setDate(now.getDate() - 1);
|
||||
|
||||
// 获取具体时分并补零 (例如 09:05)
|
||||
const hours = date.getHours().toString().padStart(2, '0');
|
||||
const minutes = date.getMinutes().toString().padStart(2, '0');
|
||||
const timePart = `${hours}:${minutes}`;
|
||||
|
||||
// --- 按照图示规则判断返回 ---
|
||||
|
||||
// 1. 如果是今天:只显示时间,如 "15:57"
|
||||
if (date.toDateString() === now.toDateString()) {
|
||||
return timePart;
|
||||
}
|
||||
|
||||
// 2. 如果是昨天:只显示 "昨天"
|
||||
if (date.toDateString() === yesterday.toDateString()) {
|
||||
return this.$t('mailboxCollect.yesterday');
|
||||
}
|
||||
|
||||
// 3. 如果是今年(非今天/昨天):按语言显示月日
|
||||
if (dateYear === nowYear) {
|
||||
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}`;
|
||||
},
|
||||
getFileIcon(fileName) {
|
||||
if (fileName.includes('.doc')) return 'el-icon-document text-blue';
|
||||
if (fileName.includes('.pdf')) return 'el-icon-document text-red';
|
||||
return 'el-icon-document';
|
||||
}
|
||||
scrollToAttachments() {
|
||||
// 1. 获取目标元素的 DOM
|
||||
const target = this.$el.querySelector('.attachment-section');
|
||||
|
||||
if (target) {
|
||||
// 2. 使用原生 scrollIntoView 实现平滑滚动
|
||||
target.scrollIntoView({
|
||||
behavior: 'smooth', // 平滑滚动
|
||||
block: 'start' // 滚动到元素顶部
|
||||
});
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.mail-detail-container { height: 100%; display: flex; flex-direction: column; background: #fff; }
|
||||
|
||||
/* 顶部工具栏 */
|
||||
.detail-toolbar { padding: 10px 20px; border-bottom: 1px solid #f0f0f0; display: flex; justify-content: space-between; align-items: center; }
|
||||
.toolbar-left { flex: 1; min-width: 0; }
|
||||
.mail-subject-top {
|
||||
},
|
||||
getFileTypeClass(fileName) {
|
||||
if (!fileName) return 'txt';
|
||||
const ext = fileName.split('.').pop().toLowerCase();
|
||||
if (['jpg', 'jpeg', 'png', 'gif'].includes(ext)) return 'img';
|
||||
if (['doc', 'docx'].includes(ext)) return 'word';
|
||||
if (['html', 'htm'].includes(ext)) return 'html';
|
||||
return 'txt';
|
||||
},
|
||||
// 你原有的 getFileIcon 也要对应修改
|
||||
getFileIcon(fileName) {
|
||||
const ext = fileName.split('.').pop().toLowerCase();
|
||||
if (['jpg', 'jpeg', 'png', 'gif'].includes(ext)) return 'el-icon-picture';
|
||||
if (['doc', 'docx'].includes(ext)) return 'el-icon-document'; // 这里可以用Word图标
|
||||
if (['html', 'htm'].includes(ext)) return 'el-icon-document-remove';
|
||||
return 'el-icon-tickets';
|
||||
},
|
||||
formatFileSize(bytes) {
|
||||
const b = Number(bytes);
|
||||
if (!b || b <= 0) return '-';
|
||||
if (b < 1024) return b + 'B';
|
||||
if (b < 1024 * 1024) return (b / 1024).toFixed(1) + 'KB';
|
||||
if (b < 1024 * 1024 * 1024) return (b / (1024 * 1024)).toFixed(1) + 'MB';
|
||||
return (b / (1024 * 1024 * 1024)).toFixed(2) + 'GB';
|
||||
},
|
||||
async ensureFileUrl(file) {
|
||||
if (file.file_url) return file.file_url;
|
||||
const inboxId = this.mailData.inbox_id;
|
||||
const partIndex = file.part_index != null ? file.part_index : 0;
|
||||
if (!inboxId) return '';
|
||||
const res = await this.$api.post('api/email_client/getAttachment', {
|
||||
inbox_id: String(inboxId),
|
||||
part_index: String(partIndex)
|
||||
});
|
||||
if (res && res.data && res.data.file_url) {
|
||||
file.file_url = res.data.file_url;
|
||||
return res.data.file_url;
|
||||
}
|
||||
return '';
|
||||
},
|
||||
async downloadAll() {
|
||||
if (this.packingAll) return;
|
||||
this.packingAll = true;
|
||||
try {
|
||||
const zip = new JSZip();
|
||||
const promises = this.mailData.attachments.map(async (file) => {
|
||||
const url = await this.ensureFileUrl(file);
|
||||
if (!url) return;
|
||||
const fileUrl = this.mediaUrl + url;
|
||||
const resp = await fetch(fileUrl);
|
||||
const blob = await resp.blob();
|
||||
zip.file(file.name || 'attachment', blob);
|
||||
});
|
||||
await Promise.all(promises);
|
||||
const content = await zip.generateAsync({ type: 'blob' });
|
||||
const zipName = (this.mailData.subject || 'attachments') + '.zip';
|
||||
saveAs(content, zipName);
|
||||
} catch (e) {
|
||||
this.$message.error(this.$t('mailboxCollect.downloadFail') || '下载失败');
|
||||
} finally {
|
||||
this.packingAll = false;
|
||||
}
|
||||
},
|
||||
async previewAttachment(file){
|
||||
console.log("🚀 ~ previewAttachment ~ file:", file);
|
||||
|
||||
var that = this;
|
||||
that.$refs.previewDialog.init(file, this.mediaUrl+file.file_url || '');
|
||||
// 1. 获取后端返回的 URL
|
||||
const res = await this.$api.post('api/email_client/getAttachment', {
|
||||
inbox_id: String(this.mailData.inbox_id),
|
||||
part_index: String(file.part_index || 0)
|
||||
});
|
||||
|
||||
if (res.data && res.data.file_url) {
|
||||
const fullUrl = this.mediaUrl + res.data.file_url;
|
||||
|
||||
// 2. 调用弹窗组件的 init 方法
|
||||
// 注意:微软预览要求 fullUrl 必须是公网可访问的!
|
||||
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
async downloadAttachment(file, index) {
|
||||
if (this.downloadingIndex >= 0) return;
|
||||
this.downloadingIndex = index;
|
||||
try {
|
||||
const url = await this.ensureFileUrl(file);
|
||||
if (!url) {
|
||||
this.$message.warning(this.$t('mailboxCollect.downloadFail') || '下载失败');
|
||||
return;
|
||||
}
|
||||
const fileUrl = this.mediaUrl + url;
|
||||
const fileName = file.name || 'attachment';
|
||||
const resp = await fetch(fileUrl);
|
||||
const blob = await resp.blob();
|
||||
saveAs(blob, fileName);
|
||||
} catch (e) {
|
||||
this.$message.error(this.$t('mailboxCollect.downloadFail') || '下载失败');
|
||||
} finally {
|
||||
this.downloadingIndex = -1;
|
||||
}
|
||||
},
|
||||
|
||||
formatDisplayTime(timestamp) {
|
||||
if (!timestamp) return '';
|
||||
|
||||
// 1. 处理 10 位秒级时间戳,转为毫秒并实例化 Date 对象
|
||||
const date = new Date(Number(timestamp) * 1000);
|
||||
const now = new Date();
|
||||
|
||||
// 提取日期信息用于比较
|
||||
const dateYear = date.getFullYear();
|
||||
const nowYear = now.getFullYear();
|
||||
const lang = localStorage.getItem('langs') === 'zh' ? 'zh-CN' : 'en-US';
|
||||
|
||||
// 获取昨天日期
|
||||
const yesterday = new Date(now);
|
||||
yesterday.setDate(now.getDate() - 1);
|
||||
|
||||
// 获取具体时分并补零 (例如 09:05)
|
||||
const hours = date.getHours().toString().padStart(2, '0');
|
||||
const minutes = date.getMinutes().toString().padStart(2, '0');
|
||||
const timePart = `${hours}:${minutes}`;
|
||||
|
||||
// --- 按照图示规则判断返回 ---
|
||||
|
||||
// 1. 如果是今天:只显示时间,如 "15:57"
|
||||
if (date.toDateString() === now.toDateString()) {
|
||||
return timePart;
|
||||
}
|
||||
|
||||
// 2. 如果是昨天:显示 "昨天 15:57"
|
||||
if (date.toDateString() === yesterday.toDateString()) {
|
||||
return this.$t('mailboxCollect.yesterday') + ' ' + timePart;
|
||||
}
|
||||
|
||||
// 3. 如果是今年(非今天/昨天):按语言显示月日
|
||||
if (dateYear === nowYear) {
|
||||
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}`;
|
||||
},
|
||||
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.mail-detail-container {
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
/* 顶部工具栏 */
|
||||
.detail-toolbar {
|
||||
padding: 10px 20px;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
.toolbar-left {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
.mail-subject-top {
|
||||
margin: 0;
|
||||
font-size: 18px;
|
||||
font-weight: bold;
|
||||
@@ -166,40 +356,307 @@
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
.action-icon {
|
||||
font-size: 18px;
|
||||
color: #606266;
|
||||
cursor: pointer;
|
||||
}
|
||||
.action-icon:hover {
|
||||
color: #409eff;
|
||||
}
|
||||
|
||||
.detail-scroll-content {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
padding: 20px 20px;
|
||||
}
|
||||
|
||||
/* 头部信息 */
|
||||
.mail-header-info {
|
||||
display: flex;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.info-main {
|
||||
flex: 1;
|
||||
margin-left: 15px;
|
||||
}
|
||||
.first-line {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-bottom: 5px;
|
||||
font-size: 14px;
|
||||
}
|
||||
.sender-name {
|
||||
font-weight: bold;
|
||||
color: #303133;
|
||||
}
|
||||
.sender-email {
|
||||
color: #909399;
|
||||
margin-left: 5px;
|
||||
}
|
||||
.send-time {
|
||||
margin-left: auto;
|
||||
color: #909399;
|
||||
}
|
||||
.detail-toggle {
|
||||
margin-left: 10px;
|
||||
color: #409eff;
|
||||
cursor: pointer;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.expanded-info {
|
||||
background: #f8f9fa;
|
||||
padding: 10px;
|
||||
border-radius: 4px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
.info-row {
|
||||
display: flex;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
.info-row .label {
|
||||
width: 60px;
|
||||
color: #909399;
|
||||
font-size: 13px;
|
||||
}
|
||||
.recipient-tags {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 5px;
|
||||
}
|
||||
.simple-info {
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
}
|
||||
|
||||
/* 正文 */
|
||||
.mail-body-content {
|
||||
line-height: 1.6;
|
||||
font-size: 14px;
|
||||
color: #303133;
|
||||
min-height: 200px;
|
||||
margin-bottom: 50px;
|
||||
}
|
||||
|
||||
/* 附件卡片 */
|
||||
.attachment-section {
|
||||
border-top: 1px solid #eee;
|
||||
padding-top: 20px;
|
||||
}
|
||||
.attachment-header {
|
||||
margin-bottom: 15px;
|
||||
font-size: 13px;
|
||||
color: #606266;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
.security-tip {
|
||||
margin-left: auto;
|
||||
color: #67c23a;
|
||||
}
|
||||
.attachment-list {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 15px;
|
||||
}
|
||||
.attachment-card {
|
||||
/* width: 260px; */
|
||||
/* border: 1px solid #e4e7ed; */
|
||||
border-radius: 4px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 10px;
|
||||
background: #fbfbfc;
|
||||
cursor: pointer;
|
||||
transition: border-color 0.2s, box-shadow 0.2s;
|
||||
}
|
||||
.attachment-card:hover {
|
||||
border-color: #409eff;
|
||||
box-shadow: 0 2px 8px rgba(64, 158, 255, 0.12);
|
||||
}
|
||||
.file-icon {
|
||||
font-size: 32px;
|
||||
color: #409eff;
|
||||
margin-right: 12px;
|
||||
}
|
||||
.file-info {
|
||||
flex: 1;
|
||||
overflow: hidden;
|
||||
}
|
||||
.file-name {
|
||||
font-size: 13px;
|
||||
color: #303133;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
.file-size {
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
margin-top: 4px;
|
||||
}
|
||||
.file-download {
|
||||
font-size: 18px;
|
||||
color: #909399;
|
||||
margin-left: 8px;
|
||||
}
|
||||
.attachment-card:hover .file-download {
|
||||
color: #409eff;
|
||||
}
|
||||
.text-blue {
|
||||
color: #409eff;
|
||||
}
|
||||
.text-red {
|
||||
color: #f56c6c;
|
||||
}
|
||||
.attachment-section {
|
||||
padding-top: 10px;
|
||||
background-color: #fff;
|
||||
border-top: 1px solid #f0f0f0;
|
||||
}
|
||||
|
||||
/* 头部样式 */
|
||||
.attachment-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 12px;
|
||||
font-size: 13px;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.attachment-header .divider {
|
||||
margin: 0 10px;
|
||||
color: #e0e0e0;
|
||||
}
|
||||
|
||||
.attachment-header .download-all {
|
||||
color: #409eff;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.attachment-header .header-right {
|
||||
color: #2ba471; /* 安全绿色 */
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
/* 列表布局 */
|
||||
.attachment-list {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
/* 附件卡片 */
|
||||
.attachment-card {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 10px;
|
||||
background-color: #f3f5f8; /* 浅灰色背景 */
|
||||
border-radius: 2px;
|
||||
cursor: default;
|
||||
transition: background-color 0.2s;
|
||||
height: 54px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.attachment-card:hover {
|
||||
background-color: #e7eaf0;
|
||||
}
|
||||
|
||||
/* 图标颜色控制 */
|
||||
.file-icon {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-right: 12px;
|
||||
border-radius: 2px;
|
||||
font-size: 20px;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
/* 根据类型设置背景色 (需在 getFileTypeClass 中返回) */
|
||||
.file-icon.img { background-color: #e34d59; } /* 红色 */
|
||||
.file-icon.word { background-color: #0052d9; } /* 蓝色 */
|
||||
.file-icon.html { background-color: #ed7b2f; } /* 橙色 */
|
||||
.file-icon.txt { background-color: #737b85; } /* 灰色 */
|
||||
|
||||
/* 信息部分 */
|
||||
.file-info {
|
||||
flex: 1;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.file-name {
|
||||
font-size: 13px;
|
||||
color: #333;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
|
||||
.file-size-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
height: 18px;
|
||||
}
|
||||
|
||||
.file-size {
|
||||
font-size: 12px;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
/* 悬浮图标控制 */
|
||||
.file-actions {
|
||||
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.attachment-card:hover .file-actions {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.file-actions i {
|
||||
margin-left: 12px;
|
||||
font-size: 16px;
|
||||
color: #666;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.file-actions i:hover {
|
||||
color: #0052d9;
|
||||
}
|
||||
.attachment-brief-bar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 8px 0;
|
||||
font-size: 13px;
|
||||
color: #606266;
|
||||
border-top: 1px solid #ebeef5;
|
||||
|
||||
|
||||
}
|
||||
.attachment-brief-bar .brief-info {
|
||||
|
||||
}
|
||||
.action-icon { font-size: 18px; color: #606266; cursor: pointer; }
|
||||
.action-icon:hover { color: #409EFF; }
|
||||
|
||||
.detail-scroll-content { flex: 1; overflow-y: auto; padding: 20px 40px; }
|
||||
|
||||
/* 头部信息 */
|
||||
.mail-header-info { display: flex; margin-bottom: 30px; }
|
||||
.info-main { flex: 1; margin-left: 15px; }
|
||||
.first-line { display: flex; align-items: center; margin-bottom: 5px; font-size: 14px; }
|
||||
.sender-name { font-weight: bold; color: #303133; }
|
||||
.sender-email { color: #909399; margin-left: 5px; }
|
||||
.send-time { margin-left: auto; color: #909399; }
|
||||
.detail-toggle { margin-left: 10px; color: #409EFF; cursor: pointer; font-size: 12px; }
|
||||
|
||||
.expanded-info { background: #f8f9fa; padding: 10px; border-radius: 4px; margin-top: 10px; }
|
||||
.info-row { display: flex; margin-bottom: 8px; }
|
||||
.info-row .label { width: 60px; color: #909399; font-size: 13px; }
|
||||
.recipient-tags { flex: 1; display: flex; flex-wrap: wrap; gap: 5px; }
|
||||
.simple-info { font-size: 12px; color: #909399; }
|
||||
|
||||
/* 正文 */
|
||||
.mail-body-content { line-height: 1.6; font-size: 14px; color: #303133; min-height: 200px; margin-bottom: 50px; }
|
||||
|
||||
/* 附件卡片 */
|
||||
.attachment-section { border-top: 1px solid #eee; padding-top: 20px; }
|
||||
.attachment-header { margin-bottom: 15px; font-size: 13px; color: #606266; display: flex; align-items: center; }
|
||||
.security-tip { margin-left: auto; color: #67C23A; }
|
||||
.attachment-list { display: flex; flex-wrap: wrap; gap: 15px; }
|
||||
.attachment-card { width: 260px; border: 1px solid #e4e7ed; border-radius: 4px; display: flex; padding: 10px; background: #fbfbfc; }
|
||||
.file-icon { font-size: 32px; color: #409EFF; margin-right: 12px; }
|
||||
.file-info { flex: 1; overflow: hidden; }
|
||||
.file-name { font-size: 13px; color: #303133; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||||
.file-size { font-size: 12px; color: #909399; margin-top: 4px; }
|
||||
.text-blue { color: #409EFF; }
|
||||
.text-red { color: #F56C6C; }
|
||||
</style>
|
||||
.attachment-brief-bar .first-file-name {
|
||||
color: #909399;
|
||||
margin-left: 4px;
|
||||
}
|
||||
.jump-link {
|
||||
margin-left: 15px;
|
||||
font-size: 13px;
|
||||
}
|
||||
.attachment-section {
|
||||
margin-top: 30px;
|
||||
padding-top: 20px;
|
||||
border-top: 2px solid #f0f2f5;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,174 +1,249 @@
|
||||
<template>
|
||||
<div class="tmr-editor-container">
|
||||
<div class="editor-header">
|
||||
<span class="title"></span>
|
||||
<button @click="showModal = true" class="preview-trigger-btn">
|
||||
<i class="icon-eye"></i> {{ $t('tmrEmailEditor.preview') }}
|
||||
</button>
|
||||
<div class="tmr-editor-container">
|
||||
<div class="editor-header">
|
||||
<div class="title-slot">
|
||||
<slot name="title"></slot>
|
||||
</div>
|
||||
|
||||
<textarea
|
||||
:value="plainText"
|
||||
@input="handleInput"
|
||||
:placeholder="resolvedPlaceholder"
|
||||
class="tmr-textarea"
|
||||
></textarea>
|
||||
|
||||
<transition name="fade">
|
||||
<div v-if="showModal" class="tmr-modal-mask" @click.self="showModal = false">
|
||||
<div class="tmr-modal-container">
|
||||
<div class="modal-header">
|
||||
<span>{{ $t('tmrEmailEditor.preview') }}</span>
|
||||
<button class="close-btn" @click="showModal = false">×</button>
|
||||
</div>
|
||||
|
||||
<div class="modal-body">
|
||||
<div class="common_tmr_email_box" v-html="htmlContentForPreview"></div>
|
||||
</div>
|
||||
|
||||
|
||||
<button @click="showModal = true" class="preview-trigger-btn">
|
||||
<i class="icon-eye"></i> {{ $t('tmrEmailEditor.preview') || '预览' }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<textarea
|
||||
ref="editorRef"
|
||||
class="tmr-textarea"
|
||||
:value="plainText"
|
||||
@input="handleInput"
|
||||
:placeholder="resolvedPlaceholder"
|
||||
></textarea>
|
||||
|
||||
<transition name="fade">
|
||||
<div v-if="showModal" class="tmr-modal-mask" @click.self="showModal = false">
|
||||
<div class="tmr-modal-container">
|
||||
<div class="modal-header">
|
||||
<span>{{ $t('tmrEmailEditor.preview') || '邮件预览' }}</span>
|
||||
<button class="close-btn" @click="showModal = false">×</button>
|
||||
</div>
|
||||
|
||||
<div class="modal-body">
|
||||
<div class="common_tmr_email_box" v-html="htmlContentForPreview"></div>
|
||||
</div>
|
||||
|
||||
<div class="modal-footer">
|
||||
<button class="confirm-btn" @click="showModal = false">关闭</button>
|
||||
</div>
|
||||
</div>
|
||||
</transition>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'TmrEmailEditor',
|
||||
props: {
|
||||
value: { type: String, default: '' },
|
||||
placeholder: { type: String, default: '' }
|
||||
</div>
|
||||
</transition>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'TmrEmailEditor',
|
||||
props: {
|
||||
// 预期格式: <div class="common_tmr_email_box">内容...</div>
|
||||
value: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
showModal: false // 控制弹窗显示
|
||||
}
|
||||
placeholder: {
|
||||
type: String,
|
||||
default: ''
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
showModal: false
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
resolvedPlaceholder() {
|
||||
return this.placeholder || (this.$t && this.$t('tmrEmailEditor.placeholder')) || '请输入邮件内容...';
|
||||
},
|
||||
computed: {
|
||||
resolvedPlaceholder() {
|
||||
return this.placeholder || this.$t('tmrEmailEditor.placeholder');
|
||||
},
|
||||
// 剥离外壳给 textarea 显示
|
||||
plainText() {
|
||||
if (!this.value) return '';
|
||||
const regex = /<div class="common_tmr_email_box">([\s\S]*?)<\/div>/i;
|
||||
const match = this.value.match(regex);
|
||||
const content = (match && match[1]) ? match[1] : this.value;
|
||||
return content.replace(/<br\s*\/?>/gi, '\n');
|
||||
},
|
||||
// 提取内部内容用于预览
|
||||
htmlContentForPreview() {
|
||||
const regex = /<div class="common_tmr_email_box">([\s\S]*?)<\/div>/i;
|
||||
const match = this.value.match(regex);
|
||||
return match ? match[1] : this.value;
|
||||
}
|
||||
// 将传入的 HTML 还原为 textarea 可读的纯文本
|
||||
plainText() {
|
||||
if (!this.value) return '';
|
||||
return this.extractContent(this.value);
|
||||
},
|
||||
methods: {
|
||||
handleInput(e) {
|
||||
const rawValue = e.target.value;
|
||||
const htmlContent = rawValue.replace(/\n/g, '<br>');
|
||||
const finalResult = `<div class="common_tmr_email_box">${htmlContent}</div>`;
|
||||
this.$emit('input', finalResult);
|
||||
}
|
||||
// 用于预览的 HTML,保持与输出一致
|
||||
htmlContentForPreview() {
|
||||
return this.value || '';
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
/**
|
||||
* 核心:剥离外层容器和换行符
|
||||
* 将 <div class="...">line1<br>line2</div> 还原为 line1\nline2
|
||||
*/
|
||||
extractContent(html) {
|
||||
if (!html) return '';
|
||||
|
||||
// 1. 匹配最外层 div 内部的内容
|
||||
const wrapperRegex = /<div class="common_tmr_email_box">([\s\S]*)<\/div>/i;
|
||||
const match = html.match(wrapperRegex);
|
||||
let content = match ? match[1] : html;
|
||||
|
||||
// 2. 将 <br> 或 <br /> 替换为换行符 \n
|
||||
content = content.replace(/<br\s*\/?>/gi, '\n');
|
||||
|
||||
// 3. (可选) 如果还有其他标签可以进一步清洗,目前保持原样
|
||||
return content;
|
||||
},
|
||||
|
||||
/**
|
||||
* 输入处理:实时包装并提交
|
||||
*/
|
||||
handleInput(e) {
|
||||
const text = e.target.value;
|
||||
|
||||
// 将换行符转回 HTML 换行
|
||||
const htmlContent = text.replace(/\n/g, '<br>');
|
||||
|
||||
// 包装外层容器
|
||||
const finalResult = `<div class="common_tmr_email_box">${htmlContent}</div>`;
|
||||
|
||||
// 触发 v-model 更新
|
||||
this.$emit('input', finalResult);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
/* 1. 基础布局 */
|
||||
.tmr-editor-container { width: 100%; position: relative; }
|
||||
.editor-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 8px 0;
|
||||
}
|
||||
.preview-trigger-btn {
|
||||
background: #f0f2f5;
|
||||
border: 1px solid #dcdfe6;
|
||||
padding: 5px 12px;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
color: #606266;
|
||||
font-size: 13px;
|
||||
}
|
||||
.preview-trigger-btn:hover { color: #409eff; border-color: #c6e2ff; background: #ecf5ff; }
|
||||
|
||||
.tmr-textarea {
|
||||
width: 100%;
|
||||
min-height: 70vh;
|
||||
padding: 15px;
|
||||
border: 1px solid #e4e7ed;
|
||||
border-radius: 4px;
|
||||
font-size: 14px;
|
||||
line-height: 1.6;
|
||||
box-sizing: border-box;
|
||||
resize: vertical;
|
||||
}
|
||||
|
||||
/* 2. 弹窗动画 */
|
||||
.fade-enter-active, .fade-leave-active { transition: opacity 0.3s; }
|
||||
.fade-enter, .fade-leave-to { opacity: 0; }
|
||||
|
||||
/* 3. 弹窗样式 */
|
||||
.tmr-modal-mask {
|
||||
position: fixed;
|
||||
z-index: 9998;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: rgba(0, 0, 0, 0.5);
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.tmr-modal-container {
|
||||
width: 1000px;
|
||||
max-width: 90%;
|
||||
background-color: #fff;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 2px 12px 0 rgba(0,0,0,.1);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.modal-header {
|
||||
padding: 15px 20px;
|
||||
border-bottom: 1px solid #eee;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.close-btn { border: none; background: none; font-size: 20px; cursor: pointer; color: #909399; }
|
||||
|
||||
.modal-body {
|
||||
padding: 20px;
|
||||
min-height: 60vh;
|
||||
overflow-y: auto;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.modal-footer {
|
||||
padding: 10px 20px;
|
||||
border-top: 1px solid #eee;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.confirm-btn {
|
||||
background: #409eff;
|
||||
color: #fff;
|
||||
border: none;
|
||||
padding: 8px 20px;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
/* 确保预览区域样式正确渲染 */
|
||||
.common_tmr_email_box {
|
||||
word-break: break-all;
|
||||
line-height: 1.6;
|
||||
}
|
||||
</style>
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
/* 1. 基础布局 */
|
||||
.tmr-editor-container {
|
||||
width: 100%;
|
||||
position: relative;
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
||||
}
|
||||
|
||||
.editor-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding-bottom: 8px;
|
||||
}
|
||||
|
||||
.preview-trigger-btn {
|
||||
background: #fff;
|
||||
border: 1px solid #dcdfe6;
|
||||
padding: 6px 15px;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
color: #606266;
|
||||
font-size: 13px;
|
||||
transition: all 0.2s;
|
||||
}
|
||||
|
||||
.preview-trigger-btn:hover {
|
||||
color: #409eff;
|
||||
border-color: #c6e2ff;
|
||||
background: #ecf5ff;
|
||||
}
|
||||
|
||||
/* 2. 编辑器样式 */
|
||||
.tmr-textarea {
|
||||
width: 100%;
|
||||
min-height: 400px;
|
||||
padding: 15px;
|
||||
border: 1px solid #e4e7ed;
|
||||
border-radius: 4px;
|
||||
font-size: 14px;
|
||||
line-height: 1.6;
|
||||
box-sizing: border-box;
|
||||
resize: vertical;
|
||||
outline: none;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.tmr-textarea:focus {
|
||||
border-color: #409eff;
|
||||
}
|
||||
|
||||
/* 3. 弹窗动画 */
|
||||
.fade-enter-active, .fade-leave-active { transition: opacity 0.3s; }
|
||||
.fade-enter, .fade-leave-to { opacity: 0; }
|
||||
|
||||
/* 4. 弹窗样式 */
|
||||
.tmr-modal-mask {
|
||||
position: fixed;
|
||||
z-index: 9999;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: rgba(0, 0, 0, 0.5);
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.tmr-modal-container {
|
||||
width: 800px;
|
||||
max-width: 90%;
|
||||
background-color: #fff;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 4px 16px rgba(0,0,0,0.15);
|
||||
overflow: hidden;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.modal-header {
|
||||
padding: 15px 20px;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
font-weight: 600;
|
||||
color: #303133;
|
||||
}
|
||||
|
||||
.close-btn {
|
||||
border: none;
|
||||
background: none;
|
||||
font-size: 24px;
|
||||
cursor: pointer;
|
||||
color: #909399;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.close-btn:hover { color: #f56c6c; }
|
||||
|
||||
.modal-body {
|
||||
padding: 30px;
|
||||
min-height: 300px;
|
||||
max-height: 70vh;
|
||||
overflow-y: auto;
|
||||
background-color: #fafafa; /* 模拟邮件阅读背景 */
|
||||
}
|
||||
|
||||
/* 模拟邮件内容容器样式 */
|
||||
.common_tmr_email_box {
|
||||
background: #fff;
|
||||
padding: 20px;
|
||||
border: 1px solid #eee;
|
||||
word-break: break-word;
|
||||
line-height: 1.6;
|
||||
white-space: pre-wrap; /* 保证换行显示 */
|
||||
min-height: 100px;
|
||||
}
|
||||
|
||||
.modal-footer {
|
||||
padding: 12px 20px;
|
||||
border-top: 1px solid #f0f0f0;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.confirm-btn {
|
||||
background: #409eff;
|
||||
color: #fff;
|
||||
border: none;
|
||||
padding: 8px 24px;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.confirm-btn:hover { background: #66b1ff; }
|
||||
</style>
|
||||
511
src/components/page/crawlTaskMonitor.vue
Normal file
511
src/components/page/crawlTaskMonitor.vue
Normal file
@@ -0,0 +1,511 @@
|
||||
<template>
|
||||
<div class="monitor-container">
|
||||
|
||||
|
||||
<div class="control-panel">
|
||||
<div class="panel-left">
|
||||
<el-radio-group v-model="filterStatus" size="small" class="status-group" @change="handleFilter">
|
||||
<el-radio-button label="">{{ $t('crawlTask.allKeywords') }}</el-radio-button>
|
||||
<el-radio-button label="0">{{ $t('crawlTask.enabled') }}</el-radio-button>
|
||||
<el-radio-button label="1">{{ $t('crawlTask.disabled') }}</el-radio-button>
|
||||
</el-radio-group>
|
||||
<el-input
|
||||
v-model="searchText"
|
||||
:placeholder="$t('crawlTask.searchPlaceholder')"
|
||||
prefix-icon="el-icon-search"
|
||||
size="small"
|
||||
class="search-box"
|
||||
clearable
|
||||
@input="handleFilter"
|
||||
/>
|
||||
<el-button
|
||||
type="primary"
|
||||
size="small"
|
||||
icon="el-icon-search"
|
||||
@click="handleSearchClick"
|
||||
>
|
||||
{{ $t('crawlTask.searchBtn') }}
|
||||
</el-button>
|
||||
|
||||
</div>
|
||||
<div class="panel-right">
|
||||
|
||||
<el-button type="primary" size="small" icon="el-icon-plus" @click="openAddDialog">{{ $t('crawlTask.addKeyword') }}</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<el-dialog
|
||||
:title="$t('crawlTask.addKeyword')"
|
||||
:visible.sync="addDialogVisible"
|
||||
width="500px"
|
||||
:close-on-click-modal="false"
|
||||
@closed="resetAddForm"
|
||||
>
|
||||
<el-form label-width="120px" size="small">
|
||||
<el-form-item :label="$t('crawlTask.keyword')">
|
||||
<el-input
|
||||
v-model="addForm.field"
|
||||
:placeholder="$t('crawlTask.keywordPlaceholder')"
|
||||
clearable
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('crawlTask.runOnce')">
|
||||
<el-switch
|
||||
v-model="addForm.runNow"
|
||||
:active-text="$t('crawlTask.yes')"
|
||||
:inactive-text="$t('crawlTask.no')"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button size="small" @click="addDialogVisible = false">{{ $t('crawlTask.cancel') }}</el-button>
|
||||
<el-button type="primary" size="small" :loading="addLoading" @click="submitAddKeyword">
|
||||
{{ $t('crawlTask.confirm') }}
|
||||
</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
|
||||
<div v-loading="loading" class="task-list">
|
||||
<el-empty v-if="list.length === 0" :description="$t('crawlTask.emptyResult')" />
|
||||
|
||||
<div v-for="item in list" :key="item.id" class="task-row" :class="'status-' + item.stateClass">
|
||||
<div class="col-base">
|
||||
<div class="status-dot"></div>
|
||||
<div class="id-info">
|
||||
<span class="task-id">#{{ item.id}}</span>
|
||||
<span class="task-name">{{ item.task_name }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-metrics">
|
||||
<div class="metric-item">
|
||||
<span class="m-label">{{ $t('crawlTask.source') }}</span>
|
||||
<span class="m-value mini-text">{{ item.source }}</span>
|
||||
</div>
|
||||
<div class="metric-item highlight">
|
||||
<span class="m-label">{{ $t('crawlTask.totalPages') }}</span>
|
||||
<span class="m-value">{{ item.total_pages }}</span>
|
||||
</div>
|
||||
<div class="metric-item highlight">
|
||||
<span class="m-label">{{ $t('crawlTask.crawledPages') }}</span>
|
||||
<span class="m-value">{{ item.last_page }}</span>
|
||||
</div>
|
||||
<div class="metric-item highlight">
|
||||
<span class="m-label">{{ $t('crawlTask.expertCountLabel') }}</span>
|
||||
<span class="m-value expert-num">{{ item.expert_count }}</span>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="col-timeline">
|
||||
<div class="time-block">
|
||||
<i class="el-icon-time"></i>
|
||||
<div class="time-detail">
|
||||
<span>{{ $t('crawlTask.created') }}: {{ item.create_time }}</span>
|
||||
<span :class="item.state === 'done' ? 'success-text' : ''">
|
||||
{{ item.state === 'done' ? $t('crawlTask.completed') : $t('crawlTask.updated') }}: {{ item.update_time }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="duration-tag" v-if="item.duration">
|
||||
<i class="el-icon-odometer"></i> {{ item.duration }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-action">
|
||||
<div class="prog-box">
|
||||
<span class="prog-num">{{ item.progress }}%</span>
|
||||
<el-progress
|
||||
:percentage="item.progress"
|
||||
:show-text="false"
|
||||
:stroke-width="4"
|
||||
:status="item.state === 'error' ? 'exception' : (item.state === 'done' ? 'success' : '')"
|
||||
/>
|
||||
</div>
|
||||
<div class="btn-group">
|
||||
<!-- <el-tooltip content="查看日志" placement="top">
|
||||
<el-button type="text" icon="el-icon-document" @click="handleAction('logs', item)"></el-button>
|
||||
</el-tooltip> -->
|
||||
<!-- <el-tooltip content="执行单次抓取" placement="top" > -->
|
||||
<el-button
|
||||
type="text"
|
||||
:icon="runOnceLoadingId === item.id ? 'el-icon-loading' : 'el-icon-finished'"
|
||||
class="op-run-once"
|
||||
:disabled="runOnceLoadingId === item.id"
|
||||
@click="handleRunOnce(item)"
|
||||
>{{ runOnceLoadingId === item.id ? $t('crawlTask.runOnceLoading') : $t('crawlTask.runOnceBtn') }}</el-button>
|
||||
<!-- </el-tooltip> -->
|
||||
<!-- <el-tooltip :content="item.state == 'running' ? '暂停抓取' : '恢复抓取'" placement="top"> -->
|
||||
<el-button
|
||||
type="text"
|
||||
:icon="item.state === 'running' ? 'el-icon-video-pause' : 'el-icon-video-play'"
|
||||
:class="['toggle-btn', item.state === 'running' ? 'op-pause' : 'op-resume']"
|
||||
@click="handleToggleTask(item)"
|
||||
>{{ item.state === 'running' ? $t('crawlTask.disabled') : $t('crawlTask.enabled') }}</el-button>
|
||||
<!-- </el-tooltip> -->
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="pagination-container">
|
||||
<el-pagination
|
||||
background
|
||||
layout="total, sizes, prev, pager, next, jumper"
|
||||
:current-page.sync="currentPage"
|
||||
:page-size="pageSize"
|
||||
:page-sizes="[5, 10, 20, 50]"
|
||||
:total="total"
|
||||
@size-change="handleSizeChange"
|
||||
@current-change="handlePageChange"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
loading: false,
|
||||
searchText: '',
|
||||
filterStatus: '',
|
||||
currentPage: 1,
|
||||
pageSize: 10,
|
||||
total: 0,
|
||||
list: [],
|
||||
addDialogVisible: false,
|
||||
addLoading: false,
|
||||
runOnceLoading: false,
|
||||
runOnceLoadingId: null,
|
||||
addForm: {
|
||||
field: '',
|
||||
runNow: false
|
||||
}
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.fetchList();
|
||||
},
|
||||
methods: {
|
||||
calcProgress(lastPage, totalPages) {
|
||||
const current = Number(lastPage || 0);
|
||||
const total = Number(totalPages || 0);
|
||||
if (total <= 0) return 0;
|
||||
let percent = (current / total) * 100;
|
||||
if (percent > 100) percent = 100;
|
||||
return Number(percent.toFixed(2));
|
||||
},
|
||||
normalizeItem(item) {
|
||||
const totalPages = Number(item.total_pages || 0);
|
||||
const lastPage = Number(item.last_page || 0);
|
||||
const percent = this.calcProgress(lastPage, totalPages);
|
||||
const stateNum = Number(item.state);
|
||||
const stateClass = stateNum === 0 ? 'running' : 'paused';
|
||||
const source = (item.source || '').toUpperCase() === 'PUBMED' ? 'PubMed' : (item.source || '-');
|
||||
return {
|
||||
id: item.expert_fetch_id || item.id || 0,
|
||||
field: item.field || '',
|
||||
expert_count: item.expert_count || 0,
|
||||
task_name: item.field ? `${item.field}`:'-',
|
||||
source,
|
||||
state: stateClass,
|
||||
stateClass,
|
||||
progress: percent,
|
||||
create_time: item.ctime_text || '-',
|
||||
update_time: item.last_time_text || '-',
|
||||
duration: '',
|
||||
total_pages: Number(item.total_pages || 0),
|
||||
last_page: Number(item.last_page || 0),
|
||||
duplicates: 0,
|
||||
failed: 0
|
||||
};
|
||||
},
|
||||
async fetchList() {
|
||||
this.loading = true;
|
||||
try {
|
||||
const params = {
|
||||
keyword: this.searchText || '',
|
||||
pageIndex: this.currentPage,
|
||||
pageSize: this.pageSize
|
||||
};
|
||||
if (this.filterStatus !== '') {
|
||||
params.state = this.filterStatus;
|
||||
}
|
||||
const res = await this.$api.post('api/expert_manage/getFetchList', params);
|
||||
if (res && res.code === 0 && res.data) {
|
||||
const rows = res.data.list || [];
|
||||
this.list = rows.map(this.normalizeItem);
|
||||
this.total = Number(res.data.total || rows.length || 0);
|
||||
} else {
|
||||
this.list = [];
|
||||
this.total = 0;
|
||||
}
|
||||
} catch (e) {
|
||||
this.list = [];
|
||||
this.total = 0;
|
||||
} finally {
|
||||
this.loading = false;
|
||||
}
|
||||
},
|
||||
handleFilter() {
|
||||
this.currentPage = 1;
|
||||
this.fetchList();
|
||||
},
|
||||
handleSearchClick() {
|
||||
this.handleFilter();
|
||||
},
|
||||
handleSizeChange(val) {
|
||||
this.pageSize = val;
|
||||
this.currentPage = 1;
|
||||
this.fetchList();
|
||||
},
|
||||
handlePageChange(val) {
|
||||
this.currentPage = val;
|
||||
this.fetchList();
|
||||
window.scrollTo({ top: 0, behavior: 'smooth' });
|
||||
},
|
||||
resetQuery() {
|
||||
this.searchText = '';
|
||||
this.filterStatus = '';
|
||||
this.currentPage = 1;
|
||||
this.fetchList();
|
||||
},
|
||||
openAddDialog() {
|
||||
this.addDialogVisible = true;
|
||||
},
|
||||
resetAddForm() {
|
||||
this.addLoading = false;
|
||||
this.runOnceLoading = false;
|
||||
this.addForm = {
|
||||
field: '',
|
||||
runNow: false
|
||||
};
|
||||
},
|
||||
async submitAddKeyword() {
|
||||
const field = (this.addForm.field || '').trim();
|
||||
if (!field) {
|
||||
this.$message.warning(this.$t('crawlTask.enterKeyword'));
|
||||
return;
|
||||
}
|
||||
const runNow = !!this.addForm.runNow;
|
||||
this.addLoading = true;
|
||||
try {
|
||||
const addRes = await this.$api.post('api/expert_manage/addFetchField', { field });
|
||||
if (!addRes || addRes.code !== 0) {
|
||||
this.$message.error((addRes && addRes.msg) || this.$t('crawlTask.addKeywordFailed'));
|
||||
return;
|
||||
}
|
||||
|
||||
this.$message.success(this.$t('crawlTask.addKeywordSuccess'));
|
||||
this.addDialogVisible = false;
|
||||
this.currentPage = 1;
|
||||
await this.fetchList();
|
||||
|
||||
if (runNow) {
|
||||
// 勾选“单次抓取”时,在列表对应行按钮上显示 loading
|
||||
const lowerField = field.toLowerCase();
|
||||
const target = this.list.find(
|
||||
(row) => ((row.field || '').trim().toLowerCase() === lowerField)
|
||||
);
|
||||
this.runOnceLoading = true;
|
||||
this.runOnceLoadingId = target ? target.id : null;
|
||||
const runRes = await this.$api.post('api/expert_finder/fetchOneField', { field });
|
||||
if (!runRes || runRes.code !== 0) {
|
||||
this.$message.warning((runRes && runRes.msg) || this.$t('crawlTask.runOnceFailed'));
|
||||
} else {
|
||||
this.$message.success(this.$t('crawlTask.runOnceSuccess'));
|
||||
}
|
||||
await this.fetchList();
|
||||
}
|
||||
} catch (e) {
|
||||
this.$message.error(this.$t('crawlTask.operationRetry'));
|
||||
} finally {
|
||||
this.addLoading = false;
|
||||
this.runOnceLoading = false;
|
||||
this.runOnceLoadingId = null;
|
||||
this.loading = false;
|
||||
}
|
||||
},
|
||||
async handleToggleTask(item) {
|
||||
const isRunning = item.state === 'running';
|
||||
const newState = isRunning ? '1' : '0';
|
||||
try {
|
||||
this.loading = true;
|
||||
const res = await this.$api.post('api/expert_manage/editFetchField', {
|
||||
expert_fetch_id: item.id,
|
||||
state: newState
|
||||
});
|
||||
if (res && res.code === 0) {
|
||||
item.state = isRunning ? 'paused' : 'running';
|
||||
item.stateClass = item.state;
|
||||
this.$message.success(isRunning ? this.$t('crawlTask.disabledMsg') : this.$t('crawlTask.enabledMsg'));
|
||||
} else {
|
||||
this.$message.error((res && res.msg) || (isRunning ? this.$t('crawlTask.pauseFailed') : this.$t('crawlTask.resumeFailed')));
|
||||
}
|
||||
} catch (e) {
|
||||
this.$message.error(isRunning ? this.$t('crawlTask.pauseFailed') : this.$t('crawlTask.resumeFailed'));
|
||||
} finally {
|
||||
this.loading = false;
|
||||
}
|
||||
},
|
||||
handleRestart(item) {
|
||||
item.state = 'running';
|
||||
item.stateClass = 'running';
|
||||
item.progress = 0;
|
||||
this.$message.success(this.$t('crawlTask.restartSuccess'));
|
||||
},
|
||||
async handleRunOnce(item) {
|
||||
const field = (item.field || item.task_name || '').trim();
|
||||
if (!field) {
|
||||
this.$message.warning(this.$t('crawlTask.missingKeyword'));
|
||||
return;
|
||||
}
|
||||
this.runOnceLoadingId = item.id;
|
||||
try {
|
||||
const res = await this.$api.post('/api/expert_finder/fetchOneField', { field });
|
||||
if (res && res.code === 0) {
|
||||
this.$message.success(this.$t('crawlTask.runOnceSuccess'));
|
||||
await this.fetchList();
|
||||
} else {
|
||||
this.$message.error((res && res.msg) || this.$t('crawlTask.runOnceFailed'));
|
||||
}
|
||||
} catch (e) {
|
||||
this.$message.error(this.$t('crawlTask.runOnceFailed'));
|
||||
} finally {
|
||||
this.runOnceLoadingId = null;
|
||||
}
|
||||
},
|
||||
handleAction(msg, item) {
|
||||
if (msg === 'logs') {
|
||||
this.$message.info(`${this.$t('crawlTask.viewLogs')}: #${item.id}`);
|
||||
return;
|
||||
}
|
||||
this.$message.info(msg);
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.monitor-container {
|
||||
padding:0px 20px;
|
||||
background: #f4f7f9;
|
||||
min-height: 100vh;
|
||||
color: #334155;
|
||||
}
|
||||
|
||||
/* 统计卡片 */
|
||||
.stat-overview { display: flex; gap: 16px; margin-bottom: 24px; }
|
||||
.stat-card {
|
||||
background: #fff;
|
||||
padding: 16px 20px;
|
||||
border-radius: 8px;
|
||||
flex: 1;
|
||||
box-shadow: 0 1px 3px rgba(0,0,0,0.04);
|
||||
border-top: 3px solid #0a3088; /* 呼应你偏好的深蓝色 */
|
||||
}
|
||||
.stat-val { font-size: 22px; font-weight: bold; color: #0a3088; display: block; }
|
||||
.stat-label { font-size: 12px; color: #64748b; margin-top: 4px; }
|
||||
|
||||
/* 过滤工具栏 */
|
||||
.control-panel {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 16px;
|
||||
background: #fff;
|
||||
padding: 12px;
|
||||
border-radius: 8px;
|
||||
align-items: center;
|
||||
}
|
||||
.panel-left { display: flex; align-items: center; gap: 12px; }
|
||||
.search-box { width: 200px; }
|
||||
.date-picker { width: 240px !important; }
|
||||
|
||||
/* 任务行核心样式 */
|
||||
.task-list { min-height: 400px; }
|
||||
.task-row {
|
||||
background: #fff;
|
||||
margin-bottom: 8px;
|
||||
border-radius: 6px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 12px 20px;
|
||||
transition: all 0.2s;
|
||||
border: 1px solid transparent;
|
||||
}
|
||||
.status-paused {
|
||||
background: #f3f4f6;
|
||||
}
|
||||
.task-row:hover {
|
||||
border-color: #cbd5e1;
|
||||
box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
|
||||
}
|
||||
|
||||
/* 列定义 */
|
||||
.col-base { flex: 1.5; display: flex; align-items: center; gap: 15px; }
|
||||
.col-metrics { flex: 2; display: flex; justify-content: space-around; border-left: 1px solid #f1f5f9; border-right: 1px solid #f1f5f9; }
|
||||
.col-timeline { flex: 1.1; padding: 0 25px; display: flex; align-items: center; justify-content: space-between; }
|
||||
.col-action { flex:1.8; display: flex; align-items: center; gap: 15px; }
|
||||
|
||||
/* 状态点 */
|
||||
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #94a3b8; position: relative; }
|
||||
.status-dot { width: 10px; height: 10px; }
|
||||
.status-running .status-dot { background: #3b82f6; }
|
||||
.status-running .status-dot::after {
|
||||
content: ''; position: absolute; width: 100%; height: 100%; background: inherit;
|
||||
border-radius: 50%; animation: pulse 1.5s infinite;
|
||||
}
|
||||
.status-done .status-dot { background: #10b981; }
|
||||
.status-paused .status-dot { background: #ef4444; }
|
||||
.status-error .status-dot { background: #ef4444; }
|
||||
|
||||
/* 文字样式 */
|
||||
.task-id { font-family: monospace; color: #94a3b8; font-size: 12px; display: block; }
|
||||
.task-name { font-weight: 600; font-size: 14px; color: #1e293b; }
|
||||
|
||||
.metric-item { text-align: center; }
|
||||
.m-label { font-size: 11px; color: #94a3b8; display: block; margin-bottom: 2px; }
|
||||
.m-value { font-size: 16px; font-weight: bold; color: #475569; }
|
||||
.m-value.mini-text { font-size: 12px; font-weight: normal; }
|
||||
.m-value.expert-num { color: #006699; }
|
||||
.success-text { color: #10b981; }
|
||||
.danger { color: #ef4444; }
|
||||
|
||||
/* 时间线样式 */
|
||||
.time-block { display: flex; align-items: center; gap: 10px; color: #64748b; font-size: 12px; }
|
||||
.time-block i { font-size: 16px; }
|
||||
.time-detail span { display: block; line-height: 1.4; }
|
||||
.duration-tag { background: #f1f5f9; padding: 2px 8px; border-radius: 4px; font-size: 11px; color: #475569; }
|
||||
|
||||
/* 进度与分页 */
|
||||
.prog-box { flex: 1; }
|
||||
.prog-num { font-size: 12px; font-weight: bold; display: block; text-align: right; margin-bottom: 4px; min-width: 56px; }
|
||||
.pagination-container { margin-top: 20px; display: flex; justify-content: flex-end; padding: 10px; }
|
||||
.btn-group .el-button.op-pause,
|
||||
.btn-group .el-button.op-pause i { color: #fc4d4d !important; }
|
||||
.btn-group .el-button.op-resume,
|
||||
.btn-group .el-button.op-resume i { color: #67c23a !important; }
|
||||
.btn-group .el-button.op-restart,
|
||||
.btn-group .el-button.op-restart i { color: #409eff !important; }
|
||||
.btn-group .el-button.op-run-once,
|
||||
.btn-group .el-button.op-run-once i { color: #006699 !important; }
|
||||
.btn-group .el-button {
|
||||
font-size: 20px;
|
||||
padding: 6px;
|
||||
}
|
||||
.btn-group .el-button.op-run-once {
|
||||
font-size: 13px;
|
||||
padding: 4px 6px;
|
||||
}
|
||||
.btn-group .el-button.toggle-btn {
|
||||
font-size: 13px;
|
||||
padding: 4px 6px;
|
||||
}
|
||||
|
||||
@keyframes pulse {
|
||||
0% { transform: scale(1); opacity: 0.8; }
|
||||
100% { transform: scale(2.5); opacity: 0; }
|
||||
}
|
||||
</style>
|
||||
@@ -240,7 +240,7 @@ If you're still having trouble with Chrome, you could use other browsers to comp
|
||||
<el-dialog :visible.sync="questionVisible" width="1000px" :close-on-click-modal="false">
|
||||
<!-- 审稿人表单修改 -->
|
||||
<!-- 不显示给编辑的话 -->
|
||||
<common-review-article
|
||||
<common-review-article v-if="questionVisible"
|
||||
:form="questionform1"
|
||||
type="questionform"
|
||||
:txt_mess="txt_mess"
|
||||
|
||||
@@ -29,6 +29,15 @@
|
||||
style="width: 260px"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="">
|
||||
<el-input
|
||||
v-model="query.field"
|
||||
:placeholder="$t('expertDatabase.fieldPlaceholder')"
|
||||
clearable
|
||||
style="width: 260px"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" :loading="loading" @click="handleSearch">
|
||||
@@ -107,6 +116,7 @@ export default {
|
||||
query: {
|
||||
major_id: null,
|
||||
keyword: '',
|
||||
field: '',
|
||||
pageIndex: 1,
|
||||
pageSize: 10
|
||||
},
|
||||
@@ -167,6 +177,7 @@ export default {
|
||||
const params = {
|
||||
major_id: this.query.major_id,
|
||||
keyword: this.query.keyword,
|
||||
field: this.query.field,
|
||||
pageIndex: this.query.pageIndex,
|
||||
pageSize: this.query.pageSize
|
||||
};
|
||||
@@ -202,6 +213,7 @@ export default {
|
||||
this.query = {
|
||||
major_id: null,
|
||||
keyword: '',
|
||||
field: '',
|
||||
pageIndex: 1,
|
||||
pageSize: 10
|
||||
};
|
||||
@@ -217,7 +229,7 @@ export default {
|
||||
this.fetchList();
|
||||
},
|
||||
async handleExport() {
|
||||
if (!this.query.major_id && !this.query.keyword) {
|
||||
if (!this.query.major_id && !this.query.keyword && !this.query.field) {
|
||||
this.$message.warning(this.$t('expertDatabase.exportWarn'));
|
||||
return;
|
||||
}
|
||||
@@ -225,7 +237,8 @@ export default {
|
||||
try {
|
||||
const params = {
|
||||
major_id: this.query.major_id,
|
||||
keyword: this.query.keyword
|
||||
keyword: this.query.keyword,
|
||||
field: this.query.field
|
||||
};
|
||||
const res = await this.$api.post('api/expert_manage/exportExcel', params);
|
||||
if (res && res.code === 0 && res.data && res.data.file_url) {
|
||||
@@ -259,6 +272,11 @@ export default {
|
||||
margin: 0 20px;
|
||||
margin-left: 0;
|
||||
}
|
||||
.form-line-break {
|
||||
flex-basis: 100%;
|
||||
width: 100%;
|
||||
height: 0;
|
||||
}
|
||||
.actions {
|
||||
white-space: nowrap;
|
||||
}
|
||||
@@ -269,11 +287,11 @@ export default {
|
||||
margin-top: 15px;
|
||||
text-align: right;
|
||||
}
|
||||
/deep/ .dark-table-header th {
|
||||
::v-deep .dark-table-header th {
|
||||
background-color: #f5f7fa;
|
||||
font-weight: 600;
|
||||
}
|
||||
/deep/ .el-form-item--mini.el-form-item,
|
||||
::v-deep .el-form-item--mini.el-form-item,
|
||||
.el-form-item--small.el-form-item {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -67,8 +67,8 @@
|
||||
<el-form-item :label="$t('mailboxConfig.password')" prop="password">
|
||||
<el-input
|
||||
v-model="form.password"
|
||||
type="password"
|
||||
show-password
|
||||
type="text"
|
||||
|
||||
clearable
|
||||
autocomplete="new-password"
|
||||
></el-input>
|
||||
@@ -256,6 +256,7 @@
|
||||
today_sent: item.today_sent,
|
||||
state: item.state,
|
||||
remaining_today: item.remaining_today,
|
||||
smtp_password: item.smtp_password,
|
||||
};
|
||||
}.bind(this));
|
||||
this.tableData = list;
|
||||
@@ -289,12 +290,14 @@
|
||||
this.$nextTick(function() { if (this.$refs.formRef) this.$refs.formRef.clearValidate(); }.bind(this));
|
||||
},
|
||||
handleEdit(row) {
|
||||
console.log("🚀 ~ handleEdit ~ row:", row);
|
||||
|
||||
this.dialogTitle = this.$t('mailboxConfig.dialogEdit');
|
||||
this.form = {
|
||||
id: row.id,
|
||||
journal_id: row.journal_id,
|
||||
account: row.account || row.smtp_user || '',
|
||||
password: '',
|
||||
password: row.smtp_password || '',
|
||||
smtp_from_name: row.smtp_from_name || '',
|
||||
smtp_host: row.smtp_host || '',
|
||||
smtp_port: row.smtp_port != null && row.smtp_port !== '' ? String(row.smtp_port) : '',
|
||||
|
||||
@@ -395,5 +395,6 @@ export default {
|
||||
padding: 10px;
|
||||
border: 1px solid #eee;
|
||||
background: #fff;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -107,7 +107,7 @@
|
||||
:source-content.sync="sourceContent"
|
||||
:source-rows="16"
|
||||
:source-placeholder="$t('mailboxSend.sourcePlaceholder')"
|
||||
:show-select-template-button="true"
|
||||
:show-select-template-button="false"
|
||||
@onSelectTemplate="showTemplateDialog = true"
|
||||
/>
|
||||
</div>
|
||||
@@ -672,24 +672,23 @@ import TemplateSelectorDialog from '@/components/page/components/email/TemplateS
|
||||
this.$message.warning(this.$t('mailboxSend.needAccount'));
|
||||
return;
|
||||
}
|
||||
if (!this.selectedTemplateId || !this.selectedStyleId) {
|
||||
this.$message.warning(this.$t('mailboxSend.selectTemplateStyleFirst'));
|
||||
return;
|
||||
}
|
||||
// if (!this.selectedTemplateId || !this.selectedStyleId) {
|
||||
// this.$message.warning(this.$t('mailboxSend.selectTemplateStyleFirst'));
|
||||
// return;
|
||||
// }
|
||||
|
||||
this.sendLoading = true;
|
||||
const params = {
|
||||
journal_id: String(journalId),
|
||||
template_id: String(this.selectedTemplateId),
|
||||
to_email: toList.join(','),
|
||||
style_id: String(this.selectedStyleId),
|
||||
expert_id: expert_id_list.join(',') || '1',
|
||||
subject: this.queryMail.sendtitle || '',
|
||||
content: this.queryMail.content || '',
|
||||
j_email_id: String(jEmailId),
|
||||
journal_id: String(journalId),
|
||||
};
|
||||
|
||||
const self = this;
|
||||
this.$api
|
||||
.post('api/email_client/sendTemplateStyleTest', params)
|
||||
.post('api/email_client/sendOne', params)
|
||||
.then((res) => {
|
||||
if (res && res.code === 0) {
|
||||
self.$message.success(self.$t('mailboxSend.sendSuccess'));
|
||||
|
||||
545
src/components/page/scholarCrawlersKeywords.vue
Normal file
545
src/components/page/scholarCrawlersKeywords.vue
Normal file
@@ -0,0 +1,545 @@
|
||||
<template>
|
||||
<div class="keywords-container">
|
||||
<transition name="el-zoom-in-top" appear>
|
||||
<div class="page-header">
|
||||
<div class="header-left">
|
||||
<h2 class="page-title">{{ $t('crawlerKeywords.pageTitle') }}</h2>
|
||||
<p class="page-desc">
|
||||
<i class="el-icon-info"></i> {{ $t('crawlerKeywords.pageDesc') }}
|
||||
</p>
|
||||
</div>
|
||||
<div class="header-actions">
|
||||
|
||||
<!-- <el-button
|
||||
type="primary"
|
||||
icon="el-icon-video-play"
|
||||
@click="handleStartCrawl"
|
||||
:loading="crawlLoading"
|
||||
class="glow-button"
|
||||
round
|
||||
>
|
||||
{{ $t('crawlerKeywords.startCrawl') }}
|
||||
</el-button> -->
|
||||
</div>
|
||||
</div>
|
||||
</transition>
|
||||
|
||||
<div class="add-section shadow-hover">
|
||||
<el-input
|
||||
v-model="newKeyword"
|
||||
:placeholder="$t('crawlerKeywords.inputPlaceholder')"
|
||||
class="add-input-custom"
|
||||
prefix-icon="el-icon-collection-tag"
|
||||
clearable
|
||||
@keyup.enter.native="handleAdd"
|
||||
/>
|
||||
<el-button
|
||||
type="primary"
|
||||
icon="el-icon-plus"
|
||||
@click="handleAdd"
|
||||
:loading="addLoading"
|
||||
class="add-btn"
|
||||
>
|
||||
{{ $t('crawlerKeywords.addKeyword') }}
|
||||
</el-button>
|
||||
</div>
|
||||
|
||||
<el-card shadow="never" class="table-card animated-card">
|
||||
<div class="table-toolbar">
|
||||
<el-input
|
||||
v-model="searchText"
|
||||
:placeholder="$t('crawlerKeywords.searchPlaceholder')"
|
||||
prefix-icon="el-icon-search"
|
||||
clearable
|
||||
class="search-input"
|
||||
@input="handleSearch"
|
||||
/>
|
||||
<el-button style="margin-left: 20px;"
|
||||
type="primary"
|
||||
icon="el-icon-search"
|
||||
@click="handleSearchNow"
|
||||
>
|
||||
{{ $t('crawlerKeywords.searchBtn') }}
|
||||
</el-button>
|
||||
</div>
|
||||
|
||||
<el-table
|
||||
:data="list"
|
||||
v-loading="loading"
|
||||
border
|
||||
stripe
|
||||
highlight-current-row
|
||||
header-row-class-name="custom-header"
|
||||
style="width: 100%"
|
||||
class="modern-table"
|
||||
>
|
||||
<el-table-column prop="keyword" :label="$t('crawlerKeywords.colKeyword')" min-width="180">
|
||||
<template slot-scope="scope">
|
||||
<transition name="fade-slide" mode="out-in">
|
||||
<span :key="'t'+scope.row.id" v-if="editingId !== scope.row.id" class="keyword-text">
|
||||
{{ scope.row.keyword }}
|
||||
</span>
|
||||
<el-input
|
||||
:key="'e'+scope.row.id"
|
||||
v-else
|
||||
v-model="editForm.keyword"
|
||||
size="small"
|
||||
v-focus
|
||||
class="edit-input"
|
||||
/>
|
||||
</transition>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column prop="category" :label="$t('crawlerKeywords.colCategory')" width="150">
|
||||
<template slot-scope="scope">
|
||||
<transition name="fade-slide" mode="out-in">
|
||||
<div :key="editingId === scope.row.id">
|
||||
<el-tag
|
||||
v-if="editingId !== scope.row.id"
|
||||
:type="scope.row.category ? 'success' : 'info'"
|
||||
size="small"
|
||||
effect="light"
|
||||
>
|
||||
{{ scope.row.category || 'Default' }}
|
||||
</el-tag>
|
||||
<el-input v-else v-model="editForm.category" size="small" />
|
||||
</div>
|
||||
</transition>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column prop="state" :label="$t('crawlerKeywords.colStatus')" width="140" align="center">
|
||||
<template slot-scope="scope">
|
||||
<div class="status-container">
|
||||
<span :class="['status-dot', 'pulse', 'status-' + scope.row.state]"></span>
|
||||
<span :class="['status-label', 'text-' + scope.row.state]">
|
||||
{{ getStateText(scope.row.state) }}
|
||||
</span>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column prop="expert_count" :label="$t('crawlerKeywords.colExpertCount')" width="120" align="center">
|
||||
<template slot-scope="scope">
|
||||
<span class="count-badge">{{ scope.row.expert_count }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column prop="last_crawl_time" :label="$t('crawlerKeywords.colLastCrawl')" width="180" />
|
||||
|
||||
<el-table-column :label="$t('crawlerKeywords.colAction')" width="160" align="center" fixed="right">
|
||||
<template slot-scope="scope">
|
||||
<div class="action-wrapper">
|
||||
<template v-if="editingId === scope.row.id">
|
||||
<el-button type="text" icon="el-icon-circle-check" class="save-btn" @click="handleSaveEdit(scope.row)">
|
||||
{{ $t('crawlerKeywords.save') }}
|
||||
</el-button>
|
||||
<el-button type="text" icon="el-icon-circle-close" class="cancel-btn" @click="editingId = null">
|
||||
{{ $t('crawlerKeywords.cancel') }}
|
||||
</el-button>
|
||||
</template>
|
||||
<template v-else>
|
||||
<el-tooltip :content="$t('crawlerKeywords.refresh')" placement="top">
|
||||
<el-button
|
||||
type="text"
|
||||
icon="el-icon-refresh"
|
||||
:class="['refresh-icon', { 'is-spinning': scope.row._refreshing }]"
|
||||
@click="handleRefresh(scope.row)"
|
||||
/>
|
||||
</el-tooltip>
|
||||
<el-tooltip :content="$t('crawlerKeywords.edit')" placement="top">
|
||||
<el-button type="text" icon="el-icon-edit-outline" @click="handleEdit(scope.row)" />
|
||||
</el-tooltip>
|
||||
<el-tooltip :content="$t('crawlerKeywords.delete')" placement="top">
|
||||
<el-button type="text" icon="el-icon-delete" class="del-btn" @click="handleDelete(scope.row)" />
|
||||
</el-tooltip>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<div class="pagination-wrapper">
|
||||
<el-pagination
|
||||
background
|
||||
layout="total, sizes, prev, pager, next, jumper"
|
||||
:current-page="query.pageIndex"
|
||||
:page-size="query.pageSize"
|
||||
:page-sizes="[10, 20, 50]"
|
||||
:total="total"
|
||||
@size-change="handleSizeChange"
|
||||
@current-change="handlePageChange"
|
||||
/>
|
||||
</div>
|
||||
</el-card>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Common from '@/components/common/common';
|
||||
|
||||
const API = {
|
||||
list: 'api/expert_manage/getKeywordList',
|
||||
add: 'api/expert_manage/addKeyword',
|
||||
update: 'api/expert_manage/updateKeyword',
|
||||
delete: 'api/expert_manage/deleteKeyword',
|
||||
refresh: 'api/expert_manage/refreshKeyword',
|
||||
startCrawl: 'api/expert_manage/startCrawl',
|
||||
exportData: 'api/expert_manage/exportKeywords'
|
||||
};
|
||||
|
||||
export default {
|
||||
name: 'scholarCrawlersKeywords',
|
||||
directives: {
|
||||
focus: {
|
||||
inserted: (el) => el.querySelector('input').focus()
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
mediaUrl: Common.mediaUrl,
|
||||
newKeyword: '',
|
||||
searchText: '',
|
||||
loading: false,
|
||||
addLoading: false,
|
||||
exportLoading: false,
|
||||
crawlLoading: false,
|
||||
editingId: null,
|
||||
editForm: { keyword: '', category: '' },
|
||||
query: { pageIndex: 1, pageSize: 10 },
|
||||
list: [],
|
||||
total: 0,
|
||||
searchTimer: null
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.fetchList();
|
||||
},
|
||||
methods: {
|
||||
getStateText(state) {
|
||||
const map = {
|
||||
running: this.$t('crawlerKeywords.stateRunning'),
|
||||
paused: this.$t('crawlerKeywords.statePaused'),
|
||||
error: this.$t('crawlerKeywords.stateError'),
|
||||
done: this.$t('crawlerKeywords.stateDone')
|
||||
};
|
||||
return map[state] || state || '-';
|
||||
},
|
||||
async fetchList() {
|
||||
this.loading = true;
|
||||
try {
|
||||
const params = {
|
||||
keyword: this.searchText || '',
|
||||
pageIndex: this.query.pageIndex,
|
||||
pageSize: this.query.pageSize
|
||||
};
|
||||
const res = await this.$api.post(API.list, params);
|
||||
if (res && res.code === 0 && res.data) {
|
||||
this.list = (res.data.list || []).map(item => ({
|
||||
...item,
|
||||
_refreshing: false
|
||||
}));
|
||||
this.total = res.data.total || 0;
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
} finally {
|
||||
setTimeout(() => { this.loading = false; }, 300); // 增加微小延迟让加载动画更平滑
|
||||
}
|
||||
},
|
||||
handleSearch() {
|
||||
if (this.searchTimer) clearTimeout(this.searchTimer);
|
||||
this.searchTimer = setTimeout(() => {
|
||||
this.query.pageIndex = 1;
|
||||
this.fetchList();
|
||||
}, 400);
|
||||
},
|
||||
handleSearchNow() {
|
||||
if (this.searchTimer) {
|
||||
clearTimeout(this.searchTimer);
|
||||
this.searchTimer = null;
|
||||
}
|
||||
this.query.pageIndex = 1;
|
||||
this.fetchList();
|
||||
},
|
||||
async handleAdd() {
|
||||
const kw = (this.newKeyword || '').trim();
|
||||
if (!kw) {
|
||||
this.$message.warning(this.$t('crawlerKeywords.emptyKeywordWarn'));
|
||||
return;
|
||||
}
|
||||
this.addLoading = true;
|
||||
try {
|
||||
const res = await this.$api.post(API.add, { keyword: kw });
|
||||
if (res && res.code === 0) {
|
||||
this.$notify({ title: 'Success', message: this.$t('crawlerKeywords.addSuccess'), type: 'success' });
|
||||
this.newKeyword = '';
|
||||
this.query.pageIndex = 1;
|
||||
this.fetchList();
|
||||
}
|
||||
} finally {
|
||||
this.addLoading = false;
|
||||
}
|
||||
},
|
||||
handleEdit(row) {
|
||||
this.editingId = row.id;
|
||||
this.editForm = { keyword: row.keyword, category: row.category || '' };
|
||||
},
|
||||
async handleSaveEdit(row) {
|
||||
if (!(this.editForm.keyword || '').trim()) {
|
||||
this.$message.warning(this.$t('crawlerKeywords.emptyKeywordWarn'));
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const res = await this.$api.post(API.update, {
|
||||
id: String(row.id),
|
||||
keyword: this.editForm.keyword.trim(),
|
||||
category: this.editForm.category || ''
|
||||
});
|
||||
if (res && res.code === 0) {
|
||||
this.$message.success(this.$t('crawlerKeywords.updateSuccess'));
|
||||
this.editingId = null;
|
||||
this.fetchList();
|
||||
}
|
||||
} catch (e) {
|
||||
this.$message.error(this.$t('crawlerKeywords.updateFail'));
|
||||
}
|
||||
},
|
||||
handleDelete(row) {
|
||||
this.$confirm(`确定要删除关键词 "${row.keyword}" 吗?`, '安全警告', {
|
||||
confirmButtonText: '确定删除',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
center: true,
|
||||
roundButton: true
|
||||
}).then(async () => {
|
||||
const res = await this.$api.post(API.delete, { id: String(row.id) });
|
||||
if (res && res.code === 0) {
|
||||
this.$notify({ title: 'Deleted', type: 'success', duration: 2000 });
|
||||
this.fetchList();
|
||||
}
|
||||
}).catch(() => {});
|
||||
},
|
||||
async handleRefresh(row) {
|
||||
row._refreshing = true;
|
||||
try {
|
||||
const res = await this.$api.post(API.refresh, { id: String(row.id) });
|
||||
if (res && res.code === 0) {
|
||||
this.$message.success(this.$t('crawlerKeywords.refreshSuccess'));
|
||||
this.fetchList();
|
||||
}
|
||||
} finally {
|
||||
row._refreshing = false;
|
||||
}
|
||||
},
|
||||
async handleStartCrawl() {
|
||||
this.crawlLoading = true;
|
||||
try {
|
||||
const res = await this.$api.post(API.startCrawl, {});
|
||||
if (res && res.code === 0) {
|
||||
this.$message({ message: this.$t('crawlerKeywords.crawlStarted'), type: 'success', showClose: true });
|
||||
this.fetchList();
|
||||
}
|
||||
} finally {
|
||||
this.crawlLoading = false;
|
||||
}
|
||||
},
|
||||
async handleExport() {
|
||||
this.exportLoading = true;
|
||||
try {
|
||||
const res = await this.$api.post(API.exportData, {});
|
||||
if (res && res.code === 0 && res.data.file_url) {
|
||||
window.open(this.mediaUrl + res.data.file_url, '_blank');
|
||||
}
|
||||
} finally {
|
||||
this.exportLoading = false;
|
||||
}
|
||||
},
|
||||
handleSizeChange(size) {
|
||||
this.query.pageSize = size;
|
||||
this.fetchList();
|
||||
},
|
||||
handlePageChange(page) {
|
||||
this.query.pageIndex = page;
|
||||
this.fetchList();
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
/* 容器及整体布局 */
|
||||
.keywords-container {
|
||||
padding: 10px;
|
||||
|
||||
margin: 0 auto;
|
||||
background-color: #f8fafc;
|
||||
/* min-height: 100vh; */
|
||||
}
|
||||
|
||||
/* 头部样式 */
|
||||
.page-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
.page-title {
|
||||
margin: 0 0 6px;
|
||||
font-size: 24px;
|
||||
font-weight: 700;
|
||||
color: #1e293b;
|
||||
letter-spacing: -0.5px;
|
||||
}
|
||||
.page-desc {
|
||||
margin: 0;
|
||||
font-size: 14px;
|
||||
color: #64748b;
|
||||
}
|
||||
|
||||
/* 新增区域:卡片化 */
|
||||
.add-section {
|
||||
display: flex;
|
||||
gap: 16px;
|
||||
margin-bottom: 24px;
|
||||
background: #ffffff;
|
||||
border-radius: 12px;
|
||||
padding: 20px;
|
||||
border: 1px solid #e2e8f0;
|
||||
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
}
|
||||
.shadow-hover:hover {
|
||||
box-shadow: 0 10px 20px -5px rgba(0, 0, 0, 0.05);
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
.add-input-custom ::v-deep .el-input__inner {
|
||||
border-radius: 8px;
|
||||
background-color: #f1f5f9;
|
||||
border-color: transparent;
|
||||
}
|
||||
.add-input-custom ::v-deep .el-input__inner:focus {
|
||||
background-color: #fff;
|
||||
border-color: #409eff;
|
||||
}
|
||||
|
||||
/* 按钮发光 */
|
||||
.glow-button {
|
||||
box-shadow: 0 4px 12px rgba(64, 158, 255, 0.3);
|
||||
}
|
||||
.glow-button:hover {
|
||||
box-shadow: 0 6px 16px rgba(64, 158, 255, 0.4);
|
||||
}
|
||||
|
||||
/* 表格卡片 */
|
||||
.table-card {
|
||||
border-radius: 12px;
|
||||
border: 1px solid #e2e8f0;
|
||||
padding: 10px;
|
||||
}
|
||||
.table-toolbar {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 18px;
|
||||
}
|
||||
.search-input ::v-deep .el-input__inner {
|
||||
border-radius: 20px;
|
||||
}
|
||||
|
||||
/* 状态标签与脉冲 */
|
||||
.status-container {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
.status-dot {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 50%;
|
||||
margin-right: 8px;
|
||||
}
|
||||
.pulse {
|
||||
animation: shadow-pulse 2s infinite;
|
||||
}
|
||||
@keyframes shadow-pulse {
|
||||
0% { box-shadow: 0 0 0 0px rgba(103, 194, 58, 0.4); }
|
||||
70% { box-shadow: 0 0 0 8px rgba(103, 194, 58, 0); }
|
||||
100% { box-shadow: 0 0 0 0px rgba(103, 194, 58, 0); }
|
||||
}
|
||||
|
||||
.status-running { background: #67C23A; }
|
||||
.status-paused { background: #E6A23C; }
|
||||
.status-error { background: #F56C6C; animation-name: shadow-pulse-error; }
|
||||
.status-done { background: #94a3b8; }
|
||||
|
||||
@keyframes shadow-pulse-error {
|
||||
0% { box-shadow: 0 0 0 0px rgba(245, 108, 108, 0.4); }
|
||||
70% { box-shadow: 0 0 0 8px rgba(245, 108, 108, 0); }
|
||||
100% { box-shadow: 0 0 0 0px rgba(245, 108, 108, 0); }
|
||||
}
|
||||
|
||||
.text-running { color: #67C23A; font-weight: 600; }
|
||||
.text-error { color: #F56C6C; font-weight: 600; }
|
||||
|
||||
/* 表格定制 */
|
||||
::v-deep .custom-header th {
|
||||
/* background-color: #f8fafc !important; */
|
||||
color: #475569;
|
||||
font-weight: 600;
|
||||
/* height: 50px; */
|
||||
}
|
||||
.count-badge {
|
||||
background: #eff6ff;
|
||||
color: #2563eb;
|
||||
padding: 2px 8px;
|
||||
border-radius: 12px;
|
||||
font-weight: 700;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
/* 操作按钮 */
|
||||
.action-wrapper .el-button {
|
||||
font-size: 18px;
|
||||
padding: 0 6px;
|
||||
transition: all 0.2s;
|
||||
}
|
||||
.action-wrapper .el-button:hover {
|
||||
transform: scale(1.2);
|
||||
}
|
||||
.del-btn { color: #ef4444 !important; }
|
||||
.save-btn { color: #10b981 !important; font-size: 14px !important; }
|
||||
.cancel-btn { color: #64748b !important; font-size: 14px !important; }
|
||||
|
||||
/* 刷新旋转 */
|
||||
.is-spinning {
|
||||
animation: rotate 1s linear infinite;
|
||||
color: #409eff;
|
||||
}
|
||||
@keyframes rotate {
|
||||
from { transform: rotate(0deg); }
|
||||
to { transform: rotate(360deg); }
|
||||
}
|
||||
|
||||
/* 过渡动画 */
|
||||
.fade-slide-enter-active, .fade-slide-leave-active {
|
||||
transition: all 0.25s ease;
|
||||
}
|
||||
.fade-slide-enter {
|
||||
opacity: 0;
|
||||
transform: translateY(5px);
|
||||
}
|
||||
.fade-slide-leave-to {
|
||||
opacity: 0;
|
||||
transform: translateY(-5px);
|
||||
}
|
||||
|
||||
.pagination-wrapper {
|
||||
margin-top: 24px;
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
::v-deep .el-card__body{
|
||||
padding: 10px !important;
|
||||
}
|
||||
</style>
|
||||
@@ -1097,6 +1097,20 @@ export default new Router({
|
||||
title: 'Scholar Database'
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/crawlTaskMonitor',
|
||||
component: () => import('../components/page/crawlTaskMonitor'),
|
||||
meta: {
|
||||
title: 'Crawl Task Monitor'
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/scholarCrawlersKeywords',
|
||||
component: () => import('../components/page/scholarCrawlersKeywords'),
|
||||
meta: {
|
||||
title: 'Crawl Keywords Config'
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/expertDatabase', //专家库
|
||||
component: () => import('../components/page/expertDatabase'),
|
||||
|
||||
@@ -60,7 +60,7 @@ module.exports = {
|
||||
assetsDir: 'static',
|
||||
productionSourceMap: false,
|
||||
devServer: {
|
||||
|
||||
|
||||
// public: 'http://192.168.110.159:8080/', // 你自己本地的ip地址:端口号
|
||||
port: '8080',
|
||||
open: true,
|
||||
@@ -77,7 +77,16 @@ module.exports = {
|
||||
changeOrigin: true,
|
||||
pathRewrite: {
|
||||
'^/api': ''
|
||||
}
|
||||
},
|
||||
compress: false, // 💡 关键:禁止压缩,否则 SSE 流会被攒着不发
|
||||
|
||||
// 增加超时时间,防止长连接被代理提前掐断
|
||||
proxyTimeout: 10 * 60 * 1000,
|
||||
timeout: 10 * 60 * 1000
|
||||
},
|
||||
'/public': {
|
||||
target: 'https://submission.tmrjournals.com/',
|
||||
changeOrigin: true
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user