fix: preview body empty when no article content
topics.html: currentPreviewBody returns placeholder instead of empty string when platform has no content; openTopicArticlePreview properly awaits fetch Ultraworked with Sisyphus Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -444,8 +444,7 @@ const TopicsApp = {
|
|||||||
},
|
},
|
||||||
currentPreviewBody() {
|
currentPreviewBody() {
|
||||||
const html = this.platformContents[this.previewPlatform];
|
const html = this.platformContents[this.previewPlatform];
|
||||||
if (!html) return '';
|
if (!html || html.length < 50) return '<div style="padding:40px;text-align:center;color:#909399;"><p style="font-size:36px;margin:0 0 12px;">📝</p><p>该平台内容暂未生成或内容为空</p><p style="font-size:13px;margin-top:8px;">可点击上方「批量创作」重新生成,或在编辑模式下手动添加内容</p></div>';
|
||||||
if (html.length < 50) return '<div style="padding:40px;text-align:center;color:#909399;"><p style="font-size:36px;margin:0 0 12px;">📝</p><p>该平台内容暂未生成或内容为空</p><p style="font-size:13px;margin-top:8px;">可点击上方「批量创作」重新生成,或在编辑模式下手动添加内容</p></div>';
|
|
||||||
try {
|
try {
|
||||||
const parser = new DOMParser();
|
const parser = new DOMParser();
|
||||||
const doc = parser.parseFromString(html, 'text/html');
|
const doc = parser.parseFromString(html, 'text/html');
|
||||||
@@ -551,7 +550,7 @@ const TopicsApp = {
|
|||||||
platformName(platform) { return { zhihu: '知乎', wechat: '微信公众号', xiaohongshu: '小红书' }[platform] || platform; },
|
platformName(platform) { return { zhihu: '知乎', wechat: '微信公众号', xiaohongshu: '小红书' }[platform] || platform; },
|
||||||
platformShort(platform) { return { zhihu: '知', wechat: '公', xiaohongshu: '红' }[platform] || platform; },
|
platformShort(platform) { return { zhihu: '知', wechat: '公', xiaohongshu: '红' }[platform] || platform; },
|
||||||
fmtWordCount(wc) { if (!wc) return ''; if (wc >= 1000) return (wc / 1000).toFixed(wc >= 10000 ? 0 : 1) + 'k'; return wc + ''; },
|
fmtWordCount(wc) { if (!wc) return ''; if (wc >= 1000) return (wc / 1000).toFixed(wc >= 10000 ? 0 : 1) + 'k'; return wc + ''; },
|
||||||
openTopicArticlePreview(topic, article) {
|
async openTopicArticlePreview(topic, article) {
|
||||||
this.previewTopic = topic;
|
this.previewTopic = topic;
|
||||||
this.previewPlatform = article.platform;
|
this.previewPlatform = article.platform;
|
||||||
this.previewVisible = true;
|
this.previewVisible = true;
|
||||||
@@ -559,9 +558,13 @@ const TopicsApp = {
|
|||||||
this.previewImages = {};
|
this.previewImages = {};
|
||||||
const token = this.getToken();
|
const token = this.getToken();
|
||||||
if (!token) return;
|
if (!token) return;
|
||||||
fetch(`/api/articles/${topic.id}/preview?platform=${article.platform}`, { headers: { 'Authorization': 'Bearer ' + token } })
|
try {
|
||||||
.then(r => r.ok ? r.json() : null).then(d => { if (d && d.html) { this.platformContents[article.platform] = d.html; if (d.images) this.previewImages[article.platform] = d.images; } })
|
const r = await fetch(`/api/articles/${topic.id}/preview?platform=${article.platform}`, { headers: { 'Authorization': 'Bearer ' + token } });
|
||||||
.catch(e => console.error(`加载${article.platform}预览失败:`, e));
|
if (r.ok) {
|
||||||
|
const d = await r.json();
|
||||||
|
if (d && d.html) { this.platformContents[article.platform] = d.html; if (d.images) this.previewImages[article.platform] = d.images; }
|
||||||
|
}
|
||||||
|
} catch (e) { console.error(`加载${article.platform}预览失败:`, e); }
|
||||||
},
|
},
|
||||||
copyContent(platform) {
|
copyContent(platform) {
|
||||||
const html = this.platformContents[platform];
|
const html = this.platformContents[platform];
|
||||||
|
|||||||
Reference in New Issue
Block a user