-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Expand file tree
/
Copy pathfunction-lib.ts
More file actions
132 lines (121 loc) · 2.93 KB
/
function-lib.ts
File metadata and controls
132 lines (121 loc) · 2.93 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
import { Result } from '@/request/Result'
import { get, post, del, put, exportFile } from '@/request/index'
import type { pageRequest } from '@/api/type/common'
import type { functionLibData } from '@/api/type/function-lib'
import { type Ref } from 'vue'
const prefix = '/function_lib'
/**
* 获取函数列表
* param {
"name": "string",
}
*/
const getAllFunctionLib: (param?: any, loading?: Ref<boolean>) => Promise<Result<any>> = (
param,
loading
) => {
return get(`${prefix}`, param || {}, loading)
}
/**
* 获取分页函数列表
* page {
"current_page": "string",
"page_size": "string",
}
* param {
"name": "string",
}
*/
const getFunctionLib: (
page: pageRequest,
param: any,
loading?: Ref<boolean>
) => Promise<Result<any>> = (page, param, loading) => {
return get(`${prefix}/${page.current_page}/${page.page_size}`, param, loading)
}
/**
* 创建函数
* @param 参数
*/
const postFunctionLib: (data: functionLibData, loading?: Ref<boolean>) => Promise<Result<any>> = (
data,
loading
) => {
return post(`${prefix}`, data, undefined, loading)
}
/**
* 修改函数
* @param 参数
*/
const putFunctionLib: (
function_lib_id: string,
data: functionLibData,
loading?: Ref<boolean>
) => Promise<Result<any>> = (function_lib_id, data, loading) => {
return put(`${prefix}/${function_lib_id}`, data, undefined, loading)
}
/**
* 调试函数
* @param 参数
*/
const postFunctionLibDebug: (data: any, loading?: Ref<boolean>) => Promise<Result<any>> = (
data: any,
loading
) => {
return post(`${prefix}/debug`, data, undefined, loading)
}
/**
* 删除函数
* @param 参数 function_lib_id
*/
const delFunctionLib: (
function_lib_id: String,
loading?: Ref<boolean>
) => Promise<Result<boolean>> = (function_lib_id, loading) => {
return del(`${prefix}/${function_lib_id}`, undefined, {}, loading)
}
/**
* 获取函数详情
* @param function_lib_id 函数id
* @param loading 加载器
* @returns 函数详情
*/
const getFunctionLibById: (
function_lib_id: String,
loading?: Ref<boolean>
) => Promise<Result<any>> = (function_lib_id, loading) => {
return get(`${prefix}/${function_lib_id}`, undefined, loading)
}
const pylint: (code: string, loading?: Ref<boolean>) => Promise<Result<any>> = (code, loading) => {
return post(`${prefix}/pylint`, { code }, {}, loading)
}
const exportFunctionLib = (
id: string,
name: string,
loading?: Ref<boolean>
) => {
return exportFile(
name + '.fx',
`${prefix}/${id}/export`,
undefined,
loading
)
}
const importFunctionLib: (data: any, loading?: Ref<boolean>) => Promise<Result<any>> = (
data,
loading
) => {
return post(`${prefix}/import`, data, undefined, loading)
}
export default {
getFunctionLib,
postFunctionLib,
putFunctionLib,
postFunctionLibDebug,
getAllFunctionLib,
delFunctionLib,
getFunctionLibById,
exportFunctionLib,
importFunctionLib,
pylint
}