sun-form-v3 1.0.71 → 1.0.73
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/abap-DfvySaIJ.js +1404 -0
- package/dist/apex-B__0irD3.js +332 -0
- package/dist/assets/css.worker-OK053IOu.js +84 -0
- package/dist/assets/editor.worker-D9iUZyMP.js +11 -0
- package/dist/assets/html.worker-CL40hqKM.js +458 -0
- package/dist/assets/json.worker-6f9bhSHY.js +42 -0
- package/dist/assets/ts.worker-B6g3wjaE.js +37021 -0
- package/dist/azcli-CDMGhRmx.js +74 -0
- package/dist/bat-0Mk8aqzx.js +106 -0
- package/dist/bicep-BBi_I06Z.js +108 -0
- package/dist/cameligo-D0G_Zm6X.js +180 -0
- package/dist/clojure-o2ZKLeMp.js +767 -0
- package/dist/coffee-DOQff5VC.js +238 -0
- package/dist/cpp-CQGJnWhD.js +395 -0
- package/dist/csharp-C1jLsHl8.js +332 -0
- package/dist/csp-C_ttMQaW.js +59 -0
- package/dist/css-BC202kVV.js +193 -0
- package/dist/cssMode-BXBciaWt.js +1541 -0
- package/dist/cypher-DwtEH7Fi.js +269 -0
- package/dist/dart-D9XknsP2.js +287 -0
- package/dist/dockerfile-DgsNjqqa.js +136 -0
- package/dist/ecl-BAMCHBl6.js +462 -0
- package/dist/elixir-CegIttP8.js +575 -0
- package/dist/favicon.ico +0 -0
- package/dist/flow9-9608t7UV.js +148 -0
- package/dist/freemarker2-CmygUpuu.js +995 -0
- package/dist/fsharp-CCtt9-1_.js +223 -0
- package/dist/go-CGUIPbct.js +224 -0
- package/dist/graphql-BNRIFFIn.js +157 -0
- package/dist/handlebars-DQf1H2VV.js +425 -0
- package/dist/hcl-C__KLIXe.js +189 -0
- package/dist/html-Xh9UOPja.js +314 -0
- package/dist/htmlMode-B0QDpKvf.js +1551 -0
- package/dist/index-BkAjoBLc.js +122298 -0
- package/dist/ini-CeKYn_zA.js +77 -0
- package/dist/java-Dm24deQl.js +238 -0
- package/dist/javascript-lDZ3h7g8.js +76 -0
- package/dist/jsonMode-C5XJ2eKG.js +1957 -0
- package/dist/julia-BImNW7VE.js +517 -0
- package/dist/kotlin-BfE79GEb.js +259 -0
- package/dist/less-DglNOcaC.js +168 -0
- package/dist/lexon-BA0dRz9Q.js +163 -0
- package/dist/liquid-Cjj1frmx.js +246 -0
- package/dist/lua-DMkWzJcm.js +168 -0
- package/dist/m3-sA-5shO8.js +216 -0
- package/dist/markdown-OYRB1igA.js +235 -0
- package/dist/mdx-CzfefEJ-.js +171 -0
- package/dist/mips-rRzkJ_7G.js +204 -0
- package/dist/msdax-DoVJdUhd.js +381 -0
- package/dist/mysql-Ty44IHXo.js +884 -0
- package/dist/objective-c-VUfyhYrA.js +189 -0
- package/dist/pascal-DkASiYyw.js +257 -0
- package/dist/pascaligo-p-ELPlVO.js +170 -0
- package/dist/perl-Cjl1FxLZ.js +632 -0
- package/dist/pgsql-DjVenF7s.js +857 -0
- package/dist/php-CwvGzZOO.js +506 -0
- package/dist/pla-Br1iaBIV.js +143 -0
- package/dist/postiats-BaeP8zZY.js +913 -0
- package/dist/powerquery-CLCshuo8.js +896 -0
- package/dist/powershell-CZV50w5N.js +245 -0
- package/dist/protobuf-MV3XTewJ.js +426 -0
- package/dist/pug-DkDg4c4l.js +408 -0
- package/dist/python-DyY6ldcy.js +282 -0
- package/dist/qsharp-BAtiKA97.js +291 -0
- package/dist/r-8ocrd-h-.js +249 -0
- package/dist/razor-Bg8q70Ua.js +556 -0
- package/dist/redis-9sZiddxc.js +308 -0
- package/dist/redshift-DQfTOGC0.js +815 -0
- package/dist/restructuredtext-DXU-vkgr.js +180 -0
- package/dist/ruby-DotfqwMf.js +517 -0
- package/dist/rust-BIauJ5KN.js +349 -0
- package/dist/sb-CmWMvDEV.js +121 -0
- package/dist/scala-C81brEbk.js +376 -0
- package/dist/scheme-D0pcFz2x.js +114 -0
- package/dist/scss-BOdN2fGG.js +268 -0
- package/dist/shell-6E09eAkU.js +227 -0
- package/dist/solidity-CWStzA1K.js +1373 -0
- package/dist/sophia-76Sb6CWe.js +205 -0
- package/dist/sparql-BmZTkOWT.js +207 -0
- package/dist/sql-Cs9TBAW5.js +859 -0
- package/dist/st-B-rqE1Bu.js +422 -0
- package/dist/style.css +1 -0
- package/dist/sun-form-v3.es.js +4 -0
- package/dist/sun-form-v3.umd.js +1905 -0
- package/dist/swift-Btsj6YxQ.js +318 -0
- package/dist/systemverilog-B3RHBRa2.js +582 -0
- package/dist/tcl-Dpj776pn.js +238 -0
- package/dist/tsMode-CRd35KrT.js +886 -0
- package/dist/twig-Bb9JmBsE.js +398 -0
- package/dist/typescript-BYlzZUqk.js +349 -0
- package/dist/typespec-CDWeg3SU.js +123 -0
- package/dist/vb-DEXnYwEI.js +378 -0
- package/dist/wgsl-D602c1lx.js +445 -0
- package/dist/xml-CuwYh5uN.js +101 -0
- package/dist/yaml-CpETH-QO.js +212 -0
- package/package.json +7 -10
- package/src/App.vue +0 -9
- package/src/assets/font/YouSheBiaoTiHei-2.ttf +0 -0
- package/src/assets/font/demo.css +0 -539
- package/src/assets/font/demo_index.html +0 -1200
- package/src/assets/font/iconfont.css +0 -191
- package/src/assets/font/iconfont.js +0 -1
- package/src/assets/font/iconfont.json +0 -317
- package/src/assets/font/iconfont.ttf +0 -0
- package/src/assets/font/iconfont.woff +0 -0
- package/src/assets/font/iconfont.woff2 +0 -0
- package/src/assets/img/bg_footer.png +0 -0
- package/src/assets/img/bg_title.png +0 -0
- package/src/assets/img/file.png +0 -0
- package/src/assets/img/logo.png +0 -0
- package/src/assets/img/logo2.png +0 -0
- package/src/assets/img/logo22.png +0 -0
- package/src/assets/img/logo23.png +0 -0
- package/src/assets/img/logo3.png +0 -0
- package/src/assets/img//347/237/251/345/275/242@2x.png +0 -0
- package/src/assets/logo.svg +0 -1
- package/src/assets/styles/element/index.scss +0 -15
- package/src/assets/styles/index.css +0 -3
- package/src/components/a.js +0 -14
- package/src/components/aDesigner/config.vue +0 -127
- package/src/components/aDesigner/design.vue +0 -20
- package/src/components/aDesigner/index.vue +0 -144
- package/src/components/aDesigner/panel.vue +0 -144
- package/src/components/aDesigner/show.vue +0 -24
- package/src/components/widgetCommonComps/commonApiConfig/index.vue +0 -194
- package/src/components/widgetCommonComps/commonCard/index.vue +0 -36
- package/src/components/widgetCommonComps/commonCodeEditor/editor.vue +0 -219
- package/src/components/widgetCommonComps/commonCodeEditor/modalEditor.vue +0 -68
- package/src/components/widgetCommonComps/commonCollapseCard/index.vue +0 -10
- package/src/components/widgetCommonComps/commonContainer/index.vue +0 -95
- package/src/components/widgetCommonComps/commonJsonInput/index.vue +0 -59
- package/src/components/widgetCommonComps/commonLabelContainer/index.vue +0 -39
- package/src/components/widgetCommonComps/commonSidetree/index.vue +0 -61
- package/src/components/widgetCommonComps/commonTypeInput/index.vue +0 -75
- package/src/components/widgetCommonComps/commonWidgetLabelContainer/index.vue +0 -55
- package/src/components/widgetCommonComps/index copy.js +0 -17
- package/src/components/widgetCommonComps/index.js +0 -17
- package/src/components/widgetConfigComps/config-input/index.vue +0 -60
- package/src/components/widgetConfigComps/index copy.js +0 -13
- package/src/components/widgetConfigComps/index.js +0 -17
- package/src/components/widgetShowComps/index.js +0 -29
- package/src/components/widgetShowComps/widget-form/index.vue +0 -43
- package/src/components/widgetShowComps/widget-homepage/index.vue +0 -41
- package/src/components/widgetShowComps/widget-input/index.vue +0 -85
- package/src/components/widgetShowComps/widget-select/index.vue +0 -31
- package/src/designer.js +0 -342
- package/src/http.js +0 -293
- package/src/index.js +0 -24
- package/src/index2.js +0 -23
- package/src/main.js +0 -19
- package/src/remark.js +0 -708
- package/src/testBtn.vue +0 -11
- package/src/testInput.vue +0 -12
- package/src/util/jsformat.js +0 -568
- package/src/widgetConfig.js +0 -1112
package/src/designer.js
DELETED
@@ -1,342 +0,0 @@
|
|
1
|
-
import XEUtils from "xe-utils"
|
2
|
-
import Http from './http'
|
3
|
-
import {
|
4
|
-
ElNotification
|
5
|
-
} from 'element-plus'
|
6
|
-
import {
|
7
|
-
reactive,
|
8
|
-
ref,
|
9
|
-
watch
|
10
|
-
} from 'vue'
|
11
|
-
/**
|
12
|
-
* 设计器类,用于管理组件配置和交互
|
13
|
-
* @class Designer
|
14
|
-
* @param {Object} options 初始化选项,包含组件配置
|
15
|
-
*/
|
16
|
-
class Designer {
|
17
|
-
constructor({
|
18
|
-
widgetConfig,
|
19
|
-
showMode = false
|
20
|
-
}) {
|
21
|
-
/**
|
22
|
-
* 渲染器模式
|
23
|
-
*/
|
24
|
-
this.showMode = ref(showMode)
|
25
|
-
/**
|
26
|
-
* 反向响应式的组件配置对象
|
27
|
-
*/
|
28
|
-
this.widgetConfig = reactive(widgetConfig);
|
29
|
-
/**
|
30
|
-
* XEUtils 工具库实例
|
31
|
-
*/
|
32
|
-
this.$utils = XEUtils;
|
33
|
-
/**
|
34
|
-
* 组件映射表,用于快速查找组件
|
35
|
-
*/
|
36
|
-
this.widgetMap = new Map();
|
37
|
-
/**
|
38
|
-
* Vue 实例映射表,用于快速查找 Vue 实例
|
39
|
-
*/
|
40
|
-
this.vueInstanceMap = new Map();
|
41
|
-
/**
|
42
|
-
* 组件ID列表
|
43
|
-
*/
|
44
|
-
this.widgetIds = [];
|
45
|
-
/**
|
46
|
-
* 当前选中的组件引用
|
47
|
-
*/
|
48
|
-
this.chosenWidget = ref(null);
|
49
|
-
/**
|
50
|
-
* 操作历史列表
|
51
|
-
*/
|
52
|
-
this.historyList = [];
|
53
|
-
/**
|
54
|
-
* 操作历史索引
|
55
|
-
*/
|
56
|
-
this.historyIndex = ref(0);
|
57
|
-
/**
|
58
|
-
* 标记是否在操作历史中
|
59
|
-
*/
|
60
|
-
this.isHistory = false;
|
61
|
-
/**
|
62
|
-
* Http服务实例,用于发起请求
|
63
|
-
*/
|
64
|
-
this.$http = new Http({
|
65
|
-
baseUrl: "/api"
|
66
|
-
});
|
67
|
-
/**
|
68
|
-
* 根据组件配置构建组件映射表
|
69
|
-
*/
|
70
|
-
this.buildWidgetMap(this.widgetConfig);
|
71
|
-
/**
|
72
|
-
* 监听组件配置的变化,重建组件映射表,并更新选中组件
|
73
|
-
*/
|
74
|
-
watch(() => this.widgetConfig, (val) => {
|
75
|
-
this.rebuildWidgetMap();
|
76
|
-
this.chosenWidget.value = this.getWidgetById(this.widgetConfig.chosenId);
|
77
|
-
}, {
|
78
|
-
deep: true,
|
79
|
-
immediate: true
|
80
|
-
});
|
81
|
-
/**
|
82
|
-
* 监听组件列表的变化,记录操作历史
|
83
|
-
*/
|
84
|
-
watch(() => this.widgetConfig.widgetList, (val) => {
|
85
|
-
if (!this.isHistory) {
|
86
|
-
this.historyList.push({
|
87
|
-
widgetConfig: this.$utils.clone(this.widgetConfig, true),
|
88
|
-
time: this.$utils.toDateString(new Date(), 'HH:mm:ss'),
|
89
|
-
index: this.historyList.length
|
90
|
-
});
|
91
|
-
this.historyIndex.value = this.historyList.length - 1;
|
92
|
-
} else {
|
93
|
-
this.isHistory = false;
|
94
|
-
}
|
95
|
-
}, {
|
96
|
-
deep: true,
|
97
|
-
immediate: true
|
98
|
-
});
|
99
|
-
}
|
100
|
-
eventHandle({
|
101
|
-
value = null,
|
102
|
-
eventType,
|
103
|
-
widget,
|
104
|
-
tableItemData
|
105
|
-
}) {
|
106
|
-
if (!this.showMode) return;
|
107
|
-
if (widget.props[eventType]) {
|
108
|
-
let funcstr = widget.props[eventType]
|
109
|
-
let func = new Function('value', 'widget','self','app', funcstr);
|
110
|
-
func(value, widget, this.getVueInstance(widget.id), this)
|
111
|
-
}
|
112
|
-
}
|
113
|
-
/**
|
114
|
-
* 设置vue实例
|
115
|
-
*/
|
116
|
-
setVueIncetance(id, vueInstance) {
|
117
|
-
this.vueInstanceMap.set(id, vueInstance);
|
118
|
-
}
|
119
|
-
/**
|
120
|
-
* 获取vue实例
|
121
|
-
*/
|
122
|
-
getVueInstance(id) {
|
123
|
-
return this.vueInstanceMap.get(id);
|
124
|
-
}
|
125
|
-
/**
|
126
|
-
* 设置当前选中的组件
|
127
|
-
* @param {Object} chosenWidget 选中的组件对象
|
128
|
-
*/
|
129
|
-
setChosenWidget(chosenWidget) {
|
130
|
-
this.chosenWidget.value = chosenWidget;
|
131
|
-
}
|
132
|
-
/**
|
133
|
-
* 根据组件的apiSet配置发起请求
|
134
|
-
* @param {Object} widget 当前组件对象
|
135
|
-
*/
|
136
|
-
requestByApisetConfig(widget) {
|
137
|
-
let apiSet = widget.props.apiSet;
|
138
|
-
if (!apiSet || !apiSet.apiurl) {
|
139
|
-
return;
|
140
|
-
}
|
141
|
-
let params = {};
|
142
|
-
let headers = {};
|
143
|
-
let method = apiSet.method;
|
144
|
-
if (apiSet.contentType == "FormData") {
|
145
|
-
if (method == "post" || method == "put" || method == "patch") {
|
146
|
-
method += "FormData";
|
147
|
-
}
|
148
|
-
}
|
149
|
-
if (apiSet.params.length) {
|
150
|
-
apiSet.params.forEach(e => {
|
151
|
-
params[e.label] = e.value;
|
152
|
-
});
|
153
|
-
}
|
154
|
-
if (apiSet.headers.length) {
|
155
|
-
apiSet.headers.forEach(e => {
|
156
|
-
headers[e.label] = e.value;
|
157
|
-
});
|
158
|
-
}
|
159
|
-
if (apiSet.paramsFormat) {
|
160
|
-
let fun = new Function("params", "widget", "app", apiSet.paramsFormat);
|
161
|
-
let paramData = this.$utils.clone(params, true);
|
162
|
-
var funcData = fun(paramData, widget, this);
|
163
|
-
if (funcData && typeof this.$utils.isPlainObject(funcData)) {
|
164
|
-
params = funcData;
|
165
|
-
}
|
166
|
-
}
|
167
|
-
if (apiSet.headersFormat) {
|
168
|
-
let fun = new Function("headers", "widget", "app", apiSet.headersFormat);
|
169
|
-
let headerData = this.$utils.clone(headers, true);
|
170
|
-
var funcData = fun(headerData, widget, this);
|
171
|
-
if (funcData && typeof this.$utils.isPlainObject(funcData)) {
|
172
|
-
headers = funcData;
|
173
|
-
}
|
174
|
-
}
|
175
|
-
this.$http[method](apiSet.apiurl, params, headers)
|
176
|
-
.then(res => {
|
177
|
-
if (apiSet.successFormat) {
|
178
|
-
let fun = new Function("res", "widget", "app", apiSet.successFormat);
|
179
|
-
fun(res, widget, this);
|
180
|
-
}
|
181
|
-
})
|
182
|
-
.catch(err => {
|
183
|
-
if (apiSet.errorFormat) {
|
184
|
-
let fun = new Function("error", "widget", "app", apiSet.errorFormat);
|
185
|
-
fun(err, widget, this);
|
186
|
-
}
|
187
|
-
});
|
188
|
-
}
|
189
|
-
/**
|
190
|
-
* 根据ID获取组件
|
191
|
-
* @param {String} id 组件ID
|
192
|
-
* @returns {Object|null} 组件对象或null(如果未找到)
|
193
|
-
*/
|
194
|
-
getWidgetById(id) {
|
195
|
-
return this.widgetMap.get(id);
|
196
|
-
}
|
197
|
-
/**
|
198
|
-
* 根据历史索引更新组件配置
|
199
|
-
* @param {Object} updates 更新的对象
|
200
|
-
*/
|
201
|
-
updateByHistory(updates) {
|
202
|
-
this.isHistory = true;
|
203
|
-
this.$utils.destructuring(this.widgetConfig, updates);
|
204
|
-
}
|
205
|
-
/**
|
206
|
-
* 更新组件的属性
|
207
|
-
* @param {String} id 组件ID
|
208
|
-
* @param {Object} updates 更新的对象
|
209
|
-
* @param {Boolean} force 是否强制更新,即使存在相同的ID
|
210
|
-
*/
|
211
|
-
updateWidget(id, updates, force) {
|
212
|
-
const widget = this.getWidgetById(id);
|
213
|
-
if (widget) {
|
214
|
-
console.log('widget', widget);
|
215
|
-
console.log('updates', updates);
|
216
|
-
if (widget.id !== updates.id) {
|
217
|
-
if (this.widgetIds.includes(updates.id) && !force) {
|
218
|
-
ElNotification.warning('已经存在相同的id的组件,组件id不允许重复');
|
219
|
-
return;
|
220
|
-
}
|
221
|
-
}
|
222
|
-
if (id === 'homepage') {
|
223
|
-
if (updates.id !== id) {
|
224
|
-
ElNotification.warning('主页面的id不允许修改');
|
225
|
-
}
|
226
|
-
updates.id = updates.type = 'homepage';
|
227
|
-
}
|
228
|
-
this.$utils.destructuring(widget, updates);
|
229
|
-
} else {
|
230
|
-
console.warn(`Widget with id ${id} not found.`);
|
231
|
-
}
|
232
|
-
}
|
233
|
-
/**
|
234
|
-
* 重建组件映射表
|
235
|
-
*/
|
236
|
-
rebuildWidgetMap() {
|
237
|
-
this.widgetMap.clear();
|
238
|
-
this.widgetIds = [];
|
239
|
-
this.buildWidgetMap(this.widgetConfig);
|
240
|
-
}
|
241
|
-
/**
|
242
|
-
* 递归构建组件映射表
|
243
|
-
* @param {Object} widget 当前组件对象
|
244
|
-
*/
|
245
|
-
buildWidgetMap(widget) {
|
246
|
-
this.widgetMap.set(widget.id, widget);
|
247
|
-
this.widgetIds.push(widget.id);
|
248
|
-
if (widget.widgetList && widget.widgetList.length) {
|
249
|
-
widget.widgetList.forEach(widget => {
|
250
|
-
this.buildWidgetMap(widget);
|
251
|
-
});
|
252
|
-
}
|
253
|
-
}
|
254
|
-
/**
|
255
|
-
* 设置当前选中的组件ID
|
256
|
-
* @param {String} id 组件ID
|
257
|
-
*/
|
258
|
-
setChosenId(id) {
|
259
|
-
this.widgetConfig.chosenId = id;
|
260
|
-
}
|
261
|
-
/**
|
262
|
-
* 获取当前选中的组件ID
|
263
|
-
* @returns {String} 当前选中的组件ID
|
264
|
-
*/
|
265
|
-
getChosenId() {
|
266
|
-
return this.widgetConfig.chosenId;
|
267
|
-
}
|
268
|
-
/**
|
269
|
-
* 获取初始化的数据对象
|
270
|
-
* @param {Object} obj 初始数据对象
|
271
|
-
* @returns {Object} 处理后的初始数据对象
|
272
|
-
*/
|
273
|
-
getChosenInitData(obj) {
|
274
|
-
obj = this.$utils.clone(obj, true);
|
275
|
-
obj.id = this.getUniqueId(obj.type);
|
276
|
-
this.setChosenId(obj.id);
|
277
|
-
let delkeyArr = ['isForm', 'canAddDataTableQuery', 'canAddDataTableList', 'addToPanel', 'active'];
|
278
|
-
let delkey = (key) => {
|
279
|
-
delete obj[key];
|
280
|
-
}
|
281
|
-
delkeyArr.forEach(e => {
|
282
|
-
delkey(e);
|
283
|
-
});
|
284
|
-
return obj;
|
285
|
-
}
|
286
|
-
/**
|
287
|
-
* 生成唯一的ID
|
288
|
-
* @param {String} prefix ID前缀
|
289
|
-
* @returns {String} 唯一的ID
|
290
|
-
*/
|
291
|
-
getUniqueId(prefix) {
|
292
|
-
return prefix + '_' + Math.floor(new Date().getTime() % 100000) + "" + this.$utils.uniqueId();
|
293
|
-
}
|
294
|
-
/**
|
295
|
-
* 获取组件列表
|
296
|
-
* @returns {Array} 组件列表
|
297
|
-
*/
|
298
|
-
getWidgetList() {
|
299
|
-
return this.widgetConfig.widgetList;
|
300
|
-
}
|
301
|
-
/**
|
302
|
-
* 获取组件配置
|
303
|
-
* @returns {Object} 组件配置对象
|
304
|
-
*/
|
305
|
-
getWidgetConfig() {
|
306
|
-
return this.widgetConfig;
|
307
|
-
}
|
308
|
-
/**
|
309
|
-
* 更新组件配置
|
310
|
-
* @param {Object} config 新的组件配置
|
311
|
-
*/
|
312
|
-
updateWidgetConfig(config) {
|
313
|
-
this.widgetConfig = config;
|
314
|
-
}
|
315
|
-
/**
|
316
|
-
* 根据组件ID查找其父组件
|
317
|
-
* @param {String} id 组件ID
|
318
|
-
* @returns {Object|null} 父组件对象或null(如果未找到)
|
319
|
-
*/
|
320
|
-
getParentWidgetById(id) {
|
321
|
-
function recurse(items) {
|
322
|
-
for (const item of items) {
|
323
|
-
if (item.id === id) {
|
324
|
-
let index = items.findIndex(e => e.id === id);
|
325
|
-
return {
|
326
|
-
widgetList: items,
|
327
|
-
index: index
|
328
|
-
};
|
329
|
-
}
|
330
|
-
if (item.widgetList && item.widgetList.length > 0) {
|
331
|
-
const activeItem = recurse(item.widgetList);
|
332
|
-
if (activeItem) {
|
333
|
-
return activeItem;
|
334
|
-
}
|
335
|
-
}
|
336
|
-
}
|
337
|
-
return null;
|
338
|
-
}
|
339
|
-
return recurse(this.widgetConfig.widgetList);
|
340
|
-
}
|
341
|
-
}
|
342
|
-
export default Designer;
|
package/src/http.js
DELETED
@@ -1,293 +0,0 @@
|
|
1
|
-
import axios from 'axios'
|
2
|
-
// import qs from 'qs'
|
3
|
-
import XEUtils from 'xe-utils/index'
|
4
|
-
import {
|
5
|
-
ElNotification
|
6
|
-
} from 'element-plus'
|
7
|
-
/**
|
8
|
-
* Http类用于封装HTTP请求
|
9
|
-
* 提供了多种请求方法,如GET、POST、PUT、DELETE等
|
10
|
-
* 支持设置基础URL、请求头、超时时间等选项
|
11
|
-
* 可以自定义请求成功和失败的处理函数
|
12
|
-
*/
|
13
|
-
class Http {
|
14
|
-
/**
|
15
|
-
* 构造函数初始化Http对象
|
16
|
-
* @param {Object} options 配置选项,包括baseUrl、headers、timeout、httpSuccessHandle、httpErrorHandle、httpBeforeSendHandle
|
17
|
-
*/
|
18
|
-
constructor({
|
19
|
-
baseUrl = "",
|
20
|
-
headers = {},
|
21
|
-
timeout = 1000000,
|
22
|
-
httpSuccessHandle = null,
|
23
|
-
httpErrorHandle = null,
|
24
|
-
httpBeforeSendHandle = null
|
25
|
-
}) {
|
26
|
-
this.options = {
|
27
|
-
baseUrl,
|
28
|
-
headers,
|
29
|
-
timeout,
|
30
|
-
httpSuccessHandle,
|
31
|
-
httpErrorHandle,
|
32
|
-
httpBeforeSendHandle
|
33
|
-
}
|
34
|
-
// 定义不同Content-Type的headers
|
35
|
-
this.formDataHeader = {
|
36
|
-
'Content-Type': 'application/x-www-form-urlencoded'
|
37
|
-
}
|
38
|
-
this.formFileHeader = {
|
39
|
-
'Content-Type': 'multipart/form-data'
|
40
|
-
}
|
41
|
-
this.jsonHeader = {
|
42
|
-
'Content-Type': 'application/json'
|
43
|
-
}
|
44
|
-
}
|
45
|
-
|
46
|
-
/**
|
47
|
-
* 处理请求参数
|
48
|
-
* @param {any} data 请求参数
|
49
|
-
* @returns 处理后的请求参数
|
50
|
-
*/
|
51
|
-
paramHandle(data) {
|
52
|
-
// 如果data是数组,直接返回
|
53
|
-
if (data instanceof Array) {
|
54
|
-
return data;
|
55
|
-
}
|
56
|
-
// 如果data不是对象,直接返回
|
57
|
-
if (typeof data !== 'object') {
|
58
|
-
return data
|
59
|
-
}
|
60
|
-
// 如果data存在,返回合并后的对象
|
61
|
-
if (data) {
|
62
|
-
return Object.assign({}, this.httpBeforeSendHandle ? this.httpBeforeSendHandle() || {} : {}, data)
|
63
|
-
} else {
|
64
|
-
// 如果data不存在,仅返回httpBeforeSendHandle处理的结果
|
65
|
-
return this.httpBeforeSendHandle()
|
66
|
-
}
|
67
|
-
}
|
68
|
-
|
69
|
-
/**
|
70
|
-
* 发送请求
|
71
|
-
* @param {Object} config 请求配置,包括url、method、params、data、headers等
|
72
|
-
* @returns 返回axios发送请求的Promise
|
73
|
-
*/
|
74
|
-
send(config) {
|
75
|
-
// 创建axios实例
|
76
|
-
const api = axios.create({
|
77
|
-
baseURL: this.options.baseUrl,
|
78
|
-
timeout: this.options.timeout,
|
79
|
-
responseType: 'json'
|
80
|
-
})
|
81
|
-
// 请求拦截器,设置请求头
|
82
|
-
api.interceptors.request.use(
|
83
|
-
request => {
|
84
|
-
if (this.options.headers) {
|
85
|
-
for (var key in this.options.headers) {
|
86
|
-
request.headers[key] = headers[key]
|
87
|
-
}
|
88
|
-
}
|
89
|
-
return request
|
90
|
-
}
|
91
|
-
)
|
92
|
-
// 响应拦截器,处理请求成功和失败的情况
|
93
|
-
api.interceptors.response.use(
|
94
|
-
response => {
|
95
|
-
if (this.options.httpSuccessHandle) {
|
96
|
-
this.options.httpSuccessHandle(response.data)
|
97
|
-
}
|
98
|
-
return Promise.resolve(response.data)
|
99
|
-
},
|
100
|
-
error => {
|
101
|
-
if (this.options.httpErrorHandle) {
|
102
|
-
this.options.httpErrorHandle(error)
|
103
|
-
}
|
104
|
-
ElNotification({
|
105
|
-
title: '消息',
|
106
|
-
message: '数据请求失败',
|
107
|
-
type: 'error'
|
108
|
-
})
|
109
|
-
return Promise.reject(error)
|
110
|
-
}
|
111
|
-
)
|
112
|
-
// 发送请求
|
113
|
-
return api(config)
|
114
|
-
}
|
115
|
-
|
116
|
-
/**
|
117
|
-
* 发送GET请求
|
118
|
-
* @param {string} url 请求URL
|
119
|
-
* @param {any} data 请求参数
|
120
|
-
* @param {Object} headers 请求头
|
121
|
-
* @returns 返回发送GET请求的Promise
|
122
|
-
*/
|
123
|
-
get(url, data, headers) { //get请求
|
124
|
-
return this.send({
|
125
|
-
url: url,
|
126
|
-
method: 'get',
|
127
|
-
params: this.paramHandle(data),
|
128
|
-
headers: headers
|
129
|
-
})
|
130
|
-
}
|
131
|
-
|
132
|
-
/**
|
133
|
-
* 发送GET请求,返回Blob类型数据
|
134
|
-
* @param {string} url 请求URL
|
135
|
-
* @param {any} data 请求参数
|
136
|
-
* @param {Object} headers 请求头
|
137
|
-
* @returns 返回发送GET请求的Promise
|
138
|
-
*/
|
139
|
-
getBlob(url, data, headers) { //get请求
|
140
|
-
return this.send({
|
141
|
-
url: url,
|
142
|
-
method: 'get',
|
143
|
-
responseType: 'blob',
|
144
|
-
params: this.paramHandle(data),
|
145
|
-
headers: headers
|
146
|
-
})
|
147
|
-
}
|
148
|
-
|
149
|
-
/**
|
150
|
-
* 发送POST请求
|
151
|
-
* @param {string} url 请求URL
|
152
|
-
* @param {any} data 请求参数
|
153
|
-
* @param {Object} headers 请求头
|
154
|
-
* @returns 返回发送POST请求的Promise
|
155
|
-
*/
|
156
|
-
post(url, data, headers = {}) { //post请求
|
157
|
-
return this.send({
|
158
|
-
url: url,
|
159
|
-
method: 'post',
|
160
|
-
data: this.paramHandle(data),
|
161
|
-
headers: {
|
162
|
-
...headers,
|
163
|
-
...this.jsonHeader
|
164
|
-
}
|
165
|
-
})
|
166
|
-
}
|
167
|
-
|
168
|
-
/**
|
169
|
-
* 发送PUT请求
|
170
|
-
* @param {string} url 请求URL
|
171
|
-
* @param {any} data 请求参数
|
172
|
-
* @param {Object} headers 请求头
|
173
|
-
* @returns 返回发送PUT请求的Promise
|
174
|
-
*/
|
175
|
-
put(url, data, headers) { //put请求
|
176
|
-
return this.send({
|
177
|
-
url: url,
|
178
|
-
method: 'put',
|
179
|
-
data: this.paramHandle(data),
|
180
|
-
headers: headers
|
181
|
-
})
|
182
|
-
}
|
183
|
-
|
184
|
-
/**
|
185
|
-
* 发送PATCH请求
|
186
|
-
* @param {string} url 请求URL
|
187
|
-
* @param {any} data 请求参数
|
188
|
-
* @param {Object} headers 请求头
|
189
|
-
* @returns 返回发送PATCH请求的Promise
|
190
|
-
*/
|
191
|
-
patch(url, data, headers) { //patch请求
|
192
|
-
return this.send({
|
193
|
-
url: url,
|
194
|
-
method: 'patch',
|
195
|
-
data: this.paramHandle(data),
|
196
|
-
headers: headers
|
197
|
-
})
|
198
|
-
}
|
199
|
-
|
200
|
-
/**
|
201
|
-
* 发送DELETE请求
|
202
|
-
* @param {string} url 请求URL
|
203
|
-
* @param {any} data 请求参数
|
204
|
-
* @param {Object} headers 请求头
|
205
|
-
* @returns 返回发送DELETE请求的Promise
|
206
|
-
*/
|
207
|
-
delete(url, data, headers) { //delete请求
|
208
|
-
return this.send({
|
209
|
-
url: url,
|
210
|
-
method: 'delete',
|
211
|
-
params: this.paramHandle(data),
|
212
|
-
headers: headers
|
213
|
-
})
|
214
|
-
}
|
215
|
-
|
216
|
-
/**
|
217
|
-
* 发送使用FormData的POST请求
|
218
|
-
* @param {string} url 请求URL
|
219
|
-
* @param {any} data 请求参数
|
220
|
-
* @param {Object} headers 请求头
|
221
|
-
* @returns 返回发送POST请求的Promise
|
222
|
-
*/
|
223
|
-
postFormData(url, data, headers) { //formdata的post请求
|
224
|
-
return this.send({
|
225
|
-
url: url,
|
226
|
-
method: 'post',
|
227
|
-
data: XEUtils.serialize(this.paramHandle(data)),
|
228
|
-
headers: {
|
229
|
-
...this.formDataHeader,
|
230
|
-
...headers
|
231
|
-
}
|
232
|
-
})
|
233
|
-
}
|
234
|
-
|
235
|
-
/**
|
236
|
-
* 发送上传文件的POST请求
|
237
|
-
* @param {string} url 请求URL
|
238
|
-
* @param {any} data 请求参数
|
239
|
-
* @param {Object} headers 请求头
|
240
|
-
* @returns 返回发送POST请求的Promise
|
241
|
-
*/
|
242
|
-
postFile(url, data, headers) { //formdata的post请求
|
243
|
-
return this.send({
|
244
|
-
url: url,
|
245
|
-
method: 'post',
|
246
|
-
data: data,
|
247
|
-
headers: {
|
248
|
-
...this.formDataHeader,
|
249
|
-
...headers
|
250
|
-
}
|
251
|
-
})
|
252
|
-
}
|
253
|
-
|
254
|
-
/**
|
255
|
-
* 发送使用FormData的PUT请求
|
256
|
-
* @param {string} url 请求URL
|
257
|
-
* @param {any} data 请求参数
|
258
|
-
* @param {Object} headers 请求头
|
259
|
-
* @returns 返回发送PUT请求的Promise
|
260
|
-
*/
|
261
|
-
putFormData(url, data, headers) { //formdata的put请求
|
262
|
-
return this.send({
|
263
|
-
url: url,
|
264
|
-
method: 'put',
|
265
|
-
data: XEUtils.serialize(this.paramHandle(data)),
|
266
|
-
headers: {
|
267
|
-
...this.formDataHeader,
|
268
|
-
...headers
|
269
|
-
}
|
270
|
-
})
|
271
|
-
}
|
272
|
-
|
273
|
-
/**
|
274
|
-
* 发送使用FormData的PATCH请求
|
275
|
-
* @param {string} url 请求URL
|
276
|
-
* @param {any} data 请求参数
|
277
|
-
* @param {Object} headers 请求头
|
278
|
-
* @returns 返回发送PATCH请求的Promise
|
279
|
-
*/
|
280
|
-
patchFormData(url, data, headers) { //formdata的patch请求
|
281
|
-
return this.send({
|
282
|
-
url: url,
|
283
|
-
method: 'patch',
|
284
|
-
data: XEUtils.serialize(this.paramHandle(data)),
|
285
|
-
headers: {
|
286
|
-
...this.formDataHeader,
|
287
|
-
...headers
|
288
|
-
}
|
289
|
-
})
|
290
|
-
}
|
291
|
-
|
292
|
-
}
|
293
|
-
export default Http
|
package/src/index.js
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
import './assets/styles/element/index.scss'
|
2
|
-
import './assets/styles/index.css'
|
3
|
-
import designer from './components/aDesigner/index.vue'
|
4
|
-
import sunForm from './components/aDesigner/show.vue'
|
5
|
-
import compsCommon from './components/widgetCommonComps/index'
|
6
|
-
import compsWidget from './components/widgetShowComps/index'
|
7
|
-
const install = (app) => {
|
8
|
-
Object.entries({
|
9
|
-
...compsCommon,
|
10
|
-
...compsWidget,
|
11
|
-
}).forEach(([name, component]) => {
|
12
|
-
app.component(name, component);
|
13
|
-
});
|
14
|
-
app.component("designer", designer);
|
15
|
-
app.component("sunForm", sunForm);
|
16
|
-
};
|
17
|
-
console.log(compsCommon);
|
18
|
-
export {
|
19
|
-
designer,
|
20
|
-
sunForm,
|
21
|
-
};
|
22
|
-
export default {
|
23
|
-
install
|
24
|
-
};
|
package/src/index2.js
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
import './assets/styles/element/index.scss'
|
2
|
-
import './assets/styles/index.css'
|
3
|
-
import widgetShowComps from './components/widgetShowComps/index'
|
4
|
-
import widgetCommonComps from './components/widgetCommonComps/index'
|
5
|
-
import widgetConfigComps from './components/widgetConfigComps/index'
|
6
|
-
import designer from './components/aDesigner/index.vue'
|
7
|
-
designer.install = function (app) {
|
8
|
-
app.use(widgetShowComps)
|
9
|
-
app.use(widgetCommonComps)
|
10
|
-
app.use(widgetConfigComps)
|
11
|
-
};
|
12
|
-
let comps = [designer]
|
13
|
-
const install = (app) => {
|
14
|
-
app.use(widgetShowComps)
|
15
|
-
app.use(widgetCommonComps)
|
16
|
-
app.use(widgetConfigComps)
|
17
|
-
comps.forEach(item => {
|
18
|
-
app.component(item.name, item)
|
19
|
-
})
|
20
|
-
};
|
21
|
-
export default {
|
22
|
-
install
|
23
|
-
};
|
package/src/main.js
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
import {
|
2
|
-
createApp
|
3
|
-
} from 'vue'
|
4
|
-
import App from './App.vue'
|
5
|
-
import comps from './index2'
|
6
|
-
import ElementPlus from 'element-plus'
|
7
|
-
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
|
8
|
-
import VxeUITable from 'vxe-table'
|
9
|
-
import 'vxe-table/lib/style.css'
|
10
|
-
import XEUtils from 'xe-utils'
|
11
|
-
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
|
12
|
-
const app = createApp(App)
|
13
|
-
app.use(ElementPlus)
|
14
|
-
app.use(VxeUITable)
|
15
|
-
app.use(comps)
|
16
|
-
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
|
17
|
-
app.component(key, component)
|
18
|
-
}
|
19
|
-
app.mount('#app')
|