refactor time-label
This commit is contained in:
@@ -2,28 +2,33 @@
|
||||
<div class="demo">
|
||||
<div v-for="item in timeList" :key="item.offset" class="row">
|
||||
<span class="label" v-text="item.label" />
|
||||
<pass-time-label :timestamp="item.timestamp" underline />
|
||||
<TimeLabel :timestamp="item.timestamp" underline />
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<span class="label" v-text="'仅时间 / 仅日期'" />
|
||||
<pass-time-label :timestamp="now" only-time underline />
|
||||
<pass-time-label :timestamp="now" only-date underline />
|
||||
<TimeLabel :timestamp="now" only-time underline />
|
||||
<TimeLabel :timestamp="now" only-date underline />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { PassTimeLabel } from "timi-web";
|
||||
import { TimeLabel } from "timi-web";
|
||||
|
||||
const now = Date.now();
|
||||
|
||||
/** 点击标签可在「多久以前」与完整时间之间切换。 */
|
||||
/** 点击标签可在相对时间与完整时间之间切换。 */
|
||||
const timeList = [
|
||||
{ offset: 30_000, label: "30 秒前" },
|
||||
{ offset: 30 * 60_000, label: "30 分钟前" },
|
||||
{ offset: 5 * 3600_000, label: "5 小时前" },
|
||||
{ offset: 3 * 86400_000, label: "3 天前" }
|
||||
{ offset: 3 * 86400_000, label: "3 天前" },
|
||||
{ offset: -30_000, label: "30 秒后" },
|
||||
{ offset: -30 * 60_000, label: "30 分钟后" },
|
||||
{ offset: -5 * 3600_000, label: "5 小时后" },
|
||||
{ offset: -2 * 86400_000, label: "2 天后" },
|
||||
{ offset: -4 * 86400_000, label: "4 天后" }
|
||||
].map(item => ({
|
||||
...item,
|
||||
timestamp: now - item.offset
|
||||
Reference in New Issue
Block a user