From 55597cd8b96af125f97f7b2c9dd2001c7f608789 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E7=90=A6?= Date: Thu, 25 Jun 2026 17:57:51 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=A1=B5=E9=9D=A2=E3=80=81?= =?UTF-8?q?=E4=BF=AE=E5=A4=8DBUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/src/components/AuthorInfo.vue | 134 +++++++++++++ .../src/components/admin/AdminTableFilter.vue | 136 +++++++++++++ client/src/components/admin/ImagePicker.vue | 189 ++++++++++++++++++ .../src/components/admin/PostHistoryModal.vue | 23 ++- client/src/composables/useLocalTableFilter.ts | 50 +++++ client/src/pages/Blog.vue | 10 + client/src/pages/BlogDetail.vue | 37 ++-- client/src/pages/ColumnDetail.vue | 10 + client/src/pages/Home.vue | 11 + .../src/pages/admin/AttachmentCategories.vue | 23 ++- client/src/pages/admin/Attachments.vue | 57 +++--- client/src/pages/admin/Categories.vue | 23 ++- client/src/pages/admin/CodeTypes.vue | 52 ++++- client/src/pages/admin/Columns.vue | 49 ++++- client/src/pages/admin/EmailSuffixes.vue | 50 ++++- client/src/pages/admin/Inquiries.vue | 58 +++++- client/src/pages/admin/Partners.vue | 24 ++- client/src/pages/admin/Posts.vue | 123 ++++++++---- client/src/pages/admin/Snippets.vue | 171 ++++++++-------- client/src/pages/admin/Tags.vue | 25 ++- client/src/pages/admin/Testimonials.vue | 49 ++++- client/src/pages/admin/UserForm.vue | 15 ++ client/src/pages/admin/Users.vue | 149 ++++++++------ client/src/pages/admin/Works.vue | 63 +++++- client/src/services/api.ts | 110 ++++++++-- server/handlers/attachment.go | 3 +- server/handlers/inquiry.go | 34 +++- server/handlers/post.go | 36 +++- server/handlers/snippet.go | 11 +- server/handlers/user.go | 9 +- server/main.go | 2 + server/models/post.go | 9 + server/models/user.go | 2 + server/nl_blog.sql | 3 + server/repositories/attachment_repository.go | 7 +- server/repositories/inquiry_repository.go | 74 ++++++- server/repositories/migration.go | 19 ++ server/repositories/post_repository.go | 95 +++++++-- server/repositories/snippet_repository.go | 27 ++- server/repositories/user_repository.go | 32 ++- 40 files changed, 1680 insertions(+), 324 deletions(-) create mode 100644 client/src/components/AuthorInfo.vue create mode 100644 client/src/components/admin/AdminTableFilter.vue create mode 100644 client/src/components/admin/ImagePicker.vue create mode 100644 client/src/composables/useLocalTableFilter.ts diff --git a/client/src/components/AuthorInfo.vue b/client/src/components/AuthorInfo.vue new file mode 100644 index 0000000..0185cb4 --- /dev/null +++ b/client/src/components/AuthorInfo.vue @@ -0,0 +1,134 @@ + + + diff --git a/client/src/components/admin/AdminTableFilter.vue b/client/src/components/admin/AdminTableFilter.vue new file mode 100644 index 0000000..1efc3aa --- /dev/null +++ b/client/src/components/admin/AdminTableFilter.vue @@ -0,0 +1,136 @@ + + + + + diff --git a/client/src/components/admin/ImagePicker.vue b/client/src/components/admin/ImagePicker.vue new file mode 100644 index 0000000..51cb21b --- /dev/null +++ b/client/src/components/admin/ImagePicker.vue @@ -0,0 +1,189 @@ + + + diff --git a/client/src/components/admin/PostHistoryModal.vue b/client/src/components/admin/PostHistoryModal.vue index cb0d3df..e5d8889 100644 --- a/client/src/components/admin/PostHistoryModal.vue +++ b/client/src/components/admin/PostHistoryModal.vue @@ -43,7 +43,15 @@ v{{ item.version }} {{ item.modifiedAt }} -

{{ item.modifiedByName || `用户#${item.modifiedBy}` }}

+

{{ item.title }}

@@ -66,7 +74,17 @@
专栏:{{ previewData.columnName || '—' }}
标签:{{ previewData.tagNames?.join(', ') || '—' }}
状态:{{ previewData.isPublished === 1 ? '已发布' : '草稿' }}
-
修改人:{{ previewData.modifiedByName || previewData.modifiedBy }}
+
+ 操作人: + +
摘要:{{ previewData.excerpt || '—' }}
正文: @@ -133,6 +151,7 @@ import { type PostHistoryDiff } from '../../services/api' import { useToast } from '../../composables/useToast' +import AuthorInfo from '../AuthorInfo.vue' const FIELD_LABELS: Record = { title: '标题', diff --git a/client/src/composables/useLocalTableFilter.ts b/client/src/composables/useLocalTableFilter.ts new file mode 100644 index 0000000..899b43e --- /dev/null +++ b/client/src/composables/useLocalTableFilter.ts @@ -0,0 +1,50 @@ +import { ref, type Ref } from 'vue' + +export function matchKeyword( + item: Record, + fields: string[], + keyword: string +): boolean { + const q = keyword.trim().toLowerCase() + if (!q) return true + return fields.some((field) => { + const value = item[field] + if (value == null) return false + return String(value).toLowerCase().includes(q) + }) +} + +export function matchKeywordFn( + item: T, + keyword: string, + getter: (item: T) => string +): boolean { + const q = keyword.trim().toLowerCase() + if (!q) return true + return getter(item).toLowerCase().includes(q) +} + +/** 关键词输入 + 已应用关键词(点击查询后生效) */ +export function useAppliedKeyword() { + const keyword = ref('') + const appliedKeyword = ref('') + + const apply = () => { + appliedKeyword.value = keyword.value.trim() + } + + const reset = () => { + keyword.value = '' + appliedKeyword.value = '' + } + + return { keyword, appliedKeyword, apply, reset } +} + +export function resetRefFilters(filters: Record>, defaults: Record) { + Object.keys(defaults).forEach((key) => { + if (filters[key]) { + filters[key].value = defaults[key] + } + }) +} diff --git a/client/src/pages/Blog.vue b/client/src/pages/Blog.vue index 89b08e3..c101a9b 100644 --- a/client/src/pages/Blog.vue +++ b/client/src/pages/Blog.vue @@ -110,6 +110,15 @@
{{ post.categoryName || post.category?.name || '未分类' }} {{ post.date }} +
#{{ tag.name }}
@@ -145,6 +154,7 @@ import { useScrollAnimation } from '../composables/useScrollAnimation' import { useSearchHistory } from '../composables/useSearchHistory' import CustomSelect from '../components/CustomSelect.vue' import SearchSuggestDropdown from '../components/SearchSuggestDropdown.vue' +import AuthorInfo from '../components/AuthorInfo.vue' const { getHistory, addHistory, removeHistory, clearHistory } = useSearchHistory() diff --git a/client/src/pages/BlogDetail.vue b/client/src/pages/BlogDetail.vue index 786153e..38ec6ee 100644 --- a/client/src/pages/BlogDetail.vue +++ b/client/src/pages/BlogDetail.vue @@ -152,19 +152,14 @@ {{ post.date }}

{{ post.title }}

-
-
- Avatar -
-
-
年糕崽崽
-
前端架构师
-
-
+
@@ -265,11 +260,16 @@
{{ recPost.title }}
-
- - {{ recPost.categoryName }} - - {{ recPost.date }} +
+ + {{ recPost.date }}
@@ -383,6 +383,7 @@ import { useRoute, useRouter } from 'vue-router' import { fetchPost, getRecommendedPosts, fetchColumnPosts, fetchSnippet, Post, Snippet, getPublicSettings } from '../services/api' import { useScrollAnimation } from '../composables/useScrollAnimation' import Icon from '../components/Icon.vue' +import AuthorInfo from '../components/AuthorInfo.vue' import SnippetModal from '../components/SnippetModal.vue' import MarkdownIt from 'markdown-it' diff --git a/client/src/pages/ColumnDetail.vue b/client/src/pages/ColumnDetail.vue index 4bad477..f7bfce5 100644 --- a/client/src/pages/ColumnDetail.vue +++ b/client/src/pages/ColumnDetail.vue @@ -38,6 +38,15 @@
{{ post.categoryName || '未分类' }} {{ post.date }} +
#{{ tag.name }}
@@ -72,6 +81,7 @@ import { ref, onMounted, nextTick, computed } from 'vue' import { useRoute, useRouter } from 'vue-router' import { fetchColumn, fetchColumnPosts, Column, Post } from '../services/api' import { useScrollAnimation } from '../composables/useScrollAnimation' +import AuthorInfo from '../components/AuthorInfo.vue' const route = useRoute() const router = useRouter() diff --git a/client/src/pages/Home.vue b/client/src/pages/Home.vue index f12dbe7..3109420 100644 --- a/client/src/pages/Home.vue +++ b/client/src/pages/Home.vue @@ -57,6 +57,16 @@

{{ featuredPost.title }}

+
+ +
@@ -22,7 +29,7 @@ - + #{{ category.id }} {{ category.name }} {{ category.description || '-' }} @@ -43,7 +50,7 @@
-
+
📂

暂无分类

创建分类来整理您的附件

@@ -56,14 +63,24 @@ diff --git a/client/src/pages/admin/Snippets.vue b/client/src/pages/admin/Snippets.vue index 5652933..7eac269 100644 --- a/client/src/pages/admin/Snippets.vue +++ b/client/src/pages/admin/Snippets.vue @@ -7,6 +7,20 @@ + 新增代码片段
+ + + +
@@ -20,11 +34,11 @@ - +
{{ snippet.id }} {{ snippet.title }} - {{ snippet.type }} + {{ snippet.codeType?.name || snippet.type }} {{ snippet.viewCount || 0 }} @@ -40,23 +54,54 @@
-
-

暂无代码片段,请点击上方按钮新增

+
+

{{ appliedKeyword || filterCodeTypeId ? '没有匹配的代码片段' : '暂无代码片段,请点击上方按钮新增' }}

\ No newline at end of file + diff --git a/client/src/pages/admin/Tags.vue b/client/src/pages/admin/Tags.vue index 33993fb..8f14642 100644 --- a/client/src/pages/admin/Tags.vue +++ b/client/src/pages/admin/Tags.vue @@ -9,6 +9,13 @@ 新建标签
+ +
@@ -24,7 +31,7 @@ - + {{ tag.id }} {{ tag.name }} - @@ -43,7 +50,7 @@ -
+

暂无标签数据

@@ -51,14 +58,22 @@