针对前端打包时候切换开发和生产环境的ws url
continuous-integration/drone/push Build is passing Details

This commit is contained in:
giaogiao 2023-09-14 10:09:08 +08:00
parent 86414244a8
commit 300ac78672
3 changed files with 6 additions and 6 deletions

View File

@ -28,7 +28,7 @@ steps:
- npm install yarn - npm install yarn
- yarn config set registry https://registry.npm.taobao.org --global - yarn config set registry https://registry.npm.taobao.org --global
- yarn - yarn
- yarn run eject - sed -i 's?(dev_ws_url)?(dev_ws_url)?g' ./src/api/websocket.js
- yarn build - yarn build
- name: build - name: build

View File

@ -35,7 +35,7 @@ func Hello(c echo.Context) error {
msg := "" msg := ""
err := websocket.Message.Receive(ws, &msg) err := websocket.Message.Receive(ws, &msg)
if err != nil { if err != nil {
c.Logger().Error(err) c.Logger().Error(err.Error())
break break
} }
//暂时不解析的json //暂时不解析的json
@ -45,13 +45,13 @@ func Hello(c echo.Context) error {
} }
json.Unmarshal([]byte(msg), &wsValue) json.Unmarshal([]byte(msg), &wsValue)
if err := json.Unmarshal([]byte(msg), &wsValue); err != nil { if err := json.Unmarshal([]byte(msg), &wsValue); err != nil {
fmt.Println(err) fmt.Println(err.Error())
} }
switch wsValue.Method { switch wsValue.Method {
case "start": case "start":
var startdata MacData var startdata MacData
if err := json.Unmarshal(json_data, &startdata); err != nil { if err := json.Unmarshal(json_data, &startdata); err != nil {
c.Logger().Error(err) c.Logger().Error(err.Error())
return return
} }
Send_start(startdata.Mac, &ws, wsValue.Uuid) Send_start(startdata.Mac, &ws, wsValue.Uuid)
@ -61,14 +61,14 @@ func Hello(c echo.Context) error {
case "del": case "del":
var DelData DelData var DelData DelData
if err := json.Unmarshal(json_data, &DelData); err != nil { if err := json.Unmarshal(json_data, &DelData); err != nil {
c.Logger().Error(err) c.Logger().Error(err.Error())
return return
} }
Del(&ws, wsValue.Uuid, DelData.ID) Del(&ws, wsValue.Uuid, DelData.ID)
case "add": case "add":
var AddData AddData var AddData AddData
if err := json.Unmarshal(json_data, &AddData); err != nil { if err := json.Unmarshal(json_data, &AddData); err != nil {
c.Logger().Error(err) c.Logger().Error(err.Error())
return return
} }
Add(&ws, wsValue.Uuid, AddData.Nmae, AddData.Mac) Add(&ws, wsValue.Uuid, AddData.Nmae, AddData.Mac)

BIN
wol.db

Binary file not shown.