index.ts
1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import type { CheckShareModeType, ConfigurationContentType, GetShareDataType } from './model'
import { useParseParams } from '@/core/LoadData/module/useParseParams'
import { defHttp } from '@/utils/http'
enum Api {
GET_CONTENT = '/configuration/center/get_configuration_info',
SAVE_CONTENT = '/configuration/content',
SHARE_LOGIN = '/auth/login/public',
SHARE_MODE_CHECK = '/share/check/SCADA/',
GET_SHARE_DATA = '/share/SCADA/share_data/',
APP_GET_TOKEN = '/third/login/id/',
}
export const getConfigurationContent = (id: string = useParseParams().configurationId) => {
return defHttp.get<ConfigurationContentType>({
url: `${Api.GET_CONTENT}/${id}`,
})
}
export const saveConfigurationContent = (params: ConfigurationContentType) => {
const { configurationContentList, configurationId, configurationName } = params
const defaultParams = useParseParams()
return defHttp.put({
url: Api.SAVE_CONTENT,
data: {
configurationName,
configurationId: configurationId || defaultParams.configurationId,
configurationContentList,
} as ConfigurationContentType,
})
}
export const getShareToken = (publicId: string) => {
return defHttp.post<Record<'token' | 'refreshToken', string>>({
url: Api.SHARE_LOGIN,
data: { publicId },
}, { joinPrefix: false })
}
export const checkShareModeNeedPassword = (id: string) => {
return defHttp.get<CheckShareModeType>({
url: `${Api.SHARE_MODE_CHECK}${id}`,
})
}
export const getShareDataByAccessCredentials = (id: string, accessCredentials?: string) => {
return defHttp.get<GetShareDataType>({
url: `${Api.GET_SHARE_DATA}${id}`,
params: { accessCredentials },
})
}
export const doAppLogin = (userId: string) => {
return defHttp.get<Record<'refreshToken' | 'token', string>>({
url: `${Api.APP_GET_TOKEN}${userId}`,
})
}