Phase3: 三平台封面图生成
- cover_generator.py: Pillow生成知乎/微信/小红书封面图(渐变背景+标题) - 知乎 1200×630 蓝调, 微信 900×500 绿调, 小红书 1080×1440 红调 - creator.py 流水线增加 cover_generator 作为最终回退 - db_helper.py 新增 save_cover_to_article - main.py 挂载 /automation/images 静态目录 - articles.py preview 接口返回 images 字段 - topics.html 预览dialog展示封面图
This commit is contained in:
@@ -163,6 +163,9 @@
|
||||
</div>
|
||||
</div>
|
||||
<div style="width:100%;">
|
||||
<div v-if="!editing && previewImages[previewPlatform] && previewImages[previewPlatform].cover" style="margin-bottom:16px; border:1px solid #ebeef5; border-radius:8px; overflow:hidden; text-align:center;">
|
||||
<img :src="'/' + previewImages[previewPlatform].cover" alt="封面图" style="max-width:100%; max-height:360px; object-fit:contain;" @error="$event.target.style.display='none'" />
|
||||
</div>
|
||||
<div v-if="!editing" class="preview-body" style="border:1px solid #ebeef5; border-radius:8px; background:#fff; padding:20px; width:100%; line-height:1.8;" v-html="currentPreviewBody"></div>
|
||||
<div v-else ref="editor" contenteditable="true" style="min-height:300px; height:68vh; border:1px solid #409eff; border-radius:8px; background:#fff; padding:20px; overflow-y:auto; width:100%; line-height:1.8; outline:none; box-shadow:0 0 0 2px rgba(64,158,255,0.2);" @input="editContent = $event.target.innerHTML"></div>
|
||||
</div>
|
||||
@@ -196,7 +199,7 @@ const TopicsApp = {
|
||||
stats: { total: 0, pending: 0, review: 0, ready: 0, published: 0, today: 0 },
|
||||
topics: [], allTopics: [], todayTopics: [], todayCount: 0,
|
||||
previewVisible: false, previewTopic: null, previewFullscreen: false,
|
||||
previewPlatform: 'zhihu', platformContents: {}, editing: false, editContent: '',
|
||||
previewPlatform: 'zhihu', platformContents: {}, previewImages: {}, editing: false, editContent: '',
|
||||
publishDialogVisible: false, publishTopic: null,
|
||||
publishPlatforms: { zhihu: true, wechat: true, xiaohongshu: true },
|
||||
publishing: false,
|
||||
@@ -317,14 +320,14 @@ const TopicsApp = {
|
||||
} catch (error) { this.$message.error(`批量审查失败: ${error.message}`); }
|
||||
},
|
||||
async openPreview(topic) {
|
||||
this.previewTopic = topic; this.previewPlatform = 'zhihu'; this.previewVisible = true; this.platformContents = {};
|
||||
this.previewTopic = topic; this.previewPlatform = 'zhihu'; this.previewVisible = true; this.platformContents = {}; this.previewImages = {};
|
||||
const token = this.getToken();
|
||||
if (!token) return;
|
||||
const platforms = ['zhihu', 'wechat', 'xiaohongshu'];
|
||||
const names = { zhihu: '知乎', wechat: '微信公众号', xiaohongshu: '小红书' };
|
||||
await Promise.all(platforms.map(p =>
|
||||
fetch(`/api/articles/${topic.id}/preview?platform=${p}`, { headers: { 'Authorization': 'Bearer ' + token } })
|
||||
.then(r => r.ok ? r.json() : null).then(d => { if (d && d.html) this.platformContents[p] = d.html; }).catch(e => { console.error(`加载${p}预览失败:`, e); this.$message.error(`加载${names[p]}预览失败`); })
|
||||
.then(r => r.ok ? r.json() : null).then(d => { if (d && d.html) { this.platformContents[p] = d.html; if (d.images) this.previewImages[p] = d.images; } }).catch(e => { console.error(`加载${p}预览失败:`, e); this.$message.error(`加载${names[p]}预览失败`); })
|
||||
));
|
||||
},
|
||||
togglePreviewFullscreen() {
|
||||
|
||||
Reference in New Issue
Block a user