feat: update date format

This commit is contained in:
yanghao05
2025-04-18 17:43:48 +08:00
parent 4165d440ed
commit 8e65d136d9
3 changed files with 6 additions and 37 deletions

View File

@@ -1,11 +1,9 @@
<script setup>
import { postService } from '@/api/postService'; // Assuming you have a postService for API calls
import { postService } from '@/api/postService';
import { formatDate } from '@/utils/date';
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';
@@ -18,10 +16,6 @@ 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();
@@ -117,12 +111,6 @@ const confirmDelete = (post) => {
});
};
// Format datetime to YY/MM/DD HH:mm:ss
const formatDate = (date) => {
return dayjs.tz(date, 'Asia/Shanghai').format('YYYY-MM-DD HH:mm:ss');
};
// Add these helper functions next to existing price-related functions
const getDiscountAmount = (price, discount) => {
return price * (100 - discount) / 100;
@@ -262,7 +250,7 @@ const formatMediaTypes = (mediaTypes) => {
<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>