fix: content quality, image format, task monitor, calendar data source, search UI & sort
This commit is contained in:
+221
-18
@@ -31,6 +31,7 @@
|
||||
<el-button size="default" :type="activeTab === 'menus' ? 'primary' : ''" @click="switchTab('menus')">菜单管理</el-button>
|
||||
<el-button size="default" :type="activeTab === 'logs' ? 'primary' : ''" @click="switchTab('logs')">运行日志</el-button>
|
||||
<el-button size="default" :type="activeTab === 'assistant' ? 'primary' : ''" @click="switchTab('assistant')">AI 助手</el-button>
|
||||
<el-button size="default" :type="activeTab === 'searchproviders' ? 'primary' : ''" @click="switchTab('searchproviders')">搜索API</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -441,16 +442,8 @@
|
||||
|
||||
<div v-if="activeTab === 'logs'">
|
||||
<div class="toolbar">
|
||||
<el-select v-model="logType" placeholder="日志类型" style="width:200px;">
|
||||
<el-option label="创作日志" value="creator"></el-option>
|
||||
<el-option label="审查日志" value="optimizer"></el-option>
|
||||
<el-option label="研究日志" value="research"></el-option>
|
||||
<el-option label="大纲日志" value="outline"></el-option>
|
||||
<el-option label="写作日志" value="writer"></el-option>
|
||||
<el-option label="发布日志" value="publisher"></el-option>
|
||||
<el-option label="收集日志" value="collector"></el-option>
|
||||
<el-option label="通知日志" value="notifier"></el-option>
|
||||
<el-option label="趋势日志" value="trends"></el-option>
|
||||
<el-select v-model="logType" placeholder="日志类型" style="width:200px;" @focus="loadLogTypes">
|
||||
<el-option v-for="t in logTypes" :key="t.module_id" :label="t.name" :value="t.module_id"></el-option>
|
||||
</el-select>
|
||||
<el-date-picker v-model="logDate" type="date" placeholder="选择日期" format="YYYY-MM-DD" value-format="YYYY-MM-DD" style="width:200px;"></el-date-picker>
|
||||
<el-button type="primary" @click="fetchLogs" :loading="logsLoading">加载日志</el-button>
|
||||
@@ -480,7 +473,119 @@
|
||||
</el-form>
|
||||
</div>
|
||||
|
||||
<div v-if="activeTab === 'searchproviders'">
|
||||
<div class="toolbar">
|
||||
<el-button type="primary" size="small" @click="addSearchProvider">新增提供商</el-button>
|
||||
<el-button size="small" @click="testAllSearchProviders">测试全部</el-button>
|
||||
<el-button size="small" @click="resetSearchUsage">重置用量</el-button>
|
||||
<span style="font-size:13px;color:#909399;margin-left:8px;">共 {{ searchProviders.length }} 个</span>
|
||||
</div>
|
||||
<div v-if="searchProvidersLoading" class="card-loading">加载中...</div>
|
||||
<template v-else-if="searchProviders.length === 0">
|
||||
<div class="empty-state">
|
||||
<el-icon style="font-size:48px;color:#c0c4cc;"><IconSearch /></el-icon>
|
||||
<div class="empty-text">暂无搜索API提供商</div>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else>
|
||||
<el-table :data="searchProviders" border stripe class="data-table" style="width:100%">
|
||||
<el-table-column prop="id" label="ID" width="50"></el-table-column>
|
||||
<el-table-column prop="name" label="名称" width="120"></el-table-column>
|
||||
<el-table-column prop="provider_type" label="类型" width="100">
|
||||
<template #default="scope">
|
||||
<el-tag :type="scope.row.provider_type === 'baidu' ? 'primary' : scope.row.provider_type === 'bing' ? 'success' : 'warning'" size="small">{{ scope.row.provider_type }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="enabled" label="启用" width="60">
|
||||
<template #default="scope">
|
||||
<el-switch v-model="scope.row.enabled" @change="updateSearchProvider(scope.row)"></el-switch>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="priority" label="优先级" width="70"></el-table-column>
|
||||
<el-table-column prop="daily_limit" label="日限" width="70"></el-table-column>
|
||||
<el-table-column prop="usage_today" label="已用/日限" width="120">
|
||||
<template #default="scope">
|
||||
<div style="display:flex;align-items:center;gap:4px;">
|
||||
<el-progress :percentage="Math.round(scope.row.usage_today / scope.row.daily_limit * 100)" :stroke-width="12" :status="scope.row.usage_today >= scope.row.daily_limit ? 'exception' : scope.row.usage_today / scope.row.daily_limit > 0.8 ? 'warning' : 'success'" style="flex:1;min-width:80px;"></el-progress>
|
||||
<span :style="{fontSize:'11px',color: scope.row.usage_today >= scope.row.daily_limit ? '#f56c6c' : scope.row.usage_today / scope.row.daily_limit > 0.8 ? '#e6a23c' : '#67c23a'}">{{ scope.row.usage_today }}/{{ scope.row.daily_limit }}</span>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="api_url" label="API地址" min-width="200">
|
||||
<template #default="scope">
|
||||
<span style="font-size:12px;word-break:break-all;">{{ scope.row.api_url || '-' }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="console_url" label="控制台" min-width="160">
|
||||
<template #default="scope">
|
||||
<a v-if="scope.row.console_url" :href="scope.row.console_url" target="_blank" style="font-size:12px;color:#409eff;">打开</a>
|
||||
<span v-else style="color:#c0c4cc;">-</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="200" fixed="right">
|
||||
<template #default="scope">
|
||||
<el-button size="small" @click="editSearchProvider(scope.row)">编辑</el-button>
|
||||
<el-button size="small" @click="testSearchProvider(scope.row)">测试</el-button>
|
||||
<el-button size="small" type="danger" @click="deleteSearchProvider(scope.row.id)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<div class="card-list-mobile">
|
||||
<div v-for="item in searchProviders" :key="item.id" class="card-item">
|
||||
<div class="card-row"><span class="card-label">名称</span><span class="card-value">{{ item.name }}</span></div>
|
||||
<div class="card-row"><span class="card-label">类型</span><span class="card-value">{{ item.provider_type }}</span></div>
|
||||
<div class="card-row"><span class="card-label">用量</span><span class="card-value">{{ item.usage_today }}/{{ item.daily_limit }}</span></div>
|
||||
<div class="card-actions"><el-button size="small" @click="editSearchProvider(item)">编辑</el-button><el-button size="small" type="danger" @click="deleteSearchProvider(item.id)">删除</el-button></div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<el-dialog v-model="searchProviderDialogVisible" :title="searchProviderDialogTitle" width="720px" :close-on-click-modal="false">
|
||||
<el-form :model="searchProviderForm" label-width="110px">
|
||||
<el-row :gutter="16">
|
||||
<el-col :span="12"><el-form-item label="名称"><el-input v-model="searchProviderForm.name" placeholder="如:百度千帆"/></el-form-item></el-col>
|
||||
<el-col :span="12"> <el-form-item label="类型">
|
||||
<el-select v-model="searchProviderForm.provider_type" style="width:100%">
|
||||
<el-option label="百度千帆" value="baidu"></el-option>
|
||||
<el-option label="opencode云搜索" value="mcp"></el-option>
|
||||
</el-select>
|
||||
</el-form-item></el-col>
|
||||
</el-row>
|
||||
<el-row :gutter="16">
|
||||
<el-col :span="12"><el-form-item label="API Key"><el-input v-model="searchProviderForm.api_key" type="password" show-password placeholder="sk-..."/></el-form-item></el-col>
|
||||
<el-col :span="12"><el-form-item label="优先级"><el-input-number v-model="searchProviderForm.priority" :min="1" :max="99" style="width:100%"/></el-form-item></el-col>
|
||||
</el-row>
|
||||
<el-row :gutter="16">
|
||||
<el-col :span="14"><el-form-item label="API地址"><el-input v-model="searchProviderForm.api_url" placeholder="https://..."/></el-form-item></el-col>
|
||||
<el-col :span="10"><el-form-item label="日限额"><el-input-number v-model="searchProviderForm.daily_limit" :min="1" :max="999999" style="width:100%"/></el-form-item></el-col>
|
||||
</el-row>
|
||||
<el-row :gutter="16">
|
||||
<el-col :span="24"><el-form-item label="控制台地址"><el-input v-model="searchProviderForm.console_url" placeholder="https://console.xxx.com/..."/></el-form-item></el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="searchProviderDialogVisible = false">取消</el-button>
|
||||
<el-button type="primary" @click="saveSearchProvider" :loading="searchProviderSaving">保存</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<el-dialog v-model="searchProviderTestVisible" title="测试结果" width="600px">
|
||||
<div v-if="searchProviderTesting" style="text-align:center;padding:20px;">测试中...</div>
|
||||
<div v-else>
|
||||
<div :style="{padding:'8px',marginBottom:'8px',borderRadius:'4px',background:searchProviderTestResult.ok ? '#f0f9eb' : '#fef0f0',color:searchProviderTestResult.ok ? '#67c23a' : '#f56c6c'}">
|
||||
{{ searchProviderTestResult.ok ? '✅ 连接成功' : '❌ 连接失败' }}
|
||||
</div>
|
||||
<div v-if="searchProviderTestResult.error" style="color:#f56c6c;font-size:13px;margin-bottom:8px;">{{ searchProviderTestResult.error }}</div>
|
||||
<div v-if="searchProviderTestResult.results && searchProviderTestResult.results.length">
|
||||
<div v-for="r in searchProviderTestResult.results" :key="r.url" style="padding:8px;border-bottom:1px solid #eee;">
|
||||
<div style="font-weight:bold;">{{ r.title }}</div>
|
||||
<div style="font-size:12px;color:#909399;">{{ r.url }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<template #footer><el-button @click="searchProviderTestVisible = false">关闭</el-button></template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
@@ -761,6 +866,7 @@ const llmConfigs = ref([]);
|
||||
};
|
||||
|
||||
const logType = ref('creator');
|
||||
const logTypes = ref([]);
|
||||
const users = ref([]);
|
||||
const usersLoading = ref(false);
|
||||
const userDialogVisible = ref(false);
|
||||
@@ -810,10 +916,25 @@ const llmConfigs = ref([]);
|
||||
const logDate = ref(new Date().toISOString().slice(0, 10));
|
||||
const logContent = ref('');
|
||||
const logsLoading = ref(false);
|
||||
const loadLogTypes = async () => {
|
||||
try {
|
||||
logTypes.value = await api.get('/api/admin/task-logs/log-types');
|
||||
logTypes.value.unshift({ module_id: 'creator', name: '创作日志', log_file: 'creator' });
|
||||
logTypes.value.unshift({ module_id: 'optimizer', name: '审查日志', log_file: 'optimizer' });
|
||||
logTypes.value.unshift({ module_id: 'research', name: '研究日志', log_file: 'research' });
|
||||
logTypes.value.unshift({ module_id: 'outline', name: '大纲日志', log_file: 'outline' });
|
||||
logTypes.value.unshift({ module_id: 'writer', name: '写作日志', log_file: 'writer' });
|
||||
logTypes.value.unshift({ module_id: 'publisher', name: '发布日志', log_file: 'publisher' });
|
||||
logTypes.value.unshift({ module_id: 'collector', name: '收集日志', log_file: 'collector' });
|
||||
logTypes.value.unshift({ module_id: 'trends', name: '趋势日志', log_file: 'trends' });
|
||||
} catch (e) { console.error('加载日志类型失败:', e); }
|
||||
};
|
||||
const fetchLogs = async () => {
|
||||
logsLoading.value = true;
|
||||
try {
|
||||
const resp = await fetch(`/api/system/logs/${logDate.value}?log_type=${logType.value}`, {
|
||||
const module = logTypes.value.find(t => t.name === logType.value);
|
||||
const logFile = module ? module.log_file : logType.value;
|
||||
const resp = await fetch(`/api/system/logs/${logDate.value}?log_type=${logFile}`, {
|
||||
headers: { 'Authorization': `Bearer ${localStorage.getItem('authToken')}` }
|
||||
});
|
||||
if (resp.ok) {
|
||||
@@ -863,12 +984,89 @@ const llmConfigs = ref([]);
|
||||
} catch (e) { console.error('加载AI助手配置失败', e); }
|
||||
};
|
||||
const saveAssistantPrompt = async () => {
|
||||
assistantSaving.value = true;
|
||||
try {
|
||||
await api.post('/api/admin/systemconfigs', { key: 'assistant_system_prompt', value: assistantPrompt.value, description: 'AI 助手系统提示词' });
|
||||
ElementPlus.ElMessage.success('保存成功');
|
||||
} catch (e) { ElementPlus.ElMessage.error('保存失败: ' + e.message); }
|
||||
finally { assistantSaving.value = false; }
|
||||
const configs = await api.get('/api/admin/systemconfigs');
|
||||
const cfg = configs.find(c => c.key === 'assistant_system_prompt');
|
||||
if (cfg) { await api.put(`/api/admin/systemconfigs/${cfg.id}`, { value: assistantPrompt.value, description: 'AI 助手系统提示词' }); }
|
||||
else { await api.post('/api/admin/systemconfigs', { key: 'assistant_system_prompt', value: assistantPrompt.value, description: 'AI 助手系统提示词' }); }
|
||||
ElMessage.success('保存成功');
|
||||
} catch (e) { ElMessage.error('保存失败: ' + e.message); }
|
||||
};
|
||||
|
||||
const searchProviders = ref([]);
|
||||
const searchProvidersLoading = ref(false);
|
||||
const searchProviderDialogVisible = ref(false);
|
||||
const searchProviderDialogTitle = ref('新增搜索API');
|
||||
const searchProviderSaving = ref(false);
|
||||
const searchProviderForm = reactive({ id: null, name: '', provider_type: 'baidu', api_key: '', api_url: '', console_url: '', priority: 1, daily_limit: 1500, enabled: true });
|
||||
const searchProviderTestVisible = ref(false);
|
||||
const searchProviderTesting = ref(false);
|
||||
const searchProviderTestResult = ref({ ok: false, error: '', results: [] });
|
||||
|
||||
const loadSearchProviders = async () => {
|
||||
searchProvidersLoading.value = true;
|
||||
try { searchProviders.value = await api.get('/api/search-providers'); }
|
||||
catch (e) { ElMessage.error('加载搜索API失败: ' + e.message); }
|
||||
finally { searchProvidersLoading.value = false; }
|
||||
};
|
||||
const addSearchProvider = () => {
|
||||
searchProviderDialogTitle.value = '新增搜索API';
|
||||
searchProviderForm.id = null;
|
||||
searchProviderForm.name = '';
|
||||
searchProviderForm.provider_type = 'baidu';
|
||||
searchProviderForm.api_key = '';
|
||||
searchProviderForm.api_url = '';
|
||||
searchProviderForm.console_url = '';
|
||||
searchProviderForm.priority = 1;
|
||||
searchProviderForm.daily_limit = 1500;
|
||||
searchProviderForm.enabled = true;
|
||||
searchProviderDialogVisible.value = true;
|
||||
};
|
||||
const editSearchProvider = (row) => {
|
||||
searchProviderDialogTitle.value = '编辑搜索API';
|
||||
Object.assign(searchProviderForm, { id: row.id, name: row.name, provider_type: row.provider_type, api_key: row.api_key, api_url: row.api_url, console_url: row.console_url || '', priority: row.priority, daily_limit: row.daily_limit, enabled: row.enabled });
|
||||
searchProviderDialogVisible.value = true;
|
||||
};
|
||||
const saveSearchProvider = async () => {
|
||||
searchProviderSaving.value = true;
|
||||
try {
|
||||
const body = { name: searchProviderForm.name, provider_type: searchProviderForm.provider_type, api_key: searchProviderForm.api_key, api_url: searchProviderForm.api_url, console_url: searchProviderForm.console_url, priority: searchProviderForm.priority, daily_limit: searchProviderForm.daily_limit, enabled: searchProviderForm.enabled };
|
||||
if (searchProviderForm.id) { await api.put(`/api/search-providers/${searchProviderForm.id}`, body); ElMessage.success('更新成功'); }
|
||||
else { await api.post('/api/search-providers', body); ElMessage.success('创建成功'); }
|
||||
searchProviderDialogVisible.value = false;
|
||||
await loadSearchProviders();
|
||||
} catch (e) { ElMessage.error('保存失败: ' + e.message); }
|
||||
finally { searchProviderSaving.value = false; }
|
||||
};
|
||||
const deleteSearchProvider = async (id) => {
|
||||
try { await ElMessageBox.confirm('确定删除该提供商吗?', '提示', { type: 'warning' }); await api.delete(`/api/search-providers/${id}`); ElMessage.success('删除成功'); await loadSearchProviders(); }
|
||||
catch (e) { if (e !== 'cancel') ElMessage.error('删除失败: ' + e.message); }
|
||||
};
|
||||
const updateSearchProvider = async (row) => {
|
||||
try { await api.put(`/api/search-providers/${row.id}`, { enabled: row.enabled }); }
|
||||
catch (e) { ElMessage.error('更新失败: ' + e.message); }
|
||||
};
|
||||
const testSearchProvider = async (row) => {
|
||||
searchProviderTesting.value = true;
|
||||
searchProviderTestVisible.value = true;
|
||||
searchProviderTestResult.value = { ok: false, error: '', results: [] };
|
||||
try {
|
||||
const r = await api.post(`/api/search-providers/${row.id}/test`, { query: '测试搜索' });
|
||||
searchProviderTestResult.value = r;
|
||||
} catch (e) { searchProviderTestResult.value = { ok: false, error: e.message, results: [] }; }
|
||||
finally { searchProviderTesting.value = false; }
|
||||
};
|
||||
const testAllSearchProviders = async () => {
|
||||
for (const p of searchProviders.value) {
|
||||
try {
|
||||
const r = await api.post(`/api/search-providers/${p.id}/test`, { query: '测试搜索' });
|
||||
ElMessage({ type: r.ok ? 'success' : 'error', message: `${p.name}: ${r.ok ? 'OK' : '失败 ' + (r.error || '')}` });
|
||||
} catch (e) { ElMessage.error(`${p.name} 测试失败: ${e.message}`); }
|
||||
}
|
||||
};
|
||||
const resetSearchUsage = async () => {
|
||||
try { await api.post('/api/search-providers/reset-usage'); ElMessage.success('用量已重置'); await loadSearchProviders(); }
|
||||
catch (e) { ElMessage.error('重置失败: ' + e.message); }
|
||||
};
|
||||
|
||||
const formatDate = (dateStr) => { if (!dateStr) return '-'; return new Date(dateStr.replace(' ', 'T')).toLocaleString('zh-CN', { year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit' }); };
|
||||
@@ -877,7 +1075,8 @@ const llmConfigs = ref([]);
|
||||
const tabLoaders = {
|
||||
llmconfigs: loadLLMConfigs, platformconfigs: loadPlatformConfigs, systemconfigs: loadSystemConfigs,
|
||||
users: fetchUsers,
|
||||
orgs: loadOrgs, roles: loadRoles, menus: loadMenus, assistant: loadAssistantConfig, logs: fetchLogs,
|
||||
logs: loadLogTypes, orgs: loadOrgs, roles: loadRoles, menus: loadMenus, assistant: loadAssistantConfig,
|
||||
searchproviders: loadSearchProviders,
|
||||
};
|
||||
const loadedTabs = new Set([]);
|
||||
|
||||
@@ -909,8 +1108,12 @@ const llmConfigs = ref([]);
|
||||
logout, currentUser, isAdmin, redirectToPage,
|
||||
users, usersLoading, userDialogVisible, userDialogTitle, userSubmitting, userForm, userPage, userPageSize, paginatedUsers,
|
||||
fetchUsers, addUser, showEditUserDialog, submitUser, deleteUser,
|
||||
logType, logDate, logContent, logsLoading, fetchLogs,
|
||||
logType, logTypes, logDate, logContent, logsLoading, fetchLogs,
|
||||
assistantPrompt, assistantEnabled, assistantSaving, saveAssistantPrompt,
|
||||
searchProviders, searchProvidersLoading, searchProviderDialogVisible, searchProviderDialogTitle, searchProviderSaving, searchProviderForm,
|
||||
searchProviderTestVisible, searchProviderTesting, searchProviderTestResult,
|
||||
loadSearchProviders, addSearchProvider, editSearchProvider, saveSearchProvider, deleteSearchProvider, updateSearchProvider,
|
||||
testSearchProvider, testAllSearchProviders, resetSearchUsage,
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
@@ -222,12 +222,17 @@ const ArticlesApp = {
|
||||
const titleEl = doc.querySelector('h1');
|
||||
const title = titleEl ? titleEl.textContent.trim() : (this.previewArticleData.topic_title || '');
|
||||
const body = doc.body;
|
||||
if (body) body.querySelectorAll('script, style, svg, img, nav, footer, .interaction').forEach(el => el.remove());
|
||||
const contentEls = body ? Array.from(body.querySelectorAll('p, h1, h2, h3, h4, li')) : [];
|
||||
const text = contentEls.map(el => el.textContent.trim()).filter(t => t && t.length > 1).join('\n\n');
|
||||
navigator.clipboard.writeText(`标题:${title}\n\n内容:\n${text}`)
|
||||
.then(() => this.$message.success('已复制到剪贴板'))
|
||||
.catch(() => this.$message.error('复制失败'));
|
||||
if (body) body.querySelectorAll('script, style, nav, footer, .interaction, .ad, aside, .comment').forEach(el => el.remove());
|
||||
const container = doc.createElement('div');
|
||||
if (titleEl) { const h1 = doc.createElement('h1'); h1.textContent = title; container.appendChild(h1); }
|
||||
body.querySelectorAll('h2,h3,h4,p,li,blockquote,img,pre,code,table,hr').forEach(el => container.appendChild(el.cloneNode(true)));
|
||||
const cleanHtml = container.innerHTML;
|
||||
const blob = new Blob([cleanHtml], { type: 'text/html' });
|
||||
const plainText = container.textContent;
|
||||
const item = new ClipboardItem({ 'text/html': blob, 'text/plain': new Blob([plainText], { type: 'text/plain' }) });
|
||||
navigator.clipboard.write([item]).then(() => this.$message.success('✅ 已复制(含格式和配图),Ctrl+V 粘贴')).catch(() => {
|
||||
navigator.clipboard.writeText(cleanHtml).then(() => this.$message.success('✅ 已复制 HTML')).catch(() => this.$message.error('❌ 复制失败'));
|
||||
});
|
||||
},
|
||||
async deleteArticle(article) {
|
||||
try {
|
||||
|
||||
@@ -189,14 +189,15 @@
|
||||
<el-table v-else :data="selectedDayEntries" stripe>
|
||||
<el-table-column prop="title" label="标题" min-width="120"></el-table-column>
|
||||
<el-table-column prop="platform" label="平台" width="100">
|
||||
<template #default="scope">{{ platformName(scope.row.platform) }}</template>
|
||||
<template #default="scope">{{ scope.row._source === 'topic' ? (scope.row.status === 'published' ? '已发布' : '选题') : platformName(scope.row.platform) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="status" label="状态" width="80">
|
||||
<template #default="scope"><el-tag :type="statusType(scope.row.status)" size="small">{{ statusLabel(scope.row.status) }}</el-tag></template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="120">
|
||||
<template #default="scope">
|
||||
<el-button size="small" @click="openEntryDialog(scope.row)">编辑</el-button>
|
||||
<el-button v-if="scope.row._source === 'topic'" size="small" type="primary" @click="openEntryDialog(scope.row)">查看</el-button>
|
||||
<el-button v-else size="small" @click="openEntryDialog(scope.row)">编辑</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
@@ -407,11 +408,51 @@ function getDayMeta(year, month, day) {
|
||||
loadingCalendar.value = true;
|
||||
calendarError.value = '';
|
||||
errorMsg.value = '';
|
||||
try { entries.value = await api(`/api/calendar?year=${currentYear.value}&month=${currentMonth.value}`); } catch (e) { console.error(e); calendarError.value = e.message; errorMsg.value = '加载失败: ' + e.message; }
|
||||
try {
|
||||
const [calEntries, topicList] = await Promise.all([
|
||||
api(`/api/calendar?year=${currentYear.value}&month=${currentMonth.value}`),
|
||||
api('/api/topics?limit=200'),
|
||||
]);
|
||||
topics.value = topicList;
|
||||
|
||||
const virtualEntries = [];
|
||||
(topicList || []).forEach(t => {
|
||||
const s = t.status;
|
||||
if ((s === 'ready' || s === '待发布') && t.ready_at) {
|
||||
const d = new Date(t.ready_at);
|
||||
if (d.getFullYear() === currentYear.value && d.getMonth() + 1 === currentMonth.value) {
|
||||
virtualEntries.push({ id: 'topic_ready_' + t.id, title: t.title, planned_date: t.ready_at, platform: '', status: 'planned', platform_icon: '📋', topic_status: 'ready', _source: 'topic' });
|
||||
}
|
||||
} else if ((s === 'published' || s === '已发布') && t.published_at) {
|
||||
const d = new Date(t.published_at);
|
||||
if (d.getFullYear() === currentYear.value && d.getMonth() + 1 === currentMonth.value) {
|
||||
virtualEntries.push({ id: 'topic_pub_' + t.id, title: t.title, planned_date: t.published_at, platform: '', status: 'published', platform_icon: '📄', topic_status: 'published', _source: 'topic' });
|
||||
}
|
||||
}
|
||||
});
|
||||
entries.value = [...(calEntries || []), ...virtualEntries];
|
||||
} catch (e) { console.error(e); calendarError.value = e.message; errorMsg.value = '加载失败: ' + e.message; }
|
||||
finally { loadingCalendar.value = false; }
|
||||
};
|
||||
const fetchStats = async () => {
|
||||
try { stats.value = await api(`/api/calendar/stats?year=${currentYear.value}&month=${currentMonth.value}`); } catch (e) { console.error(e); ElMessage.error('加载统计失败: ' + e.message); }
|
||||
try {
|
||||
const [calStats, topicList] = await Promise.all([
|
||||
api(`/api/calendar/stats?year=${currentYear.value}&month=${currentMonth.value}`),
|
||||
api('/api/topics?limit=200').catch(() => []),
|
||||
]);
|
||||
const s = { planned: calStats.planned || 0, published: calStats.published || 0, delayed: calStats.delayed || 0, cancelled: calStats.cancelled || 0 };
|
||||
(topicList || []).forEach(t => {
|
||||
const st = t.status;
|
||||
if ((st === 'ready' || st === '待发布') && t.ready_at) {
|
||||
const d = new Date(t.ready_at);
|
||||
if (d.getFullYear() === currentYear.value && d.getMonth() + 1 === currentMonth.value) s.planned++;
|
||||
} else if ((st === 'published' || st === '已发布') && t.published_at) {
|
||||
const d = new Date(t.published_at);
|
||||
if (d.getFullYear() === currentYear.value && d.getMonth() + 1 === currentMonth.value) s.published++;
|
||||
}
|
||||
});
|
||||
stats.value = s;
|
||||
} catch (e) { console.error(e); ElMessage.error('加载统计失败: ' + e.message); }
|
||||
};
|
||||
const fetchTopics = async () => {
|
||||
try { const res = await api('/api/topics?limit=100'); topics.value = res; } catch (e) { console.error(e); ElMessage.error('加载选题失败: ' + e.message); }
|
||||
@@ -423,7 +464,14 @@ function getDayMeta(year, month, day) {
|
||||
|
||||
const openDayDialog = (day) => { selectedDay.value = day; selectedDayEntries.value = entries.value.filter(e => { const pd = new Date(e.planned_date); return pd.getFullYear() === day.year && pd.getMonth() + 1 === day.month && pd.getDate() === day.day; }); dayDialogVisible.value = true; };
|
||||
const openCreateDialog = () => { isEdit.value = false; entryForm.value = { id: null, title: '', planned_date: `${selectedDay.value.year}-${selectedDay.value.month}-${selectedDay.value.day}`, platform: 'zhihu', topic_id: null, status: 'planned', notes: '' }; entryDialogVisible.value = true; };
|
||||
const openEntryDialog = (entry) => { isEdit.value = true; entryForm.value = { ...entry, planned_date: entry.planned_date }; entryDialogVisible.value = true; };
|
||||
const openEntryDialog = (entry) => {
|
||||
if (entry._source === 'topic') {
|
||||
const topicId = entry.id.replace(/^topic_(ready|pub)_/, '');
|
||||
window.location.href = '/topics.html?topic_id=' + topicId;
|
||||
return;
|
||||
}
|
||||
isEdit.value = true; entryForm.value = { ...entry, planned_date: entry.planned_date }; entryDialogVisible.value = true;
|
||||
};
|
||||
|
||||
const saveEntry = async () => {
|
||||
saving.value = true;
|
||||
@@ -463,7 +511,6 @@ function getDayMeta(year, month, day) {
|
||||
isAdmin.value = d.user.role === 'admin';
|
||||
fetchEntries();
|
||||
fetchStats();
|
||||
fetchTopics();
|
||||
})
|
||||
.catch(() => {
|
||||
localStorage.removeItem('authToken');
|
||||
|
||||
@@ -327,22 +327,51 @@
|
||||
this.loadingPlan = true;
|
||||
try {
|
||||
const token = localStorage.getItem('authToken');
|
||||
const now = new Date();
|
||||
const year = now.getFullYear();
|
||||
const month = now.getMonth() + 1;
|
||||
const resp = await fetch(`/api/calendar?year=${year}&month=${month}`, {
|
||||
headers: { 'Authorization': 'Bearer ' + token }
|
||||
const today = new Date();
|
||||
today.setHours(0, 0, 0, 0);
|
||||
const end = new Date(today);
|
||||
end.setDate(end.getDate() + 7);
|
||||
|
||||
const [entries, topics] = await Promise.all([
|
||||
fetch(`/api/calendar?year=${today.getFullYear()}&month=${today.getMonth() + 1}`, {
|
||||
headers: { 'Authorization': 'Bearer ' + token }
|
||||
}).then(r => r.ok ? r.json() : []),
|
||||
fetch('/api/topics?limit=200', {
|
||||
headers: { 'Authorization': 'Bearer ' + token }
|
||||
}).then(r => r.ok ? r.json() : [])
|
||||
]);
|
||||
|
||||
const events = [];
|
||||
(entries || []).forEach(e => {
|
||||
events.push({
|
||||
id: 'cal_' + e.id,
|
||||
date: e.planned_date,
|
||||
title: e.title,
|
||||
status: e.status === 'published' ? 'published' : 'planned'
|
||||
});
|
||||
});
|
||||
if (resp.ok) {
|
||||
const all = await resp.json();
|
||||
const today = new Date();
|
||||
today.setHours(0, 0, 0, 0);
|
||||
const end = new Date(today);
|
||||
end.setDate(end.getDate() + 7);
|
||||
this.upcomingEntries = (all || [])
|
||||
.filter(e => { const d = new Date(e.planned_date); return d >= today && d < end; })
|
||||
.sort((a, b) => a.planned_date.localeCompare(b.planned_date));
|
||||
}
|
||||
(topics || []).forEach(t => {
|
||||
const s = t.status;
|
||||
if ((s === 'ready' || s === '待发布') && t.ready_at) {
|
||||
events.push({
|
||||
id: 'topic_ready_' + t.id,
|
||||
date: t.ready_at,
|
||||
title: t.title,
|
||||
status: 'planned'
|
||||
});
|
||||
} else if ((s === 'published' || s === '已发布') && t.published_at) {
|
||||
events.push({
|
||||
id: 'topic_pub_' + t.id,
|
||||
date: t.published_at,
|
||||
title: t.title,
|
||||
status: 'published'
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
this.upcomingEntries = events
|
||||
.filter(e => { const d = new Date(e.date); return d >= today && d < end; })
|
||||
.sort((a, b) => a.date.localeCompare(b.date));
|
||||
} catch (e) {
|
||||
console.error('获取近期计划失败:', e);
|
||||
} finally { this.loadingPlan = false; }
|
||||
|
||||
@@ -100,9 +100,9 @@
|
||||
<span v-else :class="['module-status', mod.last_status === 'success' ? 'completed' : mod.last_status === 'failed' ? 'failed' : '']">{{ mod.last_status === 'success' ? '正常' : mod.last_status === 'failed' ? '失败' : '空闲' }}</span>
|
||||
</div>
|
||||
<div class="module-content">
|
||||
<div><span>最后运行</span><span>{{ mod.last_run || '从未' }}</span></div>
|
||||
<div><span>最后运行</span><span>{{ mod.last_run || '从未' }}<span v-if="mod.last_status" :style="{marginLeft:'6px',padding:'1px 6px',borderRadius:'8px',fontSize:'11px',fontWeight:500}"><span v-if="mod.last_status==='success'" style="color:#67c23a;">✅成功</span><span v-else-if="mod.last_status==='failed'" style="color:#f56c6c;">❌失败</span><span v-else-if="mod.last_status==='running'" style="color:#e6a23c;">⏳运行中</span></span></span></div>
|
||||
<div><span>下次运行</span><span>{{ mod.next_run || '—' }}</span></div>
|
||||
<div><span>累计运行</span><span>{{ mod.total_runs }} 次 <span style="color:#67c23a;">{{ mod.success_runs }} 成功</span> <span style="color:#f56c6c;">{{ mod.failed_runs }} 失败</span></span></div>
|
||||
<div><span>累计运行</span><span>{{ mod.total_runs }} 次 <span style="color:#67c23a;">{{ mod.success_runs }} 成功</span> <span style="color:#f56c6c;">{{ mod.failed_runs }} 失败</span><span v-if="mod.running > 0" style="color:#e6a23c;"> {{ mod.running }} 运行中</span></span></div>
|
||||
<div style="margin-top:10px; border-bottom:none;">
|
||||
<el-button size="small" type="primary" @click.stop="triggerModule(mod.module_id)" :loading="runningModule === mod.module_id" :disabled="!mod.enabled">立即运行</el-button>
|
||||
<el-button size="small" @click.stop="openModuleDetail(mod)">查看详情</el-button>
|
||||
@@ -619,6 +619,7 @@ const TasksApp = {
|
||||
'scheduled_metrics_sync': { icon: 'IconDashboard', name: '指标同步', defaultTime: '06:00' },
|
||||
'scheduled_refresh_search_cache': { icon: 'IconRefresh', name: '搜索缓存', defaultTime: '01:00' },
|
||||
'scheduled_fetch_trends': { icon: 'IconRefresh', name: '热点趋势', defaultTime: '01:10' },
|
||||
'scheduled_task_monitor': { icon: 'IconRefresh', name: '任务监控', defaultTime: '*' },
|
||||
};
|
||||
const MODULE_TRIGGER_ENDPOINTS = {
|
||||
scheduled_collect: '/api/system/collect/run',
|
||||
@@ -762,7 +763,7 @@ const TasksApp = {
|
||||
},
|
||||
async triggerModule(modId) {
|
||||
const endpoint = this.MODULE_TRIGGER_ENDPOINTS[modId];
|
||||
if (!endpoint) { ElMessage.error('未知模块'); return; }
|
||||
if (!endpoint) { ElMessage.info('此模块自动运行,无需手动触发'); return; }
|
||||
this.runningModule = modId;
|
||||
try {
|
||||
await this.api(endpoint, { method: 'POST' });
|
||||
|
||||
+161
-20
@@ -22,8 +22,11 @@
|
||||
.topic-card-meta { display: flex; flex-direction: column; gap: 3px; font-size: var(--font-size-caption); color: var(--color-text-regular); margin-bottom: 10px; }
|
||||
.topic-card-actions { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 4px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--color-border); }
|
||||
.topic-card-actions .el-button { margin: 0; width: 100%; justify-content: center; padding: 8px 4px !important; }
|
||||
.topic-card.is-checked { border-color: var(--color-primary); box-shadow: 0 0 0 1px rgba(64,158,255,0.2); }
|
||||
.topic-card-actions .el-button--danger { grid-column: 1 / -1; }
|
||||
.topic-card.is-checked { border-color: var(--color-primary); box-shadow: 0 0 0 1px rgba(64,158,255,0.2); }
|
||||
.topic-card-actions .el-button--danger { grid-column: 1 / -1; }
|
||||
.search-area { background:#f8faff; border:1px solid #e8edf5; border-radius:8px; padding:12px 16px; margin-bottom:12px; }
|
||||
.search-area .el-form-item { margin-bottom:6px; }
|
||||
.search-toggle { cursor:pointer; user-select:none; font-size:14px; color:#409eff; }
|
||||
}
|
||||
</style>
|
||||
<script src="uni-nav.js"></script>
|
||||
@@ -53,9 +56,52 @@
|
||||
<el-button size="default" :type="filterStatus === 'ready' ? 'primary' : ''" @click="filterStatus = 'ready'; fetchTopics()">待发布 ({{ statusStats.ready }})</el-button>
|
||||
<el-button size="default" :type="filterStatus === 'published' ? 'primary' : ''" @click="filterStatus = 'published'; fetchTopics()">已发布 ({{ statusStats.published }})</el-button>
|
||||
</div>
|
||||
<el-table ref="topicTable" :data="paginatedTopics" stripe v-loading="loadingTable" @selection-change="selectedTopicIds = $event.map(item => item.id)">
|
||||
<div style="margin-bottom:10px;">
|
||||
<span class="search-toggle" @click="showSearch = !showSearch">🔍 {{ showSearch ? '收起搜索' : '展开搜索' }}</span>
|
||||
<span v-if="searchActive" style="margin-left:8px;font-size:12px;color:#909399;">筛选条件已生效,共 {{ filteredTopics.length }} 条</span>
|
||||
</div>
|
||||
<div v-if="showSearch" class="search-area">
|
||||
<el-form :model="searchForm" size="small" label-width="70px" @submit.prevent>
|
||||
<el-row :gutter="12">
|
||||
<el-col :span="6"><el-form-item label="选题ID"><el-input v-model="searchForm.id" placeholder="如 A07" clearable @input="doSearch"></el-input></el-form-item></el-col>
|
||||
<el-col :span="10"><el-form-item label="标题"><el-input v-model="searchForm.title" placeholder="关键词" clearable @input="doSearch"></el-input></el-form-item></el-col>
|
||||
<el-col :span="8"><el-form-item label="领域"><el-input v-model="searchForm.field" placeholder="如 科技前沿" clearable @input="doSearch"></el-input></el-form-item></el-col>
|
||||
</el-row>
|
||||
<el-row :gutter="12">
|
||||
<el-col :span="12"><el-form-item label="创建时间">
|
||||
<el-date-picker v-model="searchForm.createdStart" type="date" placeholder="开始" style="width:130px;" value-format="YYYY-MM-DD" @change="doSearch"></el-date-picker>
|
||||
<span style="margin:0 4px;color:#909399;">~</span>
|
||||
<el-date-picker v-model="searchForm.createdEnd" type="date" placeholder="结束" style="width:130px;" value-format="YYYY-MM-DD" @change="doSearch"></el-date-picker>
|
||||
</el-form-item></el-col>
|
||||
<el-col :span="12"><el-form-item label="创作时间">
|
||||
<el-date-picker v-model="searchForm.generatedStart" type="date" placeholder="开始" style="width:130px;" value-format="YYYY-MM-DD" @change="doSearch"></el-date-picker>
|
||||
<span style="margin:0 4px;color:#909399;">~</span>
|
||||
<el-date-picker v-model="searchForm.generatedEnd" type="date" placeholder="结束" style="width:130px;" value-format="YYYY-MM-DD" @change="doSearch"></el-date-picker>
|
||||
</el-form-item></el-col>
|
||||
</el-row>
|
||||
<el-row :gutter="12">
|
||||
<el-col :span="12"><el-form-item label="审查时间">
|
||||
<el-date-picker v-model="searchForm.reviewedStart" type="date" placeholder="开始" style="width:130px;" value-format="YYYY-MM-DD" @change="doSearch"></el-date-picker>
|
||||
<span style="margin:0 4px;color:#909399;">~</span>
|
||||
<el-date-picker v-model="searchForm.reviewedEnd" type="date" placeholder="结束" style="width:130px;" value-format="YYYY-MM-DD" @change="doSearch"></el-date-picker>
|
||||
</el-form-item></el-col>
|
||||
<el-col :span="12"><el-form-item label="发布时间">
|
||||
<el-date-picker v-model="searchForm.publishedStart" type="date" placeholder="开始" style="width:130px;" value-format="YYYY-MM-DD" @change="doSearch"></el-date-picker>
|
||||
<span style="margin:0 4px;color:#909399;">~</span>
|
||||
<el-date-picker v-model="searchForm.publishedEnd" type="date" placeholder="结束" style="width:130px;" value-format="YYYY-MM-DD" @change="doSearch"></el-date-picker>
|
||||
</el-form-item></el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="24" style="text-align:right;">
|
||||
<el-button type="primary" @click="doSearch" size="small">查询</el-button>
|
||||
<el-button @click="resetSearch" size="small">重置</el-button>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
</div>
|
||||
<el-table ref="topicTable" :data="paginatedTopics" stripe v-loading="loadingTable" @selection-change="selectedTopicIds = $event.map(item => item.id)" @sort-change="handleSortChange" :default-sort="{ prop: 'created_at', order: 'ascending' }">
|
||||
<el-table-column type="selection" width="55"></el-table-column>
|
||||
<el-table-column prop="id" label="ID" width="70" fixed></el-table-column>
|
||||
<el-table-column prop="id" label="ID" width="70" fixed sortable="custom"></el-table-column>
|
||||
<el-table-column prop="title" label="标题" min-width="200"></el-table-column>
|
||||
<el-table-column prop="field" label="领域" width="100"></el-table-column>
|
||||
<el-table-column prop="status" label="状态" width="90">
|
||||
@@ -64,9 +110,10 @@
|
||||
<el-table-column prop="compliance_score" label="合规分" width="90">
|
||||
<template #default="scope"><el-progress :percentage="scope.row.compliance_score || 0" :format="() => scope.row.compliance_score || '-'" :stroke-width="15"></el-progress></template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="created_at" label="创建时间" width="140"><template #default="scope">{{ formatDate(scope.row.created_at) }}</template></el-table-column>
|
||||
<el-table-column prop="generated_at" label="创作时间" width="140"><template #default="scope">{{ scope.row.generated_at ? formatDate(scope.row.generated_at) : '-' }}</template></el-table-column>
|
||||
<el-table-column prop="published_at" label="发布时间" width="140"><template #default="scope">{{ scope.row.published_at ? formatDate(scope.row.published_at) : '-' }}</template></el-table-column>
|
||||
<el-table-column prop="created_at" label="创建时间" width="140" sortable="custom"><template #default="scope">{{ formatDate(scope.row.created_at) }}</template></el-table-column>
|
||||
<el-table-column prop="generated_at" label="创作时间" width="140" sortable="custom"><template #default="scope">{{ scope.row.generated_at ? formatDate(scope.row.generated_at) : '-' }}</template></el-table-column>
|
||||
<el-table-column prop="reviewed_at" label="审查时间" width="140" sortable="custom"><template #default="scope">{{ scope.row.reviewed_at ? formatDate(scope.row.reviewed_at) : '-' }}</template></el-table-column>
|
||||
<el-table-column prop="published_at" label="发布时间" width="140" sortable="custom"><template #default="scope">{{ scope.row.published_at ? formatDate(scope.row.published_at) : '-' }}</template></el-table-column>
|
||||
<el-table-column label="操作" width="230" fixed="right">
|
||||
<template #default="scope">
|
||||
<div style="display: flex; gap: 4px; white-space: nowrap;">
|
||||
@@ -100,6 +147,7 @@
|
||||
<div class="topic-card-meta">
|
||||
<div>创建: {{ formatDate(topic.created_at) }}</div>
|
||||
<div>创作: {{ topic.generated_at ? formatDate(topic.generated_at) : '-' }}</div>
|
||||
<div>审查: {{ topic.reviewed_at ? formatDate(topic.reviewed_at) : '-' }}</div>
|
||||
<div>发布: {{ topic.published_at ? formatDate(topic.published_at) : '-' }}</div>
|
||||
</div>
|
||||
<div class="topic-card-actions">
|
||||
@@ -177,6 +225,7 @@
|
||||
<span style="margin: 0 8px;">|</span>
|
||||
<span>状态:{{ getStatusLabel(previewTopic.status) }}</span>
|
||||
<span v-if="previewTopic.generated_at" style="margin-left:8px;">创作:{{ formatDate(previewTopic.generated_at) }}</span>
|
||||
<span v-if="previewTopic.reviewed_at" style="margin-left:8px;">审查:{{ formatDate(previewTopic.reviewed_at) }}</span>
|
||||
<span v-if="previewTopic.published_at" style="margin-left:8px;">发布:{{ formatDate(previewTopic.published_at) }}</span>
|
||||
</div>
|
||||
<div>
|
||||
@@ -204,16 +253,66 @@ const TopicsApp = {
|
||||
publishPlatforms: { zhihu: true, wechat: true, xiaohongshu: true },
|
||||
publishing: false,
|
||||
savingContent: false,
|
||||
currentPage: 1, pageSize: 10
|
||||
currentPage: 1, pageSize: 10,
|
||||
sortField: 'created_at', sortOrder: 'ascending',
|
||||
showSearch: false,
|
||||
searchForm: { id: '', title: '', field: '', createdStart: null, createdEnd: null, generatedStart: null, generatedEnd: null, reviewedStart: null, reviewedEnd: null, publishedStart: null, publishedEnd: null }
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
searchActive() {
|
||||
const f = this.searchForm;
|
||||
return !!(f.id || f.title || f.field || f.createdStart || f.createdEnd || f.generatedStart || f.generatedEnd || f.reviewedStart || f.reviewedEnd || f.publishedStart || f.publishedEnd);
|
||||
},
|
||||
filteredTopics() {
|
||||
if (this.filterStatus === 'today') return this.todayTopics;
|
||||
if (!this.filterStatus) return this.topics;
|
||||
const map = { 'pending': ['pending','待处理'], 'review': ['review','待审查'], 'ready': ['ready','待发布'], 'published': ['published','已发布'] };
|
||||
const allowed = map[this.filterStatus] || [this.filterStatus];
|
||||
return this.topics.filter(t => allowed.includes(t.status));
|
||||
let list;
|
||||
if (this.filterStatus === 'today') list = this.todayTopics;
|
||||
else if (!this.filterStatus) list = this.topics;
|
||||
else {
|
||||
const map = { 'pending': ['pending','待处理'], 'review': ['review','待审查'], 'ready': ['ready','待发布'], 'published': ['published','已发布'] };
|
||||
const allowed = map[this.filterStatus] || [this.filterStatus];
|
||||
list = this.topics.filter(t => allowed.includes(t.status));
|
||||
}
|
||||
// 搜索过滤
|
||||
const sf = this.searchForm;
|
||||
if (sf.id || sf.title || sf.field || sf.createdStart || sf.createdEnd || sf.generatedStart || sf.generatedEnd || sf.reviewedStart || sf.reviewedEnd || sf.publishedStart || sf.publishedEnd) {
|
||||
list = list.filter(t => {
|
||||
if (sf.id && !t.id.toLowerCase().includes(sf.id.toLowerCase())) return false;
|
||||
if (sf.title && !t.title.toLowerCase().includes(sf.title.toLowerCase())) return false;
|
||||
if (sf.field && !(t.field || '').toLowerCase().includes(sf.field.toLowerCase())) return false;
|
||||
const inRange = (val, start, end) => {
|
||||
if (!val) return !start && !end;
|
||||
const d = val.slice(0, 10);
|
||||
if (start && d < start) return false;
|
||||
if (end && d > end) return false;
|
||||
return true;
|
||||
};
|
||||
return inRange(t.created_at, sf.createdStart, sf.createdEnd)
|
||||
&& inRange(t.generated_at, sf.generatedStart, sf.generatedEnd)
|
||||
&& inRange(t.reviewed_at, sf.reviewedStart, sf.reviewedEnd)
|
||||
&& inRange(t.published_at, sf.publishedStart, sf.publishedEnd);
|
||||
});
|
||||
}
|
||||
if (this.sortField) {
|
||||
const field = this.sortField;
|
||||
const isDateField = ['created_at','generated_at','reviewed_at','published_at','updated_at'].includes(field);
|
||||
list = [...list].sort((a, b) => {
|
||||
const va = a[field], vb = b[field];
|
||||
if (!va && !vb) return 0;
|
||||
if (!va) return 1;
|
||||
if (!vb) return -1;
|
||||
let cmp;
|
||||
if (isDateField) {
|
||||
const ta = new Date(va.replace(' ', 'T')).getTime();
|
||||
const tb = new Date(vb.replace(' ', 'T')).getTime();
|
||||
cmp = ta - tb;
|
||||
} else {
|
||||
cmp = String(va).localeCompare(String(vb), 'zh', { numeric: true });
|
||||
}
|
||||
return this.sortOrder === 'descending' ? -cmp : cmp;
|
||||
});
|
||||
}
|
||||
return list;
|
||||
},
|
||||
paginatedTopics() {
|
||||
const start = (this.currentPage - 1) * this.pageSize;
|
||||
@@ -356,13 +455,42 @@ const TopicsApp = {
|
||||
const title = titleEl ? titleEl.textContent.trim() : (this.previewTopic?.title || '');
|
||||
const body = doc.body;
|
||||
if (body) {
|
||||
body.querySelectorAll('script, style, nav, .header, .tags, footer, .interaction, svg, img, button').forEach(el => el.remove());
|
||||
body.querySelectorAll('script, style, nav, .header, .tags, footer, .interaction, button, .ad, aside, .comment').forEach(el => el.remove());
|
||||
}
|
||||
|
||||
if (platform === 'xiaohongshu') {
|
||||
const lines = [];
|
||||
body.querySelectorAll('h1,h2,h3,h4,p,li').forEach(el => {
|
||||
const text = el.textContent.trim();
|
||||
if (!text || text.length < 2) return;
|
||||
const tag = el.tagName.toLowerCase();
|
||||
const prefix = tag.startsWith('h') ? '\n### ' : '- ';
|
||||
const clean = text.replace(/\n/g, ' ').replace(/^[\s#]+|[\s#]+$/g, '');
|
||||
if (clean) lines.push(prefix + clean);
|
||||
});
|
||||
const md = `**${title}**\n\n${lines.join('\n')}`;
|
||||
navigator.clipboard.writeText(md).then(() => this.$message.success('✅ 已复制 Markdown(小红书格式)')).catch(() => this.$message.error('❌ 复制失败'));
|
||||
} else {
|
||||
const container = doc.createElement('div');
|
||||
if (titleEl) {
|
||||
const h1 = doc.createElement('h1');
|
||||
h1.textContent = title;
|
||||
container.appendChild(h1);
|
||||
}
|
||||
body.querySelectorAll('h2,h3,h4,p,li,blockquote,img,pre,code,table,hr').forEach(el => {
|
||||
const clone = el.cloneNode(true);
|
||||
container.appendChild(clone);
|
||||
});
|
||||
const cleanHtml = container.innerHTML;
|
||||
const blob = new Blob([cleanHtml], { type: 'text/html' });
|
||||
const richText = new Blob([cleanHtml], { type: 'text/plain' });
|
||||
const item = new ClipboardItem({ 'text/html': blob, 'text/plain': richText });
|
||||
navigator.clipboard.write([item]).then(() => {
|
||||
this.$message.success(`✅ 已复制(含格式和配图),Ctrl+V 粘贴到${platform === 'zhihu' ? '知乎' : '微信公众号'}`);
|
||||
}).catch(() => {
|
||||
navigator.clipboard.writeText(cleanHtml).then(() => this.$message.success('✅ 已复制 HTML')).catch(() => this.$message.error('❌ 复制失败'));
|
||||
});
|
||||
}
|
||||
const contentEls = body ? Array.from(body.querySelectorAll('p, h1, h2, h3, h4, li')) : [];
|
||||
const text = contentEls.map(el => el.textContent.trim()).filter(t => t && t.length > 1).join('\n\n');
|
||||
navigator.clipboard.writeText(`标题:${title}\n\n内容:\n${text}`)
|
||||
.then(() => this.$message.success(`已复制内容,请前往${platform}粘贴发布`))
|
||||
.catch(() => this.$message.error('复制失败,请手动复制'));
|
||||
},
|
||||
async createTopic(topic) {
|
||||
if (this.isStatus(topic, 'published')) { this.$message.info('已发布选题不可创作'); return; }
|
||||
@@ -451,6 +579,11 @@ const TopicsApp = {
|
||||
} catch (e) { this.$message.error('保存失败: ' + e.message); }
|
||||
finally { this.savingContent = false; }
|
||||
},
|
||||
doSearch() { this.currentPage = 1; },
|
||||
resetSearch() {
|
||||
this.searchForm = { id: '', title: '', field: '', createdStart: null, createdEnd: null, generatedStart: null, generatedEnd: null, reviewedStart: null, reviewedEnd: null, publishedStart: null, publishedEnd: null };
|
||||
this.currentPage = 1;
|
||||
},
|
||||
handleLogout() { localStorage.removeItem('authToken'); localStorage.removeItem('userRole'); localStorage.removeItem('currentUser'); window.location.href = '/login.html'; },
|
||||
redirectToPage(page) { window.location.href = page.startsWith('/') ? page : '/' + page; },
|
||||
getStatusLabel(status) { return { 'pending': '待处理', 'review': '待审查', 'ready': '待发布', 'published': '已发布' }[status] || status; },
|
||||
@@ -471,6 +604,11 @@ const TopicsApp = {
|
||||
table.toggleRowSelection(row, !allChecked);
|
||||
}
|
||||
},
|
||||
handleSortChange({ prop, order }) {
|
||||
this.sortField = prop || 'created_at';
|
||||
this.sortOrder = order || 'ascending';
|
||||
this.currentPage = 1;
|
||||
},
|
||||
formatDate(dateStr) {
|
||||
if (!dateStr) return '-';
|
||||
try { return new Date(dateStr.replace(' ', 'T')).toLocaleString('zh-CN', { year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit' }); }
|
||||
@@ -482,8 +620,11 @@ const TopicsApp = {
|
||||
mounted() {
|
||||
const token = localStorage.getItem('authToken');
|
||||
if (!token) { window.location.href = '/login.html'; return; }
|
||||
const urlFilter = new URLSearchParams(window.location.search).get('filter');
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
const urlFilter = params.get('filter');
|
||||
if (urlFilter) this.filterStatus = urlFilter;
|
||||
const topicId = params.get('topic_id');
|
||||
if (topicId) { this.searchForm.id = topicId; this.showSearch = true; }
|
||||
fetch('/api/auth/me', { headers: { 'Authorization': 'Bearer ' + token } })
|
||||
.then(r => r.ok ? r.json() : Promise.reject())
|
||||
.then(data => { this.currentUser = data.user; this.isAdmin = data.user.role === 'admin'; this.isLoggedIn = true; this.fetchTopics(); this.fetchTodayCount(); })
|
||||
|
||||
Reference in New Issue
Block a user