Browse Source

fix: interface定义

feature/three
guoapeng 3 months ago
parent
commit
2b35e03fc0
  1. 7
      src/apis/login.ts
  2. 2
      src/apis/system.ts
  3. 7
      src/apis/user.ts
  4. 21
      src/types/socket.d.ts
  5. 13
      src/types/system.d.ts
  6. 17
      src/types/user.d.ts

7
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<any> => http.post('login', params)
export const login = (params: User.Login): Promise<User.User> => http.post('/auth/login', params)
export const logout = (params: User.Login): Promise<null> => http.post('/auth/logout', params)

2
src/apis/system.ts

@ -1,3 +1,3 @@
import http from 'libs/http'
export const debugControl = <T>(params: System.CmdControlParams<T>): Promise<any> => http.post('/debug/cmd', params)
export const debugControl = <T>(params: System.CmdControlParams<T>): Promise<null> => http.post('/debug/cmd', params)

7
src/apis/user.ts

@ -0,0 +1,7 @@
import http from 'libs/http'
export const current = (): Promise<User.User> => http.get('/auth/current')
export const addUser = (params: User.User): Promise<null> => http.post('/user', params)
export const updateUser = (params: User.User): Promise<null> => http.put('/user', params)
export const userList = (params: System.Page): Promise<System.PageResponse<User.User>> => http.get('/user/list', { params })
export const delUser = (params: string): Promise<null> => http.delete(`/user/${params}`)

21
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
}
}

13
src/types/System.d.ts → src/types/system.d.ts

@ -15,4 +15,17 @@ declare namespace System {
interface SystemUser {
username: string
}
interface ApiResponse<T> {
code: string
data: T
msg: string
}
interface Page {
pageNum: number
pageSize: number
}
interface PageResponse<T> {
list: T[]
total: number
}
}

17
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
}
}
Loading…
Cancel
Save