fix: timeshow
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
<script setup>
|
||||
import { mediaService } from "@/api/mediaService";
|
||||
import dayjs from 'dayjs';
|
||||
import timezone from 'dayjs/plugin/timezone';
|
||||
import utc from 'dayjs/plugin/utc';
|
||||
import { InputText } from "primevue";
|
||||
import Badge from "primevue/badge";
|
||||
import Button from "primevue/button";
|
||||
@@ -131,6 +134,15 @@ const formatFileSize = (bytes) => {
|
||||
// Convert back to number and format with commas
|
||||
return `${Number(size).toLocaleString("en-US")} ${sizes[i]}`;
|
||||
};
|
||||
|
||||
// Configure dayjs
|
||||
dayjs.extend(utc);
|
||||
dayjs.extend(timezone);
|
||||
|
||||
// Add formatDate function
|
||||
const formatDate = (date) => {
|
||||
return dayjs.tz(date, 'Asia/Shanghai').format('YYYY-MM-DD HH:mm:ss');
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -191,7 +203,14 @@ const formatFileSize = (bytes) => {
|
||||
</template>
|
||||
</Column>
|
||||
|
||||
<Column field="upload_time" header="上传时间"></Column>
|
||||
<Column field="upload_time" header="时间信息">
|
||||
<template #body="{ data }">
|
||||
<div class="flex flex-col">
|
||||
<span class="text-gray-500">更新: {{ formatDate(data.updated_at) }}</span>
|
||||
<span class="text-gray-400">上传: {{ formatDate(data.created_at) }}</span>
|
||||
</div>
|
||||
</template>
|
||||
</Column>
|
||||
|
||||
<Column field="file_size" header="文件大小">
|
||||
<template #body="{ data }">
|
||||
|
||||
@@ -179,7 +179,7 @@ onMounted(() => {
|
||||
<span class="text-orange-500">优惠: -¥{{ formatPrice(getDiscountAmount(data.price,
|
||||
data.discount)) }}</span>
|
||||
<span class="font-bold">实付: ¥{{ formatPrice(getFinalPrice(data.price, data.discount))
|
||||
}}</span>
|
||||
}}</span>
|
||||
</div>
|
||||
</template>
|
||||
</Column>
|
||||
|
||||
@@ -3,6 +3,9 @@ import { postService } from '@/api/postService'; // Assuming you have a postServ
|
||||
import { InputText } from 'primevue';
|
||||
import Badge from 'primevue/badge';
|
||||
|
||||
import dayjs from 'dayjs';
|
||||
import timezone from 'dayjs/plugin/timezone';
|
||||
import utc from 'dayjs/plugin/utc';
|
||||
import Button from 'primevue/button';
|
||||
import Column from 'primevue/column';
|
||||
import ConfirmDialog from 'primevue/confirmdialog';
|
||||
@@ -15,6 +18,10 @@ import { useToast } from 'primevue/usetoast';
|
||||
import { onMounted, ref } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
|
||||
// Configure dayjs
|
||||
dayjs.extend(utc);
|
||||
dayjs.extend(timezone);
|
||||
|
||||
// Import useRouter for navigation
|
||||
const router = useRouter();
|
||||
const confirm = useConfirm();
|
||||
@@ -115,17 +122,8 @@ const confirmDelete = (post) => {
|
||||
};
|
||||
|
||||
// Format datetime to YY/MM/DD HH:mm:ss
|
||||
const formatDateTime = (dateStr) => {
|
||||
const date = new Date(dateStr);
|
||||
return date.toLocaleString('zh-CN', {
|
||||
year: 'numeric',
|
||||
month: '2-digit',
|
||||
day: '2-digit',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
second: '2-digit',
|
||||
hour12: false
|
||||
}).replace(/\//g, '-');
|
||||
const formatDate = (date) => {
|
||||
return dayjs.tz(date, 'Asia/Shanghai').format('YYYY-MM-DD HH:mm:ss');
|
||||
};
|
||||
|
||||
// Calculate price after discount
|
||||
@@ -153,8 +151,8 @@ const fetchPosts = async () => {
|
||||
status: statusMap[post.status] || '未知',
|
||||
mediaTypes: getMediaTypes(post.assets),
|
||||
price: post.price / 100,
|
||||
publishedAt: formatDateTime(post.created_at),
|
||||
editedAt: formatDateTime(post.updated_at),
|
||||
publishedAt: formatDate(post.created_at),
|
||||
editedAt: formatDate(post.updated_at),
|
||||
viewCount: post.views,
|
||||
likes: post.likes
|
||||
}));
|
||||
@@ -273,15 +271,12 @@ const formatMediaTypes = (mediaTypes) => {
|
||||
</template>
|
||||
</Column>
|
||||
|
||||
<Column field="publishedAt" header="发布时间" sortable>
|
||||
<Column field="updated_at" header="时间信息" sortable>
|
||||
<template #body="{ data }">
|
||||
<div class="text-sm text-gray-900">{{ data.publishedAt }}</div>
|
||||
</template>
|
||||
</Column>
|
||||
|
||||
<Column field="editedAt" header="编辑时间" sortable>
|
||||
<template #body="{ data }">
|
||||
<div class="text-sm text-gray-900">{{ data.editedAt }}</div>
|
||||
<div class="flex flex-col">
|
||||
<span class="text-gray-500">更新: {{ formatDate(data.updated_at) }}</span>
|
||||
<span class="text-gray-400">创建: {{ formatDate(data.created_at) }}</span>
|
||||
</div>
|
||||
</template>
|
||||
</Column>
|
||||
|
||||
|
||||
@@ -165,15 +165,12 @@ onMounted(() => {
|
||||
</template>
|
||||
</Column>
|
||||
|
||||
<Column field="created_at" header="创建时间" sortable>
|
||||
<Column field="updated_at" header="时间信息" sortable>
|
||||
<template #body="{ data }">
|
||||
{{ formatDate(data.created_at) }}
|
||||
</template>
|
||||
</Column>
|
||||
|
||||
<Column field="updated_at" header="更新时间" sortable>
|
||||
<template #body="{ data }">
|
||||
{{ formatDate(data.updated_at) }}
|
||||
<div class="flex flex-col">
|
||||
<span class="text-gray-500">更新: {{ formatDate(data.updated_at) }}</span>
|
||||
<span class="text-gray-400">创建: {{ formatDate(data.created_at) }}</span>
|
||||
</div>
|
||||
</template>
|
||||
</Column>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user