13 changed files with 248 additions and 25 deletions
-
4package-lock.json
-
2scripts/start.js
-
1src/assets/icon_bluetooth.svg
-
38src/components/Header.tsx
-
7src/pages/measure/components/MeasureAction.tsx
-
2src/pages/measure/components/konva/MeasurementCanvas.tsx
-
119src/pages/system/Setting.tsx
-
6src/pages/system/types.ts
-
29src/services/ble/ble.ts
-
14src/services/wsTypes.ts
-
31src/store/ble/bleState.ts
-
6src/store/features/contextSlice.ts
-
2src/store/index.ts
@ -0,0 +1 @@ |
|||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" fill="none" version="1.1" width="10" height="15" viewBox="0 0 10 15"><g><path d="M6.7674,7.5L10,10.7572L5.78936,15L4.30071,15L4.30071,9.9855L1.05248,13.2585L5.32382e-7,12.1972L4.30071,7.86375L4.30071,7.13625L0,2.80275L1.05247,1.7415L4.30071,5.0145L4.30071,0L5.78936,0L10,4.24275L6.7674,7.5ZM5.78936,8.63625L5.78936,12.879L7.89431,10.7572L5.78936,8.63625ZM5.78936,6.36375L7.89431,4.24275L5.78936,2.121L5.78936,6.36375Z" fill="#3165D2" fill-opacity="1" style="mix-blend-mode:passthrough"/></g></svg> |
@ -0,0 +1,29 @@ |
|||
import httpRequest, {type BaseResponse} from "../httpRequest"; |
|||
export function start() { |
|||
return httpRequest<BaseResponse>({ |
|||
url: "/api/ble/list/start", |
|||
method: "POST", |
|||
}); |
|||
} |
|||
|
|||
export function stop() { |
|||
return httpRequest<BaseResponse>({ |
|||
url: "/api/ble/list/stop", |
|||
method: "POST", |
|||
}); |
|||
} |
|||
|
|||
export function connect(address: string) { |
|||
return httpRequest<BaseResponse>({ |
|||
url: `/api/ble/connect/${address}`, |
|||
method: "POST" |
|||
}); |
|||
} |
|||
export function disconnect() { |
|||
return httpRequest<BaseResponse>({ |
|||
url: `/api/ble/disconnect`, |
|||
method: "POST" |
|||
}); |
|||
} |
|||
|
|||
|
@ -0,0 +1,31 @@ |
|||
// counterSlice.ts 文件
|
|||
|
|||
import { createSlice } from "@reduxjs/toolkit"; |
|||
import { ChannelMessage } from "../../services/wsTypes"; |
|||
|
|||
const initialState: ChannelMessage["data"] = { |
|||
isConnect: false, //是否连接
|
|||
connectPort: "COM4", //串口名
|
|||
sn: "", //连接的设备ID
|
|||
descriptivePortName: "COM4 serial ch340", //用于详细系
|
|||
}; |
|||
|
|||
// 创建一个 Slice
|
|||
export const bleStateSlice = createSlice({ |
|||
name: "bleState", |
|||
initialState, |
|||
// 定义 reducers 并生成关联的操作
|
|||
reducers: { |
|||
// 定义一个加的方法
|
|||
updateBleState: (state, { payload }) => { |
|||
state.isConnect = payload.isConnect; |
|||
state.connectPort = payload.connectPort; |
|||
state.sn = payload.sn; |
|||
state.descriptivePortName = payload.descriptivePortName; |
|||
}, |
|||
}, |
|||
}); |
|||
export const { updateBleState } = bleStateSlice.actions; |
|||
|
|||
// 默认导出
|
|||
export default bleStateSlice.reducer; |
Write
Preview
Loading…
Cancel
Save
Reference in new issue