Fix preview dialog scroll & preserve HTML structure on edit save
This commit is contained in:
@@ -9,7 +9,7 @@
|
|||||||
<style>
|
<style>
|
||||||
.selected-count { color: var(--color-text-secondary); font-size: var(--font-size-body); margin-left: auto; }
|
.selected-count { color: var(--color-text-secondary); font-size: var(--font-size-body); margin-left: auto; }
|
||||||
.preview-dialog-custom .el-dialog__body { overflow-y: auto; max-height: calc(90vh - 120px); padding: 16px 20px; }
|
.preview-dialog-custom .el-dialog__body { overflow-y: auto; max-height: calc(90vh - 120px); padding: 16px 20px; }
|
||||||
.preview-dialog-custom .preview-body { max-height: none !important; min-height: 300px; overflow: visible; }
|
.preview-dialog-custom .preview-body { max-height: calc(90vh - 200px); min-height: 300px; overflow-y: auto; }
|
||||||
.preview-dialog-custom .preview-body img { max-width: 100%; }
|
.preview-dialog-custom .preview-body img { max-width: 100%; }
|
||||||
.topic-card-list { display: none; }
|
.topic-card-list { display: none; }
|
||||||
@media (max-width: 768px) {
|
@media (max-width: 768px) {
|
||||||
@@ -426,12 +426,23 @@ const TopicsApp = {
|
|||||||
if (!this.previewTopic || !this.editContent) { this.$message.warning('没有内容可保存'); return; }
|
if (!this.previewTopic || !this.editContent) { this.$message.warning('没有内容可保存'); return; }
|
||||||
this.savingContent = true;
|
this.savingContent = true;
|
||||||
try {
|
try {
|
||||||
|
const original = this.platformContents[this.previewPlatform] || '';
|
||||||
|
let headHtml = '';
|
||||||
|
if (original) {
|
||||||
|
try {
|
||||||
|
const parser = new DOMParser();
|
||||||
|
const doc = parser.parseFromString(original, 'text/html');
|
||||||
|
const head = doc.querySelector('head');
|
||||||
|
if (head) headHtml = head.innerHTML;
|
||||||
|
} catch (e) {}
|
||||||
|
}
|
||||||
|
const fullHtml = '<!DOCTYPE html><html><head>' + headHtml + '</head><body>' + this.editContent + '</body></html>';
|
||||||
await this.api(`/api/articles/${this.previewTopic.id}/content`, {
|
await this.api(`/api/articles/${this.previewTopic.id}/content`, {
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
body: JSON.stringify({ platform: this.previewPlatform, html_content: this.editContent })
|
body: JSON.stringify({ platform: this.previewPlatform, html_content: fullHtml })
|
||||||
});
|
});
|
||||||
this.$message.success('保存成功');
|
this.$message.success('保存成功');
|
||||||
this.platformContents[this.previewPlatform] = this.editContent;
|
this.platformContents[this.previewPlatform] = fullHtml;
|
||||||
this.editing = false;
|
this.editing = false;
|
||||||
} catch (e) { this.$message.error('保存失败: ' + e.message); }
|
} catch (e) { this.$message.error('保存失败: ' + e.message); }
|
||||||
finally { this.savingContent = false; }
|
finally { this.savingContent = false; }
|
||||||
|
|||||||
Reference in New Issue
Block a user