From df4ab31dd66a9d6df328968662a6a3d54db62099 Mon Sep 17 00:00:00 2001 From: lizheming Date: Thu, 26 Nov 2026 23:52:34 +0800 Subject: [PATCH 1/2] fix(say): improve admin list links and labels --- packages/say/plugin.js | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/packages/say/plugin.js b/packages/say/plugin.js index ad7aaf8..61b560d 100644 --- a/packages/say/plugin.js +++ b/packages/say/plugin.js @@ -9,7 +9,7 @@ const feedback = require('./lib/publish-feedback'); const {whoami} = require('./lib/commands'); const {createQqWebhook} = require('./lib/qq-webhook'); const {renderSayPage, createSayViewModel} = require('./lib/render'); -const {listUrl, tagUrl} = require('./lib/urls'); +const {listUrl, tagUrl, detailUrl} = require('./lib/urls'); const {renderWalineComments} = require('./lib/comment-render'); const {SayComments} = require('./lib/comments'); const {FrontendPublish, renderComposer} = require('./lib/frontend-publish'); @@ -31,6 +31,19 @@ const kindOptions = [ const statusOptions = [ {label: '公开', value: 'public'}, {label: '私密', value: 'private'}, {label: '隐藏', value: 'hidden'} ]; +function formatAdminDate(value) { + if (!value) return '—'; + // Database date strings already carry the site's wall-clock date. + if (typeof value === 'string' && /^\d{4}-\d{2}-\d{2}(?: |$)/.test(value)) { + return value.slice(0, 10); + } + const date = new Date(value); + if (!Number.isFinite(date.getTime())) return '—'; + return new Intl.DateTimeFormat('en-CA', { + timeZone: 'Asia/Shanghai', year: 'numeric', month: '2-digit', day: '2-digit' + }).format(date); +} + const publishFields = [ {name: 'kind', type: 'radio', label: '类型', required: true, options: kindOptions}, {name: 'status', type: 'radio', label: '状态', required: true, options: statusOptions}, @@ -472,12 +485,15 @@ module.exports = { {key: 'delete', label: '删除', action: 'delete-says', type: 'danger'} ]}, toolbar: [{label: '新增碎语', href: '/admin/plugins/say/publish', type: 'primary'}], columns: [ - {key: 'id', title: 'ID'}, {key: 'kind', title: '类型'}, {key: 'status', title: '状态'}, + {key: 'idLink', title: 'ID', type: 'actions'}, {key: 'kind', title: '类型'}, {key: 'status', title: '状态'}, {key: 'content', title: '内容'}, {key: 'tags', title: '标签'}, {key: 'createdAt', title: '时间'}, {key: 'actions', title: '操作', type: 'actions'} - ], rows: items.map(item => ({id: item.id, kind: item.kind, status: item.status, + ], rows: items.map(item => ({id: item.id, + idLink: [{label: String(item.id), href: detailUrl(item.id)}], + kind: kindOptions.find(option => option.value === item.kind)?.label || item.kind, + status: statusOptions.find(option => option.value === item.status)?.label || item.status, content: item.text || item.title || item.url, tags: item.tags.map(tag => `#${tag}`).join(' '), - createdAt: item.createdAt, actions: [ + createdAt: formatAdminDate(item.createdAt), actions: [ {label: '编辑', href: `/admin/plugins/say/edit?id=${item.id}`}, {label: item.status === 'public' ? '设为私密' : '设为公开', action: 'toggle-say', input: {id: item.id, status: item.status === 'public' ? 'private' : 'public'}}, From ebfd665bcd34d2462a9beebe7121b3093efb7632 Mon Sep 17 00:00:00 2001 From: lizheming Date: Thu, 26 Nov 2026 23:58:37 +0800 Subject: [PATCH 2/2] fix(say): include time in admin list dates --- packages/say/plugin.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/packages/say/plugin.js b/packages/say/plugin.js index 61b560d..fc18364 100644 --- a/packages/say/plugin.js +++ b/packages/say/plugin.js @@ -33,15 +33,19 @@ const statusOptions = [ ]; function formatAdminDate(value) { if (!value) return '—'; - // Database date strings already carry the site's wall-clock date. - if (typeof value === 'string' && /^\d{4}-\d{2}-\d{2}(?: |$)/.test(value)) { - return value.slice(0, 10); + // Database strings already represent the site's wall-clock time. + if (typeof value === 'string') { + const match = /^(\d{4}-\d{2}-\d{2})(?: (\d{2}:\d{2}:\d{2})(?:\.\d+)?)?$/.exec(value); + if (match) return `${match[1]} ${match[2] || '00:00:00'}`; } const date = new Date(value); if (!Number.isFinite(date.getTime())) return '—'; - return new Intl.DateTimeFormat('en-CA', { - timeZone: 'Asia/Shanghai', year: 'numeric', month: '2-digit', day: '2-digit' - }).format(date); + const parts = new Intl.DateTimeFormat('en-CA', { + timeZone: 'Asia/Shanghai', year: 'numeric', month: '2-digit', day: '2-digit', + hour: '2-digit', minute: '2-digit', second: '2-digit', hourCycle: 'h23' + }).formatToParts(date); + const fields = Object.fromEntries(parts.map(part => [part.type, part.value])); + return `${fields.year}-${fields.month}-${fields.day} ${fields.hour}:${fields.minute}:${fields.second}`; } const publishFields = [