修改样式
This commit is contained in:
@@ -15,6 +15,29 @@ import {formatTimestamp, formatTimestampWithMonthName} from "@/utils/utils";
|
||||
import {useUserStore, useConfigStore} from "@/store";
|
||||
const userStore = useUserStore()
|
||||
const configStore = useConfigStore()
|
||||
|
||||
function normalizeTimestamp(input: unknown): number | null {
|
||||
if (input == null || input === '') return null
|
||||
const raw = Number(input)
|
||||
if (!Number.isFinite(raw) || raw <= 0) return null
|
||||
|
||||
// 10位秒级、13位毫秒级、16位微秒级都做兼容
|
||||
if (raw < 1e11) return Math.trunc(raw * 1000)
|
||||
if (raw > 1e14) return Math.trunc(raw / 1000)
|
||||
return Math.trunc(raw)
|
||||
}
|
||||
|
||||
function formatRecipeTime(value: unknown): string {
|
||||
const ts = normalizeTimestamp(value)
|
||||
if (!ts) return '--'
|
||||
return formatTimestamp(ts)
|
||||
}
|
||||
|
||||
function formatCommentTime(value: unknown): string {
|
||||
const ts = normalizeTimestamp(value)
|
||||
if (!ts) return '--'
|
||||
return formatTimestampWithMonthName(ts)
|
||||
}
|
||||
// 加载状态
|
||||
const loading = ref(true);
|
||||
// 获取菜谱详情
|
||||
@@ -108,7 +131,7 @@ function getCommentList() {
|
||||
user_name: userInfo.user_name, // 用户名
|
||||
user_avatar: userInfo.user_avatar, // 用户头像地址
|
||||
user_content: item.content, // 用户评论内容
|
||||
create_time: formatTimestampWithMonthName(item.createTime), // 创建时间
|
||||
create_time: formatCommentTime(item.createTime), // 创建时间
|
||||
}
|
||||
})
|
||||
tableTotal.value = res.total
|
||||
@@ -192,7 +215,7 @@ function handleSend() {
|
||||
>{{ recipeDetail?.recipeName || '' }}</view
|
||||
>
|
||||
<view class="flex-center-sb text-28rpx text-#fff">
|
||||
<text>{{ formatTimestamp(recipeDetail?.createTime) }}</text>
|
||||
<text>{{ formatRecipeTime(recipeDetail?.createTime) }}</text>
|
||||
<view class="flex items-center">
|
||||
<image
|
||||
src="@img/chef/1326.png"
|
||||
|
||||
Reference in New Issue
Block a user