Current weather(当前天气)
天气卡片突出当前温度,并提供天气状况和体感温度。
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": "header",
"justify": "between",
"align": "center",
"children": [
{
"$type": "Text",
"$key": "city",
"value": "得克萨斯州奥斯汀",
"color": "secondary"
},
{
"$type": "Icon",
"$key": "icon",
"name": "sun",
"size": "lg"
}
]
},
{
"$type": "Text",
"$key": "temp",
"value": "94°F",
"size": "3xl",
"weight": "bold"
},
{
"$type": "Text",
"$key": "description",
"value": "晴朗,体感 98°F",
"color": "secondary"
}
]
}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
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