fix: 合规审查卡死修复 + 小红书复制格式 + today-only过滤
This commit is contained in:
@@ -459,17 +459,30 @@ const TopicsApp = {
|
||||
}
|
||||
|
||||
if (platform === 'xiaohongshu') {
|
||||
const lines = [];
|
||||
const container = doc.createElement('div');
|
||||
if (titleEl) {
|
||||
const strong = doc.createElement('strong');
|
||||
strong.textContent = title;
|
||||
container.appendChild(strong);
|
||||
container.appendChild(doc.createElement('br'));
|
||||
container.appendChild(doc.createElement('br'));
|
||||
}
|
||||
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 clone = el.cloneNode(true);
|
||||
container.appendChild(clone);
|
||||
container.appendChild(doc.createElement('br'));
|
||||
});
|
||||
const cleanHtml = container.innerHTML;
|
||||
const blob = new Blob([cleanHtml], { type: 'text/html' });
|
||||
const richText = new Blob([cleanHtml.replace(/<[^>]+>/g, '').replace(/\n{3,}/g, '\n\n')], { type: 'text/plain' });
|
||||
const item = new ClipboardItem({ 'text/html': blob, 'text/plain': richText });
|
||||
navigator.clipboard.write([item]).then(() => {
|
||||
this.$message.success('✅ 已复制(含格式),Ctrl+V 粘贴到小红书');
|
||||
}).catch(() => {
|
||||
navigator.clipboard.writeText(cleanHtml.replace(/<[^>]+>/g, '').replace(/\n{3,}/g, '\n\n')).then(() => this.$message.success('✅ 已复制')).catch(() => this.$message.error('❌ 复制失败'));
|
||||
});
|
||||
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) {
|
||||
@@ -477,7 +490,7 @@ const TopicsApp = {
|
||||
h1.textContent = title;
|
||||
container.appendChild(h1);
|
||||
}
|
||||
body.querySelectorAll('h2,h3,h4,p,li,blockquote,img,pre,code,table,hr').forEach(el => {
|
||||
body.querySelectorAll('h2,h3,h4,p,li,blockquote,pre,code,table,hr').forEach(el => {
|
||||
const clone = el.cloneNode(true);
|
||||
container.appendChild(clone);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user