refactor(comment): 统一字段命名并改用时间戳存储创建时间
将 author 字段重命名为 name,pub_date 改为 created 并使用时间戳存储 更新相关 API、数据库 schema 和前端组件以适配新字段 同时将 user_agent 简化为 ua 并改进日期处理逻辑
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -8,8 +8,8 @@ export type AdminLoginResponse = {
|
||||
|
||||
export type CommentItem = {
|
||||
id: number;
|
||||
pubDate: string;
|
||||
author: string;
|
||||
created: number;
|
||||
name: string;
|
||||
email: string;
|
||||
avatar: string;
|
||||
postSlug: string;
|
||||
@@ -18,6 +18,7 @@ export type CommentItem = {
|
||||
contentText: string;
|
||||
contentHtml: string;
|
||||
status: string;
|
||||
ua?: string | null;
|
||||
};
|
||||
|
||||
export type CommentListResponse = {
|
||||
|
||||
@@ -32,12 +32,12 @@
|
||||
v-if="item.avatar"
|
||||
:src="item.avatar"
|
||||
class="cell-avatar"
|
||||
:alt="item.author"
|
||||
:alt="item.name"
|
||||
/>
|
||||
<div class="cell-author-main">
|
||||
<div class="cell-author-name">{{ item.author }}</div>
|
||||
<div class="cell-author-name">{{ item.name }}</div>
|
||||
<div class="cell-author-email">{{ item.email }}</div>
|
||||
<span class="cell-time">{{ formatDate(item.pubDate) }}</span>
|
||||
<span class="cell-time">{{ formatDate(item.created) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -138,10 +138,10 @@ const filteredComments = computed(() => {
|
||||
return comments.value.filter((item) => item.status === statusFilter.value);
|
||||
});
|
||||
|
||||
function formatDate(value: string) {
|
||||
function formatDate(value: number) {
|
||||
const d = new Date(value);
|
||||
if (Number.isNaN(d.getTime())) {
|
||||
return value;
|
||||
return String(value);
|
||||
}
|
||||
return d.toLocaleString();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user