-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathContentView.swift
85 lines (71 loc) · 2.19 KB
/
ContentView.swift
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
//
// ContentView.swift
// bmob-chatgpt-demo
// fda2aa4220549f74
// Created by magic on 2023/7/6.
//
import SwiftUI
import BmobChatAi
//struct Category {
// let id: Int
// let name: String
//}
//
//struct Item {
// let id: Int
// let name: String
// let categoryId: Int
//}
struct ContentView: View {
let categories = [
Category(id: 1, name: "全能问题"),
Category(id: 2, name: "娱乐"),
Category(id: 3, name: "效率")
]
var body: some View {
NavigationView {
List {
ForEach(categories, id: \.id) { category in
Section(header: Text(category.name)) {
ForEach(items.filter { $0.categoryId == category.id }, id: \.id) { item in
NavigationLink(destination: ChatView( info: item)) {
// #3493ff
Image(systemName: item.img).foregroundColor(Color(red: 52/255, green: 147/255, blue: 255/255))
Text(item.name)
}
}
}
}
}
.navigationTitle("发现")
}
}
}
//The production process of water cup
struct ItemDetailView: View {
let item: Item
var body: some View {
Text(item.name)
.navigationTitle(item.name)
}
}
func loadData() {
// 在视图显示时调用的回调函数
// webSocketManager.connect()
// // 设置闭包属性,在接收到 WebSocket 文本消息时进行处理
// webSocketManager.onReceiveMessage = { message in
// print("接收到 WebSocket 文本消息:\(message)")
// // 在这里进行接收到 WebSocket 文本消息后的处理
// }
// // 设置错误处理闭包属性
// webSocketManager.onError = { error in
// print("WebSocket 出现错误:\(error.localizedDescription)")
// }
// 发送消息
// webSocketManager.send(message: "ping")
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}