From 567452f570b047b1c170ff33dd5c6c0a6addcbbb Mon Sep 17 00:00:00 2001 From: Tim Date: Mon, 8 Sep 2025 13:46:22 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=A0=87=E9=A2=98/=E5=86=85=E5=AE=B9?= =?UTF-8?q?=E5=8F=98=E5=8C=96=E7=9A=84ui?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/PostChangeLogItem.vue | 42 +++++++++++++++---- frontend_nuxt/pages/posts/[id]/index.vue | 10 ++++- 2 files changed, 43 insertions(+), 9 deletions(-) diff --git a/frontend_nuxt/components/PostChangeLogItem.vue b/frontend_nuxt/components/PostChangeLogItem.vue index 3005e5c3b..e5f970054 100644 --- a/frontend_nuxt/components/PostChangeLogItem.vue +++ b/frontend_nuxt/components/PostChangeLogItem.vue @@ -2,10 +2,7 @@
{{ log.username }} - - 变更了文章内容 -
-
+ 变更了文章内容 变更了文章标题 变更了文章分类 变更了文章标签 @@ -23,6 +20,11 @@
{{ log.time }}
+
@@ -30,14 +32,37 @@ import { computed } from 'vue' import { html } from 'diff2html' import { createTwoFilesPatch } from 'diff' +import { useIsMobile } from '~/utils/screen' import 'diff2html/bundles/css/diff2html.min.css' -const props = defineProps({ log: Object }) +const props = defineProps({ + log: Object, + title: String, +}) + const diffHtml = computed(() => { + const isMobile = useIsMobile() if (props.log.type === 'CONTENT') { const oldContent = props.log.oldContent ?? '' const newContent = props.log.newContent ?? '' - const diff = createTwoFilesPatch('old', 'new', oldContent, newContent) - return html(diff, { inputFormat: 'diff', showFiles: false, matching: 'lines' }) + const diff = createTwoFilesPatch(props.title, props.title, oldContent, newContent) + return html(diff, { + inputFormat: 'diff', + showFiles: false, + matching: 'lines', + drawFileList: false, + outputFormat: isMobile.value ? 'line-by-line' : 'side-by-side', + }) + } else if (props.log.type === 'TITLE') { + const oldTitle = props.log.oldTitle ?? '' + const newTitle = props.log.newTitle ?? '' + const diff = createTwoFilesPatch(oldTitle, newTitle, '', '') + return html(diff, { + inputFormat: 'diff', + showFiles: false, + matching: 'lines', + drawFileList: false, + outputFormat: isMobile.value ? 'line-by-line' : 'side-by-side', + }) } return '' }) @@ -47,8 +72,9 @@ const diffHtml = computed(() => { .change-log-container { display: flex; flex-direction: column; - padding-bottom: 30px; + /* padding-bottom: 30px; */ opacity: 0.7; + font-size: 14px; } .change-log-user { font-weight: bold; diff --git a/frontend_nuxt/pages/posts/[id]/index.vue b/frontend_nuxt/pages/posts/[id]/index.vue index d2bb041bf..218ef8779 100644 --- a/frontend_nuxt/pages/posts/[id]/index.vue +++ b/frontend_nuxt/pages/posts/[id]/index.vue @@ -134,7 +134,7 @@ :post-closed="closed" @deleted="onCommentDeleted" /> - + @@ -377,6 +377,14 @@ const mapChangeLog = (l) => ({ newClosed: l.newClosed, newPinnedAt: l.newPinnedAt, newFeatured: l.newFeatured, + oldContent: l.oldContent, + newContent: l.newContent, + oldTitle: l.oldTitle, + newTitle: l.newTitle, + oldCategory: l.oldCategory, + newCategory: l.newCategory, + oldTags: l.oldTags, + newTags: l.newTags, icon: changeLogIcon(l), })