Flight tracker(航班追踪)
航班卡片显示出发地、目的地、准点状态、航程进度和预计剩余时间。
loading
安装
bash
npm install @assistant-ui/generative-ui zod1
用法
将下方规格传给渲染器。此规格包含完整的展示数据,渲染时使用已完成状态。
tsx
import { defaultGenerativeUILibrary, renderGenerativeUI } from "@assistant-ui/generative-ui/react";
renderGenerativeUI(spec, defaultGenerativeUILibrary, { status: "done" });1
2
3
2
3
规格
tsx
const spec = {
"$type": "Card",
"children": [
{
"$type": "Row",
"$key": "airline-row",
"justify": "between",
"children": [
{
"$type": "Caption",
"$key": "airline",
"value": "联合航空 · UA 872"
},
{
"$type": "Caption",
"$key": "status",
"value": "准点"
}
]
},
{
"$type": "Row",
"$key": "cities",
"justify": "between",
"align": "center",
"children": [
{
"$type": "Text",
"$key": "origin",
"value": "SFO",
"size": "3xl",
"weight": "bold"
},
{
"$type": "Text",
"$key": "arrow",
"value": "",
"color": "secondary",
"children": {
"$type": "Icon",
"name": "plane",
"size": "md"
}
},
{
"$type": "Text",
"$key": "dest",
"value": "NRT",
"size": "3xl",
"weight": "bold"
}
]
},
{
"$type": "Box",
"$key": "track",
"width": "100%",
"height": 6,
"radius": "full",
"background": "var(--muted)",
"children": {
"$type": "Box",
"width": "62%",
"height": 6,
"radius": "full",
"background": "var(--primary)"
}
},
{
"$type": "Row",
"$key": "meta",
"justify": "between",
"children": [
{
"$type": "Caption",
"$key": "elapsed",
"value": "已飞行 6 小时 40 分钟"
},
{
"$type": "Caption",
"$key": "remaining",
"value": "剩余 4 小时 10 分钟"
}
]
}
]
}1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87