From bd3348f9a5ede9e0c7fc54ca2d2810f140b1d2a9 Mon Sep 17 00:00:00 2001 From: guoapeng Date: Mon, 28 Apr 2025 16:33:56 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=B0=83=E8=AF=95ts=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E8=A1=A5=E5=85=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/apis/system.ts | 8 ++-- src/components/common/FTStream/index.vue | 2 +- src/libs/utils.ts | 2 +- src/stores/debugStore.ts | 40 ++++++++--------- src/stores/systemStore.ts | 5 +-- src/types/System.d.ts | 8 ++++ src/types/debug.d.ts | 74 ++++++++++++++++++++++++++++++++ src/types/socket.d.ts | 25 +++++++++++ src/views/debug/index.vue | 43 ++++++++++--------- 9 files changed, 157 insertions(+), 50 deletions(-) create mode 100644 src/types/System.d.ts create mode 100644 src/types/debug.d.ts create mode 100644 src/types/socket.d.ts diff --git a/src/apis/system.ts b/src/apis/system.ts index f651a64..8d9ff45 100644 --- a/src/apis/system.ts +++ b/src/apis/system.ts @@ -1,9 +1,9 @@ import http from 'libs/http' -export interface Params { +export interface Params { commandId: string command: string - params: any + params: T } -export const debugControl = (params: Params): Promise => http.post('/debug/cmd', params) -export const control = (params: Params): Promise => http.post('/cmd', params) +export const debugControl = (params: Params): Promise => http.post('/debug/cmd', params) +export const control = (params: Params): Promise => http.post('/cmd', params) diff --git a/src/components/common/FTStream/index.vue b/src/components/common/FTStream/index.vue index dff1d0a..ad94392 100644 --- a/src/components/common/FTStream/index.vue +++ b/src/components/common/FTStream/index.vue @@ -112,7 +112,7 @@ const handleMouseUp = () => { v-for="item in systemStore.systemList" :key="item" :timestamp="JSON.stringify(item.content)" > - + {{ item.title }} diff --git a/src/libs/utils.ts b/src/libs/utils.ts index 9cf535b..547dfc4 100644 --- a/src/libs/utils.ts +++ b/src/libs/utils.ts @@ -11,7 +11,7 @@ export const sendControl = async (params: any, type: 'debug' | 'control' = 'cont systemStore.systemList = [] const cmdName = cmdNameMap[params.command as keyof typeof cmdNameMap] || params.command - await (type === 'debug' ? debugControl(params) : control(params)) + await (type === 'debug' ? debugControl(params) : control(params)) systemStore.updateStreamVisible(true) FtMessage.success(`[${cmdName}]已发送`) } diff --git a/src/stores/debugStore.ts b/src/stores/debugStore.ts index cf27124..56419b1 100644 --- a/src/stores/debugStore.ts +++ b/src/stores/debugStore.ts @@ -1,61 +1,61 @@ import { defineStore } from 'pinia' export const useDebugStore = defineStore('debug', { - state: () => ({ + state: (): Debug.DebugStore => ({ formData: { // 加液机械臂 liquidArmData: { - largeArmAngle: 10, - smallArmAngle: 20, - largeArmRotationRate: 10, - smallArmRotationRate: 10, + largeArmAngle: undefined, + smallArmAngle: undefined, + largeArmRotationRate: undefined, + smallArmRotationRate: undefined, }, // 加液泵 liquidPumpData: { - index: 1, - rate: 3, + index: undefined, + rate: undefined, }, // 摇匀速度 shakeSpeed: { - rate: 10, + rate: undefined, }, // 加热区 heatArea: { index: 1, heatMotorData: { - distance: 1, - rate: 10, + distance: undefined, + rate: undefined, }, heatTemperature: { - temperature: 20, + temperature: undefined, }, }, // 转运模组 transferModule: { // X轴 xMotorData: { - xDimDistance: 1, - xDimRate: 10, + xDimDistance: undefined, + xDimRate: undefined, }, // y轴 yMotorData: { - yDimDistance: 1, - yDimRate: 10, + yDimDistance: undefined, + yDimRate: undefined, }, // z轴 zMotorData: { - zDimDistance: 1, - zDimRate: 10, + zDimDistance: undefined, + zDimRate: undefined, }, // 夹爪 JawData: { - rate: 10, + rate: undefined, }, }, // 拍子模组 lidData: { - rate: 10, - distance: 19, + rate: undefined, + distance: undefined, }, }, }), diff --git a/src/stores/systemStore.ts b/src/stores/systemStore.ts index 00460d9..b053684 100644 --- a/src/stores/systemStore.ts +++ b/src/stores/systemStore.ts @@ -1,12 +1,9 @@ import { defineStore } from 'pinia' export const useSystemStore = defineStore('system', { - state: () => ({ + state: (): System.SystemStore => ({ systemStatus: { }, - systemSensor: { - humidity: 0, - }, isDebug: import.meta.env.FT_NODE_ENV === 'dev', streamVisible: false, systemList: [], diff --git a/src/types/System.d.ts b/src/types/System.d.ts new file mode 100644 index 0000000..722d2b9 --- /dev/null +++ b/src/types/System.d.ts @@ -0,0 +1,8 @@ +declare namespace System { + interface SystemStore { + systemStatus: any + systemList: Socket.NotificationData[] + streamVisible: boolean + isDebug: boolean + } +} diff --git a/src/types/debug.d.ts b/src/types/debug.d.ts new file mode 100644 index 0000000..a582734 --- /dev/null +++ b/src/types/debug.d.ts @@ -0,0 +1,74 @@ +declare namespace Debug { + interface DebugStore { + formData: FormData + } + interface FormData { + liquidArmData: LiquidArmData + liquidPumpData: LiquidPumpData + shakeSpeed: ShakeSpeed + heatArea: HeatArea + transferModule: TransferModule + lidData: LidData + } + interface LiquidArmData { + largeArmAngle: number | undefined + smallArmAngle: number | undefined + largeArmRotationRate: number | undefined + smallArmRotationRate: number | undefined + } + + interface LiquidPumpData { + index: number | undefined + rate: number | undefined + } + + interface ShakeSpeed { + rate: number | undefined + } + + interface HeatMotorData { + distance: number | undefined + rate: number | undefined + } + + interface HeatTemperature { + temperature: number | undefined + } + + interface HeatArea { + index: number | undefined + heatMotorData: HeatMotorData + heatTemperature: HeatTemperature + } + + interface XMotorData { + xDimDistance: number | undefined + xDimRate: number | undefined + } + + interface YMotorData { + yDimDistance: number | undefined + yDimRate: number | undefined + } + + interface ZMotorData { + zDimDistance: number | undefined + zDimRate: number | undefined + } + + interface JawData { + rate: number | undefined + } + + interface TransferModule { + xMotorData: XMotorData + yMotorData: YMotorData + zMotorData: ZMotorData + JawData: JawData + } + + interface LidData { + rate: number | undefined + distance: number | undefined + } +} diff --git a/src/types/socket.d.ts b/src/types/socket.d.ts new file mode 100644 index 0000000..200c6cc --- /dev/null +++ b/src/types/socket.d.ts @@ -0,0 +1,25 @@ +declare namespace Socket { + type Response = NotificationResponse | MachineStateResponse + + interface NotificationResponse { + type: 'notification' + data: NotificationData + } + + interface MachineStateResponse { + type: 'machineState' + data: MachineStateData + } + interface NotificationData { + commandId: string + command: string + level: string + title: string + content: string + dateTime: string + } + + type MachineStateData = MachineStateBase & { + [key: string]: any + } +} diff --git a/src/views/debug/index.vue b/src/views/debug/index.vue index e477a39..5c96c3e 100644 --- a/src/views/debug/index.vue +++ b/src/views/debug/index.vue @@ -17,7 +17,7 @@ onUnmounted(() => { socket.unregisterCallback(receiveMessage, 'notification') }) -const receiveMessage = (data: any) => { +const receiveMessage = (data: Socket.NotificationData) => { systemStore.pushSystemList(data) } @@ -340,14 +340,14 @@ const door_stop = async () => {
- + - + @@ -368,7 +368,7 @@ const door_stop = async () => {
- + @@ -420,14 +420,14 @@ const door_stop = async () => {
- + - + @@ -464,28 +464,28 @@ const door_stop = async () => {
- + - + - + - + @@ -507,14 +507,14 @@ const door_stop = async () => {
- + - + @@ -540,7 +540,7 @@ const door_stop = async () => {
- + @@ -608,14 +608,14 @@ const door_stop = async () => {
- + - + @@ -638,14 +638,14 @@ const door_stop = async () => {
- + - + @@ -668,14 +668,14 @@ const door_stop = async () => {
- + - + @@ -698,7 +698,7 @@ const door_stop = async () => {
- + @@ -772,6 +772,9 @@ const door_stop = async () => { :deep(.el-input-group__append) { padding: 0 10px; } +:deep(.el-card__header) { + background:rgba(0,0,0,0.03); +} .card-header { display: flex;