support datetime

This commit is contained in:
Timi
2026-10-12 16:31:23 +08:00
parent 5e4b7404d8
commit 4910a277b8
2 changed files with 15 additions and 7 deletions
+14 -6
View File
@@ -1,6 +1,6 @@
<template>
<span
v-if="timestamp"
v-if="currentTimestamp"
class="tui-passtime-label"
:class="{ underline }"
role="button"
@@ -20,6 +20,7 @@ defineOptions({
const props = withDefaults(defineProps<{
timestamp?: number;
datetime?: string;
onlyTime?: boolean;
onlyDate?: boolean;
underline?: boolean;
@@ -29,20 +30,27 @@ const props = withDefaults(defineProps<{
underline: false
});
const { timestamp, onlyTime, onlyDate } = toRefs(props);
const { timestamp, datetime, onlyTime, onlyDate } = toRefs(props);
const showingDetail = ref(false);
const currentTimestamp = computed(() => {
if (!datetime.value) {
return timestamp.value;
}
return new Date(datetime.value.replace(" ", "T")).getTime();
});
const content = computed(() => {
if (!showingDetail.value) {
return Time.toPassedDateTime(timestamp.value);
return Time.toPassedDateTime(currentTimestamp.value);
}
if (onlyTime.value) {
return Time.toTime(timestamp.value);
return Time.toTime(currentTimestamp.value);
}
if (onlyDate.value) {
return Time.toDate(timestamp.value);
return Time.toDate(currentTimestamp.value);
}
return Time.toDateTime(timestamp.value);
return Time.toDateTime(currentTimestamp.value);
});
function toggle(event: MouseEvent | KeyboardEvent): void {