vue-api-request-builder 0.1.0
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/README.md +188 -0
- package/dist/index.d.ts +84 -0
- package/dist/index.es.js +633 -0
- package/dist/index.umd.js +6 -0
- package/dist/vite.svg +1 -0
- package/dist/vue-api-request-builder.css +1 -0
- package/lib/components/KeyValueInput.vue +144 -0
- package/lib/components/RequestForm.vue +388 -0
- package/lib/components/ResponseSection.vue +144 -0
- package/lib/index.ts +17 -0
- package/lib/types/request.ts +55 -0
- package/lib/utils/request.ts +194 -0
- package/package.json +49 -0
package/dist/index.es.js
ADDED
|
@@ -0,0 +1,633 @@
|
|
|
1
|
+
import { defineComponent as F, ref as w, watch as q, resolveComponent as y, createElementBlock as R, openBlock as g, createElementVNode as h, createCommentVNode as T, createBlock as z, createVNode as l, withCtx as d, createTextVNode as _, toDisplayString as J, Fragment as A, renderList as le, computed as I } from "vue";
|
|
2
|
+
const oe = { class: "key-value-input flex flex-col gap-1" }, se = { class: "flex gap-2" }, ne = {
|
|
3
|
+
key: 0,
|
|
4
|
+
class: "flex flex-col gap-1"
|
|
5
|
+
}, ue = { class: "flex w-full gap-1 items-center" }, re = /* @__PURE__ */ F({
|
|
6
|
+
__name: "KeyValueInput",
|
|
7
|
+
props: {
|
|
8
|
+
modelValue: {},
|
|
9
|
+
addButtonText: { default: "添加参数" },
|
|
10
|
+
showPreview: { type: Boolean, default: !1 },
|
|
11
|
+
previewText: { default: "" }
|
|
12
|
+
},
|
|
13
|
+
emits: ["update:modelValue"],
|
|
14
|
+
setup(t, { emit: x }) {
|
|
15
|
+
const r = t, s = x, n = w(r.modelValue);
|
|
16
|
+
q(
|
|
17
|
+
() => r.modelValue,
|
|
18
|
+
(i) => {
|
|
19
|
+
n.value = i;
|
|
20
|
+
}
|
|
21
|
+
), q(
|
|
22
|
+
n,
|
|
23
|
+
(i) => {
|
|
24
|
+
s("update:modelValue", i);
|
|
25
|
+
},
|
|
26
|
+
{ deep: !0 }
|
|
27
|
+
);
|
|
28
|
+
const f = () => {
|
|
29
|
+
n.value.push({ key: "", value: "" });
|
|
30
|
+
}, a = (i) => {
|
|
31
|
+
n.value.splice(i, 1);
|
|
32
|
+
}, v = () => {
|
|
33
|
+
n.value = [];
|
|
34
|
+
};
|
|
35
|
+
return (i, u) => {
|
|
36
|
+
const m = y("a-button"), c = y("a-popconfirm"), B = y("a-input"), $ = y("a-typography-paragraph"), U = y("a-typography");
|
|
37
|
+
return g(), R("div", oe, [
|
|
38
|
+
h("div", se, [
|
|
39
|
+
l(m, {
|
|
40
|
+
type: "primary",
|
|
41
|
+
onClick: f,
|
|
42
|
+
class: "w-40 max-w-full",
|
|
43
|
+
size: "small"
|
|
44
|
+
}, {
|
|
45
|
+
default: d(() => [
|
|
46
|
+
_(J(i.addButtonText), 1)
|
|
47
|
+
]),
|
|
48
|
+
_: 1
|
|
49
|
+
}),
|
|
50
|
+
l(c, {
|
|
51
|
+
title: "确认清空",
|
|
52
|
+
description: "确定要清空所有参数吗?",
|
|
53
|
+
"ok-text": "确认",
|
|
54
|
+
"cancel-text": "取消",
|
|
55
|
+
onConfirm: v
|
|
56
|
+
}, {
|
|
57
|
+
default: d(() => [
|
|
58
|
+
l(m, {
|
|
59
|
+
type: "primary",
|
|
60
|
+
danger: "",
|
|
61
|
+
class: "w-40 max-w-full",
|
|
62
|
+
size: "small",
|
|
63
|
+
disabled: n.value.length === 0
|
|
64
|
+
}, {
|
|
65
|
+
default: d(() => u[0] || (u[0] = [
|
|
66
|
+
_(" 清空 ")
|
|
67
|
+
])),
|
|
68
|
+
_: 1
|
|
69
|
+
}, 8, ["disabled"])
|
|
70
|
+
]),
|
|
71
|
+
_: 1
|
|
72
|
+
})
|
|
73
|
+
]),
|
|
74
|
+
n.value.length > 0 ? (g(), R("div", ne, [
|
|
75
|
+
(g(!0), R(A, null, le(n.value, (k, S) => (g(), R("div", {
|
|
76
|
+
key: S,
|
|
77
|
+
class: "flex"
|
|
78
|
+
}, [
|
|
79
|
+
h("div", ue, [
|
|
80
|
+
l(m, {
|
|
81
|
+
type: "primary",
|
|
82
|
+
danger: "",
|
|
83
|
+
onClick: (j) => a(S),
|
|
84
|
+
class: "w-16",
|
|
85
|
+
size: "small"
|
|
86
|
+
}, {
|
|
87
|
+
default: d(() => u[1] || (u[1] = [
|
|
88
|
+
_(" 删除 ")
|
|
89
|
+
])),
|
|
90
|
+
_: 2
|
|
91
|
+
}, 1032, ["onClick"]),
|
|
92
|
+
l(B, {
|
|
93
|
+
value: k.key,
|
|
94
|
+
"onUpdate:value": (j) => k.key = j,
|
|
95
|
+
placeholder: "键",
|
|
96
|
+
style: { width: "60%" },
|
|
97
|
+
size: "small"
|
|
98
|
+
}, null, 8, ["value", "onUpdate:value"]),
|
|
99
|
+
l(B, {
|
|
100
|
+
value: k.value,
|
|
101
|
+
"onUpdate:value": (j) => k.value = j,
|
|
102
|
+
placeholder: "值",
|
|
103
|
+
style: { width: "100%" },
|
|
104
|
+
size: "small"
|
|
105
|
+
}, null, 8, ["value", "onUpdate:value"])
|
|
106
|
+
])
|
|
107
|
+
]))), 128))
|
|
108
|
+
])) : T("", !0),
|
|
109
|
+
i.showPreview ? (g(), z(U, {
|
|
110
|
+
key: 1,
|
|
111
|
+
class: "m-0"
|
|
112
|
+
}, {
|
|
113
|
+
default: d(() => [
|
|
114
|
+
l($, { class: "!m-0" }, {
|
|
115
|
+
default: d(() => [
|
|
116
|
+
h("pre", null, J(i.previewText), 1)
|
|
117
|
+
]),
|
|
118
|
+
_: 1
|
|
119
|
+
})
|
|
120
|
+
]),
|
|
121
|
+
_: 1
|
|
122
|
+
})) : T("", !0)
|
|
123
|
+
]);
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
}), G = (t, x) => {
|
|
127
|
+
const r = t.__vccOpts || t;
|
|
128
|
+
for (const [s, n] of x)
|
|
129
|
+
r[s] = n;
|
|
130
|
+
return r;
|
|
131
|
+
}, D = /* @__PURE__ */ G(re, [["__scopeId", "data-v-1e5ef051"]]), de = {
|
|
132
|
+
method: "GET",
|
|
133
|
+
url: "https://yesno.wtf",
|
|
134
|
+
path: "/api",
|
|
135
|
+
auth: {
|
|
136
|
+
type: "none"
|
|
137
|
+
},
|
|
138
|
+
params: [],
|
|
139
|
+
headers: [],
|
|
140
|
+
body: {
|
|
141
|
+
type: "application/json"
|
|
142
|
+
}
|
|
143
|
+
}, pe = { class: "request-form" }, ie = { class: "flex flex-col gap-1" }, ve = { class: "flex flex-row gap-1" }, me = { class: "flex flex-row gap-1" }, fe = { class: "mt-1" }, ce = {
|
|
144
|
+
key: 0,
|
|
145
|
+
class: "flex flex-col gap-1 mt-2"
|
|
146
|
+
}, ye = { class: "flex flex-row gap-1 h-6" }, we = { class: "flex flex-row gap-1" }, _e = {
|
|
147
|
+
key: 1,
|
|
148
|
+
class: "flex flex-col gap-1 mt-1"
|
|
149
|
+
}, xe = { class: "flex flex-row gap-1 items-center" }, ke = /* @__PURE__ */ F({
|
|
150
|
+
__name: "RequestForm",
|
|
151
|
+
props: {
|
|
152
|
+
modelValue: { default: () => de }
|
|
153
|
+
},
|
|
154
|
+
emits: ["update:modelValue"],
|
|
155
|
+
setup(t, { emit: x }) {
|
|
156
|
+
const r = t, s = x, n = w(r.modelValue.method), f = w(r.modelValue.url), a = w(r.modelValue.auth.type), v = w(r.modelValue.path), i = w(r.modelValue.auth.username || ""), u = w(r.modelValue.auth.password || ""), m = w(r.modelValue.auth.token || ""), c = w(r.modelValue.params), B = w(r.modelValue.headers), $ = w(r.modelValue.body.formData || []), U = w(r.modelValue.body.type), k = w(r.modelValue.body.json || ""), S = w(r.modelValue.body.raw || ""), j = w("");
|
|
157
|
+
function K(o, e) {
|
|
158
|
+
let b;
|
|
159
|
+
return function(...V) {
|
|
160
|
+
clearTimeout(b), b = setTimeout(() => o.apply(this, V), e);
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
const L = () => ({
|
|
164
|
+
method: n.value,
|
|
165
|
+
url: f.value,
|
|
166
|
+
path: v.value,
|
|
167
|
+
auth: {
|
|
168
|
+
type: a.value,
|
|
169
|
+
...a.value === "Basic" ? {
|
|
170
|
+
username: i.value,
|
|
171
|
+
password: u.value
|
|
172
|
+
} : a.value === "Bearer" ? {
|
|
173
|
+
token: m.value
|
|
174
|
+
} : {}
|
|
175
|
+
},
|
|
176
|
+
params: c.value,
|
|
177
|
+
headers: B.value,
|
|
178
|
+
body: {
|
|
179
|
+
type: U.value,
|
|
180
|
+
...U.value === "application/json" ? { json: k.value } : U.value === "multipart/form-data" ? { formData: $.value } : { raw: S.value }
|
|
181
|
+
}
|
|
182
|
+
}), W = K(() => {
|
|
183
|
+
s("update:modelValue", L());
|
|
184
|
+
}, 100);
|
|
185
|
+
q(
|
|
186
|
+
[
|
|
187
|
+
n,
|
|
188
|
+
f,
|
|
189
|
+
v,
|
|
190
|
+
a,
|
|
191
|
+
i,
|
|
192
|
+
u,
|
|
193
|
+
m,
|
|
194
|
+
c,
|
|
195
|
+
B,
|
|
196
|
+
U,
|
|
197
|
+
$,
|
|
198
|
+
k,
|
|
199
|
+
S
|
|
200
|
+
],
|
|
201
|
+
() => {
|
|
202
|
+
W();
|
|
203
|
+
},
|
|
204
|
+
{ deep: !0 }
|
|
205
|
+
), q(
|
|
206
|
+
() => r.modelValue,
|
|
207
|
+
(o) => {
|
|
208
|
+
const e = L();
|
|
209
|
+
JSON.stringify(o) !== JSON.stringify(e) && (n.value = o.method, f.value = o.url, v.value = o.path, a.value = o.auth.type, i.value = o.auth.username || "", u.value = o.auth.password || "", m.value = o.auth.token || "", c.value = o.params, B.value = o.headers, U.value = o.body.type, $.value = o.body.formData || [], k.value = o.body.json || "", S.value = o.body.raw || "");
|
|
210
|
+
},
|
|
211
|
+
{ deep: !0 }
|
|
212
|
+
);
|
|
213
|
+
const M = I(() => {
|
|
214
|
+
const o = c.value.filter((e) => !!e.key).map((e) => e.key + "=" + encodeURIComponent(e.value)).join("&");
|
|
215
|
+
return o === "" ? "" : "?" + o;
|
|
216
|
+
}), X = I(() => {
|
|
217
|
+
switch (U.value) {
|
|
218
|
+
case "application/json":
|
|
219
|
+
try {
|
|
220
|
+
return k.value ? JSON.stringify(JSON.parse(k.value), null, 2) : "-空-";
|
|
221
|
+
} catch {
|
|
222
|
+
return "Invalid JSON";
|
|
223
|
+
}
|
|
224
|
+
case "multipart/form-data":
|
|
225
|
+
const o = "----WebKitFormBoundaryPreview";
|
|
226
|
+
return $.value.filter((b) => !!b.key).map(
|
|
227
|
+
(b) => `--${o}\r
|
|
228
|
+
Content-Disposition: form-data; name="${b.key}"\r
|
|
229
|
+
\r
|
|
230
|
+
${b.value}\r
|
|
231
|
+
`
|
|
232
|
+
).join("") + `--${o}--\r
|
|
233
|
+
`;
|
|
234
|
+
case "text/plain":
|
|
235
|
+
return S.value || "-空-";
|
|
236
|
+
default:
|
|
237
|
+
return "-空-";
|
|
238
|
+
}
|
|
239
|
+
}), Q = () => {
|
|
240
|
+
try {
|
|
241
|
+
k.value && (JSON.parse(k.value), j.value = "");
|
|
242
|
+
} catch {
|
|
243
|
+
j.value = "Invalid JSON format";
|
|
244
|
+
}
|
|
245
|
+
}, Y = () => {
|
|
246
|
+
try {
|
|
247
|
+
const o = f.value, e = new URL(o);
|
|
248
|
+
f.value = `${e.protocol}//${e.host}`, v.value = e.pathname;
|
|
249
|
+
const b = new URLSearchParams(e.search), V = [];
|
|
250
|
+
b.forEach((O, C) => {
|
|
251
|
+
V.push({ key: C, value: O });
|
|
252
|
+
}), c.value = V;
|
|
253
|
+
} catch (o) {
|
|
254
|
+
console.error("URL解析失败:", o);
|
|
255
|
+
}
|
|
256
|
+
}, Z = I(() => {
|
|
257
|
+
if (!f.value) return !1;
|
|
258
|
+
try {
|
|
259
|
+
const o = f.value, e = new URL(o);
|
|
260
|
+
return e.search !== "" || e.pathname !== "/";
|
|
261
|
+
} catch {
|
|
262
|
+
return !1;
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
return (o, e) => {
|
|
266
|
+
const b = y("a-input"), V = y("a-button"), O = y("a-select-option"), C = y("a-select"), E = y("a-card"), P = y("a-radio-button"), H = y("a-radio-group"), ee = y("a-input-password"), N = y("a-textarea"), te = y("a-alert"), ae = y("a-form");
|
|
267
|
+
return g(), R("div", pe, [
|
|
268
|
+
l(ae, { layout: "vertical" }, {
|
|
269
|
+
default: d(() => [
|
|
270
|
+
l(E, {
|
|
271
|
+
title: "URL配置",
|
|
272
|
+
class: "form-section",
|
|
273
|
+
size: "small"
|
|
274
|
+
}, {
|
|
275
|
+
default: d(() => [
|
|
276
|
+
h("div", ie, [
|
|
277
|
+
h("div", ve, [
|
|
278
|
+
l(b, {
|
|
279
|
+
value: f.value,
|
|
280
|
+
"onUpdate:value": e[0] || (e[0] = (p) => f.value = p),
|
|
281
|
+
placeholder: "基础URL",
|
|
282
|
+
size: "small"
|
|
283
|
+
}, null, 8, ["value"]),
|
|
284
|
+
Z.value ? (g(), z(V, {
|
|
285
|
+
key: 0,
|
|
286
|
+
type: "primary",
|
|
287
|
+
size: "small",
|
|
288
|
+
onClick: Y
|
|
289
|
+
}, {
|
|
290
|
+
default: d(() => e[13] || (e[13] = [
|
|
291
|
+
_("拆解")
|
|
292
|
+
])),
|
|
293
|
+
_: 1
|
|
294
|
+
})) : T("", !0)
|
|
295
|
+
]),
|
|
296
|
+
h("div", me, [
|
|
297
|
+
l(C, {
|
|
298
|
+
value: n.value,
|
|
299
|
+
"onUpdate:value": e[1] || (e[1] = (p) => n.value = p),
|
|
300
|
+
class: "w-40",
|
|
301
|
+
size: "small"
|
|
302
|
+
}, {
|
|
303
|
+
default: d(() => [
|
|
304
|
+
l(O, { value: "GET" }, {
|
|
305
|
+
default: d(() => e[14] || (e[14] = [
|
|
306
|
+
_("GET")
|
|
307
|
+
])),
|
|
308
|
+
_: 1
|
|
309
|
+
}),
|
|
310
|
+
l(O, { value: "POST" }, {
|
|
311
|
+
default: d(() => e[15] || (e[15] = [
|
|
312
|
+
_("POST")
|
|
313
|
+
])),
|
|
314
|
+
_: 1
|
|
315
|
+
}),
|
|
316
|
+
l(O, { value: "PUT" }, {
|
|
317
|
+
default: d(() => e[16] || (e[16] = [
|
|
318
|
+
_("PUT")
|
|
319
|
+
])),
|
|
320
|
+
_: 1
|
|
321
|
+
}),
|
|
322
|
+
l(O, { value: "DELETE" }, {
|
|
323
|
+
default: d(() => e[17] || (e[17] = [
|
|
324
|
+
_("DELETE")
|
|
325
|
+
])),
|
|
326
|
+
_: 1
|
|
327
|
+
}),
|
|
328
|
+
l(O, { value: "OPTIONS" }, {
|
|
329
|
+
default: d(() => e[18] || (e[18] = [
|
|
330
|
+
_("OPTIONS")
|
|
331
|
+
])),
|
|
332
|
+
_: 1
|
|
333
|
+
})
|
|
334
|
+
]),
|
|
335
|
+
_: 1
|
|
336
|
+
}, 8, ["value"]),
|
|
337
|
+
l(b, {
|
|
338
|
+
value: v.value,
|
|
339
|
+
"onUpdate:value": e[2] || (e[2] = (p) => v.value = p),
|
|
340
|
+
placeholder: "路径",
|
|
341
|
+
size: "small"
|
|
342
|
+
}, null, 8, ["value"])
|
|
343
|
+
])
|
|
344
|
+
]),
|
|
345
|
+
h("div", fe, [
|
|
346
|
+
l(D, {
|
|
347
|
+
modelValue: c.value,
|
|
348
|
+
"onUpdate:modelValue": e[3] || (e[3] = (p) => c.value = p),
|
|
349
|
+
"add-button-text": "添加参数",
|
|
350
|
+
"show-preview": !0,
|
|
351
|
+
"preview-text": f.value + v.value + M.value
|
|
352
|
+
}, null, 8, ["modelValue", "preview-text"])
|
|
353
|
+
])
|
|
354
|
+
]),
|
|
355
|
+
_: 1
|
|
356
|
+
}),
|
|
357
|
+
l(E, {
|
|
358
|
+
title: "认证方案",
|
|
359
|
+
class: "form-section",
|
|
360
|
+
size: "small"
|
|
361
|
+
}, {
|
|
362
|
+
default: d(() => [
|
|
363
|
+
l(H, {
|
|
364
|
+
value: a.value,
|
|
365
|
+
"onUpdate:value": e[4] || (e[4] = (p) => a.value = p),
|
|
366
|
+
"button-style": "solid",
|
|
367
|
+
size: "small"
|
|
368
|
+
}, {
|
|
369
|
+
default: d(() => [
|
|
370
|
+
l(P, { value: "none" }, {
|
|
371
|
+
default: d(() => e[19] || (e[19] = [
|
|
372
|
+
_("无认证")
|
|
373
|
+
])),
|
|
374
|
+
_: 1
|
|
375
|
+
}),
|
|
376
|
+
l(P, { value: "Basic" }, {
|
|
377
|
+
default: d(() => e[20] || (e[20] = [
|
|
378
|
+
_("Basic认证")
|
|
379
|
+
])),
|
|
380
|
+
_: 1
|
|
381
|
+
}),
|
|
382
|
+
l(P, { value: "Bearer" }, {
|
|
383
|
+
default: d(() => e[21] || (e[21] = [
|
|
384
|
+
_("Bearer认证")
|
|
385
|
+
])),
|
|
386
|
+
_: 1
|
|
387
|
+
})
|
|
388
|
+
]),
|
|
389
|
+
_: 1
|
|
390
|
+
}, 8, ["value"]),
|
|
391
|
+
a.value === "Basic" ? (g(), R("div", ce, [
|
|
392
|
+
h("div", ye, [
|
|
393
|
+
e[22] || (e[22] = h("p", { class: "m-0 w-16" }, "用户名", -1)),
|
|
394
|
+
l(b, {
|
|
395
|
+
value: i.value,
|
|
396
|
+
"onUpdate:value": e[5] || (e[5] = (p) => i.value = p),
|
|
397
|
+
size: "small"
|
|
398
|
+
}, null, 8, ["value"])
|
|
399
|
+
]),
|
|
400
|
+
h("div", we, [
|
|
401
|
+
e[23] || (e[23] = h("p", { class: "m-0 w-16" }, "密码", -1)),
|
|
402
|
+
l(ee, {
|
|
403
|
+
value: u.value,
|
|
404
|
+
"onUpdate:value": e[6] || (e[6] = (p) => u.value = p),
|
|
405
|
+
size: "small"
|
|
406
|
+
}, null, 8, ["value"])
|
|
407
|
+
])
|
|
408
|
+
])) : T("", !0),
|
|
409
|
+
a.value === "Bearer" ? (g(), R("div", _e, [
|
|
410
|
+
h("div", xe, [
|
|
411
|
+
e[24] || (e[24] = h("p", { class: "m-0 w-16 h-full" }, "Token", -1)),
|
|
412
|
+
l(N, {
|
|
413
|
+
value: m.value,
|
|
414
|
+
"onUpdate:value": e[7] || (e[7] = (p) => m.value = p),
|
|
415
|
+
size: "small",
|
|
416
|
+
class: "mt-1",
|
|
417
|
+
rows: "4",
|
|
418
|
+
placeholder: "请输入Token"
|
|
419
|
+
}, null, 8, ["value"])
|
|
420
|
+
])
|
|
421
|
+
])) : T("", !0)
|
|
422
|
+
]),
|
|
423
|
+
_: 1
|
|
424
|
+
}),
|
|
425
|
+
l(E, {
|
|
426
|
+
title: "请求头",
|
|
427
|
+
class: "form-section",
|
|
428
|
+
size: "small"
|
|
429
|
+
}, {
|
|
430
|
+
default: d(() => [
|
|
431
|
+
l(D, {
|
|
432
|
+
modelValue: B.value,
|
|
433
|
+
"onUpdate:modelValue": e[8] || (e[8] = (p) => B.value = p),
|
|
434
|
+
"add-button-text": "添加请求头",
|
|
435
|
+
"show-preview": !1
|
|
436
|
+
}, null, 8, ["modelValue"])
|
|
437
|
+
]),
|
|
438
|
+
_: 1
|
|
439
|
+
}),
|
|
440
|
+
n.value === "POST" || n.value === "PUT" ? (g(), z(E, {
|
|
441
|
+
key: 0,
|
|
442
|
+
title: "请求体",
|
|
443
|
+
class: "form-section",
|
|
444
|
+
size: "small"
|
|
445
|
+
}, {
|
|
446
|
+
default: d(() => [
|
|
447
|
+
l(H, {
|
|
448
|
+
value: U.value,
|
|
449
|
+
"onUpdate:value": e[9] || (e[9] = (p) => U.value = p),
|
|
450
|
+
"button-style": "solid",
|
|
451
|
+
size: "small",
|
|
452
|
+
class: "mb-1"
|
|
453
|
+
}, {
|
|
454
|
+
default: d(() => [
|
|
455
|
+
l(P, { value: "application/json" }, {
|
|
456
|
+
default: d(() => e[25] || (e[25] = [
|
|
457
|
+
_("JSON")
|
|
458
|
+
])),
|
|
459
|
+
_: 1
|
|
460
|
+
}),
|
|
461
|
+
l(P, { value: "multipart/form-data" }, {
|
|
462
|
+
default: d(() => e[26] || (e[26] = [
|
|
463
|
+
_("Form Data")
|
|
464
|
+
])),
|
|
465
|
+
_: 1
|
|
466
|
+
}),
|
|
467
|
+
l(P, { value: "text/plain" }, {
|
|
468
|
+
default: d(() => e[27] || (e[27] = [
|
|
469
|
+
_("Raw")
|
|
470
|
+
])),
|
|
471
|
+
_: 1
|
|
472
|
+
})
|
|
473
|
+
]),
|
|
474
|
+
_: 1
|
|
475
|
+
}, 8, ["value"]),
|
|
476
|
+
U.value === "application/json" ? (g(), R(A, { key: 0 }, [
|
|
477
|
+
l(N, {
|
|
478
|
+
value: k.value,
|
|
479
|
+
"onUpdate:value": e[10] || (e[10] = (p) => k.value = p),
|
|
480
|
+
rows: 6,
|
|
481
|
+
placeholder: "请输入 JSON 数据",
|
|
482
|
+
onInput: Q
|
|
483
|
+
}, null, 8, ["value"]),
|
|
484
|
+
j.value ? (g(), z(te, {
|
|
485
|
+
key: 0,
|
|
486
|
+
type: "error",
|
|
487
|
+
message: j.value,
|
|
488
|
+
banner: "",
|
|
489
|
+
style: { "margin-bottom": "8px" }
|
|
490
|
+
}, null, 8, ["message"])) : T("", !0)
|
|
491
|
+
], 64)) : T("", !0),
|
|
492
|
+
U.value === "multipart/form-data" ? (g(), z(D, {
|
|
493
|
+
key: 1,
|
|
494
|
+
modelValue: $.value,
|
|
495
|
+
"onUpdate:modelValue": e[11] || (e[11] = (p) => $.value = p),
|
|
496
|
+
"add-button-text": "添加表单字段",
|
|
497
|
+
"show-preview": !1
|
|
498
|
+
}, null, 8, ["modelValue"])) : T("", !0),
|
|
499
|
+
U.value === "text/plain" ? (g(), z(N, {
|
|
500
|
+
key: 2,
|
|
501
|
+
value: S.value,
|
|
502
|
+
"onUpdate:value": e[12] || (e[12] = (p) => S.value = p),
|
|
503
|
+
rows: 6,
|
|
504
|
+
placeholder: "请输入原始数据"
|
|
505
|
+
}, null, 8, ["value"])) : T("", !0),
|
|
506
|
+
h("pre", null, J(X.value), 1)
|
|
507
|
+
]),
|
|
508
|
+
_: 1
|
|
509
|
+
})) : T("", !0)
|
|
510
|
+
]),
|
|
511
|
+
_: 1
|
|
512
|
+
})
|
|
513
|
+
]);
|
|
514
|
+
};
|
|
515
|
+
}
|
|
516
|
+
}), Te = /* @__PURE__ */ G(ke, [["__scopeId", "data-v-c9f65487"]]);
|
|
517
|
+
async function Se(t, x = "xhr") {
|
|
518
|
+
return x === "fetch" ? be(t) : he(t);
|
|
519
|
+
}
|
|
520
|
+
async function be(t) {
|
|
521
|
+
var f;
|
|
522
|
+
const x = t.params.filter((a) => !!a.key).map((a) => `${a.key}=${encodeURIComponent(a.value)}`).join("&"), r = `${t.url}${t.path}${x ? "?" + x : ""}`, s = new Headers();
|
|
523
|
+
t.headers.forEach((a) => {
|
|
524
|
+
a.key && s.append(a.key, a.value);
|
|
525
|
+
});
|
|
526
|
+
const n = {
|
|
527
|
+
method: t.method,
|
|
528
|
+
headers: s,
|
|
529
|
+
credentials: "omit"
|
|
530
|
+
};
|
|
531
|
+
if (t.auth.type === "Basic" && t.auth.username && t.auth.password) {
|
|
532
|
+
const a = btoa(`${t.auth.username}:${t.auth.password}`);
|
|
533
|
+
s.append("Authorization", `Basic ${a}`);
|
|
534
|
+
} else t.auth.type === "Bearer" && t.auth.token && s.append("Authorization", `Bearer ${t.auth.token}`);
|
|
535
|
+
if (t.method === "POST" || t.method === "PUT")
|
|
536
|
+
switch (t.body.type) {
|
|
537
|
+
case "application/json":
|
|
538
|
+
n.body = t.body.json || "", s.set("Content-Type", "application/json; charset=utf-8");
|
|
539
|
+
break;
|
|
540
|
+
case "multipart/form-data":
|
|
541
|
+
const a = new FormData();
|
|
542
|
+
(f = t.body.formData) == null || f.forEach((v) => {
|
|
543
|
+
v.key && a.append(v.key, v.value);
|
|
544
|
+
}), n.body = a;
|
|
545
|
+
break;
|
|
546
|
+
case "text/plain":
|
|
547
|
+
n.body = t.body.raw || "", s.set("Content-Type", "text/plain; charset=utf-8");
|
|
548
|
+
break;
|
|
549
|
+
}
|
|
550
|
+
try {
|
|
551
|
+
const a = await fetch(r, n), v = {};
|
|
552
|
+
a.headers.forEach((m, c) => {
|
|
553
|
+
v[c.toLowerCase()] = m;
|
|
554
|
+
});
|
|
555
|
+
let i = "";
|
|
556
|
+
if ((v["content-type"] || "").startsWith("application/json"))
|
|
557
|
+
try {
|
|
558
|
+
const m = await a.json();
|
|
559
|
+
i = JSON.stringify(m, null, 2);
|
|
560
|
+
} catch {
|
|
561
|
+
i = await a.text();
|
|
562
|
+
}
|
|
563
|
+
else
|
|
564
|
+
i = await a.text();
|
|
565
|
+
return {
|
|
566
|
+
status: a.status.toString(),
|
|
567
|
+
headers: v,
|
|
568
|
+
body: i
|
|
569
|
+
};
|
|
570
|
+
} catch {
|
|
571
|
+
throw new Error("Request failed");
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
async function he(t) {
|
|
575
|
+
return new Promise((x, r) => {
|
|
576
|
+
var i;
|
|
577
|
+
const s = new XMLHttpRequest(), n = t.auth.type === "Basic" ? t.auth.username : null, f = t.auth.type === "Basic" ? t.auth.password : null, a = t.params.filter((u) => !!u.key).map((u) => `${u.key}=${encodeURIComponent(u.value)}`).join("&"), v = `${t.url}${t.path}${a ? "?" + a : ""}`;
|
|
578
|
+
if (s.open(t.method, v, !0, n, f), t.headers.forEach((u) => {
|
|
579
|
+
u.key && s.setRequestHeader(u.key, u.value);
|
|
580
|
+
}), t.auth.type === "Bearer" && t.auth.token && s.setRequestHeader("Authorization", `Bearer ${t.auth.token}`), t.method === "POST" || t.method === "PUT") {
|
|
581
|
+
let u = "";
|
|
582
|
+
switch (t.body.type) {
|
|
583
|
+
case "application/json":
|
|
584
|
+
u = t.body.json || "", s.setRequestHeader("Content-Type", "application/json; charset=utf-8");
|
|
585
|
+
break;
|
|
586
|
+
case "multipart/form-data":
|
|
587
|
+
const m = new FormData();
|
|
588
|
+
(i = t.body.formData) == null || i.forEach((c) => {
|
|
589
|
+
c.key && m.append(c.key, c.value);
|
|
590
|
+
}), u = m;
|
|
591
|
+
break;
|
|
592
|
+
case "text/plain":
|
|
593
|
+
u = t.body.raw || "", s.setRequestHeader("Content-Type", "text/plain; charset=utf-8");
|
|
594
|
+
break;
|
|
595
|
+
}
|
|
596
|
+
s.send(u);
|
|
597
|
+
} else
|
|
598
|
+
s.send();
|
|
599
|
+
s.onload = () => {
|
|
600
|
+
const u = ge(s), m = {
|
|
601
|
+
status: s.status.toString(),
|
|
602
|
+
headers: u,
|
|
603
|
+
body: ""
|
|
604
|
+
};
|
|
605
|
+
if ((u["content-type"] || "").startsWith("application/json"))
|
|
606
|
+
try {
|
|
607
|
+
m.body = JSON.stringify(JSON.parse(s.responseText), null, 2);
|
|
608
|
+
} catch {
|
|
609
|
+
m.body = s.responseText;
|
|
610
|
+
}
|
|
611
|
+
else
|
|
612
|
+
m.body = s.responseText;
|
|
613
|
+
x(m);
|
|
614
|
+
}, s.onerror = () => {
|
|
615
|
+
r(new Error("Request failed"));
|
|
616
|
+
};
|
|
617
|
+
});
|
|
618
|
+
}
|
|
619
|
+
function ge(t) {
|
|
620
|
+
const x = t.getAllResponseHeaders().trim().split(/[\r\n]+/), r = {};
|
|
621
|
+
return x.forEach(function(s) {
|
|
622
|
+
var v;
|
|
623
|
+
const n = s.split(": "), f = ((v = n.shift()) == null ? void 0 : v.toLowerCase()) || "", a = n.join(": ");
|
|
624
|
+
r[f] = a;
|
|
625
|
+
}), r;
|
|
626
|
+
}
|
|
627
|
+
export {
|
|
628
|
+
D as KeyValueInput,
|
|
629
|
+
Te as RequestForm,
|
|
630
|
+
Te as default,
|
|
631
|
+
de as defaultRequestSchema,
|
|
632
|
+
Se as executeRequest
|
|
633
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
(function(h,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(h=typeof globalThis<"u"?globalThis:h||self,e(h.ApiRequestBuilder={},h.Vue))})(this,function(h,e){"use strict";const q={class:"key-value-input flex flex-col gap-1"},P={class:"flex gap-2"},z={key:0,class:"flex flex-col gap-1"},D={class:"flex w-full gap-1 items-center"},I=e.defineComponent({__name:"KeyValueInput",props:{modelValue:{},addButtonText:{default:"添加参数"},showPreview:{type:Boolean,default:!1},previewText:{default:""}},emits:["update:modelValue"],setup(o,{emit:y}){const d=o,n=y,r=e.ref(d.modelValue);e.watch(()=>d.modelValue,i=>{r.value=i}),e.watch(r,i=>{n("update:modelValue",i)},{deep:!0});const m=()=>{r.value.push({key:"",value:""})},a=i=>{r.value.splice(i,1)},u=()=>{r.value=[]};return(i,s)=>{const c=e.resolveComponent("a-button"),f=e.resolveComponent("a-popconfirm"),C=e.resolveComponent("a-input"),_=e.resolveComponent("a-typography-paragraph"),w=e.resolveComponent("a-typography");return e.openBlock(),e.createElementBlock("div",q,[e.createElementVNode("div",P,[e.createVNode(c,{type:"primary",onClick:m,class:"w-40 max-w-full",size:"small"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(i.addButtonText),1)]),_:1}),e.createVNode(f,{title:"确认清空",description:"确定要清空所有参数吗?","ok-text":"确认","cancel-text":"取消",onConfirm:u},{default:e.withCtx(()=>[e.createVNode(c,{type:"primary",danger:"",class:"w-40 max-w-full",size:"small",disabled:r.value.length===0},{default:e.withCtx(()=>s[0]||(s[0]=[e.createTextVNode(" 清空 ")])),_:1},8,["disabled"])]),_:1})]),r.value.length>0?(e.openBlock(),e.createElementBlock("div",z,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.value,(x,N)=>(e.openBlock(),e.createElementBlock("div",{key:N,class:"flex"},[e.createElementVNode("div",D,[e.createVNode(c,{type:"primary",danger:"",onClick:k=>a(N),class:"w-16",size:"small"},{default:e.withCtx(()=>s[1]||(s[1]=[e.createTextVNode(" 删除 ")])),_:2},1032,["onClick"]),e.createVNode(C,{value:x.key,"onUpdate:value":k=>x.key=k,placeholder:"键",style:{width:"60%"},size:"small"},null,8,["value","onUpdate:value"]),e.createVNode(C,{value:x.value,"onUpdate:value":k=>x.value=k,placeholder:"值",style:{width:"100%"},size:"small"},null,8,["value","onUpdate:value"])])]))),128))])):e.createCommentVNode("",!0),i.showPreview?(e.openBlock(),e.createBlock(w,{key:1,class:"m-0"},{default:e.withCtx(()=>[e.createVNode(_,{class:"!m-0"},{default:e.withCtx(()=>[e.createElementVNode("pre",null,e.toDisplayString(i.previewText),1)]),_:1})]),_:1})):e.createCommentVNode("",!0)])}}}),S=(o,y)=>{const d=o.__vccOpts||o;for(const[n,r]of y)d[n]=r;return d},g=S(I,[["__scopeId","data-v-1e5ef051"]]),j={method:"GET",url:"https://yesno.wtf",path:"/api",auth:{type:"none"},params:[],headers:[],body:{type:"application/json"}},J={class:"request-form"},L={class:"flex flex-col gap-1"},F={class:"flex flex-row gap-1"},H={class:"flex flex-row gap-1"},A={class:"mt-1"},K={key:0,class:"flex flex-col gap-1 mt-2"},M={class:"flex flex-row gap-1 h-6"},G={class:"flex flex-row gap-1"},W={key:1,class:"flex flex-col gap-1 mt-1"},X={class:"flex flex-row gap-1 items-center"},R=S(e.defineComponent({__name:"RequestForm",props:{modelValue:{default:()=>j}},emits:["update:modelValue"],setup(o,{emit:y}){const d=o,n=y,r=e.ref(d.modelValue.method),m=e.ref(d.modelValue.url),a=e.ref(d.modelValue.auth.type),u=e.ref(d.modelValue.path),i=e.ref(d.modelValue.auth.username||""),s=e.ref(d.modelValue.auth.password||""),c=e.ref(d.modelValue.auth.token||""),f=e.ref(d.modelValue.params),C=e.ref(d.modelValue.headers),_=e.ref(d.modelValue.body.formData||[]),w=e.ref(d.modelValue.body.type),x=e.ref(d.modelValue.body.json||""),N=e.ref(d.modelValue.body.raw||""),k=e.ref("");function te(l,t){let V;return function(...T){clearTimeout(V),V=setTimeout(()=>l.apply(this,T),t)}}const $=()=>({method:r.value,url:m.value,path:u.value,auth:{type:a.value,...a.value==="Basic"?{username:i.value,password:s.value}:a.value==="Bearer"?{token:c.value}:{}},params:f.value,headers:C.value,body:{type:w.value,...w.value==="application/json"?{json:x.value}:w.value==="multipart/form-data"?{formData:_.value}:{raw:N.value}}}),oe=te(()=>{n("update:modelValue",$())},100);e.watch([r,m,u,a,i,s,c,f,C,w,_,x,N],()=>{oe()},{deep:!0}),e.watch(()=>d.modelValue,l=>{const t=$();JSON.stringify(l)!==JSON.stringify(t)&&(r.value=l.method,m.value=l.url,u.value=l.path,a.value=l.auth.type,i.value=l.auth.username||"",s.value=l.auth.password||"",c.value=l.auth.token||"",f.value=l.params,C.value=l.headers,w.value=l.body.type,_.value=l.body.formData||[],x.value=l.body.json||"",N.value=l.body.raw||"")},{deep:!0});const ae=e.computed(()=>{const l=f.value.filter(t=>!!t.key).map(t=>t.key+"="+encodeURIComponent(t.value)).join("&");return l===""?"":"?"+l}),le=e.computed(()=>{switch(w.value){case"application/json":try{return x.value?JSON.stringify(JSON.parse(x.value),null,2):"-空-"}catch{return"Invalid JSON"}case"multipart/form-data":const l="----WebKitFormBoundaryPreview";return _.value.filter(V=>!!V.key).map(V=>`--${l}\r
|
|
2
|
+
Content-Disposition: form-data; name="${V.key}"\r
|
|
3
|
+
\r
|
|
4
|
+
${V.value}\r
|
|
5
|
+
`).join("")+`--${l}--\r
|
|
6
|
+
`;case"text/plain":return N.value||"-空-";default:return"-空-"}}),ne=()=>{try{x.value&&(JSON.parse(x.value),k.value="")}catch{k.value="Invalid JSON format"}},re=()=>{try{const l=m.value,t=new URL(l);m.value=`${t.protocol}//${t.host}`,u.value=t.pathname;const V=new URLSearchParams(t.search),T=[];V.forEach((b,v)=>{T.push({key:v,value:b})}),f.value=T}catch(l){console.error("URL解析失败:",l)}},se=e.computed(()=>{if(!m.value)return!1;try{const l=m.value,t=new URL(l);return t.search!==""||t.pathname!=="/"}catch{return!1}});return(l,t)=>{const V=e.resolveComponent("a-input"),T=e.resolveComponent("a-button"),b=e.resolveComponent("a-select-option"),v=e.resolveComponent("a-select"),E=e.resolveComponent("a-card"),B=e.resolveComponent("a-radio-button"),O=e.resolveComponent("a-radio-group"),de=e.resolveComponent("a-input-password"),U=e.resolveComponent("a-textarea"),pe=e.resolveComponent("a-alert"),ie=e.resolveComponent("a-form");return e.openBlock(),e.createElementBlock("div",J,[e.createVNode(ie,{layout:"vertical"},{default:e.withCtx(()=>[e.createVNode(E,{title:"URL配置",class:"form-section",size:"small"},{default:e.withCtx(()=>[e.createElementVNode("div",L,[e.createElementVNode("div",F,[e.createVNode(V,{value:m.value,"onUpdate:value":t[0]||(t[0]=p=>m.value=p),placeholder:"基础URL",size:"small"},null,8,["value"]),se.value?(e.openBlock(),e.createBlock(T,{key:0,type:"primary",size:"small",onClick:re},{default:e.withCtx(()=>t[13]||(t[13]=[e.createTextVNode("拆解")])),_:1})):e.createCommentVNode("",!0)]),e.createElementVNode("div",H,[e.createVNode(v,{value:r.value,"onUpdate:value":t[1]||(t[1]=p=>r.value=p),class:"w-40",size:"small"},{default:e.withCtx(()=>[e.createVNode(b,{value:"GET"},{default:e.withCtx(()=>t[14]||(t[14]=[e.createTextVNode("GET")])),_:1}),e.createVNode(b,{value:"POST"},{default:e.withCtx(()=>t[15]||(t[15]=[e.createTextVNode("POST")])),_:1}),e.createVNode(b,{value:"PUT"},{default:e.withCtx(()=>t[16]||(t[16]=[e.createTextVNode("PUT")])),_:1}),e.createVNode(b,{value:"DELETE"},{default:e.withCtx(()=>t[17]||(t[17]=[e.createTextVNode("DELETE")])),_:1}),e.createVNode(b,{value:"OPTIONS"},{default:e.withCtx(()=>t[18]||(t[18]=[e.createTextVNode("OPTIONS")])),_:1})]),_:1},8,["value"]),e.createVNode(V,{value:u.value,"onUpdate:value":t[2]||(t[2]=p=>u.value=p),placeholder:"路径",size:"small"},null,8,["value"])])]),e.createElementVNode("div",A,[e.createVNode(g,{modelValue:f.value,"onUpdate:modelValue":t[3]||(t[3]=p=>f.value=p),"add-button-text":"添加参数","show-preview":!0,"preview-text":m.value+u.value+ae.value},null,8,["modelValue","preview-text"])])]),_:1}),e.createVNode(E,{title:"认证方案",class:"form-section",size:"small"},{default:e.withCtx(()=>[e.createVNode(O,{value:a.value,"onUpdate:value":t[4]||(t[4]=p=>a.value=p),"button-style":"solid",size:"small"},{default:e.withCtx(()=>[e.createVNode(B,{value:"none"},{default:e.withCtx(()=>t[19]||(t[19]=[e.createTextVNode("无认证")])),_:1}),e.createVNode(B,{value:"Basic"},{default:e.withCtx(()=>t[20]||(t[20]=[e.createTextVNode("Basic认证")])),_:1}),e.createVNode(B,{value:"Bearer"},{default:e.withCtx(()=>t[21]||(t[21]=[e.createTextVNode("Bearer认证")])),_:1})]),_:1},8,["value"]),a.value==="Basic"?(e.openBlock(),e.createElementBlock("div",K,[e.createElementVNode("div",M,[t[22]||(t[22]=e.createElementVNode("p",{class:"m-0 w-16"},"用户名",-1)),e.createVNode(V,{value:i.value,"onUpdate:value":t[5]||(t[5]=p=>i.value=p),size:"small"},null,8,["value"])]),e.createElementVNode("div",G,[t[23]||(t[23]=e.createElementVNode("p",{class:"m-0 w-16"},"密码",-1)),e.createVNode(de,{value:s.value,"onUpdate:value":t[6]||(t[6]=p=>s.value=p),size:"small"},null,8,["value"])])])):e.createCommentVNode("",!0),a.value==="Bearer"?(e.openBlock(),e.createElementBlock("div",W,[e.createElementVNode("div",X,[t[24]||(t[24]=e.createElementVNode("p",{class:"m-0 w-16 h-full"},"Token",-1)),e.createVNode(U,{value:c.value,"onUpdate:value":t[7]||(t[7]=p=>c.value=p),size:"small",class:"mt-1",rows:"4",placeholder:"请输入Token"},null,8,["value"])])])):e.createCommentVNode("",!0)]),_:1}),e.createVNode(E,{title:"请求头",class:"form-section",size:"small"},{default:e.withCtx(()=>[e.createVNode(g,{modelValue:C.value,"onUpdate:modelValue":t[8]||(t[8]=p=>C.value=p),"add-button-text":"添加请求头","show-preview":!1},null,8,["modelValue"])]),_:1}),r.value==="POST"||r.value==="PUT"?(e.openBlock(),e.createBlock(E,{key:0,title:"请求体",class:"form-section",size:"small"},{default:e.withCtx(()=>[e.createVNode(O,{value:w.value,"onUpdate:value":t[9]||(t[9]=p=>w.value=p),"button-style":"solid",size:"small",class:"mb-1"},{default:e.withCtx(()=>[e.createVNode(B,{value:"application/json"},{default:e.withCtx(()=>t[25]||(t[25]=[e.createTextVNode("JSON")])),_:1}),e.createVNode(B,{value:"multipart/form-data"},{default:e.withCtx(()=>t[26]||(t[26]=[e.createTextVNode("Form Data")])),_:1}),e.createVNode(B,{value:"text/plain"},{default:e.withCtx(()=>t[27]||(t[27]=[e.createTextVNode("Raw")])),_:1})]),_:1},8,["value"]),w.value==="application/json"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createVNode(U,{value:x.value,"onUpdate:value":t[10]||(t[10]=p=>x.value=p),rows:6,placeholder:"请输入 JSON 数据",onInput:ne},null,8,["value"]),k.value?(e.openBlock(),e.createBlock(pe,{key:0,type:"error",message:k.value,banner:"",style:{"margin-bottom":"8px"}},null,8,["message"])):e.createCommentVNode("",!0)],64)):e.createCommentVNode("",!0),w.value==="multipart/form-data"?(e.openBlock(),e.createBlock(g,{key:1,modelValue:_.value,"onUpdate:modelValue":t[11]||(t[11]=p=>_.value=p),"add-button-text":"添加表单字段","show-preview":!1},null,8,["modelValue"])):e.createCommentVNode("",!0),w.value==="text/plain"?(e.openBlock(),e.createBlock(U,{key:2,value:N.value,"onUpdate:value":t[12]||(t[12]=p=>N.value=p),rows:6,placeholder:"请输入原始数据"},null,8,["value"])):e.createCommentVNode("",!0),e.createElementVNode("pre",null,e.toDisplayString(le.value),1)]),_:1})):e.createCommentVNode("",!0)]),_:1})])}}}),[["__scopeId","data-v-c9f65487"]]);async function Q(o,y="xhr"){return y==="fetch"?Y(o):Z(o)}async function Y(o){var m;const y=o.params.filter(a=>!!a.key).map(a=>`${a.key}=${encodeURIComponent(a.value)}`).join("&"),d=`${o.url}${o.path}${y?"?"+y:""}`,n=new Headers;o.headers.forEach(a=>{a.key&&n.append(a.key,a.value)});const r={method:o.method,headers:n,credentials:"omit"};if(o.auth.type==="Basic"&&o.auth.username&&o.auth.password){const a=btoa(`${o.auth.username}:${o.auth.password}`);n.append("Authorization",`Basic ${a}`)}else o.auth.type==="Bearer"&&o.auth.token&&n.append("Authorization",`Bearer ${o.auth.token}`);if(o.method==="POST"||o.method==="PUT")switch(o.body.type){case"application/json":r.body=o.body.json||"",n.set("Content-Type","application/json; charset=utf-8");break;case"multipart/form-data":const a=new FormData;(m=o.body.formData)==null||m.forEach(u=>{u.key&&a.append(u.key,u.value)}),r.body=a;break;case"text/plain":r.body=o.body.raw||"",n.set("Content-Type","text/plain; charset=utf-8");break}try{const a=await fetch(d,r),u={};a.headers.forEach((c,f)=>{u[f.toLowerCase()]=c});let i="";if((u["content-type"]||"").startsWith("application/json"))try{const c=await a.json();i=JSON.stringify(c,null,2)}catch{i=await a.text()}else i=await a.text();return{status:a.status.toString(),headers:u,body:i}}catch{throw new Error("Request failed")}}async function Z(o){return new Promise((y,d)=>{var i;const n=new XMLHttpRequest,r=o.auth.type==="Basic"?o.auth.username:null,m=o.auth.type==="Basic"?o.auth.password:null,a=o.params.filter(s=>!!s.key).map(s=>`${s.key}=${encodeURIComponent(s.value)}`).join("&"),u=`${o.url}${o.path}${a?"?"+a:""}`;if(n.open(o.method,u,!0,r,m),o.headers.forEach(s=>{s.key&&n.setRequestHeader(s.key,s.value)}),o.auth.type==="Bearer"&&o.auth.token&&n.setRequestHeader("Authorization",`Bearer ${o.auth.token}`),o.method==="POST"||o.method==="PUT"){let s="";switch(o.body.type){case"application/json":s=o.body.json||"",n.setRequestHeader("Content-Type","application/json; charset=utf-8");break;case"multipart/form-data":const c=new FormData;(i=o.body.formData)==null||i.forEach(f=>{f.key&&c.append(f.key,f.value)}),s=c;break;case"text/plain":s=o.body.raw||"",n.setRequestHeader("Content-Type","text/plain; charset=utf-8");break}n.send(s)}else n.send();n.onload=()=>{const s=ee(n),c={status:n.status.toString(),headers:s,body:""};if((s["content-type"]||"").startsWith("application/json"))try{c.body=JSON.stringify(JSON.parse(n.responseText),null,2)}catch{c.body=n.responseText}else c.body=n.responseText;y(c)},n.onerror=()=>{d(new Error("Request failed"))}})}function ee(o){const y=o.getAllResponseHeaders().trim().split(/[\r\n]+/),d={};return y.forEach(function(n){var u;const r=n.split(": "),m=((u=r.shift())==null?void 0:u.toLowerCase())||"",a=r.join(": ");d[m]=a}),d}h.KeyValueInput=g,h.RequestForm=R,h.default=R,h.defaultRequestSchema=j,h.executeRequest=Q,Object.defineProperties(h,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/dist/vite.svg
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.key-value-input[data-v-1e5ef051]{width:100%}.empty-state[data-v-1e5ef051]{color:#999;text-align:center;padding:8px 0}.key-value-input[data-v-1e5ef051] .ant-typography pre{background-color:#f5f5f5;padding:4px 8px;border-radius:4px;margin:0;width:100%;overflow-x:auto}.key-value-input[data-v-1e5ef051] .ant-space-item{flex:1}.key-value-input[data-v-1e5ef051] .ant-space-item:first-child{flex:0 0 100px}.key-value-input[data-v-1e5ef051] .ant-space-item:nth-child(2){flex:0 0 200px}.key-value-input[data-v-1e5ef051] .ant-list-item{padding:4px 0}[data-v-1e5ef051] .ant-typography pre{background-color:#f5f5f5;padding:8px;border-radius:4px;margin:0;width:100%;overflow-x:auto;max-height:60px;font-size:12px;line-height:1.5}.request-form[data-v-c9f65487]{margin:0;padding:0}.request-form[data-v-c9f65487] *{font-size:.9rem}.form-section[data-v-c9f65487]{margin-bottom:8px;width:100%}[data-v-c9f65487] .ant-card-head{background-color:#fafafa}[data-v-c9f65487] .ant-card-head-title{font-weight:500;padding:4px 0}[data-v-c9f65487] .ant-card-body{padding:8px 12px}[data-v-c9f65487] .ant-space{width:100%;display:flex;gap:8px;align-items:center}pre[data-v-c9f65487]{background-color:#f5f5f5;padding:8px;border-radius:4px;margin:0;width:100%;overflow-x:auto}
|