From 8ee29e95498dab4d3b5ea7efdcf0d429fa6c0f8f Mon Sep 17 00:00:00 2001 From: xiaomai Date: Tue, 5 May 2026 07:15:18 +0800 Subject: [PATCH] feat(history): exclude sort order changes from edit history Stop recording sort order changes in the backend edit log Filter out existing sort order changes from the frontend edit history panel --- DESIGN.md | 1 + backend/src/queries.ts | 17 ++++-------- frontend/src/components/EditHistoryPanel.vue | 28 +++++++++++--------- 3 files changed, 22 insertions(+), 24 deletions(-) diff --git a/DESIGN.md b/DESIGN.md index 675e09f..edbdcf4 100644 --- a/DESIGN.md +++ b/DESIGN.md @@ -344,6 +344,7 @@ - `created_at` - 详情页展示最后编辑者、最后编辑时间和编辑历史面板。 - 编辑历史中的用户信息只展示必要署名,不暴露邮箱、token、hash 或内部元数据。 +- 排序操作仍更新列表顺序、最后编辑者和最后编辑时间,但 `sort_order` / Sort order 字段变更不写入或展示在详情页编辑历史面板中。 - 编辑署名、编辑历史署名、Life 作者和讨论作者可链接到对应公开 Profile。 ## Wiki 图片上传 diff --git a/backend/src/queries.ts b/backend/src/queries.ts index 0e3a0d2..54694ea 100644 --- a/backend/src/queries.ts +++ b/backend/src/queries.ts @@ -1142,7 +1142,6 @@ async function nextPokemonInternalId( async function reorderTableRows( client: DbClient, tableName: string, - entityType: string, ids: number[], userId: number ): Promise { @@ -1171,9 +1170,6 @@ async function reorderTableRows( `, [nextSortOrder, userId, id] ); - const changes: EditChange[] = []; - pushChange(changes, 'Sort order', String(previousSortOrder), String(nextSortOrder)); - await recordEditLog(client, entityType, id, 'update', userId, changes); } } @@ -2798,9 +2794,6 @@ export async function reorderDailyChecklistItems(payload: Record { - await reorderTableRows(client, definition.table, type, ids, userId); + await reorderTableRows(client, definition.table, ids, userId); }); return listConfig(type, locale); @@ -5440,7 +5433,7 @@ async function reorderContent(type: SortableContentType, payload: Record { - await reorderTableRows(client, definition.table, definition.entityType, ids, userId); + await reorderTableRows(client, definition.table, ids, userId); }); } @@ -6618,7 +6611,7 @@ export async function createItem(payload: Record, userId: numbe } orderedIds.splice(targetIndex + (cleanPayload.insertAfterItemId !== null ? 1 : 0), 0, itemId); - await reorderTableRows(client, 'items', 'items', orderedIds, userId); + await reorderTableRows(client, 'items', orderedIds, userId); } await recordEditLog(client, 'items', itemId, 'create', userId); @@ -7526,7 +7519,7 @@ export async function reorderDishCategories(payload: Record, us throw validationError('server.validation.selectRecord'); } await withTransaction(async (client) => { - await reorderTableRows(client, 'dish_categories', 'dish-categories', ids, userId); + await reorderTableRows(client, 'dish_categories', ids, userId); }); return listDish(locale); } @@ -7537,7 +7530,7 @@ export async function reorderDishes(payload: Record, userId: nu throw validationError('server.validation.selectRecord'); } await withTransaction(async (client) => { - await reorderTableRows(client, 'dishes', 'dishes', ids, userId); + await reorderTableRows(client, 'dishes', ids, userId); }); return listDish(locale); } diff --git a/frontend/src/components/EditHistoryPanel.vue b/frontend/src/components/EditHistoryPanel.vue index 7ccdad2..239c445 100644 --- a/frontend/src/components/EditHistoryPanel.vue +++ b/frontend/src/components/EditHistoryPanel.vue @@ -2,7 +2,7 @@ import { useI18n } from 'vue-i18n'; import type { EditHistoryAction, EditHistoryEntry, EditInfo, UserSummary } from '../services/api'; -defineProps<{ +const props = defineProps<{ entity: EditInfo; history: EditHistoryEntry[]; }>(); @@ -118,7 +118,11 @@ function changeValue(value: string): string { } function visibleChanges(entry: EditHistoryEntry) { - return entry.changes.filter((change) => change.label !== 'Display ID'); + return entry.changes.filter((change) => change.label !== 'Display ID' && change.label !== 'Sort order' && change.label !== '排序'); +} + +function visibleHistoryEntries() { + return props.history.filter((entry) => entry.action !== 'update' || visibleChanges(entry).length > 0); } function historySummary(entry: EditHistoryEntry): string { @@ -148,29 +152,29 @@ function formatDateTime(value: string): string {
{{ t('history.createdBy') }}
-
{{ t('history.lastEdited') }}
-

{{ t('history.editHistory') }}

-
    -
  1. +
      +