Appearance
Ship Voyage 船舶航程
展示航程港口、时间、剩余时长和进度。
命令行安装
bash
npx @loongship-kit/ui add ship-voyage基础用法
船舶航程
出发地香港 维多利亚港
剩余时间
48h 36m
目的地KAOHSIUNG, TW
离港时间
预计到达
查看代码
vue
<script setup lang="ts">
import { ShipVoyage } from '@/components/loongship/ship-voyage'
const departTime = new Date(2026, 5, 10, 17, 23, 38).getTime()
const destinationTime = new Date(2026, 5, 12, 23, 0, 0).getTime()
const currentTimestamp = departTime + 5 * 60 * 60 * 1000
</script>
<template>
<ShipVoyage
depart-port-name="香港 维多利亚港"
:depart-time="departTime"
destination-port-name="KAOHSIUNG, TW"
:destination-time="destinationTime"
:current-timestamp="currentTimestamp"
/>
</template>航程状态
currentTimestamp 适合回放、截图和测试;不传时组件会使用当前时间并按自然分钟刷新。
未出发
出发地香港
剩余时间
54h 36m
目的地高雄
离港时间
预计到达
航行中
出发地香港
剩余时间
48h 36m
目的地高雄
离港时间
预计到达
已抵达
出发地香港
已到达
目的地高雄
离港时间
预计到达
查看代码
vue
<template>
<div class="vp-demo-showcase-column">
<ShipVoyage
title="未出发"
depart-port-name="香港"
:depart-time="departTime"
destination-port-name="高雄"
:destination-time="destinationTime"
:current-timestamp="notStartedTimestamp"
/>
<ShipVoyage
title="航行中"
depart-port-name="香港"
:depart-time="departTime"
destination-port-name="高雄"
:destination-time="destinationTime"
:current-timestamp="currentTimestamp"
/>
<ShipVoyage
title="已抵达"
depart-port-name="香港"
:depart-time="departTime"
destination-port-name="高雄"
:destination-time="destinationTime"
:current-timestamp="arrivedTimestamp"
/>
</div>
</template>自定义剩余文案
船舶航程
出发地香港
剩余时间
剩余约 49 小时
目的地高雄
离港时间
预计到达
查看代码
vue
<script setup lang="ts">
import { ShipVoyage } from '@/components/loongship/ship-voyage'
import type { ShipVoyageStatus } from '@/components/loongship/ship-voyage'
function formatRemainingText(remainingMs: number, status: ShipVoyageStatus) {
if (status === 'arrived') return '已抵达目的港'
return `剩余约 ${Math.ceil(remainingMs / 3_600_000)} 小时`
}
</script>
<template>
<ShipVoyage
depart-port-name="香港"
:depart-time="departTime"
destination-port-name="高雄"
:destination-time="destinationTime"
:current-timestamp="currentTimestamp"
:format-remaining-text="formatRemainingText"
/>
</template>API
属性
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
title | string | '船舶航程' | 空字符串时隐藏 |
departPortName | string | - | 出发地,必填 |
departTime | number | - | 离港毫秒时间戳,必填 |
destinationPortName | string | - | 目的地,必填 |
destinationTime | number | - | 预计到达毫秒时间戳,必填 |
currentTimestamp | number | Date.now() | 固定快照时间;不传时内部刷新 |
formatRemainingText | (remainingMs, status) => string | 内置格式 | 自定义剩余文案 |
插槽
无内容插槽。