From 933ebdfc46dc87e3273f75dc9200706725362d97 Mon Sep 17 00:00:00 2001 From: Sheyiyuan <2125107118@qq.com> Date: Thu, 12 Dec 2024 15:11:31 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E6=96=B0=E5=88=92=E5=AE=9A=E5=88=86?= =?UTF-8?q?=E5=8C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 4 +++- core/api.go | 6 +++++- core/web_socket.go | 20 ++++++++++++++++++++ doc/index.html | 25 +++++++++++++++++++++++++ 4 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 doc/index.html diff --git a/.gitignore b/.gitignore index b31d724..f1c3f64 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,6 @@ /ProjectWIND /data **/.DS_Store -/app_demo/ \ No newline at end of file +/app_demo/ +.idea/ +.vscode/ \ No newline at end of file diff --git a/core/api.go b/core/api.go index c072f24..7857e1b 100644 --- a/core/api.go +++ b/core/api.go @@ -359,7 +359,11 @@ func (a *apiInfo) SetGroupAddRequest(flag string, subType string, approve bool, return } -// 2.有响应API,使用http协议处理 +// 2.有响应API,需添加echo字段 + +func (a *apiInfo) GetLoginInfo(flag string, approve bool) { + +} var AppApi apiInfo diff --git a/core/web_socket.go b/core/web_socket.go index 0b9bdcd..846e99d 100644 --- a/core/web_socket.go +++ b/core/web_socket.go @@ -115,6 +115,26 @@ func processMessage(messageType int, message []byte) { } default: { + messageMap := make(map[string]interface{}) + err := json.Unmarshal(message, &messageMap) + if err != nil { + LOG.ERROR("Unmarshal error when handling api response message: %v", err) + return + } + if messageMap["status"] != "ok" { + LOG.ERROR("API response error: %v", messageMap["status"]) + return + } + if messageMap["echo"] == "" { + LOG.WARN("Unknown API response: %v", messageMap["echo"]) + return + } + apiResp := make(map[string]interface{}) + apiResp["uuid"] = messageMap["echo"] + ApiChan := make(chan map[string]interface{}) + go func(apiResp map[string]interface{}) { + ApiChan <- apiResp + }(apiResp) // 此处为api请求响应数据,通过channel返回给调用者 return } diff --git a/doc/index.html b/doc/index.html new file mode 100644 index 0000000..9ef6c8a --- /dev/null +++ b/doc/index.html @@ -0,0 +1,25 @@ + + + + + + WIND + + +

WIND

+
WIND is not
Dice
+
+
Hello World!
+
+
简单
+
开箱即用,web界面,简单易懂
+
快捷
+
app一键安装,一键启动,一键更新
+
方便
+
开发者友好,代码开源,可定制化
+
小巧
+
体积小,启动快,占用资源少
+
+ 点击这里关注我们 + + \ No newline at end of file