@tuoyuan/gateway-api-select-config 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +605 -0
- package/dist/gateway-api-select-config.css +3 -0
- package/dist/gateway-api-select-config.es.js +1767 -0
- package/dist/gateway-api-select-config.umd.js +28 -0
- package/package.json +60 -0
- package/src/components/ApiConfig.vue +2264 -0
- package/src/components/SchemaFieldEditor.vue +572 -0
- package/src/index.js +70 -0
- package/src/utils/dataExtractor.js +359 -0
- package/src/utils/dataFilters.js +300 -0
- package/src/utils/reqMappingUtils.js +147 -0
- package/src/utils/schemaUtils.js +197 -0
- package/src/utils/treeUtils.js +134 -0
|
@@ -0,0 +1,1767 @@
|
|
|
1
|
+
import { Fragment as e, computed as t, createBlock as n, createCommentVNode as r, createElementBlock as i, createElementVNode as a, createTextVNode as o, createVNode as s, defineComponent as c, getCurrentInstance as l, inject as u, normalizeClass as d, normalizeStyle as f, onMounted as p, openBlock as m, ref as h, renderList as g, resolveComponent as _, toDisplayString as v, vModelRadio as y, vModelText as b, watch as x, withCtx as S, withDirectives as C } from "vue";
|
|
2
|
+
import { Button as w, Col as T, Empty as E, Input as D, Optgroup as O, Option as k, Row as ee, Select as te, Space as ne, Tag as re, Tree as ie } from "@arco-design/web-vue";
|
|
3
|
+
//#region \0rolldown/runtime.js
|
|
4
|
+
var A = Object.defineProperty, j = (e, t) => () => (e && (t = e(e = 0)), t), M = (e, t) => {
|
|
5
|
+
let n = {};
|
|
6
|
+
for (var r in e) A(n, r, {
|
|
7
|
+
get: e[r],
|
|
8
|
+
enumerable: !0
|
|
9
|
+
});
|
|
10
|
+
return t || A(n, Symbol.toStringTag, { value: "Module" }), n;
|
|
11
|
+
}, ae = Symbol("ArcoConfigProvider"), oe = "arco", se = "$arco", N = (e) => {
|
|
12
|
+
let t = l(), n = u(ae, void 0)?.prefixCls ?? t?.appContext.config.globalProperties[se]?.classPrefix ?? oe;
|
|
13
|
+
return e ? `${n}-${e}` : n;
|
|
14
|
+
}, P = Object.prototype.toString;
|
|
15
|
+
function F(e) {
|
|
16
|
+
return P.call(e) === "[object Number]" && e === e;
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
//#region node_modules/@arco-design/web-vue/es/_virtual/plugin-vue_export-helper.js
|
|
20
|
+
var I = (e, t) => {
|
|
21
|
+
for (let [n, r] of t) e[n] = r;
|
|
22
|
+
return e;
|
|
23
|
+
}, L = c({
|
|
24
|
+
name: "IconLink",
|
|
25
|
+
props: {
|
|
26
|
+
size: { type: [Number, String] },
|
|
27
|
+
strokeWidth: {
|
|
28
|
+
type: Number,
|
|
29
|
+
default: 4
|
|
30
|
+
},
|
|
31
|
+
strokeLinecap: {
|
|
32
|
+
type: String,
|
|
33
|
+
default: "butt",
|
|
34
|
+
validator: (e) => [
|
|
35
|
+
"butt",
|
|
36
|
+
"round",
|
|
37
|
+
"square"
|
|
38
|
+
].includes(e)
|
|
39
|
+
},
|
|
40
|
+
strokeLinejoin: {
|
|
41
|
+
type: String,
|
|
42
|
+
default: "miter",
|
|
43
|
+
validator: (e) => [
|
|
44
|
+
"arcs",
|
|
45
|
+
"bevel",
|
|
46
|
+
"miter",
|
|
47
|
+
"miter-clip",
|
|
48
|
+
"round"
|
|
49
|
+
].includes(e)
|
|
50
|
+
},
|
|
51
|
+
rotate: Number,
|
|
52
|
+
spin: Boolean
|
|
53
|
+
},
|
|
54
|
+
emits: { click: (e) => !0 },
|
|
55
|
+
setup(e, { emit: n }) {
|
|
56
|
+
let r = N("icon");
|
|
57
|
+
return {
|
|
58
|
+
cls: t(() => [
|
|
59
|
+
r,
|
|
60
|
+
`${r}-link`,
|
|
61
|
+
{ [`${r}-spin`]: e.spin }
|
|
62
|
+
]),
|
|
63
|
+
innerStyle: t(() => {
|
|
64
|
+
let t = {};
|
|
65
|
+
return e.size && (t.fontSize = F(e.size) ? `${e.size}px` : e.size), e.rotate && (t.transform = `rotate(${e.rotate}deg)`), t;
|
|
66
|
+
}),
|
|
67
|
+
onClick: (e) => {
|
|
68
|
+
n("click", e);
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
}), ce = [
|
|
73
|
+
"stroke-width",
|
|
74
|
+
"stroke-linecap",
|
|
75
|
+
"stroke-linejoin"
|
|
76
|
+
];
|
|
77
|
+
function le(e, t, n, r, o, s) {
|
|
78
|
+
return m(), i("svg", {
|
|
79
|
+
viewBox: "0 0 48 48",
|
|
80
|
+
fill: "none",
|
|
81
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
82
|
+
stroke: "currentColor",
|
|
83
|
+
class: d(e.cls),
|
|
84
|
+
style: f(e.innerStyle),
|
|
85
|
+
"stroke-width": e.strokeWidth,
|
|
86
|
+
"stroke-linecap": e.strokeLinecap,
|
|
87
|
+
"stroke-linejoin": e.strokeLinejoin,
|
|
88
|
+
onClick: t[0] ||= (...t) => e.onClick && e.onClick(...t)
|
|
89
|
+
}, t[1] ||= [a("path", { d: "m14.1 25.414-4.95 4.95a6 6 0 0 0 8.486 8.485l8.485-8.485a6 6 0 0 0 0-8.485m7.779.707 4.95-4.95a6 6 0 1 0-8.486-8.485l-8.485 8.485a6 6 0 0 0 0 8.485" }, null, -1)], 14, ce);
|
|
90
|
+
}
|
|
91
|
+
var R = /* @__PURE__ */ I(L, [["render", le]]), ue = Object.assign(R, { install: (e, t) => {
|
|
92
|
+
let n = t?.iconPrefix ?? "";
|
|
93
|
+
e.component(n + R.name, R);
|
|
94
|
+
} }), de = c({
|
|
95
|
+
name: "IconBulb",
|
|
96
|
+
props: {
|
|
97
|
+
size: { type: [Number, String] },
|
|
98
|
+
strokeWidth: {
|
|
99
|
+
type: Number,
|
|
100
|
+
default: 4
|
|
101
|
+
},
|
|
102
|
+
strokeLinecap: {
|
|
103
|
+
type: String,
|
|
104
|
+
default: "butt",
|
|
105
|
+
validator: (e) => [
|
|
106
|
+
"butt",
|
|
107
|
+
"round",
|
|
108
|
+
"square"
|
|
109
|
+
].includes(e)
|
|
110
|
+
},
|
|
111
|
+
strokeLinejoin: {
|
|
112
|
+
type: String,
|
|
113
|
+
default: "miter",
|
|
114
|
+
validator: (e) => [
|
|
115
|
+
"arcs",
|
|
116
|
+
"bevel",
|
|
117
|
+
"miter",
|
|
118
|
+
"miter-clip",
|
|
119
|
+
"round"
|
|
120
|
+
].includes(e)
|
|
121
|
+
},
|
|
122
|
+
rotate: Number,
|
|
123
|
+
spin: Boolean
|
|
124
|
+
},
|
|
125
|
+
emits: { click: (e) => !0 },
|
|
126
|
+
setup(e, { emit: n }) {
|
|
127
|
+
let r = N("icon");
|
|
128
|
+
return {
|
|
129
|
+
cls: t(() => [
|
|
130
|
+
r,
|
|
131
|
+
`${r}-bulb`,
|
|
132
|
+
{ [`${r}-spin`]: e.spin }
|
|
133
|
+
]),
|
|
134
|
+
innerStyle: t(() => {
|
|
135
|
+
let t = {};
|
|
136
|
+
return e.size && (t.fontSize = F(e.size) ? `${e.size}px` : e.size), e.rotate && (t.transform = `rotate(${e.rotate}deg)`), t;
|
|
137
|
+
}),
|
|
138
|
+
onClick: (e) => {
|
|
139
|
+
n("click", e);
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
}), fe = [
|
|
144
|
+
"stroke-width",
|
|
145
|
+
"stroke-linecap",
|
|
146
|
+
"stroke-linejoin"
|
|
147
|
+
];
|
|
148
|
+
function pe(e, t, n, r, o, s) {
|
|
149
|
+
return m(), i("svg", {
|
|
150
|
+
viewBox: "0 0 48 48",
|
|
151
|
+
fill: "none",
|
|
152
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
153
|
+
stroke: "currentColor",
|
|
154
|
+
class: d(e.cls),
|
|
155
|
+
style: f(e.innerStyle),
|
|
156
|
+
"stroke-width": e.strokeWidth,
|
|
157
|
+
"stroke-linecap": e.strokeLinecap,
|
|
158
|
+
"stroke-linejoin": e.strokeLinejoin,
|
|
159
|
+
onClick: t[0] ||= (...t) => e.onClick && e.onClick(...t)
|
|
160
|
+
}, t[1] ||= [a("path", { d: "M17 42h14m6-24c0 2.823-.9 5.437-2.43 7.568-1.539 2.147-3.185 4.32-3.77 6.897l-.623 2.756A1 1 0 0 1 29.2 36H18.8a1 1 0 0 1-.976-.779l-.624-2.756c-.584-2.576-2.23-4.75-3.77-6.897A12.94 12.94 0 0 1 11 18c0-7.18 5.82-13 13-13s13 5.82 13 13Z" }, null, -1)], 14, fe);
|
|
161
|
+
}
|
|
162
|
+
var z = /* @__PURE__ */ I(de, [["render", pe]]), me = Object.assign(z, { install: (e, t) => {
|
|
163
|
+
let n = t?.iconPrefix ?? "";
|
|
164
|
+
e.component(n + z.name, z);
|
|
165
|
+
} }), he = c({
|
|
166
|
+
name: "IconFile",
|
|
167
|
+
props: {
|
|
168
|
+
size: { type: [Number, String] },
|
|
169
|
+
strokeWidth: {
|
|
170
|
+
type: Number,
|
|
171
|
+
default: 4
|
|
172
|
+
},
|
|
173
|
+
strokeLinecap: {
|
|
174
|
+
type: String,
|
|
175
|
+
default: "butt",
|
|
176
|
+
validator: (e) => [
|
|
177
|
+
"butt",
|
|
178
|
+
"round",
|
|
179
|
+
"square"
|
|
180
|
+
].includes(e)
|
|
181
|
+
},
|
|
182
|
+
strokeLinejoin: {
|
|
183
|
+
type: String,
|
|
184
|
+
default: "miter",
|
|
185
|
+
validator: (e) => [
|
|
186
|
+
"arcs",
|
|
187
|
+
"bevel",
|
|
188
|
+
"miter",
|
|
189
|
+
"miter-clip",
|
|
190
|
+
"round"
|
|
191
|
+
].includes(e)
|
|
192
|
+
},
|
|
193
|
+
rotate: Number,
|
|
194
|
+
spin: Boolean
|
|
195
|
+
},
|
|
196
|
+
emits: { click: (e) => !0 },
|
|
197
|
+
setup(e, { emit: n }) {
|
|
198
|
+
let r = N("icon");
|
|
199
|
+
return {
|
|
200
|
+
cls: t(() => [
|
|
201
|
+
r,
|
|
202
|
+
`${r}-file`,
|
|
203
|
+
{ [`${r}-spin`]: e.spin }
|
|
204
|
+
]),
|
|
205
|
+
innerStyle: t(() => {
|
|
206
|
+
let t = {};
|
|
207
|
+
return e.size && (t.fontSize = F(e.size) ? `${e.size}px` : e.size), e.rotate && (t.transform = `rotate(${e.rotate}deg)`), t;
|
|
208
|
+
}),
|
|
209
|
+
onClick: (e) => {
|
|
210
|
+
n("click", e);
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
}), ge = [
|
|
215
|
+
"stroke-width",
|
|
216
|
+
"stroke-linecap",
|
|
217
|
+
"stroke-linejoin"
|
|
218
|
+
];
|
|
219
|
+
function _e(e, t, n, r, o, s) {
|
|
220
|
+
return m(), i("svg", {
|
|
221
|
+
viewBox: "0 0 48 48",
|
|
222
|
+
fill: "none",
|
|
223
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
224
|
+
stroke: "currentColor",
|
|
225
|
+
class: d(e.cls),
|
|
226
|
+
style: f(e.innerStyle),
|
|
227
|
+
"stroke-width": e.strokeWidth,
|
|
228
|
+
"stroke-linecap": e.strokeLinecap,
|
|
229
|
+
"stroke-linejoin": e.strokeLinejoin,
|
|
230
|
+
onClick: t[0] ||= (...t) => e.onClick && e.onClick(...t)
|
|
231
|
+
}, t[1] ||= [a("path", { d: "M16 21h16m-16 8h10m11 13H11a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h21l7 7v27a2 2 0 0 1-2 2Z" }, null, -1)], 14, ge);
|
|
232
|
+
}
|
|
233
|
+
var B = /* @__PURE__ */ I(he, [["render", _e]]), ve = Object.assign(B, { install: (e, t) => {
|
|
234
|
+
let n = t?.iconPrefix ?? "";
|
|
235
|
+
e.component(n + B.name, B);
|
|
236
|
+
} });
|
|
237
|
+
//#endregion
|
|
238
|
+
//#region src/utils/schemaUtils.js
|
|
239
|
+
function V(e, t = "", n = 0) {
|
|
240
|
+
let r = [];
|
|
241
|
+
if (!e) return r;
|
|
242
|
+
if (e.type === "object" && e.items && !e.properties) {
|
|
243
|
+
if (e.items.type === "object" && e.items.properties) {
|
|
244
|
+
let i = V(e.items, t, n);
|
|
245
|
+
r.push(...i);
|
|
246
|
+
}
|
|
247
|
+
return r;
|
|
248
|
+
}
|
|
249
|
+
if (e.type === "array" && e.items) {
|
|
250
|
+
if (e.items.type === "object" && e.items.properties) {
|
|
251
|
+
let i = V(e.items, t, n);
|
|
252
|
+
r.push(...i);
|
|
253
|
+
}
|
|
254
|
+
return r;
|
|
255
|
+
}
|
|
256
|
+
if (e.type === "object" && e.properties) {
|
|
257
|
+
let i = e.required || [];
|
|
258
|
+
for (let [a, o] of Object.entries(e.properties)) {
|
|
259
|
+
let e = t ? `${t}.${a}` : a;
|
|
260
|
+
if (o.type === "object" || o.type === "array") {
|
|
261
|
+
let t = V(o, e, n + 1);
|
|
262
|
+
r.push(...t);
|
|
263
|
+
} else r.push({
|
|
264
|
+
key: e,
|
|
265
|
+
name: a,
|
|
266
|
+
label: o.label || o.title || a,
|
|
267
|
+
type: o.type,
|
|
268
|
+
description: o.description || "",
|
|
269
|
+
level: n,
|
|
270
|
+
required: i.includes(a)
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
return r;
|
|
275
|
+
}
|
|
276
|
+
function H(e) {
|
|
277
|
+
if (!e) return {};
|
|
278
|
+
if (((e) => e?.items?.properties ? Object.keys(e.items.properties).length === 0 : e?.properties ? Object.keys(e.properties).length === 0 : !1)(e)) return {
|
|
279
|
+
模式: "自动推断",
|
|
280
|
+
说明: "Schema 不完整,将返回完整的原始数据",
|
|
281
|
+
数据路径: e.x_path || e.x_value || "@"
|
|
282
|
+
};
|
|
283
|
+
let t = {};
|
|
284
|
+
if (e.items?.properties) {
|
|
285
|
+
let n = e.items.properties;
|
|
286
|
+
for (let [e, r] of Object.entries(n)) t[e] = {
|
|
287
|
+
类型: r.type,
|
|
288
|
+
路径: r.x_path,
|
|
289
|
+
格式: r.format || "无"
|
|
290
|
+
};
|
|
291
|
+
} else if (e.properties) {
|
|
292
|
+
let n = e.properties;
|
|
293
|
+
for (let [e, r] of Object.entries(n)) r.type !== "object" && r.type !== "array" && (t[e] = {
|
|
294
|
+
类型: r.type,
|
|
295
|
+
路径: r.x_path,
|
|
296
|
+
格式: r.format || "无"
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
return {
|
|
300
|
+
数据路径: e.x_path || e.x_value || "@",
|
|
301
|
+
输出字段: t
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
function ye(e) {
|
|
305
|
+
return e ? {
|
|
306
|
+
接口路径: e.apiPath,
|
|
307
|
+
入参配置: e.reqMapping || {},
|
|
308
|
+
输出配置: H(e.res_schema)
|
|
309
|
+
} : null;
|
|
310
|
+
}
|
|
311
|
+
//#endregion
|
|
312
|
+
//#region \0plugin-vue:export-helper
|
|
313
|
+
var be = (e, t) => {
|
|
314
|
+
let n = e.__vccOpts || e;
|
|
315
|
+
for (let [e, r] of t) n[e] = r;
|
|
316
|
+
return n;
|
|
317
|
+
}, xe = {
|
|
318
|
+
name: "SchemaFieldEditor",
|
|
319
|
+
components: {
|
|
320
|
+
AEmpty: E,
|
|
321
|
+
ASpace: ne,
|
|
322
|
+
ATag: re,
|
|
323
|
+
AInput: D,
|
|
324
|
+
AButton: w,
|
|
325
|
+
ASelect: te,
|
|
326
|
+
AOption: k,
|
|
327
|
+
AOptgroup: O,
|
|
328
|
+
ARow: ee,
|
|
329
|
+
ACol: T,
|
|
330
|
+
IconFile: ve,
|
|
331
|
+
IconLink: ue,
|
|
332
|
+
IconBulb: me
|
|
333
|
+
},
|
|
334
|
+
props: {
|
|
335
|
+
schema: {
|
|
336
|
+
type: Object,
|
|
337
|
+
required: !0
|
|
338
|
+
},
|
|
339
|
+
fieldPaths: {
|
|
340
|
+
type: Object,
|
|
341
|
+
default: () => ({})
|
|
342
|
+
},
|
|
343
|
+
fieldFormats: {
|
|
344
|
+
type: Object,
|
|
345
|
+
default: () => ({})
|
|
346
|
+
}
|
|
347
|
+
},
|
|
348
|
+
emits: ["update", "updateFormat"],
|
|
349
|
+
setup(e, { emit: n }) {
|
|
350
|
+
let r = t(() => V(e.schema)), i = h(null);
|
|
351
|
+
return {
|
|
352
|
+
fields: r,
|
|
353
|
+
activeExampleField: i,
|
|
354
|
+
handleInput: (e, t) => {
|
|
355
|
+
n("update", {
|
|
356
|
+
key: e,
|
|
357
|
+
path: t
|
|
358
|
+
});
|
|
359
|
+
},
|
|
360
|
+
handleFormatChange: (e, t) => {
|
|
361
|
+
n("updateFormat", {
|
|
362
|
+
key: e,
|
|
363
|
+
format: t
|
|
364
|
+
});
|
|
365
|
+
},
|
|
366
|
+
shouldShowFormat: (e) => !["array", "object"].includes(e.type),
|
|
367
|
+
isDateField: (e) => {
|
|
368
|
+
let t = e.name.toLowerCase();
|
|
369
|
+
return t.includes("time") || t.includes("date") || t.includes("created") || t.includes("updated") || e.type === "string" && (e.format === "date" || e.format === "date-time");
|
|
370
|
+
},
|
|
371
|
+
isNumberField: (e) => e.type === "number" || e.type === "integer",
|
|
372
|
+
getPlaceholder: (e) => `例如:@.${e.name}`,
|
|
373
|
+
getExamples: (e) => {
|
|
374
|
+
let t = [], n = e.name;
|
|
375
|
+
return e.type !== "array" && e.type !== "object" ? (t.push({
|
|
376
|
+
path: `@.${n}`,
|
|
377
|
+
desc: "直接取当前对象的字段"
|
|
378
|
+
}, {
|
|
379
|
+
path: `@.data.${n}`,
|
|
380
|
+
desc: "取 data 对象中的字段"
|
|
381
|
+
}, {
|
|
382
|
+
path: `@.result.${n}`,
|
|
383
|
+
desc: "取 result 对象中的字段"
|
|
384
|
+
}), n.toLowerCase().includes("id") && t.push({
|
|
385
|
+
path: `@.${n}`,
|
|
386
|
+
desc: "ID 字段(推荐)"
|
|
387
|
+
}), n.toLowerCase().includes("name") && t.push({
|
|
388
|
+
path: `@.${n}`,
|
|
389
|
+
desc: "名称字段(推荐)"
|
|
390
|
+
})) : e.type === "array" ? t.push({
|
|
391
|
+
path: `@.${n}`,
|
|
392
|
+
desc: "直接取当前对象的数组"
|
|
393
|
+
}, {
|
|
394
|
+
path: `@.data.${n}`,
|
|
395
|
+
desc: "取 data 中的数组"
|
|
396
|
+
}, {
|
|
397
|
+
path: "@.data.list",
|
|
398
|
+
desc: "取 data.list 数组"
|
|
399
|
+
}) : e.type === "object" && t.push({
|
|
400
|
+
path: `@.${n}`,
|
|
401
|
+
desc: "直接取当前对象的子对象"
|
|
402
|
+
}, {
|
|
403
|
+
path: `@.data.${n}`,
|
|
404
|
+
desc: "取 data 中的子对象"
|
|
405
|
+
}), t;
|
|
406
|
+
},
|
|
407
|
+
showExamples: (e) => {
|
|
408
|
+
i.value === e.key ? i.value = null : i.value = e.key;
|
|
409
|
+
},
|
|
410
|
+
applyExample: (e, t) => {
|
|
411
|
+
n("update", {
|
|
412
|
+
key: e,
|
|
413
|
+
path: t
|
|
414
|
+
}), i.value = null;
|
|
415
|
+
}
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
}, Se = { class: "schema-field-editor" }, Ce = {
|
|
419
|
+
key: 1,
|
|
420
|
+
class: "field-list"
|
|
421
|
+
}, we = { class: "field-header" }, Te = { class: "field-name" }, Ee = { class: "field-tags" }, De = { class: "value-container" }, Oe = { class: "input-wrapper" }, ke = {
|
|
422
|
+
key: 0,
|
|
423
|
+
class: "examples-section"
|
|
424
|
+
}, Ae = { class: "examples-header" }, je = { class: "examples-list" }, Me = ["onClick"], Ne = { class: "example-code" }, Pe = { class: "example-desc" };
|
|
425
|
+
function Fe(t, c, l, u, d, f) {
|
|
426
|
+
let p = _("icon-file"), h = _("a-empty"), y = _("a-tag"), b = _("a-col"), x = _("icon-link"), C = _("icon-bulb"), w = _("a-button"), T = _("a-input"), E = _("a-option"), D = _("a-optgroup"), O = _("a-select"), k = _("a-row");
|
|
427
|
+
return m(), i("div", Se, [u.fields.length === 0 ? (m(), n(h, {
|
|
428
|
+
key: 0,
|
|
429
|
+
description: "未定义输出字段"
|
|
430
|
+
}, {
|
|
431
|
+
image: S(() => [s(p)]),
|
|
432
|
+
default: S(() => [c[0] ||= a("div", { class: "empty-desc" }, [
|
|
433
|
+
o(" 此 API 的 schema 定义不完整(缺少 items.properties)。"),
|
|
434
|
+
a("br"),
|
|
435
|
+
o(" 保存后将自动返回完整的原始数据,无需配置字段映射。 ")
|
|
436
|
+
], -1)]),
|
|
437
|
+
_: 1
|
|
438
|
+
})) : (m(), i("div", Ce, [(m(!0), i(e, null, g(u.fields, (t) => (m(), i("div", {
|
|
439
|
+
key: t.key,
|
|
440
|
+
class: "field-item"
|
|
441
|
+
}, [s(k, {
|
|
442
|
+
gutter: 8,
|
|
443
|
+
class: "field-row"
|
|
444
|
+
}, {
|
|
445
|
+
default: S(() => [s(b, {
|
|
446
|
+
span: 5,
|
|
447
|
+
class: "field-label-col"
|
|
448
|
+
}, {
|
|
449
|
+
default: S(() => [a("div", we, [a("span", Te, v(t.label || t.name), 1), a("div", Ee, [s(y, {
|
|
450
|
+
color: "arcoblue",
|
|
451
|
+
size: "small",
|
|
452
|
+
class: "type-tag"
|
|
453
|
+
}, {
|
|
454
|
+
default: S(() => [o(v(t.type), 1)]),
|
|
455
|
+
_: 2
|
|
456
|
+
}, 1024), t.required ? (m(), n(y, {
|
|
457
|
+
key: 0,
|
|
458
|
+
color: "red",
|
|
459
|
+
size: "mini",
|
|
460
|
+
class: "required-tag"
|
|
461
|
+
}, {
|
|
462
|
+
default: S(() => [...c[1] ||= [o(" 必填 ", -1)]]),
|
|
463
|
+
_: 1
|
|
464
|
+
})) : r("", !0)])])]),
|
|
465
|
+
_: 2
|
|
466
|
+
}, 1024), s(b, {
|
|
467
|
+
span: 19,
|
|
468
|
+
class: "field-value-col"
|
|
469
|
+
}, {
|
|
470
|
+
default: S(() => [a("div", De, [a("div", Oe, [s(T, {
|
|
471
|
+
"model-value": l.fieldPaths[t.key] || "",
|
|
472
|
+
onInput: (e) => u.handleInput(t.key, e),
|
|
473
|
+
placeholder: u.getPlaceholder(t),
|
|
474
|
+
"allow-clear": "",
|
|
475
|
+
class: "path-input"
|
|
476
|
+
}, {
|
|
477
|
+
prefix: S(() => [s(x)]),
|
|
478
|
+
suffix: S(() => [u.getExamples(t).length > 0 ? (m(), n(w, {
|
|
479
|
+
key: 0,
|
|
480
|
+
onClick: (e) => u.showExamples(t),
|
|
481
|
+
type: "text",
|
|
482
|
+
size: "small",
|
|
483
|
+
class: "example-trigger-btn"
|
|
484
|
+
}, {
|
|
485
|
+
icon: S(() => [s(C)]),
|
|
486
|
+
_: 1
|
|
487
|
+
}, 8, ["onClick"])) : r("", !0)]),
|
|
488
|
+
_: 2
|
|
489
|
+
}, 1032, [
|
|
490
|
+
"model-value",
|
|
491
|
+
"onInput",
|
|
492
|
+
"placeholder"
|
|
493
|
+
])]), u.shouldShowFormat(t) ? (m(), n(k, {
|
|
494
|
+
key: 0,
|
|
495
|
+
gutter: 12,
|
|
496
|
+
align: "center",
|
|
497
|
+
class: "format-row"
|
|
498
|
+
}, {
|
|
499
|
+
default: S(() => [s(b, { span: 4 }, {
|
|
500
|
+
default: S(() => [...c[2] ||= [a("div", { class: "format-label" }, "格式化", -1)]]),
|
|
501
|
+
_: 1
|
|
502
|
+
}), s(b, { span: 20 }, {
|
|
503
|
+
default: S(() => [s(O, {
|
|
504
|
+
"model-value": l.fieldFormats[t.key] || "",
|
|
505
|
+
onChange: (e) => u.handleFormatChange(t.key, e),
|
|
506
|
+
placeholder: "选择格式化方式",
|
|
507
|
+
"allow-clear": "",
|
|
508
|
+
size: "small",
|
|
509
|
+
class: "format-select"
|
|
510
|
+
}, {
|
|
511
|
+
default: S(() => [
|
|
512
|
+
s(E, { value: "" }, {
|
|
513
|
+
default: S(() => [...c[3] ||= [o("无", -1)]]),
|
|
514
|
+
_: 1
|
|
515
|
+
}),
|
|
516
|
+
u.isDateField(t) ? (m(), n(D, {
|
|
517
|
+
key: 0,
|
|
518
|
+
label: "日期格式"
|
|
519
|
+
}, {
|
|
520
|
+
default: S(() => [
|
|
521
|
+
s(E, { value: "YYYY-MM-DD" }, {
|
|
522
|
+
default: S(() => [...c[4] ||= [o("YYYY-MM-DD", -1)]]),
|
|
523
|
+
_: 1
|
|
524
|
+
}),
|
|
525
|
+
s(E, { value: "YYYY-MM-DD HH:mm:ss" }, {
|
|
526
|
+
default: S(() => [...c[5] ||= [o("YYYY-MM-DD HH:mm:ss", -1)]]),
|
|
527
|
+
_: 1
|
|
528
|
+
}),
|
|
529
|
+
s(E, { value: "YYYY/MM/DD" }, {
|
|
530
|
+
default: S(() => [...c[6] ||= [o("YYYY/MM/DD", -1)]]),
|
|
531
|
+
_: 1
|
|
532
|
+
}),
|
|
533
|
+
s(E, { value: "timestamp" }, {
|
|
534
|
+
default: S(() => [...c[7] ||= [o("时间戳(毫秒)", -1)]]),
|
|
535
|
+
_: 1
|
|
536
|
+
}),
|
|
537
|
+
s(E, { value: "timestamp_s" }, {
|
|
538
|
+
default: S(() => [...c[8] ||= [o("时间戳(秒)", -1)]]),
|
|
539
|
+
_: 1
|
|
540
|
+
})
|
|
541
|
+
]),
|
|
542
|
+
_: 1
|
|
543
|
+
})) : r("", !0),
|
|
544
|
+
u.isNumberField(t) ? (m(), n(D, {
|
|
545
|
+
key: 1,
|
|
546
|
+
label: "数字格式"
|
|
547
|
+
}, {
|
|
548
|
+
default: S(() => [
|
|
549
|
+
s(E, { value: "number" }, {
|
|
550
|
+
default: S(() => [...c[9] ||= [o("数字", -1)]]),
|
|
551
|
+
_: 1
|
|
552
|
+
}),
|
|
553
|
+
s(E, { value: "integer" }, {
|
|
554
|
+
default: S(() => [...c[10] ||= [o("整数", -1)]]),
|
|
555
|
+
_: 1
|
|
556
|
+
}),
|
|
557
|
+
s(E, { value: "currency" }, {
|
|
558
|
+
default: S(() => [...c[11] ||= [o("货币", -1)]]),
|
|
559
|
+
_: 1
|
|
560
|
+
}),
|
|
561
|
+
s(E, { value: "percent" }, {
|
|
562
|
+
default: S(() => [...c[12] ||= [o("百分比", -1)]]),
|
|
563
|
+
_: 1
|
|
564
|
+
})
|
|
565
|
+
]),
|
|
566
|
+
_: 1
|
|
567
|
+
})) : r("", !0),
|
|
568
|
+
s(D, { label: "通用格式" }, {
|
|
569
|
+
default: S(() => [
|
|
570
|
+
s(E, { value: "string" }, {
|
|
571
|
+
default: S(() => [...c[13] ||= [o("字符串", -1)]]),
|
|
572
|
+
_: 1
|
|
573
|
+
}),
|
|
574
|
+
s(E, { value: "boolean" }, {
|
|
575
|
+
default: S(() => [...c[14] ||= [o("布尔值", -1)]]),
|
|
576
|
+
_: 1
|
|
577
|
+
}),
|
|
578
|
+
s(E, { value: "json" }, {
|
|
579
|
+
default: S(() => [...c[15] ||= [o("JSON", -1)]]),
|
|
580
|
+
_: 1
|
|
581
|
+
})
|
|
582
|
+
]),
|
|
583
|
+
_: 1
|
|
584
|
+
})
|
|
585
|
+
]),
|
|
586
|
+
_: 2
|
|
587
|
+
}, 1032, ["model-value", "onChange"])]),
|
|
588
|
+
_: 2
|
|
589
|
+
}, 1024)]),
|
|
590
|
+
_: 2
|
|
591
|
+
}, 1024)) : r("", !0)])]),
|
|
592
|
+
_: 2
|
|
593
|
+
}, 1024)]),
|
|
594
|
+
_: 2
|
|
595
|
+
}, 1024), u.activeExampleField === t.key ? (m(), i("div", ke, [
|
|
596
|
+
a("div", Ae, [s(C, { class: "examples-icon" }), c[16] ||= a("span", { class: "examples-title" }, "常用路径示例", -1)]),
|
|
597
|
+
a("div", je, [(m(!0), i(e, null, g(u.getExamples(t), (e, n) => (m(), i("div", {
|
|
598
|
+
key: n,
|
|
599
|
+
class: "example-item",
|
|
600
|
+
onClick: (n) => u.applyExample(t.key, e.path)
|
|
601
|
+
}, [a("code", Ne, v(e.path), 1), a("span", Pe, v(e.desc), 1)], 8, Me))), 128))]),
|
|
602
|
+
c[17] ||= a("div", { class: "examples-footer" }, " 点击示例可直接应用 ", -1)
|
|
603
|
+
])) : r("", !0)]))), 128))]))]);
|
|
604
|
+
}
|
|
605
|
+
var Ie = /* @__PURE__ */ be(xe, [["render", Fe], ["__scopeId", "data-v-8fa96dae"]]);
|
|
606
|
+
//#endregion
|
|
607
|
+
//#region src/utils/treeUtils.js
|
|
608
|
+
function Le(e, t) {
|
|
609
|
+
if (!t) return e;
|
|
610
|
+
let n = t.toLowerCase(), r = (e) => {
|
|
611
|
+
let t = e.name?.toLowerCase().includes(n), i = e.apiPath?.toLowerCase().includes(n), a = t || i;
|
|
612
|
+
if (e.isLeaf || e.apiPath || !e.children || e.children.length === 0) return a ? {
|
|
613
|
+
...e,
|
|
614
|
+
highlighted: !0
|
|
615
|
+
} : null;
|
|
616
|
+
if (e.children && e.children.length > 0) {
|
|
617
|
+
let t = e.children.map((e) => r(e)).filter((e) => e !== null);
|
|
618
|
+
if (a) return {
|
|
619
|
+
...e,
|
|
620
|
+
children: e.children,
|
|
621
|
+
expanded: !0,
|
|
622
|
+
highlighted: !0
|
|
623
|
+
};
|
|
624
|
+
if (t.length > 0) return {
|
|
625
|
+
...e,
|
|
626
|
+
children: t,
|
|
627
|
+
expanded: !0
|
|
628
|
+
};
|
|
629
|
+
}
|
|
630
|
+
return null;
|
|
631
|
+
};
|
|
632
|
+
return e.map((e) => r(e)).filter((e) => e !== null);
|
|
633
|
+
}
|
|
634
|
+
function Re(e, t) {
|
|
635
|
+
if (!e || !t) return !1;
|
|
636
|
+
let n = t.replace(/\./g, "\\.").replace(/\*/g, ".*");
|
|
637
|
+
return RegExp(`^${n}$`).test(e);
|
|
638
|
+
}
|
|
639
|
+
//#endregion
|
|
640
|
+
//#region src/utils/reqMappingUtils.js
|
|
641
|
+
function ze(e, t) {
|
|
642
|
+
if (!e || e.trim() === "") return {};
|
|
643
|
+
try {
|
|
644
|
+
let n = e;
|
|
645
|
+
if (t === "template") {
|
|
646
|
+
let t = /* @__PURE__ */ new Map(), r = 0;
|
|
647
|
+
n = e.replace(/\$\{([^}]+)\}/g, (e, n) => {
|
|
648
|
+
let i = `"__TEMPLATE_${r}__"`;
|
|
649
|
+
return t.set(i, e), r++, i;
|
|
650
|
+
});
|
|
651
|
+
let i = JSON.parse(n), a = (e) => {
|
|
652
|
+
if (typeof e == "string") {
|
|
653
|
+
for (let [n, r] of t.entries()) if (e === n.replace(/"/g, "")) return r;
|
|
654
|
+
return e;
|
|
655
|
+
} else if (typeof e == "object" && e) {
|
|
656
|
+
if (Array.isArray(e)) return e.map(a);
|
|
657
|
+
{
|
|
658
|
+
let t = {};
|
|
659
|
+
for (let [n, r] of Object.entries(e)) t[n] = a(r);
|
|
660
|
+
return t;
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
return e;
|
|
664
|
+
};
|
|
665
|
+
return a(i);
|
|
666
|
+
}
|
|
667
|
+
let r = JSON.parse(n);
|
|
668
|
+
if (typeof r != "object" || Array.isArray(r)) throw Error("入参配置必须是对象格式");
|
|
669
|
+
return r;
|
|
670
|
+
} catch (e) {
|
|
671
|
+
throw Error("JSON 格式错误:" + e.message);
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
function Be(e, t) {
|
|
675
|
+
if (!e || Object.keys(e).length === 0) return {
|
|
676
|
+
valid: !0,
|
|
677
|
+
error: ""
|
|
678
|
+
};
|
|
679
|
+
try {
|
|
680
|
+
for (let [n, r] of Object.entries(e)) if (t === "template") typeof r == "string" && !r.includes("${") && console.warn(`字段 "${n}" 的值不包含模板变量,建议使用固定值模式`);
|
|
681
|
+
else if (t === "function" && typeof r == "string" && !r.includes("=>")) return {
|
|
682
|
+
valid: !1,
|
|
683
|
+
error: `字段 "${n}" 的值不是有效的函数表达式`
|
|
684
|
+
};
|
|
685
|
+
return {
|
|
686
|
+
valid: !0,
|
|
687
|
+
error: ""
|
|
688
|
+
};
|
|
689
|
+
} catch (e) {
|
|
690
|
+
return {
|
|
691
|
+
valid: !1,
|
|
692
|
+
error: e.message
|
|
693
|
+
};
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
//#endregion
|
|
697
|
+
//#region src/utils/dataExtractor.js
|
|
698
|
+
var Ve = /* @__PURE__ */ M({
|
|
699
|
+
applyFormat: () => G,
|
|
700
|
+
executeReqMapping: () => q,
|
|
701
|
+
extractDataBySchema: () => U
|
|
702
|
+
});
|
|
703
|
+
function U(e, t) {
|
|
704
|
+
if (!t || typeof t != "object") return e;
|
|
705
|
+
if (t.x_path ? e = W(e, t.x_path) : t.x_value && (e = W(e, t.x_value)), Array.isArray(e)) {
|
|
706
|
+
if (t.items) return He(e, {
|
|
707
|
+
type: "array",
|
|
708
|
+
items: t.items
|
|
709
|
+
});
|
|
710
|
+
} else if (t.type === "object" && t.properties) return Ue(e, t);
|
|
711
|
+
return t.format && e != null && (e = G(e, t.format)), e;
|
|
712
|
+
}
|
|
713
|
+
function He(e, t) {
|
|
714
|
+
let n = [];
|
|
715
|
+
if (!Array.isArray(e)) return [];
|
|
716
|
+
if (!t || !t.items || typeof t.items != "object") return e;
|
|
717
|
+
let r = t.items?.properties;
|
|
718
|
+
return r && Object.keys(r).length > 0 ? (e.forEach((e) => {
|
|
719
|
+
let t = {};
|
|
720
|
+
for (let [n, i] of Object.entries(r)) {
|
|
721
|
+
if (!i || typeof i != "object") {
|
|
722
|
+
t[n] = void 0;
|
|
723
|
+
continue;
|
|
724
|
+
}
|
|
725
|
+
let r = i.x_path;
|
|
726
|
+
if (r) {
|
|
727
|
+
let a = W(e, r), o = i.format;
|
|
728
|
+
o && a != null && (a = G(a, o)), t[n] = a;
|
|
729
|
+
} else t[n] = void 0;
|
|
730
|
+
}
|
|
731
|
+
n.push(t);
|
|
732
|
+
}), n) : t.items?.x_path ? e.map((e) => {
|
|
733
|
+
let n = W(e, t.items.x_path);
|
|
734
|
+
return t.items.format && n != null && (n = G(n, t.items.format)), n;
|
|
735
|
+
}) : e;
|
|
736
|
+
}
|
|
737
|
+
function Ue(e, t) {
|
|
738
|
+
let n = {};
|
|
739
|
+
if (!t || typeof t != "object") return e;
|
|
740
|
+
let r = t.properties;
|
|
741
|
+
if (!(r && Object.keys(r).length > 0)) {
|
|
742
|
+
if (t.x_path) {
|
|
743
|
+
let n = W(e, t.x_path);
|
|
744
|
+
return t.format && n != null && (n = G(n, t.format)), n;
|
|
745
|
+
}
|
|
746
|
+
return e;
|
|
747
|
+
}
|
|
748
|
+
for (let [r, i] of Object.entries(t.properties)) {
|
|
749
|
+
if (!i || typeof i != "object") {
|
|
750
|
+
n[r] = void 0;
|
|
751
|
+
continue;
|
|
752
|
+
}
|
|
753
|
+
if (i.x_path) {
|
|
754
|
+
let t = W(e, i.x_path), a = i.format;
|
|
755
|
+
a && t != null && (t = G(t, a)), n[r] = t;
|
|
756
|
+
} else n[r] = void 0;
|
|
757
|
+
}
|
|
758
|
+
return n;
|
|
759
|
+
}
|
|
760
|
+
function W(e, t) {
|
|
761
|
+
if (!t || typeof t != "string") return;
|
|
762
|
+
let n = t.replace(/^[$@]\.?/, "").split(/[\.\[\]]/).filter((e) => e !== "" && e !== "*"), r = e;
|
|
763
|
+
for (let e of n) {
|
|
764
|
+
if (r == null) return;
|
|
765
|
+
r = r[e];
|
|
766
|
+
}
|
|
767
|
+
return r;
|
|
768
|
+
}
|
|
769
|
+
function G(e, t) {
|
|
770
|
+
try {
|
|
771
|
+
switch (t) {
|
|
772
|
+
case "YYYY-MM-DD": return K(e, "YYYY-MM-DD");
|
|
773
|
+
case "YYYY-MM-DD HH:mm:ss": return K(e, "YYYY-MM-DD HH:mm:ss");
|
|
774
|
+
case "YYYY/MM/DD": return K(e, "YYYY/MM/DD");
|
|
775
|
+
case "timestamp": return new Date(e).getTime();
|
|
776
|
+
case "timestamp_s": return Math.floor(new Date(e).getTime() / 1e3);
|
|
777
|
+
case "number": return Number(e);
|
|
778
|
+
case "integer": return Math.floor(Number(e));
|
|
779
|
+
case "currency": return "¥" + Number(e).toLocaleString("zh-CN", {
|
|
780
|
+
minimumFractionDigits: 2,
|
|
781
|
+
maximumFractionDigits: 2
|
|
782
|
+
});
|
|
783
|
+
case "percent": return (Number(e) * 100).toFixed(2) + "%";
|
|
784
|
+
case "uppercase": return String(e).toUpperCase();
|
|
785
|
+
case "lowercase": return String(e).toLowerCase();
|
|
786
|
+
case "trim": return String(e).trim();
|
|
787
|
+
case "string": return String(e);
|
|
788
|
+
case "boolean": return !!e;
|
|
789
|
+
case "json": return JSON.stringify(e);
|
|
790
|
+
default: return e;
|
|
791
|
+
}
|
|
792
|
+
} catch (t) {
|
|
793
|
+
return console.error("格式化失败:", t), e;
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
function K(e, t) {
|
|
797
|
+
let n = new Date(e);
|
|
798
|
+
if (isNaN(n.getTime())) return String(e);
|
|
799
|
+
let r = n.getFullYear(), i = String(n.getMonth() + 1).padStart(2, "0"), a = String(n.getDate()).padStart(2, "0"), o = String(n.getHours()).padStart(2, "0"), s = String(n.getMinutes()).padStart(2, "0"), c = String(n.getSeconds()).padStart(2, "0");
|
|
800
|
+
return t.replace("YYYY", String(r)).replace("MM", i).replace("DD", a).replace("HH", o).replace("mm", s).replace("ss", c).replace("/", "/");
|
|
801
|
+
}
|
|
802
|
+
function q(e, t = {}) {
|
|
803
|
+
if (!e) return {};
|
|
804
|
+
let n = {};
|
|
805
|
+
for (let [r, i] of Object.entries(e)) if (typeof i == "string") if (i.includes("=>")) try {
|
|
806
|
+
n[r] = Function("ctx", `return (${i})(ctx)`)(t);
|
|
807
|
+
} catch (e) {
|
|
808
|
+
console.error(`执行函数表达式失败 [${r}]:`, e), n[r] = i;
|
|
809
|
+
}
|
|
810
|
+
else if (i.match(/^\$\{[^}]+\}$/)) {
|
|
811
|
+
let e = t[i.match(/^\$\{([^}]+)\}$/)[1]];
|
|
812
|
+
n[r] = e === void 0 ? i : e;
|
|
813
|
+
} else if (i.includes("${")) try {
|
|
814
|
+
let e = i.replace(/\$\{([^}]+)\}/g, (e, n) => t[n] === void 0 ? e : t[n]);
|
|
815
|
+
if (e !== i) {
|
|
816
|
+
let t = Number(e);
|
|
817
|
+
!isNaN(t) && e.trim() !== "" ? n[r] = t : n[r] = e;
|
|
818
|
+
} else n[r] = e;
|
|
819
|
+
} catch (e) {
|
|
820
|
+
console.error(`解析模板字符串失败 [${r}]:`, e), n[r] = i;
|
|
821
|
+
}
|
|
822
|
+
else n[r] = i;
|
|
823
|
+
else n[r] = i;
|
|
824
|
+
return n;
|
|
825
|
+
}
|
|
826
|
+
var J = j((() => {}));
|
|
827
|
+
//#endregion
|
|
828
|
+
//#region src/utils/dataFilters.js
|
|
829
|
+
J();
|
|
830
|
+
function Y(e, t = null) {
|
|
831
|
+
if (t) {
|
|
832
|
+
let n = t.replace(/^@\./, "").split("."), r = e;
|
|
833
|
+
for (let e of n) if (r && typeof r == "object") r = r[e];
|
|
834
|
+
else {
|
|
835
|
+
r = null;
|
|
836
|
+
break;
|
|
837
|
+
}
|
|
838
|
+
if (Array.isArray(r)) return r;
|
|
839
|
+
}
|
|
840
|
+
if (Array.isArray(e)) return e;
|
|
841
|
+
if (typeof e == "object" && e) {
|
|
842
|
+
let t = [
|
|
843
|
+
"data",
|
|
844
|
+
"list",
|
|
845
|
+
"items",
|
|
846
|
+
"records",
|
|
847
|
+
"rows",
|
|
848
|
+
"result",
|
|
849
|
+
"content"
|
|
850
|
+
];
|
|
851
|
+
for (let n of t) {
|
|
852
|
+
if (Array.isArray(e[n])) return e[n];
|
|
853
|
+
if (e[n] && typeof e[n] == "object") {
|
|
854
|
+
for (let r of t) if (Array.isArray(e[n][r])) return e[n][r];
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
return [e];
|
|
858
|
+
}
|
|
859
|
+
return [];
|
|
860
|
+
}
|
|
861
|
+
function We(e, t, n = {}, r = {}) {
|
|
862
|
+
if (!e || typeof e != "object") return e;
|
|
863
|
+
let i = {};
|
|
864
|
+
for (let [a, o] of Object.entries(t)) {
|
|
865
|
+
let t;
|
|
866
|
+
if (typeof o == "function") t = o(e);
|
|
867
|
+
else if (typeof o == "string") {
|
|
868
|
+
let n = o.split(".");
|
|
869
|
+
t = e;
|
|
870
|
+
for (let e of n) if (t && typeof t == "object") t = t[e];
|
|
871
|
+
else {
|
|
872
|
+
t = void 0;
|
|
873
|
+
break;
|
|
874
|
+
}
|
|
875
|
+
} else if (Array.isArray(o)) for (let n of o) {
|
|
876
|
+
let r = e[n];
|
|
877
|
+
if (r != null && r !== "") {
|
|
878
|
+
t = r;
|
|
879
|
+
break;
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
else t = o;
|
|
883
|
+
let s = n[a];
|
|
884
|
+
s && t != null && (t = Ge(t, s));
|
|
885
|
+
let c = r[a];
|
|
886
|
+
c && t != null && (t = G(t, c)), i[a] = t;
|
|
887
|
+
}
|
|
888
|
+
return i;
|
|
889
|
+
}
|
|
890
|
+
function Ge(e, t) {
|
|
891
|
+
try {
|
|
892
|
+
switch (t) {
|
|
893
|
+
case "string": return typeof e == "object" && e ? e : String(e);
|
|
894
|
+
case "number": return Number(e);
|
|
895
|
+
case "integer": return Math.floor(Number(e));
|
|
896
|
+
case "boolean": return !!e;
|
|
897
|
+
case "date": return e;
|
|
898
|
+
default: return e;
|
|
899
|
+
}
|
|
900
|
+
} catch (t) {
|
|
901
|
+
return console.error("类型转换失败:", t), e;
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
function X(e, t) {
|
|
905
|
+
console.log("=== applyFilter 调试信息 ==="), console.log("1. 原始响应:", e), console.log("2. 过滤器配置:", t);
|
|
906
|
+
let n = Y(e, t.arrayPath);
|
|
907
|
+
return console.log("3. 提取的数组 (extractArray):", n), t.itemFilter && typeof t.itemFilter == "function" && (n = n.filter(t.itemFilter), console.log("4. 过滤后 (itemFilter):", n)), t.fieldMapping ? (console.log("5. 应用字段映射:", t.fieldMapping), n = n.map((e) => We(e, t.fieldMapping, t.fieldTypes || {}, t.fieldFormats || {})), console.log("6. 映射后的数据:", n)) : console.log("5. 没有配置字段映射,返回原始数据"), t.itemTransform && typeof t.itemTransform == "function" && (n = n.map(t.itemTransform), console.log("7. 自定义转换后:", n)), console.log("8. 最终返回的数据:", n), console.log("=== applyFilter 结束 ==="), n;
|
|
908
|
+
}
|
|
909
|
+
var Z = (e) => Y(e).map((e) => typeof e == "string" ? e : typeof e == "object" ? e.content || e.title || e.message || e.text || e.notice || "" : String(e)), Q = (e) => Y(e), Ke = (e) => Y(e), qe = (e) => e, Je = {
|
|
910
|
+
notice: Z,
|
|
911
|
+
news: Q,
|
|
912
|
+
menu: Ke,
|
|
913
|
+
user: qe
|
|
914
|
+
};
|
|
915
|
+
function Ye(e, t) {
|
|
916
|
+
let n = Je[t];
|
|
917
|
+
return n ? n(e) : Y(e);
|
|
918
|
+
}
|
|
919
|
+
async function Xe(e, t, n = {}) {
|
|
920
|
+
if (!e || !e.apiPath) throw Error("缺少必要的配置: apiPath");
|
|
921
|
+
let r = {};
|
|
922
|
+
if (e.reqMapping) {
|
|
923
|
+
let { executeReqMapping: t } = await Promise.resolve().then(() => (J(), Ve));
|
|
924
|
+
r = t(e.reqMapping, n);
|
|
925
|
+
}
|
|
926
|
+
let i = await t({
|
|
927
|
+
api: e.apiPath,
|
|
928
|
+
params: r,
|
|
929
|
+
config: {
|
|
930
|
+
access_token: !0,
|
|
931
|
+
...e.requestConfig
|
|
932
|
+
}
|
|
933
|
+
}), a = i.response || i.data || i;
|
|
934
|
+
if (e.mode === "filter" && e.filterConfig) return X(a, e.filterConfig);
|
|
935
|
+
if (e.res_schema) {
|
|
936
|
+
let { extractDataBySchema: t } = await Promise.resolve().then(() => (J(), Ve));
|
|
937
|
+
return t(a, e.res_schema);
|
|
938
|
+
} else return Y(a);
|
|
939
|
+
}
|
|
940
|
+
var Ze = {
|
|
941
|
+
name: "ApiConfig",
|
|
942
|
+
components: {
|
|
943
|
+
ATree: ie,
|
|
944
|
+
ASelect: te,
|
|
945
|
+
AOption: k,
|
|
946
|
+
AOptgroup: O,
|
|
947
|
+
SchemaFieldEditor: Ie
|
|
948
|
+
},
|
|
949
|
+
props: {
|
|
950
|
+
resSchema: {
|
|
951
|
+
type: Object,
|
|
952
|
+
required: !1,
|
|
953
|
+
default: null
|
|
954
|
+
},
|
|
955
|
+
includePattern: {
|
|
956
|
+
type: Array,
|
|
957
|
+
default: () => []
|
|
958
|
+
},
|
|
959
|
+
excludePattern: {
|
|
960
|
+
type: Array,
|
|
961
|
+
default: () => []
|
|
962
|
+
},
|
|
963
|
+
apiListUrl: {
|
|
964
|
+
type: String,
|
|
965
|
+
default: ""
|
|
966
|
+
},
|
|
967
|
+
apiLoader: {
|
|
968
|
+
type: Function,
|
|
969
|
+
default: async () => {
|
|
970
|
+
try {
|
|
971
|
+
let { request: e } = await import("@tuoyuan/gateway-request-lib"), t = await e({
|
|
972
|
+
api: "/api/system.domain.get_func_tree",
|
|
973
|
+
params: {},
|
|
974
|
+
config: { access_token: !0 }
|
|
975
|
+
});
|
|
976
|
+
if (Array.isArray(t)) return t;
|
|
977
|
+
if (t?.data) {
|
|
978
|
+
if (Array.isArray(t.data)) return t.data;
|
|
979
|
+
if (t.data?.list) return t.data.list;
|
|
980
|
+
}
|
|
981
|
+
return [];
|
|
982
|
+
} catch (e) {
|
|
983
|
+
return console.error("默认 API 加载器失败:", e), null;
|
|
984
|
+
}
|
|
985
|
+
}
|
|
986
|
+
},
|
|
987
|
+
initialConfig: {
|
|
988
|
+
type: Object,
|
|
989
|
+
default: null
|
|
990
|
+
}
|
|
991
|
+
},
|
|
992
|
+
emits: ["save", "change"],
|
|
993
|
+
setup(e, { emit: n }) {
|
|
994
|
+
let r = h(!1), i = h(""), a = h([]), o = h(""), s = h([]), c = h(null), l = h([]), u = h([]), d = h("fixed"), f = h("{\n \"page_no\": 1,\n \"page_size\": 100\n}"), m = h(""), g = h({}), _ = h({}), v = h({
|
|
995
|
+
arrayPath: "",
|
|
996
|
+
fieldMapping: {}
|
|
997
|
+
}), y = h([]), b = h(!1), S = h(null), C = h(""), w = h([]), T = t(() => {
|
|
998
|
+
if (!N.value) return [];
|
|
999
|
+
try {
|
|
1000
|
+
if (N.value.type === "array" && N.value.items) {
|
|
1001
|
+
let e = N.value.items.properties;
|
|
1002
|
+
if (e && typeof e == "object") return Object.keys(e);
|
|
1003
|
+
}
|
|
1004
|
+
if (N.value.properties && typeof N.value.properties == "object") return Object.keys(N.value.properties);
|
|
1005
|
+
} catch (e) {
|
|
1006
|
+
console.warn("提取 Schema 字段失败:", e);
|
|
1007
|
+
}
|
|
1008
|
+
return [];
|
|
1009
|
+
}), E = t(() => {
|
|
1010
|
+
if (!S.value || !v.value.arrayPath) return null;
|
|
1011
|
+
try {
|
|
1012
|
+
return Y(S.value, v.value.arrayPath);
|
|
1013
|
+
} catch (e) {
|
|
1014
|
+
return console.error("提取数组失败:", e), null;
|
|
1015
|
+
}
|
|
1016
|
+
}), D = async () => {
|
|
1017
|
+
if (!c.value) {
|
|
1018
|
+
alert("请先选择一个 API");
|
|
1019
|
+
return;
|
|
1020
|
+
}
|
|
1021
|
+
b.value = !0, S.value = null, C.value = "", w.value = [];
|
|
1022
|
+
try {
|
|
1023
|
+
let { request: e } = await import("@tuoyuan/gateway-request-lib"), t = {};
|
|
1024
|
+
try {
|
|
1025
|
+
if (f.value && f.value.trim() !== "{}") {
|
|
1026
|
+
let e = JSON.parse(f.value);
|
|
1027
|
+
t = Object.fromEntries(Object.entries(e).filter(([e, t]) => typeof t != "string" || !t.includes("=>")));
|
|
1028
|
+
}
|
|
1029
|
+
} catch (e) {
|
|
1030
|
+
console.warn("解析入参失败,使用空参数测试:", e);
|
|
1031
|
+
}
|
|
1032
|
+
let n = await e({
|
|
1033
|
+
api: c.value.apiPath,
|
|
1034
|
+
params: t,
|
|
1035
|
+
config: { access_token: !0 }
|
|
1036
|
+
}), r = n.response || n.data || n;
|
|
1037
|
+
S.value = r, O(r);
|
|
1038
|
+
} catch (e) {
|
|
1039
|
+
console.error("测试接口失败:", e), alert("测试接口失败: " + e.message);
|
|
1040
|
+
} finally {
|
|
1041
|
+
b.value = !1;
|
|
1042
|
+
}
|
|
1043
|
+
}, O = (e) => {
|
|
1044
|
+
let t = [], n = [], r = (e, n = "") => {
|
|
1045
|
+
if (Array.isArray(e)) {
|
|
1046
|
+
t.push({
|
|
1047
|
+
path: n || "@",
|
|
1048
|
+
array: e
|
|
1049
|
+
});
|
|
1050
|
+
return;
|
|
1051
|
+
}
|
|
1052
|
+
e && typeof e == "object" && Object.keys(e).forEach((t) => {
|
|
1053
|
+
r(e[t], n ? `${n}.${t}` : t);
|
|
1054
|
+
});
|
|
1055
|
+
};
|
|
1056
|
+
r(e);
|
|
1057
|
+
let i = t.find((e) => e.path.includes("list") || e.path.includes("data") || e.path.includes("items")) || t[0];
|
|
1058
|
+
i && (C.value = i.path, n = i.array), n.length > 0 && typeof n[0] == "object" && (w.value = Object.keys(n[0]));
|
|
1059
|
+
}, k = (e) => {
|
|
1060
|
+
if (y.value.some((t) => t.target === e)) {
|
|
1061
|
+
alert(`字段 "${e}" 已存在`);
|
|
1062
|
+
return;
|
|
1063
|
+
}
|
|
1064
|
+
y.value.push({
|
|
1065
|
+
target: e,
|
|
1066
|
+
source: e,
|
|
1067
|
+
type: "string",
|
|
1068
|
+
format: ""
|
|
1069
|
+
});
|
|
1070
|
+
}, ee = () => {
|
|
1071
|
+
v.value.arrayPath = C.value;
|
|
1072
|
+
}, te = (e) => {
|
|
1073
|
+
try {
|
|
1074
|
+
return JSON.stringify(e, null, 2);
|
|
1075
|
+
} catch {
|
|
1076
|
+
return String(e);
|
|
1077
|
+
}
|
|
1078
|
+
}, ne = () => {
|
|
1079
|
+
y.value.push({
|
|
1080
|
+
target: "",
|
|
1081
|
+
source: "",
|
|
1082
|
+
type: "string",
|
|
1083
|
+
format: ""
|
|
1084
|
+
});
|
|
1085
|
+
}, re = (e) => {
|
|
1086
|
+
y.value.splice(e, 1);
|
|
1087
|
+
};
|
|
1088
|
+
x(d, (e) => {
|
|
1089
|
+
f.value = {
|
|
1090
|
+
fixed: "{\n \"page_no\": 1,\n \"page_size\": 100\n}",
|
|
1091
|
+
template: "{\n \"page_no\": \"{{pageNum}}\",\n \"page_size\": \"{{pageSize}}\"\n}",
|
|
1092
|
+
function: "{\n \"page_no\": \"(ctx) => Number(ctx.pageNum) || 1\",\n \"page_size\": \"(ctx) => Number(ctx.pageSize) || 10\"\n}"
|
|
1093
|
+
}[e];
|
|
1094
|
+
}), x(y, (e) => {
|
|
1095
|
+
let t = {}, n = {}, r = {};
|
|
1096
|
+
e.forEach((e) => {
|
|
1097
|
+
if (e.target && e.source) {
|
|
1098
|
+
let i = e.source.split(",").map((e) => e.trim()).filter((e) => e);
|
|
1099
|
+
i.length === 1 ? t[e.target] = i[0] : i.length > 1 && (t[e.target] = i), e.type && (n[e.target] = e.type), e.format && (r[e.target] = e.format);
|
|
1100
|
+
}
|
|
1101
|
+
}), v.value.fieldMapping = t, v.value.fieldTypes = n, v.value.fieldFormats = r;
|
|
1102
|
+
}, { deep: !0 });
|
|
1103
|
+
let ie = t(() => A(s.value)), A = (e, t = "") => e.map((e, n) => {
|
|
1104
|
+
let r = t ? `${t}-${n}-${e.id}` : `${n}-${e.id}`;
|
|
1105
|
+
return {
|
|
1106
|
+
key: r,
|
|
1107
|
+
title: e.name,
|
|
1108
|
+
name: e.name,
|
|
1109
|
+
apiPath: e.apiPath,
|
|
1110
|
+
isLeaf: e.isLeaf,
|
|
1111
|
+
_raw: e._raw,
|
|
1112
|
+
selectable: !!e.isLeaf,
|
|
1113
|
+
children: e.children && e.children.length > 0 ? A(e.children, r) : void 0
|
|
1114
|
+
};
|
|
1115
|
+
}), j = (e, t = "", n = []) => (e.forEach((e, r) => {
|
|
1116
|
+
let i = t ? `${t}-${r}-${e.id}` : `${r}-${e.id}`;
|
|
1117
|
+
e.isLeaf || n.push(i), e.children && e.children.length > 0 && j(e.children, i, n);
|
|
1118
|
+
}), n), M = t(() => o.value ? j(s.value) : s.value.map((e) => e.id));
|
|
1119
|
+
x([s, o], () => {
|
|
1120
|
+
u.value = M.value;
|
|
1121
|
+
}, { immediate: !0 });
|
|
1122
|
+
let ae = (e, t) => {
|
|
1123
|
+
if (e.length === 0) return;
|
|
1124
|
+
let n = e[0], r = t.node;
|
|
1125
|
+
r.isLeaf && (l.value = [n], pe(r));
|
|
1126
|
+
}, oe = (e) => {
|
|
1127
|
+
console.log("Tree expand event:", e), u.value = e;
|
|
1128
|
+
}, se = t(() => {
|
|
1129
|
+
if (!N.value) return !1;
|
|
1130
|
+
if (N.value.items) {
|
|
1131
|
+
let e = N.value.items.properties;
|
|
1132
|
+
return !e || Object.keys(e).length === 0;
|
|
1133
|
+
}
|
|
1134
|
+
let e = N.value.properties;
|
|
1135
|
+
return !e || Object.keys(e).length === 0;
|
|
1136
|
+
}), N = h(e.resSchema), P = h(null), F = t(() => P.value ? V(P.value) : []), I = t(() => ({
|
|
1137
|
+
fixed: "{\n \"page_no\": 1,\n \"page_size\": 100\n}",
|
|
1138
|
+
template: "{\n \"page_no\": \"{{pageNum}}\",\n \"page_size\": \"{{pageSize}}\"\n}",
|
|
1139
|
+
function: "{\n \"page_no\": \"(ctx) => Number(ctx.pageNum) || 1\",\n \"page_size\": \"(ctx) => Number(ctx.pageSize) || 10\"\n}"
|
|
1140
|
+
})[d.value]), L = t(() => c.value ? y.value.some((e) => e.target && e.source) && !m.value : !1), ce = t(() => {
|
|
1141
|
+
if (!P.value || !F.value.length) return [];
|
|
1142
|
+
let e = {};
|
|
1143
|
+
try {
|
|
1144
|
+
f.value && f.value.trim() !== "{}" && (e = JSON.parse(f.value));
|
|
1145
|
+
} catch {
|
|
1146
|
+
return [];
|
|
1147
|
+
}
|
|
1148
|
+
return F.value.filter((e) => e.required).filter((t) => {
|
|
1149
|
+
let n = e[t.name];
|
|
1150
|
+
return n == null || n === "";
|
|
1151
|
+
}).map((e) => e.name);
|
|
1152
|
+
}), le = async () => {
|
|
1153
|
+
r.value = !0, i.value = "";
|
|
1154
|
+
try {
|
|
1155
|
+
let t;
|
|
1156
|
+
if (e.apiLoader) {
|
|
1157
|
+
if (t = await e.apiLoader(), t === null) {
|
|
1158
|
+
i.value = "请配置 apiListUrl 或提供 apiLoader 函数", r.value = !1;
|
|
1159
|
+
return;
|
|
1160
|
+
}
|
|
1161
|
+
} else if (e.apiListUrl) {
|
|
1162
|
+
let n = await fetch(e.apiListUrl);
|
|
1163
|
+
if (!n.ok) throw Error(`HTTP ${n.status}: ${n.statusText}`);
|
|
1164
|
+
let r = await n.json();
|
|
1165
|
+
if (r.code === 1e4 && r.data && r.data.list) t = r.data.list;
|
|
1166
|
+
else if (Array.isArray(r)) t = r;
|
|
1167
|
+
else if (r.data && Array.isArray(r.data)) t = r.data;
|
|
1168
|
+
else throw Error(r.msg || "接口返回数据格式错误");
|
|
1169
|
+
}
|
|
1170
|
+
let n = (e) => e.map((e) => {
|
|
1171
|
+
let r = {
|
|
1172
|
+
id: String(e.id || e.func_id),
|
|
1173
|
+
name: e.name || e.func_name,
|
|
1174
|
+
children: [],
|
|
1175
|
+
expanded: !1
|
|
1176
|
+
};
|
|
1177
|
+
if (e.children && e.children.length > 0 && r.children.push(...n(e.children)), e.funcs && e.funcs.length > 0) {
|
|
1178
|
+
let n = e.funcs.map((e) => {
|
|
1179
|
+
let n = e.api || e.path || e.func_path || e.api_path;
|
|
1180
|
+
if (!n && e.meta_domain && e.tag) {
|
|
1181
|
+
let r = (e, t) => {
|
|
1182
|
+
for (let n of e) {
|
|
1183
|
+
if (n.id === t) return n.name;
|
|
1184
|
+
if (n.children) {
|
|
1185
|
+
let e = r(n.children, t);
|
|
1186
|
+
if (e) return e;
|
|
1187
|
+
}
|
|
1188
|
+
}
|
|
1189
|
+
return null;
|
|
1190
|
+
};
|
|
1191
|
+
r(t, e.meta_domain), n = `/api/${e.tag}`;
|
|
1192
|
+
}
|
|
1193
|
+
return n ||= e.name || "(未知路径)", {
|
|
1194
|
+
id: String(e.id || e.func_id),
|
|
1195
|
+
name: e.name || e.func_name || "(未命名)",
|
|
1196
|
+
apiPath: n,
|
|
1197
|
+
isLeaf: !0,
|
|
1198
|
+
_raw: e
|
|
1199
|
+
};
|
|
1200
|
+
});
|
|
1201
|
+
r.children.push(...n);
|
|
1202
|
+
}
|
|
1203
|
+
return r.children.length === 0 && !e.funcs && !e.children && (r.isLeaf = !0, r.apiPath = e.path || e.name), r;
|
|
1204
|
+
});
|
|
1205
|
+
a.value = n(t), R();
|
|
1206
|
+
} catch (e) {
|
|
1207
|
+
i.value = "加载 API 列表失败:" + e.message, console.error("加载 API 列表失败:", e);
|
|
1208
|
+
} finally {
|
|
1209
|
+
r.value = !1;
|
|
1210
|
+
}
|
|
1211
|
+
}, R = () => {
|
|
1212
|
+
let t = [...a.value];
|
|
1213
|
+
(e.includePattern.length > 0 || e.excludePattern.length > 0) && (t = ue(t, e.includePattern, e.excludePattern)), o.value && (t = Le(t, o.value)), s.value = t;
|
|
1214
|
+
}, ue = (e, t, n) => {
|
|
1215
|
+
let r = (e) => {
|
|
1216
|
+
if ((e.isLeaf || e.apiPath) && e.apiPath) return n.some((t) => Re(e.apiPath, t)) || t.length > 0 && !t.some((t) => Re(e.apiPath, t)) ? null : e;
|
|
1217
|
+
if (e.children?.length > 0) {
|
|
1218
|
+
let t = e.children.map(r).filter(Boolean);
|
|
1219
|
+
return t.length > 0 ? {
|
|
1220
|
+
...e,
|
|
1221
|
+
children: t
|
|
1222
|
+
} : null;
|
|
1223
|
+
}
|
|
1224
|
+
return null;
|
|
1225
|
+
};
|
|
1226
|
+
return e.map(r).filter(Boolean);
|
|
1227
|
+
}, de = () => {
|
|
1228
|
+
R();
|
|
1229
|
+
}, fe = (e, t) => {
|
|
1230
|
+
if (!e) return null;
|
|
1231
|
+
let n = e, r = null, i = [
|
|
1232
|
+
{
|
|
1233
|
+
check: () => e.properties?.data?.properties?.list,
|
|
1234
|
+
path: "@.data.list",
|
|
1235
|
+
schema: () => e.properties.data.properties.list
|
|
1236
|
+
},
|
|
1237
|
+
{
|
|
1238
|
+
check: () => e.properties?.list,
|
|
1239
|
+
path: "@.list",
|
|
1240
|
+
schema: () => e.properties.list
|
|
1241
|
+
},
|
|
1242
|
+
{
|
|
1243
|
+
check: () => e.type === "array",
|
|
1244
|
+
path: "@",
|
|
1245
|
+
schema: () => e
|
|
1246
|
+
}
|
|
1247
|
+
];
|
|
1248
|
+
for (let { check: e, path: t, schema: a } of i) if (e()) {
|
|
1249
|
+
r = t, n = a();
|
|
1250
|
+
break;
|
|
1251
|
+
}
|
|
1252
|
+
return !r && t?.includes("list") && e.properties?.data && (r = "@.data.list", n = {
|
|
1253
|
+
type: "array",
|
|
1254
|
+
items: {
|
|
1255
|
+
type: "object",
|
|
1256
|
+
properties: {}
|
|
1257
|
+
}
|
|
1258
|
+
}), r && n?.type === "array" ? {
|
|
1259
|
+
type: "array",
|
|
1260
|
+
x_path: r,
|
|
1261
|
+
items: n.items
|
|
1262
|
+
} : r ? {
|
|
1263
|
+
...n,
|
|
1264
|
+
x_path: r
|
|
1265
|
+
} : n;
|
|
1266
|
+
}, pe = (t) => {
|
|
1267
|
+
c.value = t, f.value = "{\n \"page_no\": 1,\n \"page_size\": 100\n}", m.value = "", g.value = {}, _.value = {}, v.value = {
|
|
1268
|
+
arrayPath: "",
|
|
1269
|
+
fieldMapping: {}
|
|
1270
|
+
}, y.value = [], S.value = null, C.value = "", w.value = [];
|
|
1271
|
+
let r = t._raw?.res_schema || t._raw?.schema?.res_schema || t.res_schema, i = t._raw?.req_schema || t._raw?.schema?.req_schema || t.req_schema;
|
|
1272
|
+
if (N.value = fe(r, t.apiPath) || e.resSchema, P.value = i, N.value?.x_path && (v.value.arrayPath = N.value.x_path.replace(/^@\./, "")), i && F.value.length > 0) {
|
|
1273
|
+
let e = Object.fromEntries(F.value.map((e) => [e.name, e.type === "number" || e.type === "integer" ? +!!e.name.includes("page") : e.type === "boolean" ? !0 : ""]));
|
|
1274
|
+
f.value = JSON.stringify(e, null, 2);
|
|
1275
|
+
}
|
|
1276
|
+
n("change", {
|
|
1277
|
+
api: t,
|
|
1278
|
+
config: null,
|
|
1279
|
+
resSchema: N.value
|
|
1280
|
+
});
|
|
1281
|
+
}, z = ({ key: e, path: t }) => {
|
|
1282
|
+
g.value[e] = t;
|
|
1283
|
+
}, me = ({ key: e, format: t }) => {
|
|
1284
|
+
_.value[e] = t;
|
|
1285
|
+
};
|
|
1286
|
+
x([f, d], () => {
|
|
1287
|
+
try {
|
|
1288
|
+
m.value = Be(ze(f.value, d.value), d.value).error || "";
|
|
1289
|
+
} catch (e) {
|
|
1290
|
+
m.value = e.message;
|
|
1291
|
+
}
|
|
1292
|
+
});
|
|
1293
|
+
let he = () => {
|
|
1294
|
+
if (L.value) try {
|
|
1295
|
+
let e = null;
|
|
1296
|
+
f.value.trim() !== "{}" && f.value.trim() !== "" && (e = ze(f.value, d.value)), n("save", {
|
|
1297
|
+
apiPath: c.value.apiPath,
|
|
1298
|
+
reqMapping: e,
|
|
1299
|
+
mode: "filter",
|
|
1300
|
+
filterConfig: {
|
|
1301
|
+
arrayPath: v.value.arrayPath || null,
|
|
1302
|
+
fieldMapping: v.value.fieldMapping,
|
|
1303
|
+
fieldTypes: v.value.fieldTypes || {},
|
|
1304
|
+
fieldFormats: v.value.fieldFormats || {}
|
|
1305
|
+
}
|
|
1306
|
+
});
|
|
1307
|
+
} catch (e) {
|
|
1308
|
+
alert("保存失败:" + e.message), console.error("保存配置失败:", e);
|
|
1309
|
+
}
|
|
1310
|
+
}, ge = () => {
|
|
1311
|
+
confirm("确定要重置所有配置吗?") && (c.value = null, f.value = "{\n \"page_no\": 1,\n \"page_size\": 100\n}", m.value = "", g.value = {}, _.value = {}, v.value = {
|
|
1312
|
+
arrayPath: "",
|
|
1313
|
+
fieldMapping: {},
|
|
1314
|
+
fieldTypes: {},
|
|
1315
|
+
fieldFormats: {}
|
|
1316
|
+
}, y.value = [], o.value = "", R());
|
|
1317
|
+
}, _e = () => {
|
|
1318
|
+
if (!e.initialConfig) return;
|
|
1319
|
+
let t = e.initialConfig;
|
|
1320
|
+
if (t.reqMapping) {
|
|
1321
|
+
let e = Object.values(t.reqMapping)[0];
|
|
1322
|
+
typeof e == "string" && e.includes("${") ? d.value = "template" : typeof e == "string" && e.includes("=>") ? d.value = "function" : d.value = "fixed", f.value = JSON.stringify(t.reqMapping, null, 2);
|
|
1323
|
+
}
|
|
1324
|
+
if (t.filterConfig) {
|
|
1325
|
+
let e = t.filterConfig;
|
|
1326
|
+
v.value.arrayPath = e.arrayPath || "", v.value.fieldMapping = e.fieldMapping || {}, v.value.fieldTypes = e.fieldTypes || {}, v.value.fieldFormats = e.fieldFormats || {}, y.value = [], Object.entries(e.fieldMapping || {}).forEach(([t, n]) => {
|
|
1327
|
+
let r = Array.isArray(n) ? n.join(",") : n;
|
|
1328
|
+
y.value.push({
|
|
1329
|
+
target: t,
|
|
1330
|
+
source: r,
|
|
1331
|
+
type: e.fieldTypes?.[t] || "string",
|
|
1332
|
+
format: e.fieldFormats?.[t] || ""
|
|
1333
|
+
});
|
|
1334
|
+
});
|
|
1335
|
+
}
|
|
1336
|
+
};
|
|
1337
|
+
return p(() => {
|
|
1338
|
+
le(), _e();
|
|
1339
|
+
}), x([() => e.includePattern, () => e.excludePattern], () => {
|
|
1340
|
+
R();
|
|
1341
|
+
}, { deep: !0 }), {
|
|
1342
|
+
loading: r,
|
|
1343
|
+
error: i,
|
|
1344
|
+
searchKeyword: o,
|
|
1345
|
+
filteredApiTree: s,
|
|
1346
|
+
treeData: ie,
|
|
1347
|
+
defaultExpandedKeys: M,
|
|
1348
|
+
expandedKeys: u,
|
|
1349
|
+
selectedApi: c,
|
|
1350
|
+
selectedKeys: l,
|
|
1351
|
+
filterConfig: v,
|
|
1352
|
+
filterFieldMappings: y,
|
|
1353
|
+
testingApi: b,
|
|
1354
|
+
testApiResult: S,
|
|
1355
|
+
extractedArrayPreview: E,
|
|
1356
|
+
detectedArrayPath: C,
|
|
1357
|
+
detectedFields: w,
|
|
1358
|
+
resSchemaFields: T,
|
|
1359
|
+
reqMappingMode: d,
|
|
1360
|
+
reqMappingText: f,
|
|
1361
|
+
reqMappingError: m,
|
|
1362
|
+
reqMappingPlaceholder: I,
|
|
1363
|
+
fieldPaths: g,
|
|
1364
|
+
fieldFormats: _,
|
|
1365
|
+
currentResSchema: N,
|
|
1366
|
+
currentReqSchema: P,
|
|
1367
|
+
reqSchemaFields: F,
|
|
1368
|
+
isSchemaIncomplete: se,
|
|
1369
|
+
canSave: L,
|
|
1370
|
+
missingRequiredParams: ce,
|
|
1371
|
+
handleSearch: de,
|
|
1372
|
+
handleTreeSelect: ae,
|
|
1373
|
+
handleTreeExpand: oe,
|
|
1374
|
+
handleUpdateFieldPath: z,
|
|
1375
|
+
handleUpdateFieldFormat: me,
|
|
1376
|
+
handleTestApi: D,
|
|
1377
|
+
applyDetectedPath: ee,
|
|
1378
|
+
quickAddField: k,
|
|
1379
|
+
formatJson: te,
|
|
1380
|
+
addFieldMapping: ne,
|
|
1381
|
+
removeFieldMapping: re,
|
|
1382
|
+
handleSave: he,
|
|
1383
|
+
handleReset: ge
|
|
1384
|
+
};
|
|
1385
|
+
}
|
|
1386
|
+
}, Qe = { class: "api-config-component" }, $e = { class: "left-panel" }, et = { class: "search-box" }, tt = { class: "api-tree-container" }, nt = {
|
|
1387
|
+
key: 0,
|
|
1388
|
+
class: "loading"
|
|
1389
|
+
}, rt = {
|
|
1390
|
+
key: 1,
|
|
1391
|
+
class: "error"
|
|
1392
|
+
}, it = {
|
|
1393
|
+
key: 2,
|
|
1394
|
+
class: "empty"
|
|
1395
|
+
}, at = { class: "tree-node-content" }, ot = { class: "node-name" }, st = {
|
|
1396
|
+
key: 0,
|
|
1397
|
+
class: "node-path"
|
|
1398
|
+
}, ct = { class: "right-panel" }, lt = {
|
|
1399
|
+
key: 0,
|
|
1400
|
+
class: "empty-state"
|
|
1401
|
+
}, ut = {
|
|
1402
|
+
key: 1,
|
|
1403
|
+
class: "config-container"
|
|
1404
|
+
}, dt = { class: "selected-api-info" }, ft = { class: "api-info-card" }, pt = { class: "info-row" }, mt = { class: "value" }, ht = { class: "info-row" }, gt = { class: "value code" }, _t = { class: "req-mapping-section" }, vt = {
|
|
1405
|
+
key: 0,
|
|
1406
|
+
class: "req-schema-hint"
|
|
1407
|
+
}, yt = { class: "req-params-list" }, bt = { class: "param-name" }, xt = { class: "param-type" }, St = {
|
|
1408
|
+
key: 0,
|
|
1409
|
+
class: "param-required"
|
|
1410
|
+
}, Ct = {
|
|
1411
|
+
key: 1,
|
|
1412
|
+
class: "param-optional"
|
|
1413
|
+
}, wt = {
|
|
1414
|
+
key: 2,
|
|
1415
|
+
class: "param-desc"
|
|
1416
|
+
}, Tt = {
|
|
1417
|
+
key: 0,
|
|
1418
|
+
class: "missing-params-warning"
|
|
1419
|
+
}, Et = { class: "warning-content" }, Dt = { class: "warning-text" }, Ot = { class: "req-mapping-container" }, kt = { class: "req-mode-selector" }, At = { title: "直接填写固定的参数值,适合不需要动态变化的场景" }, jt = { title: "使用 ${变量名} 语法引用外部变量,适合需要动态传参的场景" }, Mt = { title: "使用函数处理参数,可以进行复杂的数据转换和逻辑处理" }, Nt = { class: "req-mapping-editor" }, Pt = ["placeholder"], Ft = {
|
|
1420
|
+
key: 0,
|
|
1421
|
+
class: "error-message"
|
|
1422
|
+
}, It = { class: "filter-mode-section" }, Lt = { class: "test-api-section" }, Rt = {
|
|
1423
|
+
key: 0,
|
|
1424
|
+
class: "test-result-panel"
|
|
1425
|
+
}, zt = { class: "result-header" }, Bt = {
|
|
1426
|
+
key: 0,
|
|
1427
|
+
class: "detected-path"
|
|
1428
|
+
}, Vt = { class: "detected-value" }, Ht = {
|
|
1429
|
+
key: 1,
|
|
1430
|
+
class: "detected-fields"
|
|
1431
|
+
}, Ut = { class: "fields-grid" }, Wt = ["onClick"], Gt = {
|
|
1432
|
+
key: 1,
|
|
1433
|
+
class: "schema-fields-hint"
|
|
1434
|
+
}, Kt = { class: "fields-grid" }, qt = ["onClick", "title"], Jt = { class: "filter-config-item" }, Yt = { class: "filter-config-item" }, Xt = { class: "config-label-row" }, Zt = {
|
|
1435
|
+
key: 0,
|
|
1436
|
+
class: "empty-hint"
|
|
1437
|
+
}, Qt = { class: "mapping-col mapping-col-target" }, $t = ["onUpdate:modelValue"], en = { class: "mapping-col mapping-col-source" }, tn = ["onUpdate:modelValue"], nn = { class: "mapping-col mapping-col-type" }, rn = { class: "mapping-col mapping-col-format" }, an = { class: "action-section" }, on = ["disabled"];
|
|
1438
|
+
function sn(t, c, l, u, d, f) {
|
|
1439
|
+
let p = _("a-tree"), h = _("a-button"), x = _("a-option"), w = _("a-select"), T = _("a-optgroup");
|
|
1440
|
+
return m(), i("div", Qe, [a("div", $e, [
|
|
1441
|
+
c[11] ||= a("div", { class: "panel-header" }, [a("h3", null, "网关接口配置")], -1),
|
|
1442
|
+
a("div", et, [C(a("input", {
|
|
1443
|
+
"onUpdate:modelValue": c[0] ||= (e) => u.searchKeyword = e,
|
|
1444
|
+
type: "text",
|
|
1445
|
+
placeholder: "搜索接口名称或路径...",
|
|
1446
|
+
class: "search-input",
|
|
1447
|
+
onInput: c[1] ||= (...e) => u.handleSearch && u.handleSearch(...e)
|
|
1448
|
+
}, null, 544), [[b, u.searchKeyword]]), c[10] ||= a("span", { class: "search-icon" }, "🔍", -1)]),
|
|
1449
|
+
c[12] ||= a("div", { class: "section-title" }, "选择 API 接口", -1),
|
|
1450
|
+
a("div", tt, [u.loading ? (m(), i("div", nt, "加载中...")) : u.error ? (m(), i("div", rt, v(u.error), 1)) : u.filteredApiTree.length === 0 ? (m(), i("div", it, v(u.searchKeyword ? "未找到匹配的接口" : "暂无可用接口"), 1)) : (m(), n(p, {
|
|
1451
|
+
key: 3,
|
|
1452
|
+
data: u.treeData,
|
|
1453
|
+
"default-expand-all": !1,
|
|
1454
|
+
"expanded-keys": u.expandedKeys,
|
|
1455
|
+
"selected-keys": u.selectedKeys,
|
|
1456
|
+
"show-line": !1,
|
|
1457
|
+
onSelect: u.handleTreeSelect,
|
|
1458
|
+
onExpand: u.handleTreeExpand
|
|
1459
|
+
}, {
|
|
1460
|
+
title: S((e) => [a("div", at, [a("span", ot, v(e.name), 1), e.apiPath ? (m(), i("span", st, v(e.apiPath), 1)) : r("", !0)])]),
|
|
1461
|
+
_: 1
|
|
1462
|
+
}, 8, [
|
|
1463
|
+
"data",
|
|
1464
|
+
"expanded-keys",
|
|
1465
|
+
"selected-keys",
|
|
1466
|
+
"onSelect",
|
|
1467
|
+
"onExpand"
|
|
1468
|
+
]))])
|
|
1469
|
+
]), a("div", ct, [u.selectedApi ? (m(), i("div", ut, [
|
|
1470
|
+
a("div", dt, [c[16] ||= a("div", { class: "section-title" }, "当前选中接口", -1), a("div", ft, [a("div", pt, [c[14] ||= a("span", { class: "label" }, "接口名称:", -1), a("span", mt, v(u.selectedApi.name), 1)]), a("div", ht, [c[15] ||= a("span", { class: "label" }, "接口路径:", -1), a("span", gt, v(u.selectedApi.apiPath), 1)])])]),
|
|
1471
|
+
a("div", _t, [
|
|
1472
|
+
c[27] ||= a("div", { class: "section-title" }, [o(" 入参配置 "), a("span", { class: "section-subtitle" }, "(可选)")], -1),
|
|
1473
|
+
u.currentReqSchema ? (m(), i("div", vt, [
|
|
1474
|
+
c[20] ||= a("div", { class: "hint-title" }, "📋 接口请求参数:", -1),
|
|
1475
|
+
a("div", yt, [(m(!0), i(e, null, g(u.reqSchemaFields, (e) => (m(), i("div", {
|
|
1476
|
+
key: e.key,
|
|
1477
|
+
class: "param-item"
|
|
1478
|
+
}, [
|
|
1479
|
+
a("span", bt, v(e.name), 1),
|
|
1480
|
+
a("span", xt, v(e.type), 1),
|
|
1481
|
+
e.required ? (m(), i("span", St, "必填")) : (m(), i("span", Ct, "可选")),
|
|
1482
|
+
e.description ? (m(), i("span", wt, v(e.description), 1)) : r("", !0)
|
|
1483
|
+
]))), 128))]),
|
|
1484
|
+
u.missingRequiredParams.length > 0 ? (m(), i("div", Tt, [c[19] ||= a("div", { class: "warning-icon" }, "⚠️", -1), a("div", Et, [c[18] ||= a("div", { class: "warning-title" }, "缺少必填参数", -1), a("div", Dt, [c[17] ||= o(" 以下参数是必填的,但未在入参配置中提供: ", -1), a("strong", null, v(u.missingRequiredParams.join("、")), 1)])])])) : r("", !0)
|
|
1485
|
+
])) : r("", !0),
|
|
1486
|
+
a("div", Ot, [a("div", kt, [
|
|
1487
|
+
a("label", At, [
|
|
1488
|
+
C(a("input", {
|
|
1489
|
+
type: "radio",
|
|
1490
|
+
"onUpdate:modelValue": c[2] ||= (e) => u.reqMappingMode = e,
|
|
1491
|
+
value: "fixed"
|
|
1492
|
+
}, null, 512), [[y, u.reqMappingMode]]),
|
|
1493
|
+
c[21] ||= a("span", null, "固定值", -1),
|
|
1494
|
+
c[22] ||= a("span", { class: "mode-hint" }, "直接填写固定参数", -1)
|
|
1495
|
+
]),
|
|
1496
|
+
a("label", jt, [
|
|
1497
|
+
C(a("input", {
|
|
1498
|
+
type: "radio",
|
|
1499
|
+
"onUpdate:modelValue": c[3] ||= (e) => u.reqMappingMode = e,
|
|
1500
|
+
value: "template"
|
|
1501
|
+
}, null, 512), [[y, u.reqMappingMode]]),
|
|
1502
|
+
c[23] ||= a("span", null, "模板字符串", -1),
|
|
1503
|
+
c[24] ||= a("span", { class: "mode-hint" }, "支持 ${变量} 语法", -1)
|
|
1504
|
+
]),
|
|
1505
|
+
a("label", Mt, [
|
|
1506
|
+
C(a("input", {
|
|
1507
|
+
type: "radio",
|
|
1508
|
+
"onUpdate:modelValue": c[4] ||= (e) => u.reqMappingMode = e,
|
|
1509
|
+
value: "function"
|
|
1510
|
+
}, null, 512), [[y, u.reqMappingMode]]),
|
|
1511
|
+
c[25] ||= a("span", null, "函数", -1),
|
|
1512
|
+
c[26] ||= a("span", { class: "mode-hint" }, "支持复杂逻辑处理", -1)
|
|
1513
|
+
])
|
|
1514
|
+
]), a("div", Nt, [C(a("textarea", {
|
|
1515
|
+
"onUpdate:modelValue": c[5] ||= (e) => u.reqMappingText = e,
|
|
1516
|
+
placeholder: u.reqMappingPlaceholder,
|
|
1517
|
+
class: "json-editor",
|
|
1518
|
+
rows: "8"
|
|
1519
|
+
}, null, 8, Pt), [[b, u.reqMappingText]]), u.reqMappingError ? (m(), i("div", Ft, v(u.reqMappingError), 1)) : r("", !0)])])
|
|
1520
|
+
]),
|
|
1521
|
+
a("div", It, [
|
|
1522
|
+
c[65] ||= a("div", { class: "section-title" }, [o(" 数据提取配置 "), a("span", { class: "section-subtitle" }, "(配置如何从接口数据中提取和映射字段)")], -1),
|
|
1523
|
+
a("div", Lt, [s(h, {
|
|
1524
|
+
type: "outline",
|
|
1525
|
+
onClick: u.handleTestApi,
|
|
1526
|
+
loading: u.testingApi,
|
|
1527
|
+
status: "success"
|
|
1528
|
+
}, {
|
|
1529
|
+
default: S(() => [...c[28] ||= [o(" 🔬 测试接口(查看返回数据) ", -1)]]),
|
|
1530
|
+
_: 1
|
|
1531
|
+
}, 8, ["onClick", "loading"]), c[29] ||= a("span", { class: "test-hint" }, "点击测试接口,查看实际返回的字段结构", -1)]),
|
|
1532
|
+
u.testApiResult ? (m(), i("div", Rt, [
|
|
1533
|
+
a("div", zt, [c[31] ||= a("span", { class: "result-title" }, "📋 接口返回数据预览", -1), s(h, {
|
|
1534
|
+
size: "mini",
|
|
1535
|
+
type: "text",
|
|
1536
|
+
onClick: c[6] ||= (e) => u.testApiResult = null
|
|
1537
|
+
}, {
|
|
1538
|
+
default: S(() => [...c[30] ||= [o("关闭", -1)]]),
|
|
1539
|
+
_: 1
|
|
1540
|
+
})]),
|
|
1541
|
+
u.detectedArrayPath ? (m(), i("div", Bt, [
|
|
1542
|
+
c[33] ||= a("div", { class: "detected-label" }, "✓ 检测到数据数组路径:", -1),
|
|
1543
|
+
a("div", Vt, v(u.detectedArrayPath), 1),
|
|
1544
|
+
s(h, {
|
|
1545
|
+
size: "mini",
|
|
1546
|
+
onClick: u.applyDetectedPath
|
|
1547
|
+
}, {
|
|
1548
|
+
default: S(() => [...c[32] ||= [o("应用此路径", -1)]]),
|
|
1549
|
+
_: 1
|
|
1550
|
+
}, 8, ["onClick"])
|
|
1551
|
+
])) : r("", !0),
|
|
1552
|
+
u.detectedFields.length > 0 ? (m(), i("div", Ht, [c[34] ||= a("div", { class: "detected-label" }, "✓ 检测到以下字段(点击快速添加):", -1), a("div", Ut, [(m(!0), i(e, null, g(u.detectedFields, (e) => (m(), i("div", {
|
|
1553
|
+
key: e,
|
|
1554
|
+
class: "field-tag",
|
|
1555
|
+
onClick: (t) => u.quickAddField(e)
|
|
1556
|
+
}, v(e), 9, Wt))), 128))])])) : r("", !0)
|
|
1557
|
+
])) : r("", !0),
|
|
1558
|
+
u.resSchemaFields.length > 0 ? (m(), i("div", Gt, [
|
|
1559
|
+
c[35] ||= a("div", { class: "hint-title" }, "📝 接口定义的字段:", -1),
|
|
1560
|
+
a("div", Kt, [(m(!0), i(e, null, g(u.resSchemaFields, (e) => (m(), i("div", {
|
|
1561
|
+
key: e,
|
|
1562
|
+
class: "field-tag clickable",
|
|
1563
|
+
onClick: (t) => u.quickAddField(e),
|
|
1564
|
+
title: `点击添加 ${e} 字段映射`
|
|
1565
|
+
}, v(e), 9, qt))), 128))]),
|
|
1566
|
+
c[36] ||= a("div", { class: "hint-desc" }, "点击字段名快速添加到映射配置", -1)
|
|
1567
|
+
])) : r("", !0),
|
|
1568
|
+
a("div", Jt, [
|
|
1569
|
+
c[37] ||= a("label", { class: "config-label" }, [o(" 数据路径 "), a("span", { class: "label-hint" }, "(可选,留空则自动推断)")], -1),
|
|
1570
|
+
C(a("input", {
|
|
1571
|
+
"onUpdate:modelValue": c[7] ||= (e) => u.filterConfig.arrayPath = e,
|
|
1572
|
+
type: "text",
|
|
1573
|
+
class: "config-input",
|
|
1574
|
+
placeholder: "例如: data.list 或 @.data.list(@表示根对象)"
|
|
1575
|
+
}, null, 512), [[b, u.filterConfig.arrayPath]]),
|
|
1576
|
+
c[38] ||= a("div", { class: "config-hint" }, " 💡 提示: 如果接口返回的数据结构是 { data: { list: [...] } }, 可以填写 \"data.list\" 或 \"@.data.list\" ", -1)
|
|
1577
|
+
]),
|
|
1578
|
+
a("div", Yt, [
|
|
1579
|
+
a("div", Xt, [c[40] ||= a("label", { class: "config-label" }, "字段映射规则", -1), s(h, {
|
|
1580
|
+
size: "mini",
|
|
1581
|
+
type: "primary",
|
|
1582
|
+
onClick: u.addFieldMapping
|
|
1583
|
+
}, {
|
|
1584
|
+
default: S(() => [...c[39] ||= [o(" + 添加字段 ", -1)]]),
|
|
1585
|
+
_: 1
|
|
1586
|
+
}, 8, ["onClick"])]),
|
|
1587
|
+
u.filterFieldMappings.length === 0 ? (m(), i("div", Zt, " 暂无字段映射,点击\"添加字段\"按钮开始配置,或先测试接口查看可用字段 ")) : r("", !0),
|
|
1588
|
+
(m(!0), i(e, null, g(u.filterFieldMappings, (e, t) => (m(), i("div", {
|
|
1589
|
+
key: t,
|
|
1590
|
+
class: "field-mapping-row"
|
|
1591
|
+
}, [
|
|
1592
|
+
a("div", Qt, [c[41] ||= a("label", { class: "col-label" }, "目标字段名", -1), C(a("input", {
|
|
1593
|
+
"onUpdate:modelValue": (t) => e.target = t,
|
|
1594
|
+
type: "text",
|
|
1595
|
+
class: "mapping-input",
|
|
1596
|
+
placeholder: "例如: id, title, content"
|
|
1597
|
+
}, null, 8, $t), [[b, e.target]])]),
|
|
1598
|
+
c[63] ||= a("div", { class: "mapping-arrow" }, "→", -1),
|
|
1599
|
+
a("div", en, [c[42] ||= a("label", { class: "col-label" }, "来源字段(支持多个,逗号分隔)", -1), C(a("input", {
|
|
1600
|
+
"onUpdate:modelValue": (t) => e.source = t,
|
|
1601
|
+
type: "text",
|
|
1602
|
+
class: "mapping-input",
|
|
1603
|
+
placeholder: "例如: content,title,message"
|
|
1604
|
+
}, null, 8, tn), [[b, e.source]])]),
|
|
1605
|
+
a("div", nn, [c[48] ||= a("label", { class: "col-label" }, "类型", -1), s(w, {
|
|
1606
|
+
modelValue: e.type,
|
|
1607
|
+
"onUpdate:modelValue": (t) => e.type = t,
|
|
1608
|
+
placeholder: "类型",
|
|
1609
|
+
size: "small",
|
|
1610
|
+
class: "mapping-select"
|
|
1611
|
+
}, {
|
|
1612
|
+
default: S(() => [
|
|
1613
|
+
s(x, { value: "string" }, {
|
|
1614
|
+
default: S(() => [...c[43] ||= [o("字符串", -1)]]),
|
|
1615
|
+
_: 1
|
|
1616
|
+
}),
|
|
1617
|
+
s(x, { value: "number" }, {
|
|
1618
|
+
default: S(() => [...c[44] ||= [o("数字", -1)]]),
|
|
1619
|
+
_: 1
|
|
1620
|
+
}),
|
|
1621
|
+
s(x, { value: "integer" }, {
|
|
1622
|
+
default: S(() => [...c[45] ||= [o("整数", -1)]]),
|
|
1623
|
+
_: 1
|
|
1624
|
+
}),
|
|
1625
|
+
s(x, { value: "boolean" }, {
|
|
1626
|
+
default: S(() => [...c[46] ||= [o("布尔", -1)]]),
|
|
1627
|
+
_: 1
|
|
1628
|
+
}),
|
|
1629
|
+
s(x, { value: "date" }, {
|
|
1630
|
+
default: S(() => [...c[47] ||= [o("日期", -1)]]),
|
|
1631
|
+
_: 1
|
|
1632
|
+
})
|
|
1633
|
+
]),
|
|
1634
|
+
_: 1
|
|
1635
|
+
}, 8, ["modelValue", "onUpdate:modelValue"])]),
|
|
1636
|
+
a("div", rn, [c[61] ||= a("label", { class: "col-label" }, "格式化", -1), s(w, {
|
|
1637
|
+
modelValue: e.format,
|
|
1638
|
+
"onUpdate:modelValue": (t) => e.format = t,
|
|
1639
|
+
placeholder: "选择格式化方式",
|
|
1640
|
+
size: "small",
|
|
1641
|
+
class: "mapping-select",
|
|
1642
|
+
"allow-clear": ""
|
|
1643
|
+
}, {
|
|
1644
|
+
default: S(() => [
|
|
1645
|
+
s(x, { value: "" }, {
|
|
1646
|
+
default: S(() => [...c[49] ||= [o("无", -1)]]),
|
|
1647
|
+
_: 1
|
|
1648
|
+
}),
|
|
1649
|
+
e.type === "date" ? (m(), n(T, {
|
|
1650
|
+
key: 0,
|
|
1651
|
+
label: "日期格式"
|
|
1652
|
+
}, {
|
|
1653
|
+
default: S(() => [
|
|
1654
|
+
s(x, { value: "YYYY-MM-DD" }, {
|
|
1655
|
+
default: S(() => [...c[50] ||= [o("YYYY-MM-DD", -1)]]),
|
|
1656
|
+
_: 1
|
|
1657
|
+
}),
|
|
1658
|
+
s(x, { value: "YYYY-MM-DD HH:mm:ss" }, {
|
|
1659
|
+
default: S(() => [...c[51] ||= [o("YYYY-MM-DD HH:mm:ss", -1)]]),
|
|
1660
|
+
_: 1
|
|
1661
|
+
}),
|
|
1662
|
+
s(x, { value: "YYYY/MM/DD" }, {
|
|
1663
|
+
default: S(() => [...c[52] ||= [o("YYYY/MM/DD", -1)]]),
|
|
1664
|
+
_: 1
|
|
1665
|
+
}),
|
|
1666
|
+
s(x, { value: "timestamp" }, {
|
|
1667
|
+
default: S(() => [...c[53] ||= [o("时间戳(毫秒)", -1)]]),
|
|
1668
|
+
_: 1
|
|
1669
|
+
}),
|
|
1670
|
+
s(x, { value: "timestamp_s" }, {
|
|
1671
|
+
default: S(() => [...c[54] ||= [o("时间戳(秒)", -1)]]),
|
|
1672
|
+
_: 1
|
|
1673
|
+
})
|
|
1674
|
+
]),
|
|
1675
|
+
_: 1
|
|
1676
|
+
})) : r("", !0),
|
|
1677
|
+
e.type === "number" || e.type === "integer" ? (m(), n(T, {
|
|
1678
|
+
key: 1,
|
|
1679
|
+
label: "数字格式"
|
|
1680
|
+
}, {
|
|
1681
|
+
default: S(() => [s(x, { value: "currency" }, {
|
|
1682
|
+
default: S(() => [...c[55] ||= [o("货币(¥)", -1)]]),
|
|
1683
|
+
_: 1
|
|
1684
|
+
}), s(x, { value: "percent" }, {
|
|
1685
|
+
default: S(() => [...c[56] ||= [o("百分比(%)", -1)]]),
|
|
1686
|
+
_: 1
|
|
1687
|
+
})]),
|
|
1688
|
+
_: 1
|
|
1689
|
+
})) : r("", !0),
|
|
1690
|
+
e.type === "string" ? (m(), n(T, {
|
|
1691
|
+
key: 2,
|
|
1692
|
+
label: "字符串格式"
|
|
1693
|
+
}, {
|
|
1694
|
+
default: S(() => [
|
|
1695
|
+
s(x, { value: "uppercase" }, {
|
|
1696
|
+
default: S(() => [...c[57] ||= [o("大写", -1)]]),
|
|
1697
|
+
_: 1
|
|
1698
|
+
}),
|
|
1699
|
+
s(x, { value: "lowercase" }, {
|
|
1700
|
+
default: S(() => [...c[58] ||= [o("小写", -1)]]),
|
|
1701
|
+
_: 1
|
|
1702
|
+
}),
|
|
1703
|
+
s(x, { value: "trim" }, {
|
|
1704
|
+
default: S(() => [...c[59] ||= [o("去除空格", -1)]]),
|
|
1705
|
+
_: 1
|
|
1706
|
+
})
|
|
1707
|
+
]),
|
|
1708
|
+
_: 1
|
|
1709
|
+
})) : r("", !0),
|
|
1710
|
+
s(T, { label: "通用格式" }, {
|
|
1711
|
+
default: S(() => [s(x, { value: "json" }, {
|
|
1712
|
+
default: S(() => [...c[60] ||= [o("JSON字符串", -1)]]),
|
|
1713
|
+
_: 1
|
|
1714
|
+
})]),
|
|
1715
|
+
_: 1
|
|
1716
|
+
})
|
|
1717
|
+
]),
|
|
1718
|
+
_: 2
|
|
1719
|
+
}, 1032, ["modelValue", "onUpdate:modelValue"])]),
|
|
1720
|
+
s(h, {
|
|
1721
|
+
size: "mini",
|
|
1722
|
+
type: "text",
|
|
1723
|
+
status: "danger",
|
|
1724
|
+
onClick: (e) => u.removeFieldMapping(t),
|
|
1725
|
+
class: "mapping-delete-btn"
|
|
1726
|
+
}, {
|
|
1727
|
+
default: S(() => [...c[62] ||= [o(" 删除 ", -1)]]),
|
|
1728
|
+
_: 1
|
|
1729
|
+
}, 8, ["onClick"])
|
|
1730
|
+
]))), 128)),
|
|
1731
|
+
c[64] ||= a("div", { class: "config-hint" }, " 💡 提示: 来源字段支持多个备选(逗号分隔),系统会自动选择第一个有值的字段。例如: \"content,title,message\" ", -1)
|
|
1732
|
+
])
|
|
1733
|
+
]),
|
|
1734
|
+
a("div", an, [a("button", {
|
|
1735
|
+
onClick: c[8] ||= (...e) => u.handleReset && u.handleReset(...e),
|
|
1736
|
+
class: "btn-secondary"
|
|
1737
|
+
}, " 重置 "), a("button", {
|
|
1738
|
+
onClick: c[9] ||= (...e) => u.handleSave && u.handleSave(...e),
|
|
1739
|
+
class: "btn-primary",
|
|
1740
|
+
disabled: !u.canSave
|
|
1741
|
+
}, " 保存配置 ", 8, on)])
|
|
1742
|
+
])) : (m(), i("div", lt, [...c[13] ||= [a("div", { class: "empty-icon" }, "📋", -1), a("div", { class: "empty-text" }, "请先选择一个 API 接口", -1)]]))])]);
|
|
1743
|
+
}
|
|
1744
|
+
var $ = /* @__PURE__ */ be(Ze, [["render", sn], ["__scopeId", "data-v-209e697e"]]);
|
|
1745
|
+
//#endregion
|
|
1746
|
+
//#region src/index.js
|
|
1747
|
+
J();
|
|
1748
|
+
var cn = $, ln = (e) => {
|
|
1749
|
+
e.component("GatewayApiSelectConfig", $), e.component("ApiConfig", $);
|
|
1750
|
+
};
|
|
1751
|
+
typeof window < "u" && window.Vue && (window.GatewayApiSelectConfig = $, window.ApiConfig = $, window.GatewayApiSelectConfigUtils = {
|
|
1752
|
+
extractDataBySchema: U,
|
|
1753
|
+
executeReqMapping: q,
|
|
1754
|
+
extractOutputFields: H,
|
|
1755
|
+
formatConfig: ye,
|
|
1756
|
+
extractArray: Y,
|
|
1757
|
+
noticeFilter: Z,
|
|
1758
|
+
newsFilter: Q,
|
|
1759
|
+
menuFilter: Ke,
|
|
1760
|
+
userFilter: qe,
|
|
1761
|
+
applyFilter: X,
|
|
1762
|
+
applyFilterByName: Ye,
|
|
1763
|
+
filters: Je,
|
|
1764
|
+
fetchGatewayData: Xe
|
|
1765
|
+
});
|
|
1766
|
+
//#endregion
|
|
1767
|
+
export { $ as ApiConfig, $ as GatewayApiSelectConfig, X as applyFilter, Ye as applyFilterByName, cn as default, q as executeReqMapping, Y as extractArray, U as extractDataBySchema, H as extractOutputFields, Xe as fetchGatewayData, Je as filters, ye as formatConfig, ln as install, Ke as menuFilter, Q as newsFilter, Z as noticeFilter, qe as userFilter };
|