From 2b35e03fc03d1696d83e36f9a1b55463b076a6d4 Mon Sep 17 00:00:00 2001 From: guoapeng Date: Wed, 7 May 2025 14:09:07 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20interface=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/apis/login.ts | 7 ++----- src/apis/system.ts | 2 +- src/apis/user.ts | 7 +++++++ src/types/System.d.ts | 18 ------------------ src/types/socket.d.ts | 21 ++++++--------------- src/types/system.d.ts | 31 +++++++++++++++++++++++++++++++ src/types/user.d.ts | 17 +++++++++++++++++ 7 files changed, 64 insertions(+), 39 deletions(-) create mode 100644 src/apis/user.ts delete mode 100644 src/types/System.d.ts create mode 100644 src/types/system.d.ts create mode 100644 src/types/user.d.ts diff --git a/src/apis/login.ts b/src/apis/login.ts index c2818d1..369aeab 100644 --- a/src/apis/login.ts +++ b/src/apis/login.ts @@ -1,7 +1,4 @@ import http from 'libs/http' -export interface Login { - username: string - password: string -} -export const login = (params: Login): Promise => http.post('login', params) +export const login = (params: User.Login): Promise => http.post('/auth/login', params) +export const logout = (params: User.Login): Promise => http.post('/auth/logout', params) diff --git a/src/apis/system.ts b/src/apis/system.ts index 99fa143..2d86b3c 100644 --- a/src/apis/system.ts +++ b/src/apis/system.ts @@ -1,3 +1,3 @@ import http from 'libs/http' -export const debugControl = (params: System.CmdControlParams): Promise => http.post('/debug/cmd', params) +export const debugControl = (params: System.CmdControlParams): Promise => http.post('/debug/cmd', params) diff --git a/src/apis/user.ts b/src/apis/user.ts new file mode 100644 index 0000000..665bf9d --- /dev/null +++ b/src/apis/user.ts @@ -0,0 +1,7 @@ +import http from 'libs/http' + +export const current = (): Promise => http.get('/auth/current') +export const addUser = (params: User.User): Promise => http.post('/user', params) +export const updateUser = (params: User.User): Promise => http.put('/user', params) +export const userList = (params: System.Page): Promise> => http.get('/user/list', { params }) +export const delUser = (params: string): Promise => http.delete(`/user/${params}`) diff --git a/src/types/System.d.ts b/src/types/System.d.ts deleted file mode 100644 index 9aea243..0000000 --- a/src/types/System.d.ts +++ /dev/null @@ -1,18 +0,0 @@ -declare namespace System { - interface SystemStore { - systemStatus: any - systemList: Socket.NotificationData[] - streamVisible: boolean - isDebug: boolean - menuExpand: boolean - systemUser: SystemUser - } - interface CmdControlParams { - commandId: string - command: string - params: T - } - interface SystemUser { - username: string - } -} diff --git a/src/types/socket.d.ts b/src/types/socket.d.ts index 200c6cc..84064f9 100644 --- a/src/types/socket.d.ts +++ b/src/types/socket.d.ts @@ -1,25 +1,16 @@ declare namespace Socket { - type Response = NotificationResponse | MachineStateResponse + type Response = NotificationResponse - interface NotificationResponse { - type: 'notification' - data: NotificationData + interface cmdResponse { + type: 'cmd_debug' | 'cmd_response' + data: cmdData } - interface MachineStateResponse { - type: 'machineState' - data: MachineStateData - } - interface NotificationData { + interface cmdData { commandId: string command: string - level: string + status: 'receive' | 'start' | 'device_result' | 'device_send' | 'success' | 'error' | 'finish' title: string content: string - dateTime: string - } - - type MachineStateData = MachineStateBase & { - [key: string]: any } } diff --git a/src/types/system.d.ts b/src/types/system.d.ts new file mode 100644 index 0000000..9d8f1cb --- /dev/null +++ b/src/types/system.d.ts @@ -0,0 +1,31 @@ +declare namespace System { + interface SystemStore { + systemStatus: any + systemList: Socket.NotificationData[] + streamVisible: boolean + isDebug: boolean + menuExpand: boolean + systemUser: SystemUser + } + interface CmdControlParams { + commandId: string + command: string + params: T + } + interface SystemUser { + username: string + } + interface ApiResponse { + code: string + data: T + msg: string + } + interface Page { + pageNum: number + pageSize: number + } + interface PageResponse { + list: T[] + total: number + } +} diff --git a/src/types/user.d.ts b/src/types/user.d.ts new file mode 100644 index 0000000..06ac548 --- /dev/null +++ b/src/types/user.d.ts @@ -0,0 +1,17 @@ +declare namespace User { + interface User { + id: number + createTime: string + updateTime: string + username: string + nickname: string + password: string | null + role: string + deleted: string + fixedUser: string + } + interface Login { + username: string + password: string + } +}