@xto/business 1.0.3 → 1.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/es/index.mjs +1018 -397
- package/es/style.css +1 -1
- package/lib/index.cjs +8 -8
- package/lib/style.css +1 -1
- package/package.json +7 -7
package/es/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { useNamespace as
|
|
3
|
-
import { Space as
|
|
4
|
-
import { Input as
|
|
5
|
-
import { Pagination as
|
|
6
|
-
const
|
|
1
|
+
import { defineComponent as I, ref as q, computed as B, openBlock as o, createElementBlock as c, normalizeClass as s, unref as a, createVNode as M, withCtx as U, Fragment as E, renderList as z, createBlock as X, withKeys as J, createCommentVNode as x, createTextVNode as j, createElementVNode as e, renderSlot as F, toDisplayString as h, normalizeStyle as H, reactive as ee, withDirectives as K, vModelSelect as te, watch as Q, vShow as G, nextTick as Z, withModifiers as _, vModelText as le } from "vue";
|
|
2
|
+
import { useNamespace as A } from "@xto/core";
|
|
3
|
+
import { Space as O, Button as W } from "@xto/base";
|
|
4
|
+
import { Input as D } from "@xto/form";
|
|
5
|
+
import { Pagination as ae } from "@xto/data";
|
|
6
|
+
const se = ["colspan"], ne = ["colspan"], oe = ["value"], dt = /* @__PURE__ */ I({
|
|
7
7
|
name: "XProTable",
|
|
8
8
|
__name: "index",
|
|
9
9
|
props: {
|
|
@@ -19,162 +19,162 @@ const le = ["colspan"], ae = ["colspan"], ne = ["value"], ye = /* @__PURE__ */ N
|
|
|
19
19
|
indexLabel: { default: "#" }
|
|
20
20
|
},
|
|
21
21
|
emits: ["update:data", "update:currentPage", "update:pageSize", "search", "refresh", "reset"],
|
|
22
|
-
setup(
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
get: () =>
|
|
26
|
-
set: (
|
|
22
|
+
setup(t, { emit: v }) {
|
|
23
|
+
const n = t, u = v, l = A("pro-table"), i = q({});
|
|
24
|
+
q([]), B({
|
|
25
|
+
get: () => n.data,
|
|
26
|
+
set: (r) => u("update:data", r)
|
|
27
27
|
});
|
|
28
|
-
const $ = (
|
|
29
|
-
|
|
30
|
-
},
|
|
31
|
-
|
|
32
|
-
},
|
|
33
|
-
|
|
34
|
-
},
|
|
35
|
-
|
|
28
|
+
const $ = (r) => {
|
|
29
|
+
u("update:currentPage", r), u("search", { ...i.value, page: r });
|
|
30
|
+
}, b = (r) => {
|
|
31
|
+
u("update:pageSize", r), u("search", { ...i.value, pageSize: r });
|
|
32
|
+
}, T = () => {
|
|
33
|
+
u("search", i.value);
|
|
34
|
+
}, g = () => {
|
|
35
|
+
i.value = {}, u("reset"), u("search", {});
|
|
36
36
|
}, y = () => {
|
|
37
|
-
|
|
38
|
-
},
|
|
39
|
-
() =>
|
|
37
|
+
u("refresh");
|
|
38
|
+
}, d = B(
|
|
39
|
+
() => n.columns.filter((r) => r.search)
|
|
40
40
|
);
|
|
41
|
-
return (
|
|
42
|
-
class: a(
|
|
41
|
+
return (r, m) => (o(), c("div", {
|
|
42
|
+
class: s(a(l).b())
|
|
43
43
|
}, [
|
|
44
|
-
|
|
44
|
+
d.value.length > 0 ? (o(), c("div", {
|
|
45
45
|
key: 0,
|
|
46
|
-
class: a(
|
|
46
|
+
class: s(a(l).e("search"))
|
|
47
47
|
}, [
|
|
48
|
-
|
|
49
|
-
default:
|
|
50
|
-
(
|
|
51
|
-
key:
|
|
48
|
+
M(a(O), null, {
|
|
49
|
+
default: U(() => [
|
|
50
|
+
(o(!0), c(E, null, z(d.value, (p) => (o(), c(E, {
|
|
51
|
+
key: p.prop
|
|
52
52
|
}, [
|
|
53
|
-
|
|
53
|
+
p.searchType === "input" || !p.searchType ? (o(), X(a(D), {
|
|
54
54
|
key: 0,
|
|
55
|
-
modelValue:
|
|
56
|
-
"onUpdate:modelValue": (
|
|
57
|
-
placeholder: `请输入${
|
|
55
|
+
modelValue: i.value[p.prop],
|
|
56
|
+
"onUpdate:modelValue": (V) => i.value[p.prop] = V,
|
|
57
|
+
placeholder: `请输入${p.label}`,
|
|
58
58
|
clearable: "",
|
|
59
|
-
onKeyup:
|
|
60
|
-
}, null, 8, ["modelValue", "onUpdate:modelValue", "placeholder"])) :
|
|
59
|
+
onKeyup: J(T, ["enter"])
|
|
60
|
+
}, null, 8, ["modelValue", "onUpdate:modelValue", "placeholder"])) : x("", !0)
|
|
61
61
|
], 64))), 128)),
|
|
62
|
-
|
|
62
|
+
M(a(W), {
|
|
63
63
|
type: "primary",
|
|
64
|
-
onClick:
|
|
64
|
+
onClick: T
|
|
65
65
|
}, {
|
|
66
|
-
default:
|
|
67
|
-
|
|
66
|
+
default: U(() => [...m[0] || (m[0] = [
|
|
67
|
+
j("搜索", -1)
|
|
68
68
|
])]),
|
|
69
69
|
_: 1
|
|
70
70
|
}),
|
|
71
|
-
|
|
72
|
-
default:
|
|
73
|
-
|
|
71
|
+
M(a(W), { onClick: g }, {
|
|
72
|
+
default: U(() => [...m[1] || (m[1] = [
|
|
73
|
+
j("重置", -1)
|
|
74
74
|
])]),
|
|
75
75
|
_: 1
|
|
76
76
|
}),
|
|
77
|
-
|
|
78
|
-
default:
|
|
79
|
-
|
|
77
|
+
M(a(W), { onClick: y }, {
|
|
78
|
+
default: U(() => [...m[2] || (m[2] = [
|
|
79
|
+
j("刷新", -1)
|
|
80
80
|
])]),
|
|
81
81
|
_: 1
|
|
82
82
|
})
|
|
83
83
|
]),
|
|
84
84
|
_: 1
|
|
85
85
|
})
|
|
86
|
-
], 2)) :
|
|
87
|
-
|
|
88
|
-
class: a(
|
|
86
|
+
], 2)) : x("", !0),
|
|
87
|
+
e("div", {
|
|
88
|
+
class: s(a(l).e("toolbar"))
|
|
89
89
|
}, [
|
|
90
|
-
|
|
91
|
-
default:
|
|
92
|
-
|
|
90
|
+
M(a(O), null, {
|
|
91
|
+
default: U(() => [
|
|
92
|
+
F(r.$slots, "toolbar")
|
|
93
93
|
]),
|
|
94
94
|
_: 3
|
|
95
95
|
})
|
|
96
96
|
], 2),
|
|
97
|
-
|
|
98
|
-
class: a(
|
|
97
|
+
e("div", {
|
|
98
|
+
class: s(a(l).e("table-wrapper"))
|
|
99
99
|
}, [
|
|
100
|
-
|
|
101
|
-
class: a(
|
|
100
|
+
e("table", {
|
|
101
|
+
class: s(a(l).e("table"))
|
|
102
102
|
}, [
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
103
|
+
e("thead", null, [
|
|
104
|
+
e("tr", null, [
|
|
105
|
+
t.selection ? (o(), c("th", {
|
|
106
106
|
key: 0,
|
|
107
|
-
class: a(
|
|
108
|
-
}, [...
|
|
109
|
-
|
|
110
|
-
])], 2)) :
|
|
111
|
-
|
|
107
|
+
class: s(a(l).e("selection"))
|
|
108
|
+
}, [...m[3] || (m[3] = [
|
|
109
|
+
e("input", { type: "checkbox" }, null, -1)
|
|
110
|
+
])], 2)) : x("", !0),
|
|
111
|
+
t.index ? (o(), c("th", {
|
|
112
112
|
key: 1,
|
|
113
|
-
class: a(
|
|
114
|
-
},
|
|
115
|
-
(
|
|
116
|
-
key:
|
|
117
|
-
class: a(
|
|
118
|
-
style:
|
|
119
|
-
width:
|
|
120
|
-
minWidth:
|
|
121
|
-
textAlign:
|
|
113
|
+
class: s(a(l).e("index"))
|
|
114
|
+
}, h(t.indexLabel), 3)) : x("", !0),
|
|
115
|
+
(o(!0), c(E, null, z(t.columns, (p) => (o(), c("th", {
|
|
116
|
+
key: p.prop,
|
|
117
|
+
class: s(a(l).e("column")),
|
|
118
|
+
style: H({
|
|
119
|
+
width: p.width,
|
|
120
|
+
minWidth: p.minWidth,
|
|
121
|
+
textAlign: p.align || "left"
|
|
122
122
|
})
|
|
123
|
-
},
|
|
123
|
+
}, h(p.label), 7))), 128))
|
|
124
124
|
])
|
|
125
125
|
]),
|
|
126
|
-
|
|
127
|
-
|
|
126
|
+
e("tbody", null, [
|
|
127
|
+
t.loading ? (o(), c("tr", {
|
|
128
128
|
key: 0,
|
|
129
|
-
class: a(
|
|
129
|
+
class: s(a(l).e("loading-row"))
|
|
130
130
|
}, [
|
|
131
|
-
|
|
132
|
-
colspan:
|
|
131
|
+
e("td", {
|
|
132
|
+
colspan: t.columns.length + (t.selection ? 1 : 0) + (t.index ? 1 : 0)
|
|
133
133
|
}, [
|
|
134
|
-
|
|
135
|
-
class: a(
|
|
134
|
+
e("div", {
|
|
135
|
+
class: s(a(l).e("loading"))
|
|
136
136
|
}, " 加载中... ", 2)
|
|
137
|
-
], 8,
|
|
138
|
-
], 2)) :
|
|
137
|
+
], 8, se)
|
|
138
|
+
], 2)) : t.data.length === 0 ? (o(), c("tr", {
|
|
139
139
|
key: 1,
|
|
140
|
-
class: a(
|
|
140
|
+
class: s(a(l).e("empty-row"))
|
|
141
141
|
}, [
|
|
142
|
-
|
|
143
|
-
colspan:
|
|
142
|
+
e("td", {
|
|
143
|
+
colspan: t.columns.length + (t.selection ? 1 : 0) + (t.index ? 1 : 0)
|
|
144
144
|
}, [
|
|
145
|
-
|
|
146
|
-
class: a(
|
|
145
|
+
e("div", {
|
|
146
|
+
class: s(a(l).e("empty"))
|
|
147
147
|
}, " 暂无数据 ", 2)
|
|
148
|
-
], 8,
|
|
149
|
-
], 2)) : (
|
|
150
|
-
key:
|
|
151
|
-
class: a(
|
|
148
|
+
], 8, ne)
|
|
149
|
+
], 2)) : (o(!0), c(E, { key: 2 }, z(t.data, (p, V) => (o(), c("tr", {
|
|
150
|
+
key: V,
|
|
151
|
+
class: s(a(l).e("row"))
|
|
152
152
|
}, [
|
|
153
|
-
|
|
153
|
+
t.selection ? (o(), c("td", {
|
|
154
154
|
key: 0,
|
|
155
|
-
class: a(
|
|
155
|
+
class: s(a(l).e("selection"))
|
|
156
156
|
}, [
|
|
157
|
-
|
|
157
|
+
e("input", {
|
|
158
158
|
type: "checkbox",
|
|
159
|
-
value:
|
|
160
|
-
}, null, 8,
|
|
161
|
-
], 2)) :
|
|
162
|
-
|
|
159
|
+
value: p
|
|
160
|
+
}, null, 8, oe)
|
|
161
|
+
], 2)) : x("", !0),
|
|
162
|
+
t.index ? (o(), c("td", {
|
|
163
163
|
key: 1,
|
|
164
|
-
class: a(
|
|
165
|
-
},
|
|
166
|
-
(
|
|
167
|
-
var
|
|
168
|
-
return
|
|
169
|
-
key:
|
|
170
|
-
class: a(
|
|
171
|
-
style:
|
|
164
|
+
class: s(a(l).e("index"))
|
|
165
|
+
}, h((t.currentPage - 1) * t.pageSize + V + 1), 3)) : x("", !0),
|
|
166
|
+
(o(!0), c(E, null, z(t.columns, (w) => {
|
|
167
|
+
var C;
|
|
168
|
+
return o(), c("td", {
|
|
169
|
+
key: w.prop,
|
|
170
|
+
class: s(a(l).e("cell")),
|
|
171
|
+
style: H({ textAlign: w.align || "left" })
|
|
172
172
|
}, [
|
|
173
|
-
|
|
174
|
-
row:
|
|
175
|
-
column:
|
|
173
|
+
F(r.$slots, (C = w.slots) == null ? void 0 : C.default, {
|
|
174
|
+
row: p,
|
|
175
|
+
column: w
|
|
176
176
|
}, () => [
|
|
177
|
-
|
|
177
|
+
j(h(w.formatter ? w.formatter(p, w, p[w.prop]) : p[w.prop]), 1)
|
|
178
178
|
])
|
|
179
179
|
], 6);
|
|
180
180
|
}), 128))
|
|
@@ -182,22 +182,22 @@ const le = ["colspan"], ae = ["colspan"], ne = ["value"], ye = /* @__PURE__ */ N
|
|
|
182
182
|
])
|
|
183
183
|
], 2)
|
|
184
184
|
], 2),
|
|
185
|
-
|
|
185
|
+
t.pagination ? (o(), c("div", {
|
|
186
186
|
key: 1,
|
|
187
|
-
class: a(
|
|
187
|
+
class: s(a(l).e("pagination"))
|
|
188
188
|
}, [
|
|
189
|
-
|
|
190
|
-
total:
|
|
191
|
-
"page-size":
|
|
192
|
-
"current-page":
|
|
189
|
+
M(a(ae), {
|
|
190
|
+
total: t.total,
|
|
191
|
+
"page-size": t.pageSize,
|
|
192
|
+
"current-page": t.currentPage,
|
|
193
193
|
layout: "total, sizes, prev, pager, next, jumper",
|
|
194
194
|
onCurrentChange: $,
|
|
195
|
-
onSizeChange:
|
|
195
|
+
onSizeChange: b
|
|
196
196
|
}, null, 8, ["total", "page-size", "current-page"])
|
|
197
|
-
], 2)) :
|
|
197
|
+
], 2)) : x("", !0)
|
|
198
198
|
], 2));
|
|
199
199
|
}
|
|
200
|
-
}),
|
|
200
|
+
}), ie = ["onUpdate:modelValue"], ce = ["value"], rt = /* @__PURE__ */ I({
|
|
201
201
|
name: "XSearchForm",
|
|
202
202
|
__name: "index",
|
|
203
203
|
props: {
|
|
@@ -207,87 +207,87 @@ const le = ["colspan"], ae = ["colspan"], ne = ["value"], ye = /* @__PURE__ */ N
|
|
|
207
207
|
labelPosition: { default: "right" }
|
|
208
208
|
},
|
|
209
209
|
emits: ["search", "reset"],
|
|
210
|
-
setup(
|
|
211
|
-
const
|
|
212
|
-
|
|
213
|
-
|
|
210
|
+
setup(t, { emit: v }) {
|
|
211
|
+
const n = t, u = v, l = A("search-form"), i = ee({});
|
|
212
|
+
n.columns.forEach((g) => {
|
|
213
|
+
g.defaultValue !== void 0 ? i[g.prop] = g.defaultValue : n.model[g.prop] !== void 0 && (i[g.prop] = n.model[g.prop]);
|
|
214
214
|
});
|
|
215
215
|
const $ = () => {
|
|
216
|
-
|
|
217
|
-
},
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
}),
|
|
221
|
-
},
|
|
222
|
-
width: typeof
|
|
216
|
+
u("search", { ...i });
|
|
217
|
+
}, b = () => {
|
|
218
|
+
n.columns.forEach((g) => {
|
|
219
|
+
i[g.prop] = g.defaultValue;
|
|
220
|
+
}), u("reset");
|
|
221
|
+
}, T = B(() => ({
|
|
222
|
+
width: typeof n.labelWidth == "number" ? `${n.labelWidth}px` : n.labelWidth
|
|
223
223
|
}));
|
|
224
|
-
return (
|
|
225
|
-
class: a(
|
|
224
|
+
return (g, y) => (o(), c("div", {
|
|
225
|
+
class: s(a(l).b())
|
|
226
226
|
}, [
|
|
227
|
-
|
|
228
|
-
class: a(
|
|
227
|
+
e("div", {
|
|
228
|
+
class: s(a(l).e("items"))
|
|
229
229
|
}, [
|
|
230
|
-
(
|
|
231
|
-
key:
|
|
232
|
-
class: a(
|
|
230
|
+
(o(!0), c(E, null, z(t.columns, (d) => (o(), c("div", {
|
|
231
|
+
key: d.prop,
|
|
232
|
+
class: s(a(l).e("item"))
|
|
233
233
|
}, [
|
|
234
|
-
|
|
235
|
-
class: a(
|
|
236
|
-
style:
|
|
237
|
-
},
|
|
238
|
-
|
|
239
|
-
class: a(
|
|
234
|
+
e("label", {
|
|
235
|
+
class: s(a(l).e("label")),
|
|
236
|
+
style: H(T.value)
|
|
237
|
+
}, h(d.label), 7),
|
|
238
|
+
e("div", {
|
|
239
|
+
class: s(a(l).e("content"))
|
|
240
240
|
}, [
|
|
241
|
-
|
|
241
|
+
d.type === "input" || !d.type ? (o(), X(a(D), {
|
|
242
242
|
key: 0,
|
|
243
|
-
modelValue:
|
|
244
|
-
"onUpdate:modelValue": (
|
|
245
|
-
placeholder:
|
|
243
|
+
modelValue: i[d.prop],
|
|
244
|
+
"onUpdate:modelValue": (r) => i[d.prop] = r,
|
|
245
|
+
placeholder: d.placeholder || `请输入${d.label}`,
|
|
246
246
|
clearable: ""
|
|
247
|
-
}, null, 8, ["modelValue", "onUpdate:modelValue", "placeholder"])) :
|
|
247
|
+
}, null, 8, ["modelValue", "onUpdate:modelValue", "placeholder"])) : d.type === "select" ? K((o(), c("select", {
|
|
248
248
|
key: 1,
|
|
249
|
-
"onUpdate:modelValue": (
|
|
250
|
-
class: a(
|
|
249
|
+
"onUpdate:modelValue": (r) => i[d.prop] = r,
|
|
250
|
+
class: s(a(l).e("select"))
|
|
251
251
|
}, [
|
|
252
|
-
y[0] || (y[0] =
|
|
253
|
-
(
|
|
254
|
-
key:
|
|
255
|
-
value:
|
|
256
|
-
},
|
|
257
|
-
], 10,
|
|
258
|
-
[
|
|
259
|
-
]) :
|
|
252
|
+
y[0] || (y[0] = e("option", { value: "" }, "请选择", -1)),
|
|
253
|
+
(o(!0), c(E, null, z(d.options, (r) => (o(), c("option", {
|
|
254
|
+
key: r.value,
|
|
255
|
+
value: r.value
|
|
256
|
+
}, h(r.label), 9, ce))), 128))
|
|
257
|
+
], 10, ie)), [
|
|
258
|
+
[te, i[d.prop]]
|
|
259
|
+
]) : d.type === "date" ? (o(), X(a(D), {
|
|
260
260
|
key: 2,
|
|
261
|
-
modelValue:
|
|
262
|
-
"onUpdate:modelValue": (
|
|
261
|
+
modelValue: i[d.prop],
|
|
262
|
+
"onUpdate:modelValue": (r) => i[d.prop] = r,
|
|
263
263
|
type: "date",
|
|
264
|
-
placeholder:
|
|
265
|
-
}, null, 8, ["modelValue", "onUpdate:modelValue", "placeholder"])) : (
|
|
264
|
+
placeholder: d.placeholder || `请选择${d.label}`
|
|
265
|
+
}, null, 8, ["modelValue", "onUpdate:modelValue", "placeholder"])) : (o(), X(a(D), {
|
|
266
266
|
key: 3,
|
|
267
|
-
modelValue:
|
|
268
|
-
"onUpdate:modelValue": (
|
|
269
|
-
placeholder:
|
|
267
|
+
modelValue: i[d.prop],
|
|
268
|
+
"onUpdate:modelValue": (r) => i[d.prop] = r,
|
|
269
|
+
placeholder: d.placeholder || `请输入${d.label}`
|
|
270
270
|
}, null, 8, ["modelValue", "onUpdate:modelValue", "placeholder"]))
|
|
271
271
|
], 2)
|
|
272
272
|
], 2))), 128))
|
|
273
273
|
], 2),
|
|
274
|
-
|
|
275
|
-
class: a(
|
|
274
|
+
e("div", {
|
|
275
|
+
class: s(a(l).e("actions"))
|
|
276
276
|
}, [
|
|
277
|
-
|
|
278
|
-
default:
|
|
279
|
-
|
|
277
|
+
M(a(O), null, {
|
|
278
|
+
default: U(() => [
|
|
279
|
+
M(a(W), {
|
|
280
280
|
type: "primary",
|
|
281
281
|
onClick: $
|
|
282
282
|
}, {
|
|
283
|
-
default:
|
|
284
|
-
|
|
283
|
+
default: U(() => [...y[1] || (y[1] = [
|
|
284
|
+
j("搜索", -1)
|
|
285
285
|
])]),
|
|
286
286
|
_: 1
|
|
287
287
|
}),
|
|
288
|
-
|
|
289
|
-
default:
|
|
290
|
-
|
|
288
|
+
M(a(W), { onClick: b }, {
|
|
289
|
+
default: U(() => [...y[2] || (y[2] = [
|
|
290
|
+
j("重置", -1)
|
|
291
291
|
])]),
|
|
292
292
|
_: 1
|
|
293
293
|
})
|
|
@@ -297,7 +297,7 @@ const le = ["colspan"], ae = ["colspan"], ne = ["value"], ye = /* @__PURE__ */ N
|
|
|
297
297
|
], 2)
|
|
298
298
|
], 2));
|
|
299
299
|
}
|
|
300
|
-
}),
|
|
300
|
+
}), ut = /* @__PURE__ */ I({
|
|
301
301
|
name: "XStatistic",
|
|
302
302
|
__name: "index",
|
|
303
303
|
props: {
|
|
@@ -312,48 +312,48 @@ const le = ["colspan"], ae = ["colspan"], ne = ["value"], ye = /* @__PURE__ */ N
|
|
|
312
312
|
titleColor: {},
|
|
313
313
|
valueColor: {}
|
|
314
314
|
},
|
|
315
|
-
setup(
|
|
316
|
-
const
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
]),
|
|
320
|
-
return ($,
|
|
321
|
-
class: a(
|
|
315
|
+
setup(t) {
|
|
316
|
+
const v = t, n = A("statistic"), u = B(() => typeof v.value == "number" ? v.value.toFixed(v.precision) : v.value), l = B(() => [
|
|
317
|
+
n.e("trend"),
|
|
318
|
+
n.em("trend", v.trend)
|
|
319
|
+
]), i = B(() => v.trend === "up" ? "↑" : v.trend === "down" ? "↓" : "");
|
|
320
|
+
return ($, b) => (o(), c("div", {
|
|
321
|
+
class: s(a(n).b())
|
|
322
322
|
}, [
|
|
323
|
-
|
|
324
|
-
class: a(
|
|
325
|
-
style:
|
|
326
|
-
},
|
|
327
|
-
|
|
328
|
-
class: a(
|
|
323
|
+
e("div", {
|
|
324
|
+
class: s(a(n).e("title")),
|
|
325
|
+
style: H({ color: t.titleColor })
|
|
326
|
+
}, h(t.title), 7),
|
|
327
|
+
e("div", {
|
|
328
|
+
class: s(a(n).e("content"))
|
|
329
329
|
}, [
|
|
330
|
-
|
|
330
|
+
t.prefix ? (o(), c("span", {
|
|
331
331
|
key: 0,
|
|
332
|
-
class: a(
|
|
333
|
-
},
|
|
334
|
-
|
|
335
|
-
class: a(
|
|
336
|
-
style:
|
|
337
|
-
},
|
|
338
|
-
|
|
332
|
+
class: s(a(n).e("prefix"))
|
|
333
|
+
}, h(t.prefix), 3)) : x("", !0),
|
|
334
|
+
e("span", {
|
|
335
|
+
class: s(a(n).e("value")),
|
|
336
|
+
style: H({ color: t.valueColor })
|
|
337
|
+
}, h(u.value), 7),
|
|
338
|
+
t.suffix ? (o(), c("span", {
|
|
339
339
|
key: 1,
|
|
340
|
-
class: a(
|
|
341
|
-
},
|
|
340
|
+
class: s(a(n).e("suffix"))
|
|
341
|
+
}, h(t.suffix), 3)) : x("", !0)
|
|
342
342
|
], 2),
|
|
343
|
-
|
|
343
|
+
t.trend ? (o(), c("div", {
|
|
344
344
|
key: 0,
|
|
345
|
-
class:
|
|
345
|
+
class: s(l.value)
|
|
346
346
|
}, [
|
|
347
|
-
|
|
348
|
-
class: a(
|
|
349
|
-
},
|
|
350
|
-
|
|
351
|
-
class: a(
|
|
352
|
-
},
|
|
353
|
-
], 2)) :
|
|
347
|
+
e("span", {
|
|
348
|
+
class: s(a(n).e("trend-icon"))
|
|
349
|
+
}, h(i.value), 3),
|
|
350
|
+
e("span", {
|
|
351
|
+
class: s(a(n).e("trend-value"))
|
|
352
|
+
}, h(t.trendValue), 3)
|
|
353
|
+
], 2)) : x("", !0)
|
|
354
354
|
], 2));
|
|
355
355
|
}
|
|
356
|
-
}),
|
|
356
|
+
}), pt = /* @__PURE__ */ I({
|
|
357
357
|
name: "XExport",
|
|
358
358
|
__name: "index",
|
|
359
359
|
props: {
|
|
@@ -362,146 +362,146 @@ const le = ["colspan"], ae = ["colspan"], ne = ["value"], ye = /* @__PURE__ */ N
|
|
|
362
362
|
sheetName: { default: "Sheet1" },
|
|
363
363
|
columns: { default: () => [] }
|
|
364
364
|
},
|
|
365
|
-
setup(
|
|
366
|
-
const
|
|
367
|
-
if (
|
|
368
|
-
|
|
365
|
+
setup(t) {
|
|
366
|
+
const v = t, n = q(!1), u = () => {
|
|
367
|
+
if (v.data.length !== 0) {
|
|
368
|
+
n.value = !0;
|
|
369
369
|
try {
|
|
370
|
-
const l =
|
|
370
|
+
const l = v.columns.length > 0 ? v.columns.map((y) => y.title) : Object.keys(v.data[0]), i = v.columns.length > 0 ? v.columns.map((y) => y.key) : Object.keys(v.data[0]), $ = [
|
|
371
371
|
l.join(","),
|
|
372
|
-
...
|
|
373
|
-
(y) =>
|
|
374
|
-
const
|
|
375
|
-
return typeof
|
|
372
|
+
...v.data.map(
|
|
373
|
+
(y) => i.map((d) => {
|
|
374
|
+
const r = y[d];
|
|
375
|
+
return typeof r == "string" && (r.includes(",") || r.includes('"')) ? `"${r.replace(/"/g, '""')}"` : r;
|
|
376
376
|
}).join(",")
|
|
377
377
|
)
|
|
378
378
|
].join(`
|
|
379
|
-
`),
|
|
380
|
-
|
|
379
|
+
`), b = new Blob([$], { type: "text/csv;charset=utf-8;" }), T = URL.createObjectURL(b), g = document.createElement("a");
|
|
380
|
+
g.href = T, g.download = `${v.filename}.csv`, document.body.appendChild(g), g.click(), document.body.removeChild(g), URL.revokeObjectURL(T);
|
|
381
381
|
} catch (l) {
|
|
382
382
|
console.error("Export failed:", l);
|
|
383
383
|
} finally {
|
|
384
|
-
|
|
384
|
+
n.value = !1;
|
|
385
385
|
}
|
|
386
386
|
}
|
|
387
387
|
};
|
|
388
|
-
return (l,
|
|
389
|
-
loading:
|
|
390
|
-
onClick:
|
|
388
|
+
return (l, i) => (o(), X(a(W), {
|
|
389
|
+
loading: n.value,
|
|
390
|
+
onClick: u
|
|
391
391
|
}, {
|
|
392
|
-
default:
|
|
393
|
-
|
|
392
|
+
default: U(() => [...i[0] || (i[0] = [
|
|
393
|
+
j("导出", -1)
|
|
394
394
|
])]),
|
|
395
|
-
icon:
|
|
396
|
-
|
|
395
|
+
icon: U(() => [...i[1] || (i[1] = [
|
|
396
|
+
j("📥", -1)
|
|
397
397
|
])]),
|
|
398
398
|
_: 1
|
|
399
399
|
}, 8, ["loading"]));
|
|
400
400
|
}
|
|
401
401
|
});
|
|
402
|
-
function
|
|
403
|
-
const
|
|
402
|
+
function Y(t) {
|
|
403
|
+
const v = {
|
|
404
404
|
"&": "&",
|
|
405
405
|
"<": "<",
|
|
406
406
|
">": ">",
|
|
407
407
|
'"': """,
|
|
408
408
|
"'": "'"
|
|
409
409
|
};
|
|
410
|
-
return
|
|
410
|
+
return t.replace(/[&<>"']/g, (n) => v[n]);
|
|
411
411
|
}
|
|
412
|
-
function
|
|
413
|
-
return
|
|
412
|
+
function R(t) {
|
|
413
|
+
return t = t.replace(/`([^`]+)`/g, '<code class="md-code">$1</code>'), t = t.replace(/\*\*([^*]+)\*\*/g, "<strong>$1</strong>"), t = t.replace(/__([^_]+)__/g, "<strong>$1</strong>"), t = t.replace(/\*([^*]+)\*/g, "<em>$1</em>"), t = t.replace(/_([^_]+)_/g, "<em>$1</em>"), t = t.replace(/~~([^~]+)~~/g, "<del>$1</del>"), t = t.replace(/\[([^\]]+)\]\(([^)]+)\)/g, '<a href="$2" target="_blank" class="md-link">$1</a>'), t = t.replace(/!\[([^\]]*)\]\(([^)]+)\)/g, '<img src="$2" alt="$1" class="md-image" />'), t;
|
|
414
414
|
}
|
|
415
|
-
function
|
|
416
|
-
const
|
|
417
|
-
`),
|
|
418
|
-
let l = !1,
|
|
419
|
-
const
|
|
420
|
-
|
|
421
|
-
},
|
|
422
|
-
|
|
423
|
-
},
|
|
424
|
-
y && (
|
|
415
|
+
function de(t, v = {}) {
|
|
416
|
+
const n = t.split(`
|
|
417
|
+
`), u = [];
|
|
418
|
+
let l = !1, i = "", $ = [], b = !1, T = "", g = !1, y = !1;
|
|
419
|
+
const d = () => {
|
|
420
|
+
b && (u.push(`</${T}>`), b = !1, T = "");
|
|
421
|
+
}, r = () => {
|
|
422
|
+
g && (u.push("</blockquote>"), g = !1);
|
|
423
|
+
}, m = () => {
|
|
424
|
+
y && (u.push("</table>"), y = !1);
|
|
425
425
|
};
|
|
426
|
-
for (let
|
|
427
|
-
let
|
|
428
|
-
if (
|
|
429
|
-
l ? (
|
|
430
|
-
`))}</code></pre>`), l = !1,
|
|
426
|
+
for (let p = 0; p < n.length; p++) {
|
|
427
|
+
let V = n[p];
|
|
428
|
+
if (V.startsWith("```")) {
|
|
429
|
+
l ? (u.push(`<pre class="md-code-block"><code class="language-${i}">${Y($.join(`
|
|
430
|
+
`))}</code></pre>`), l = !1, i = "", $ = []) : (d(), r(), m(), l = !0, i = V.slice(3).trim(), $ = []);
|
|
431
431
|
continue;
|
|
432
432
|
}
|
|
433
433
|
if (l) {
|
|
434
|
-
$.push(
|
|
434
|
+
$.push(V);
|
|
435
435
|
continue;
|
|
436
436
|
}
|
|
437
|
-
if (
|
|
438
|
-
y || (
|
|
439
|
-
const
|
|
440
|
-
if (
|
|
437
|
+
if (V.trim().startsWith("|") && V.trim().endsWith("|")) {
|
|
438
|
+
y || (d(), r(), y = !0, u.push('<table class="md-table">'));
|
|
439
|
+
const f = V.trim().slice(1, -1).split("|").map((P) => P.trim());
|
|
440
|
+
if (f.every((P) => /^[-:]+$/.test(P)))
|
|
441
441
|
continue;
|
|
442
|
-
if ((
|
|
443
|
-
const
|
|
444
|
-
if (
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
}),
|
|
442
|
+
if ((p === 0 || p > 0 && !n[p - 1].trim().startsWith("|")) && p < n.length - 1) {
|
|
443
|
+
const P = n[p + 1];
|
|
444
|
+
if (P && P.trim().startsWith("|") && P.trim().endsWith("|") && P.trim().slice(1, -1).split("|").map((L) => L.trim()).every((L) => /^[-:]+$/.test(L))) {
|
|
445
|
+
u.push("<thead><tr>"), f.forEach((L) => {
|
|
446
|
+
u.push(`<th>${R(L)}</th>`);
|
|
447
|
+
}), u.push("</tr></thead><tbody>");
|
|
448
448
|
continue;
|
|
449
449
|
}
|
|
450
450
|
}
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
}),
|
|
451
|
+
u.push("<tr>"), f.forEach((P) => {
|
|
452
|
+
u.push(`<td>${R(P)}</td>`);
|
|
453
|
+
}), u.push("</tr>");
|
|
454
454
|
continue;
|
|
455
|
-
} else y && (
|
|
456
|
-
if (!
|
|
457
|
-
|
|
455
|
+
} else y && (u.push("</tbody>"), m());
|
|
456
|
+
if (!V.trim()) {
|
|
457
|
+
d(), r(), m();
|
|
458
458
|
continue;
|
|
459
459
|
}
|
|
460
|
-
if (
|
|
461
|
-
|
|
462
|
-
const
|
|
463
|
-
|
|
460
|
+
if (V.startsWith(">")) {
|
|
461
|
+
d(), g || (u.push('<blockquote class="md-blockquote">'), g = !0);
|
|
462
|
+
const f = V.replace(/^>\s?/, "");
|
|
463
|
+
u.push(`<p>${R(f)}</p>`);
|
|
464
464
|
continue;
|
|
465
|
-
} else
|
|
466
|
-
const
|
|
467
|
-
if (
|
|
468
|
-
|
|
469
|
-
const
|
|
470
|
-
|
|
465
|
+
} else g && r();
|
|
466
|
+
const w = V.match(/^(#{1,6})\s+(.+)$/);
|
|
467
|
+
if (w) {
|
|
468
|
+
d();
|
|
469
|
+
const f = w[1].length, S = R(w[2]);
|
|
470
|
+
u.push(`<h${f} class="md-heading md-h${f}">${S}</h${f}>`);
|
|
471
471
|
continue;
|
|
472
472
|
}
|
|
473
|
-
if (/^[-*_]{3,}$/.test(
|
|
474
|
-
|
|
473
|
+
if (/^[-*_]{3,}$/.test(V.trim())) {
|
|
474
|
+
d(), u.push('<hr class="md-hr" />');
|
|
475
475
|
continue;
|
|
476
476
|
}
|
|
477
|
-
const
|
|
478
|
-
if (
|
|
479
|
-
(!
|
|
477
|
+
const C = V.match(/^[-*+]\s+(.+)$/);
|
|
478
|
+
if (C) {
|
|
479
|
+
(!b || T !== "ul") && (d(), u.push('<ul class="md-list">'), b = !0, T = "ul"), u.push(`<li>${R(C[1])}</li>`);
|
|
480
480
|
continue;
|
|
481
481
|
}
|
|
482
|
-
const k =
|
|
482
|
+
const k = V.match(/^(\d+)\.\s+(.+)$/);
|
|
483
483
|
if (k) {
|
|
484
|
-
(!
|
|
484
|
+
(!b || T !== "ol") && (d(), u.push('<ol class="md-list">'), b = !0, T = "ol"), u.push(`<li>${R(k[2])}</li>`);
|
|
485
485
|
continue;
|
|
486
486
|
}
|
|
487
|
-
|
|
487
|
+
d(), v.breaks !== !1 ? u.push(`<p class="md-paragraph">${R(V)}</p>`) : u.push(`<p class="md-paragraph">${R(V)}</p>`);
|
|
488
488
|
}
|
|
489
|
-
return
|
|
490
|
-
`))}</code></pre>`),
|
|
489
|
+
return d(), r(), m(), l && u.push(`<pre class="md-code-block"><code>${Y($.join(`
|
|
490
|
+
`))}</code></pre>`), u.join(`
|
|
491
491
|
`);
|
|
492
492
|
}
|
|
493
|
-
function re(
|
|
494
|
-
const
|
|
495
|
-
return
|
|
496
|
-
`).forEach((
|
|
497
|
-
const
|
|
498
|
-
if (
|
|
499
|
-
const $ =
|
|
500
|
-
|
|
493
|
+
function re(t) {
|
|
494
|
+
const v = [];
|
|
495
|
+
return t.split(`
|
|
496
|
+
`).forEach((u, l) => {
|
|
497
|
+
const i = u.match(/^(#{1,6})\s+(.+)$/);
|
|
498
|
+
if (i) {
|
|
499
|
+
const $ = i[1].length, b = i[2].trim(), T = `heading-${l}`;
|
|
500
|
+
v.push({ level: $, text: b, id: T });
|
|
501
501
|
}
|
|
502
|
-
}),
|
|
502
|
+
}), v;
|
|
503
503
|
}
|
|
504
|
-
const
|
|
504
|
+
const ue = ["title", "disabled", "onClick"], pe = { key: 0 }, he = ["value", "placeholder", "disabled"], me = ["innerHTML"], ht = /* @__PURE__ */ I({
|
|
505
505
|
name: "XMarkdownEditor",
|
|
506
506
|
__name: "index",
|
|
507
507
|
props: {
|
|
@@ -514,148 +514,769 @@ const ce = ["title", "disabled", "onClick"], ue = { key: 0 }, de = ["value", "pl
|
|
|
514
514
|
disabled: { type: Boolean, default: !1 }
|
|
515
515
|
},
|
|
516
516
|
emits: ["update:modelValue", "change"],
|
|
517
|
-
setup(
|
|
518
|
-
const
|
|
519
|
-
height: typeof
|
|
517
|
+
setup(t, { emit: v }) {
|
|
518
|
+
const n = t, u = v, l = A("markdown-editor"), i = q(n.modelValue), $ = q(), b = q(n.mode), T = B(() => de(i.value)), g = B(() => re(i.value)), y = B(() => ({
|
|
519
|
+
height: typeof n.height == "number" ? `${n.height}px` : n.height
|
|
520
520
|
}));
|
|
521
|
-
|
|
522
|
-
|
|
521
|
+
Q(() => n.modelValue, (C) => {
|
|
522
|
+
i.value = C;
|
|
523
523
|
});
|
|
524
|
-
const
|
|
525
|
-
const k =
|
|
526
|
-
|
|
527
|
-
},
|
|
528
|
-
|
|
529
|
-
},
|
|
530
|
-
if (!$.value ||
|
|
531
|
-
const
|
|
532
|
-
|
|
533
|
-
|
|
524
|
+
const d = (C) => {
|
|
525
|
+
const k = C.target.value;
|
|
526
|
+
i.value = k, u("update:modelValue", k), u("change", k);
|
|
527
|
+
}, r = (C) => {
|
|
528
|
+
b.value = C;
|
|
529
|
+
}, m = (C, k = "") => {
|
|
530
|
+
if (!$.value || n.disabled) return;
|
|
531
|
+
const f = $.value, S = f.selectionStart, P = f.selectionEnd, N = i.value.substring(S, P), L = i.value.substring(0, S) + C + N + k + i.value.substring(P);
|
|
532
|
+
i.value = L, u("update:modelValue", L), u("change", L), Z(() => {
|
|
533
|
+
f.focus(), f.setSelectionRange(S + C.length, S + C.length + N.length);
|
|
534
534
|
});
|
|
535
|
-
},
|
|
536
|
-
{ icon: "H1", title: "标题1", action: () =>
|
|
537
|
-
{ icon: "H2", title: "标题2", action: () =>
|
|
538
|
-
{ icon: "H3", title: "标题3", action: () =>
|
|
535
|
+
}, p = [
|
|
536
|
+
{ icon: "H1", title: "标题1", action: () => m("# ", "") },
|
|
537
|
+
{ icon: "H2", title: "标题2", action: () => m("## ", "") },
|
|
538
|
+
{ icon: "H3", title: "标题3", action: () => m("### ", "") },
|
|
539
539
|
{ type: "divider" },
|
|
540
|
-
{ icon: "B", title: "粗体", action: () =>
|
|
541
|
-
{ icon: "I", title: "斜体", action: () =>
|
|
542
|
-
{ icon: "S", title: "删除线", action: () =>
|
|
540
|
+
{ icon: "B", title: "粗体", action: () => m("**", "**") },
|
|
541
|
+
{ icon: "I", title: "斜体", action: () => m("*", "*") },
|
|
542
|
+
{ icon: "S", title: "删除线", action: () => m("~~", "~~") },
|
|
543
543
|
{ type: "divider" },
|
|
544
|
-
{ icon: "•", title: "无序列表", action: () =>
|
|
545
|
-
{ icon: "1.", title: "有序列表", action: () =>
|
|
544
|
+
{ icon: "•", title: "无序列表", action: () => m("- ", "") },
|
|
545
|
+
{ icon: "1.", title: "有序列表", action: () => m("1. ", "") },
|
|
546
546
|
{ type: "divider" },
|
|
547
|
-
{ icon: "🔗", title: "链接", action: () =>
|
|
548
|
-
{ icon: "🖼", title: "图片", action: () =>
|
|
549
|
-
{ icon: "</>", title: "代码", action: () =>
|
|
547
|
+
{ icon: "🔗", title: "链接", action: () => m("[", "](url)") },
|
|
548
|
+
{ icon: "🖼", title: "图片", action: () => m("") },
|
|
549
|
+
{ icon: "</>", title: "代码", action: () => m("`", "`") },
|
|
550
550
|
{ type: "divider" },
|
|
551
|
-
{ icon: "—", title: "分割线", action: () =>
|
|
551
|
+
{ icon: "—", title: "分割线", action: () => m(`
|
|
552
552
|
---
|
|
553
553
|
`, "") },
|
|
554
|
-
{ icon: "□", title: "引用", action: () =>
|
|
555
|
-
{ icon: "```", title: "代码块", action: () =>
|
|
556
|
-
],
|
|
554
|
+
{ icon: "□", title: "引用", action: () => m("> ", "") },
|
|
555
|
+
{ icon: "```", title: "代码块", action: () => m("\n```\n", "\n```\n") }
|
|
556
|
+
], V = B(() => [
|
|
557
557
|
l.b(),
|
|
558
|
-
l.is("disabled",
|
|
559
|
-
l.is(`mode-${
|
|
560
|
-
]),
|
|
561
|
-
if (
|
|
558
|
+
l.is("disabled", n.disabled),
|
|
559
|
+
l.is(`mode-${b.value}`)
|
|
560
|
+
]), w = (C) => {
|
|
561
|
+
if (b.value !== "split") return;
|
|
562
562
|
const k = document.querySelector(".x-markdown-editor__preview");
|
|
563
563
|
if (!k) return;
|
|
564
|
-
const
|
|
565
|
-
k.scrollTop =
|
|
564
|
+
const f = C.target, S = f.scrollTop / (f.scrollHeight - f.clientHeight);
|
|
565
|
+
k.scrollTop = S * (k.scrollHeight - k.clientHeight);
|
|
566
566
|
};
|
|
567
|
-
return (
|
|
568
|
-
class:
|
|
569
|
-
style:
|
|
567
|
+
return (C, k) => (o(), c("div", {
|
|
568
|
+
class: s(V.value),
|
|
569
|
+
style: H(y.value)
|
|
570
570
|
}, [
|
|
571
|
-
|
|
571
|
+
t.showToolbar ? (o(), c("div", {
|
|
572
572
|
key: 0,
|
|
573
|
-
class: a(
|
|
573
|
+
class: s(a(l).e("toolbar"))
|
|
574
574
|
}, [
|
|
575
|
-
|
|
576
|
-
class: a(
|
|
575
|
+
e("div", {
|
|
576
|
+
class: s(a(l).e("toolbar-left"))
|
|
577
577
|
}, [
|
|
578
|
-
(
|
|
579
|
-
key:
|
|
580
|
-
class:
|
|
581
|
-
title:
|
|
582
|
-
disabled:
|
|
583
|
-
onClick:
|
|
578
|
+
(o(), c(E, null, z(p, (f, S) => e("button", {
|
|
579
|
+
key: S,
|
|
580
|
+
class: s([a(l).e("toolbar-btn"), { "is-divider": f.type === "divider" }]),
|
|
581
|
+
title: f.title,
|
|
582
|
+
disabled: t.disabled,
|
|
583
|
+
onClick: f.action
|
|
584
584
|
}, [
|
|
585
|
-
|
|
586
|
-
], 10,
|
|
585
|
+
f.type ? x("", !0) : (o(), c("span", pe, h(f.icon), 1))
|
|
586
|
+
], 10, ue)), 64))
|
|
587
587
|
], 2),
|
|
588
|
-
|
|
589
|
-
class: a(
|
|
588
|
+
e("div", {
|
|
589
|
+
class: s(a(l).e("toolbar-right"))
|
|
590
590
|
}, [
|
|
591
|
-
|
|
592
|
-
class:
|
|
593
|
-
onClick: k[0] || (k[0] = (
|
|
591
|
+
e("button", {
|
|
592
|
+
class: s([a(l).e("mode-btn"), { "is-active": b.value === "edit" }]),
|
|
593
|
+
onClick: k[0] || (k[0] = (f) => r("edit"))
|
|
594
594
|
}, " 编辑 ", 2),
|
|
595
|
-
|
|
596
|
-
class:
|
|
597
|
-
onClick: k[1] || (k[1] = (
|
|
595
|
+
e("button", {
|
|
596
|
+
class: s([a(l).e("mode-btn"), { "is-active": b.value === "split" }]),
|
|
597
|
+
onClick: k[1] || (k[1] = (f) => r("split"))
|
|
598
598
|
}, " 分屏 ", 2),
|
|
599
|
-
|
|
600
|
-
class:
|
|
601
|
-
onClick: k[2] || (k[2] = (
|
|
599
|
+
e("button", {
|
|
600
|
+
class: s([a(l).e("mode-btn"), { "is-active": b.value === "preview" }]),
|
|
601
|
+
onClick: k[2] || (k[2] = (f) => r("preview"))
|
|
602
602
|
}, " 预览 ", 2)
|
|
603
603
|
], 2)
|
|
604
|
-
], 2)) :
|
|
605
|
-
|
|
606
|
-
class: a(
|
|
604
|
+
], 2)) : x("", !0),
|
|
605
|
+
e("div", {
|
|
606
|
+
class: s(a(l).e("body"))
|
|
607
607
|
}, [
|
|
608
|
-
|
|
608
|
+
t.showToc && g.value.length > 0 ? (o(), c("div", {
|
|
609
609
|
key: 0,
|
|
610
|
-
class: a(
|
|
610
|
+
class: s(a(l).e("toc"))
|
|
611
611
|
}, [
|
|
612
|
-
|
|
613
|
-
class: a(
|
|
612
|
+
e("div", {
|
|
613
|
+
class: s(a(l).e("toc-title"))
|
|
614
614
|
}, "目录", 2),
|
|
615
|
-
|
|
616
|
-
class: a(
|
|
615
|
+
e("ul", {
|
|
616
|
+
class: s(a(l).e("toc-list"))
|
|
617
617
|
}, [
|
|
618
|
-
(
|
|
619
|
-
key:
|
|
620
|
-
class: a(
|
|
621
|
-
style:
|
|
622
|
-
},
|
|
618
|
+
(o(!0), c(E, null, z(g.value, (f, S) => (o(), c("li", {
|
|
619
|
+
key: S,
|
|
620
|
+
class: s(a(l).e("toc-item")),
|
|
621
|
+
style: H({ paddingLeft: (f.level - 1) * 12 + "px" })
|
|
622
|
+
}, h(f.text), 7))), 128))
|
|
623
623
|
], 2)
|
|
624
|
-
], 2)) :
|
|
625
|
-
|
|
626
|
-
class: a(
|
|
624
|
+
], 2)) : x("", !0),
|
|
625
|
+
e("div", {
|
|
626
|
+
class: s(a(l).e("content"))
|
|
627
627
|
}, [
|
|
628
|
-
|
|
629
|
-
class: a(
|
|
628
|
+
K(e("div", {
|
|
629
|
+
class: s(a(l).e("editor-wrapper"))
|
|
630
630
|
}, [
|
|
631
|
-
|
|
631
|
+
e("textarea", {
|
|
632
632
|
ref_key: "editorRef",
|
|
633
633
|
ref: $,
|
|
634
|
-
class: a(
|
|
635
|
-
value:
|
|
636
|
-
placeholder:
|
|
637
|
-
disabled:
|
|
638
|
-
onInput:
|
|
639
|
-
onScroll:
|
|
640
|
-
}, null, 42,
|
|
634
|
+
class: s(a(l).e("editor")),
|
|
635
|
+
value: i.value,
|
|
636
|
+
placeholder: t.placeholder,
|
|
637
|
+
disabled: t.disabled,
|
|
638
|
+
onInput: d,
|
|
639
|
+
onScroll: w
|
|
640
|
+
}, null, 42, he)
|
|
641
641
|
], 2), [
|
|
642
|
-
[G,
|
|
642
|
+
[G, b.value !== "preview"]
|
|
643
643
|
]),
|
|
644
|
-
|
|
645
|
-
class: a(
|
|
646
|
-
innerHTML:
|
|
647
|
-
}, null, 10,
|
|
648
|
-
[G,
|
|
644
|
+
K(e("div", {
|
|
645
|
+
class: s(a(l).e("preview")),
|
|
646
|
+
innerHTML: T.value
|
|
647
|
+
}, null, 10, me), [
|
|
648
|
+
[G, b.value !== "edit"]
|
|
649
649
|
])
|
|
650
650
|
], 2)
|
|
651
651
|
], 2)
|
|
652
652
|
], 6));
|
|
653
653
|
}
|
|
654
|
+
}), fe = { class: "icon-text" }, ve = { class: "status-label" }, mt = /* @__PURE__ */ I({
|
|
655
|
+
name: "XAppCard",
|
|
656
|
+
__name: "index",
|
|
657
|
+
props: {
|
|
658
|
+
id: { default: "" },
|
|
659
|
+
name: { default: "" },
|
|
660
|
+
description: { default: "" },
|
|
661
|
+
icon: { default: "📱" },
|
|
662
|
+
iconBgColor: { default: "#409eff" },
|
|
663
|
+
status: { default: "draft" },
|
|
664
|
+
creator: { default: "" },
|
|
665
|
+
createTime: { default: "" },
|
|
666
|
+
category: { default: "" },
|
|
667
|
+
disabled: { type: Boolean, default: !1 }
|
|
668
|
+
},
|
|
669
|
+
emits: ["click", "edit", "delete", "publish"],
|
|
670
|
+
setup(t, { emit: v }) {
|
|
671
|
+
const n = t, u = v, l = A("app-card"), i = B(() => {
|
|
672
|
+
const d = {
|
|
673
|
+
published: { label: "已发布", color: "#67c23a", dotColor: "#67c23a" },
|
|
674
|
+
draft: { label: "草稿", color: "#909399", dotColor: "#909399" },
|
|
675
|
+
archived: { label: "已归档", color: "#f56c6c", dotColor: "#f56c6c" }
|
|
676
|
+
};
|
|
677
|
+
return d[n.status] || d.draft;
|
|
678
|
+
}), $ = B(() => [
|
|
679
|
+
l.b(),
|
|
680
|
+
l.m(n.status),
|
|
681
|
+
l.is("disabled", n.disabled)
|
|
682
|
+
]), b = () => {
|
|
683
|
+
n.disabled || u("click", n.id);
|
|
684
|
+
}, T = (d) => {
|
|
685
|
+
d.stopPropagation(), n.disabled || u("edit", n.id);
|
|
686
|
+
}, g = (d) => {
|
|
687
|
+
d.stopPropagation(), n.disabled || u("delete", n.id);
|
|
688
|
+
}, y = (d) => {
|
|
689
|
+
d.stopPropagation(), n.disabled || u("publish", n.id);
|
|
690
|
+
};
|
|
691
|
+
return (d, r) => (o(), c("div", {
|
|
692
|
+
class: s($.value),
|
|
693
|
+
onClick: b
|
|
694
|
+
}, [
|
|
695
|
+
e("div", {
|
|
696
|
+
class: s(a(l).e("icon")),
|
|
697
|
+
style: H({ backgroundColor: t.iconBgColor })
|
|
698
|
+
}, [
|
|
699
|
+
e("span", fe, h(t.icon), 1)
|
|
700
|
+
], 6),
|
|
701
|
+
e("div", {
|
|
702
|
+
class: s(a(l).e("status"))
|
|
703
|
+
}, [
|
|
704
|
+
e("span", {
|
|
705
|
+
class: "status-dot",
|
|
706
|
+
style: H({ backgroundColor: i.value.dotColor })
|
|
707
|
+
}, null, 4),
|
|
708
|
+
e("span", ve, h(i.value.label), 1)
|
|
709
|
+
], 2),
|
|
710
|
+
e("div", {
|
|
711
|
+
class: s(a(l).e("info"))
|
|
712
|
+
}, [
|
|
713
|
+
e("div", {
|
|
714
|
+
class: s(a(l).e("name"))
|
|
715
|
+
}, h(t.name), 3),
|
|
716
|
+
t.description ? (o(), c("div", {
|
|
717
|
+
key: 0,
|
|
718
|
+
class: s(a(l).e("description"))
|
|
719
|
+
}, h(t.description), 3)) : x("", !0)
|
|
720
|
+
], 2),
|
|
721
|
+
e("div", {
|
|
722
|
+
class: s(a(l).e("meta"))
|
|
723
|
+
}, [
|
|
724
|
+
t.creator ? (o(), c("span", {
|
|
725
|
+
key: 0,
|
|
726
|
+
class: s(a(l).e("creator"))
|
|
727
|
+
}, "创建者: " + h(t.creator), 3)) : x("", !0),
|
|
728
|
+
t.createTime ? (o(), c("span", {
|
|
729
|
+
key: 1,
|
|
730
|
+
class: s(a(l).e("time"))
|
|
731
|
+
}, h(t.createTime), 3)) : x("", !0)
|
|
732
|
+
], 2),
|
|
733
|
+
e("div", {
|
|
734
|
+
class: s(a(l).e("actions"))
|
|
735
|
+
}, [
|
|
736
|
+
e("button", {
|
|
737
|
+
class: "action-btn",
|
|
738
|
+
title: "编辑",
|
|
739
|
+
onClick: T
|
|
740
|
+
}, " ✏️ "),
|
|
741
|
+
t.status === "draft" ? (o(), c("button", {
|
|
742
|
+
key: 0,
|
|
743
|
+
class: "action-btn",
|
|
744
|
+
title: "发布",
|
|
745
|
+
onClick: y
|
|
746
|
+
}, " 🚀 ")) : x("", !0),
|
|
747
|
+
e("button", {
|
|
748
|
+
class: "action-btn action-btn--danger",
|
|
749
|
+
title: "删除",
|
|
750
|
+
onClick: g
|
|
751
|
+
}, " 🗑️ ")
|
|
752
|
+
], 2)
|
|
753
|
+
], 2));
|
|
754
|
+
}
|
|
755
|
+
}), ge = ["disabled"], ye = { class: "role-icon" }, be = { class: "role-label" }, ke = {
|
|
756
|
+
key: 0,
|
|
757
|
+
class: "timestamp"
|
|
758
|
+
}, $e = {
|
|
759
|
+
key: 0,
|
|
760
|
+
class: "loading-indicator"
|
|
761
|
+
}, Ce = {
|
|
762
|
+
key: 0,
|
|
763
|
+
class: "text-content"
|
|
764
|
+
}, xe = {
|
|
765
|
+
key: 1,
|
|
766
|
+
class: "code-block"
|
|
767
|
+
}, we = { class: "code-header" }, Te = { class: "language" }, Ve = ["onClick"], Se = { class: "code-content" }, Be = ["placeholder", "disabled", "onKeydown"], Ee = ["disabled"], ft = /* @__PURE__ */ I({
|
|
768
|
+
name: "XChat",
|
|
769
|
+
__name: "index",
|
|
770
|
+
props: {
|
|
771
|
+
messages: { default: () => [] },
|
|
772
|
+
showInput: { type: Boolean, default: !0 },
|
|
773
|
+
placeholder: { default: "输入消息..." },
|
|
774
|
+
disabled: { type: Boolean, default: !1 },
|
|
775
|
+
loading: { type: Boolean, default: !1 },
|
|
776
|
+
maxHeight: { default: 400 },
|
|
777
|
+
showClear: { type: Boolean, default: !0 },
|
|
778
|
+
showTimestamp: { type: Boolean, default: !0 }
|
|
779
|
+
},
|
|
780
|
+
emits: ["send", "clear", "copy"],
|
|
781
|
+
setup(t, { emit: v }) {
|
|
782
|
+
const n = t, u = v, l = A("chat"), i = q(""), $ = q(null), b = B(() => [
|
|
783
|
+
l.b(),
|
|
784
|
+
l.is("disabled", n.disabled)
|
|
785
|
+
]), T = B(() => ({ maxHeight: typeof n.maxHeight == "number" ? `${n.maxHeight}px` : n.maxHeight })), g = () => {
|
|
786
|
+
i.value.trim() && !n.disabled && !n.loading && (u("send", i.value.trim()), i.value = "");
|
|
787
|
+
}, y = () => {
|
|
788
|
+
u("clear");
|
|
789
|
+
}, d = async (w) => {
|
|
790
|
+
try {
|
|
791
|
+
await navigator.clipboard.writeText(w), u("copy", w);
|
|
792
|
+
} catch (C) {
|
|
793
|
+
console.error("复制失败:", C);
|
|
794
|
+
}
|
|
795
|
+
}, r = async () => {
|
|
796
|
+
await Z(), $.value && ($.value.scrollTop = $.value.scrollHeight);
|
|
797
|
+
};
|
|
798
|
+
Q(() => n.messages, () => {
|
|
799
|
+
r();
|
|
800
|
+
}, { deep: !0 });
|
|
801
|
+
const m = (w) => ({
|
|
802
|
+
user: "👤",
|
|
803
|
+
assistant: "🤖",
|
|
804
|
+
system: "⚙️"
|
|
805
|
+
})[w] || "💬", p = (w) => ({
|
|
806
|
+
user: "用户",
|
|
807
|
+
assistant: "AI助手",
|
|
808
|
+
system: "系统"
|
|
809
|
+
})[w] || "消息", V = (w) => {
|
|
810
|
+
const C = /```(\w+)?\n([\s\S]*?)```/g, k = [];
|
|
811
|
+
let f = 0, S;
|
|
812
|
+
for (; (S = C.exec(w)) !== null; )
|
|
813
|
+
S.index > f && k.push({
|
|
814
|
+
type: "text",
|
|
815
|
+
content: w.slice(f, S.index)
|
|
816
|
+
}), k.push({
|
|
817
|
+
type: "code",
|
|
818
|
+
content: S[2],
|
|
819
|
+
language: S[1] || "plaintext"
|
|
820
|
+
}), f = S.index + S[0].length;
|
|
821
|
+
return f < w.length && k.push({
|
|
822
|
+
type: "text",
|
|
823
|
+
content: w.slice(f)
|
|
824
|
+
}), k.length > 0 ? k : [{ type: "text", content: w }];
|
|
825
|
+
};
|
|
826
|
+
return (w, C) => (o(), c("div", {
|
|
827
|
+
class: s(b.value)
|
|
828
|
+
}, [
|
|
829
|
+
t.showClear ? (o(), c("div", {
|
|
830
|
+
key: 0,
|
|
831
|
+
class: s(a(l).e("toolbar"))
|
|
832
|
+
}, [
|
|
833
|
+
e("button", {
|
|
834
|
+
class: "clear-btn",
|
|
835
|
+
onClick: y,
|
|
836
|
+
disabled: t.disabled || t.messages.length === 0
|
|
837
|
+
}, " 🗑️ 清空对话 ", 8, ge)
|
|
838
|
+
], 2)) : x("", !0),
|
|
839
|
+
e("div", {
|
|
840
|
+
ref_key: "messagesContainer",
|
|
841
|
+
ref: $,
|
|
842
|
+
class: s(a(l).e("messages")),
|
|
843
|
+
style: H(T.value)
|
|
844
|
+
}, [
|
|
845
|
+
t.messages.length === 0 ? (o(), c("div", {
|
|
846
|
+
key: 0,
|
|
847
|
+
class: s(a(l).e("empty"))
|
|
848
|
+
}, [...C[1] || (C[1] = [
|
|
849
|
+
e("span", { class: "empty-icon" }, "💬", -1),
|
|
850
|
+
e("span", { class: "empty-text" }, "暂无对话消息", -1)
|
|
851
|
+
])], 2)) : x("", !0),
|
|
852
|
+
(o(!0), c(E, null, z(t.messages, (k) => (o(), c("div", {
|
|
853
|
+
key: k.id,
|
|
854
|
+
class: s([a(l).e("message"), a(l).em("message", k.role)])
|
|
855
|
+
}, [
|
|
856
|
+
e("div", {
|
|
857
|
+
class: s(a(l).e("message-header"))
|
|
858
|
+
}, [
|
|
859
|
+
e("span", ye, h(m(k.role)), 1),
|
|
860
|
+
e("span", be, h(p(k.role)), 1),
|
|
861
|
+
t.showTimestamp && k.timestamp ? (o(), c("span", ke, h(k.timestamp), 1)) : x("", !0)
|
|
862
|
+
], 2),
|
|
863
|
+
e("div", {
|
|
864
|
+
class: s(a(l).e("message-content"))
|
|
865
|
+
}, [
|
|
866
|
+
k.loading ? (o(), c("span", $e, [...C[2] || (C[2] = [
|
|
867
|
+
e("span", { class: "dot" }, null, -1),
|
|
868
|
+
e("span", { class: "dot" }, null, -1),
|
|
869
|
+
e("span", { class: "dot" }, null, -1)
|
|
870
|
+
])])) : (o(!0), c(E, { key: 1 }, z(V(k.content), (f, S) => (o(), c(E, { key: S }, [
|
|
871
|
+
f.type === "text" ? (o(), c("div", Ce, h(f.content), 1)) : (o(), c("div", xe, [
|
|
872
|
+
e("div", we, [
|
|
873
|
+
e("span", Te, h(f.language), 1),
|
|
874
|
+
e("button", {
|
|
875
|
+
class: "copy-btn",
|
|
876
|
+
onClick: (P) => d(f.content)
|
|
877
|
+
}, " 📋 复制 ", 8, Ve)
|
|
878
|
+
]),
|
|
879
|
+
e("pre", Se, [
|
|
880
|
+
e("code", null, h(f.content), 1)
|
|
881
|
+
])
|
|
882
|
+
]))
|
|
883
|
+
], 64))), 128))
|
|
884
|
+
], 2)
|
|
885
|
+
], 2))), 128))
|
|
886
|
+
], 6),
|
|
887
|
+
t.showInput ? (o(), c("div", {
|
|
888
|
+
key: 1,
|
|
889
|
+
class: s(a(l).e("input"))
|
|
890
|
+
}, [
|
|
891
|
+
K(e("textarea", {
|
|
892
|
+
"onUpdate:modelValue": C[0] || (C[0] = (k) => i.value = k),
|
|
893
|
+
placeholder: t.placeholder,
|
|
894
|
+
disabled: t.disabled || t.loading,
|
|
895
|
+
class: "input-textarea",
|
|
896
|
+
onKeydown: J(_(g, ["ctrl"]), ["enter"]),
|
|
897
|
+
rows: "3"
|
|
898
|
+
}, null, 40, Be), [
|
|
899
|
+
[le, i.value]
|
|
900
|
+
]),
|
|
901
|
+
e("button", {
|
|
902
|
+
class: "send-btn",
|
|
903
|
+
disabled: t.disabled || t.loading || !i.value.trim(),
|
|
904
|
+
onClick: g
|
|
905
|
+
}, h(t.loading ? "发送中..." : "发送"), 9, Ee)
|
|
906
|
+
], 2)) : x("", !0)
|
|
907
|
+
], 2));
|
|
908
|
+
}
|
|
909
|
+
}), Pe = { key: 0 }, He = { key: 1 }, ze = { class: "col-session-id" }, Ue = { class: "session-id" }, Ie = { class: "col-title" }, Le = { class: "col-message-count" }, Me = { class: "col-status" }, je = { class: "col-time" }, qe = { class: "col-actions" }, Ae = ["onClick"], Re = ["onClick"], We = { class: "pagination-info" }, Xe = { class: "pagination-controls" }, De = ["disabled"], Ke = { class: "pagination-current" }, Ne = ["disabled"], Oe = ["value"], vt = /* @__PURE__ */ I({
|
|
910
|
+
name: "XLogTable",
|
|
911
|
+
__name: "index",
|
|
912
|
+
props: {
|
|
913
|
+
data: { default: () => [] },
|
|
914
|
+
loading: { type: Boolean, default: !1 },
|
|
915
|
+
pagination: { default: void 0 },
|
|
916
|
+
showPagination: { type: Boolean, default: !0 }
|
|
917
|
+
},
|
|
918
|
+
emits: ["page-change", "size-change", "view-detail", "view-trace"],
|
|
919
|
+
setup(t, { emit: v }) {
|
|
920
|
+
const n = t, u = v, l = A("log-table"), i = (d) => ({
|
|
921
|
+
success: { label: "成功", color: "#67c23a" },
|
|
922
|
+
error: { label: "失败", color: "#f56c6c" },
|
|
923
|
+
running: { label: "运行中", color: "#409eff" }
|
|
924
|
+
})[d] || { label: "未知", color: "#909399" }, $ = B(() => [
|
|
925
|
+
l.b(),
|
|
926
|
+
l.is("loading", n.loading)
|
|
927
|
+
]), b = (d) => {
|
|
928
|
+
u("page-change", d);
|
|
929
|
+
}, T = (d) => {
|
|
930
|
+
u("size-change", d);
|
|
931
|
+
}, g = (d) => {
|
|
932
|
+
u("view-detail", d);
|
|
933
|
+
}, y = (d) => {
|
|
934
|
+
u("view-trace", d);
|
|
935
|
+
};
|
|
936
|
+
return (d, r) => (o(), c("div", {
|
|
937
|
+
class: s($.value)
|
|
938
|
+
}, [
|
|
939
|
+
e("div", {
|
|
940
|
+
class: s(a(l).e("wrapper"))
|
|
941
|
+
}, [
|
|
942
|
+
e("table", null, [
|
|
943
|
+
r[4] || (r[4] = e("thead", null, [
|
|
944
|
+
e("tr", null, [
|
|
945
|
+
e("th", { class: "col-session-id" }, "会话ID"),
|
|
946
|
+
e("th", { class: "col-title" }, "会话标题"),
|
|
947
|
+
e("th", { class: "col-message-count" }, "消息数"),
|
|
948
|
+
e("th", { class: "col-status" }, "状态"),
|
|
949
|
+
e("th", { class: "col-time" }, "最新消息时间"),
|
|
950
|
+
e("th", { class: "col-actions" }, "操作")
|
|
951
|
+
])
|
|
952
|
+
], -1)),
|
|
953
|
+
e("tbody", null, [
|
|
954
|
+
t.loading ? (o(), c("tr", Pe, [
|
|
955
|
+
e("td", {
|
|
956
|
+
colspan: "6",
|
|
957
|
+
class: s(a(l).e("loading-cell"))
|
|
958
|
+
}, [...r[3] || (r[3] = [
|
|
959
|
+
e("span", { class: "loading-spinner" }, null, -1),
|
|
960
|
+
e("span", { class: "loading-text" }, "加载中...", -1)
|
|
961
|
+
])], 2)
|
|
962
|
+
])) : t.data.length === 0 ? (o(), c("tr", He, [
|
|
963
|
+
e("td", {
|
|
964
|
+
colspan: "6",
|
|
965
|
+
class: s(a(l).e("empty"))
|
|
966
|
+
}, " 暂无日志记录 ", 2)
|
|
967
|
+
])) : x("", !0),
|
|
968
|
+
(o(!0), c(E, null, z(t.data, (m) => (o(), c("tr", {
|
|
969
|
+
key: m.id
|
|
970
|
+
}, [
|
|
971
|
+
e("td", ze, [
|
|
972
|
+
e("span", Ue, h(m.sessionId), 1)
|
|
973
|
+
]),
|
|
974
|
+
e("td", Ie, h(m.title), 1),
|
|
975
|
+
e("td", Le, h(m.messageCount), 1),
|
|
976
|
+
e("td", Me, [
|
|
977
|
+
e("span", {
|
|
978
|
+
class: "status-tag",
|
|
979
|
+
style: H({ backgroundColor: i(m.status).color })
|
|
980
|
+
}, h(i(m.status).label), 5)
|
|
981
|
+
]),
|
|
982
|
+
e("td", je, h(m.latestMessageTime), 1),
|
|
983
|
+
e("td", qe, [
|
|
984
|
+
e("button", {
|
|
985
|
+
class: "action-link",
|
|
986
|
+
onClick: (p) => g(m)
|
|
987
|
+
}, " 查看详情 ", 8, Ae),
|
|
988
|
+
e("button", {
|
|
989
|
+
class: "action-link",
|
|
990
|
+
onClick: (p) => y(m)
|
|
991
|
+
}, " 链路追踪 ", 8, Re)
|
|
992
|
+
])
|
|
993
|
+
]))), 128))
|
|
994
|
+
])
|
|
995
|
+
])
|
|
996
|
+
], 2),
|
|
997
|
+
t.showPagination && t.pagination ? (o(), c("div", {
|
|
998
|
+
key: 0,
|
|
999
|
+
class: s(a(l).e("pagination"))
|
|
1000
|
+
}, [
|
|
1001
|
+
e("span", We, " 共 " + h(t.pagination.total) + " 条 ", 1),
|
|
1002
|
+
e("div", Xe, [
|
|
1003
|
+
e("button", {
|
|
1004
|
+
class: "pagination-btn",
|
|
1005
|
+
disabled: t.pagination.current <= 1,
|
|
1006
|
+
onClick: r[0] || (r[0] = (m) => b(t.pagination.current - 1))
|
|
1007
|
+
}, " 上一页 ", 8, De),
|
|
1008
|
+
e("span", Ke, "第 " + h(t.pagination.current) + " 页", 1),
|
|
1009
|
+
e("button", {
|
|
1010
|
+
class: "pagination-btn",
|
|
1011
|
+
disabled: t.pagination.current >= Math.ceil(t.pagination.total / t.pagination.pageSize),
|
|
1012
|
+
onClick: r[1] || (r[1] = (m) => b(t.pagination.current + 1))
|
|
1013
|
+
}, " 下一页 ", 8, Ne)
|
|
1014
|
+
]),
|
|
1015
|
+
e("select", {
|
|
1016
|
+
class: "pagination-size-select",
|
|
1017
|
+
value: t.pagination.pageSize,
|
|
1018
|
+
onChange: r[2] || (r[2] = (m) => T(Number(m.target.value)))
|
|
1019
|
+
}, [...r[5] || (r[5] = [
|
|
1020
|
+
e("option", { value: "10" }, "10条/页", -1),
|
|
1021
|
+
e("option", { value: "20" }, "20条/页", -1),
|
|
1022
|
+
e("option", { value: "50" }, "50条/页", -1),
|
|
1023
|
+
e("option", { value: "100" }, "100条/页", -1)
|
|
1024
|
+
])], 40, Oe)
|
|
1025
|
+
], 2)) : x("", !0)
|
|
1026
|
+
], 2));
|
|
1027
|
+
}
|
|
1028
|
+
}), Fe = ["onClick"], Ge = { class: "endpoint-path" }, Ye = { class: "endpoint-url" }, Je = { class: "endpoint-desc" }, Qe = { class: "param-name" }, Ze = { class: "param-type" }, _e = { class: "param-required" }, et = {
|
|
1029
|
+
key: 0,
|
|
1030
|
+
class: "required-tag"
|
|
1031
|
+
}, tt = {
|
|
1032
|
+
key: 1,
|
|
1033
|
+
class: "optional-tag"
|
|
1034
|
+
}, lt = { class: "param-default" }, at = { class: "param-desc" }, gt = /* @__PURE__ */ I({
|
|
1035
|
+
name: "XApiDoc",
|
|
1036
|
+
__name: "index",
|
|
1037
|
+
props: {
|
|
1038
|
+
baseUrl: { default: "https://api.example.com" },
|
|
1039
|
+
endpoints: { default: () => [] },
|
|
1040
|
+
showCurlExample: { type: Boolean, default: !0 },
|
|
1041
|
+
authType: { default: "apikey" },
|
|
1042
|
+
apiKeyPlaceholder: { default: "YOUR_API_KEY" }
|
|
1043
|
+
},
|
|
1044
|
+
emits: ["copy-curl"],
|
|
1045
|
+
setup(t, { emit: v }) {
|
|
1046
|
+
const n = t, u = v, l = A("api-doc"), i = q(n.endpoints[0] || null), $ = B(() => [
|
|
1047
|
+
l.b()
|
|
1048
|
+
]), b = {
|
|
1049
|
+
GET: "#67c23a",
|
|
1050
|
+
POST: "#409eff",
|
|
1051
|
+
PUT: "#e6a23c",
|
|
1052
|
+
DELETE: "#f56c6c",
|
|
1053
|
+
PATCH: "#909399"
|
|
1054
|
+
}, T = (d) => {
|
|
1055
|
+
const r = d.method, m = `${n.baseUrl}${d.path}`;
|
|
1056
|
+
let p = `curl -X ${r} '${m}'`;
|
|
1057
|
+
return n.authType === "apikey" ? p += ` -H 'Authorization: ApiKey ${n.apiKeyPlaceholder}'` : n.authType === "bearer" ? p += ` -H 'Authorization: Bearer ${n.apiKeyPlaceholder}'` : n.authType === "basic" && (p += " -u 'username:password'"), r !== "GET" && (p += " -H 'Content-Type: application/json'"), d.requestBody && r !== "GET" && (p += ` -d '${d.requestBody}'`), p;
|
|
1058
|
+
}, g = async (d) => {
|
|
1059
|
+
try {
|
|
1060
|
+
await navigator.clipboard.writeText(d), u("copy-curl", d);
|
|
1061
|
+
} catch (r) {
|
|
1062
|
+
console.error("复制失败:", r);
|
|
1063
|
+
}
|
|
1064
|
+
}, y = (d) => {
|
|
1065
|
+
i.value = d;
|
|
1066
|
+
};
|
|
1067
|
+
return (d, r) => {
|
|
1068
|
+
var m;
|
|
1069
|
+
return o(), c("div", {
|
|
1070
|
+
class: s($.value)
|
|
1071
|
+
}, [
|
|
1072
|
+
e("div", {
|
|
1073
|
+
class: s(a(l).e("sidebar"))
|
|
1074
|
+
}, [
|
|
1075
|
+
e("div", {
|
|
1076
|
+
class: s(a(l).e("sidebar-header"))
|
|
1077
|
+
}, "API 端点", 2),
|
|
1078
|
+
e("div", {
|
|
1079
|
+
class: s(a(l).e("endpoint-list"))
|
|
1080
|
+
}, [
|
|
1081
|
+
(o(!0), c(E, null, z(t.endpoints, (p) => (o(), c("div", {
|
|
1082
|
+
key: `${p.method}-${p.path}`,
|
|
1083
|
+
class: s([a(l).e("endpoint-item"), { "is-active": i.value === p }]),
|
|
1084
|
+
onClick: (V) => y(p)
|
|
1085
|
+
}, [
|
|
1086
|
+
e("span", {
|
|
1087
|
+
class: "method-tag",
|
|
1088
|
+
style: H({ backgroundColor: b[p.method] })
|
|
1089
|
+
}, h(p.method), 5),
|
|
1090
|
+
e("span", Ge, h(p.path), 1)
|
|
1091
|
+
], 10, Fe))), 128))
|
|
1092
|
+
], 2)
|
|
1093
|
+
], 2),
|
|
1094
|
+
e("div", {
|
|
1095
|
+
class: s(a(l).e("content"))
|
|
1096
|
+
}, [
|
|
1097
|
+
i.value ? (o(), c(E, { key: 0 }, [
|
|
1098
|
+
e("div", {
|
|
1099
|
+
class: s(a(l).e("header"))
|
|
1100
|
+
}, [
|
|
1101
|
+
e("span", {
|
|
1102
|
+
class: "method-badge",
|
|
1103
|
+
style: H({ backgroundColor: b[i.value.method] })
|
|
1104
|
+
}, h(i.value.method), 5),
|
|
1105
|
+
e("span", Ye, h(t.baseUrl) + h(i.value.path), 1),
|
|
1106
|
+
e("span", Je, h(i.value.description), 1)
|
|
1107
|
+
], 2),
|
|
1108
|
+
(m = i.value.parameters) != null && m.length ? (o(), c("div", {
|
|
1109
|
+
key: 0,
|
|
1110
|
+
class: s(a(l).e("section"))
|
|
1111
|
+
}, [
|
|
1112
|
+
e("div", {
|
|
1113
|
+
class: s(a(l).e("section-title"))
|
|
1114
|
+
}, "请求参数", 2),
|
|
1115
|
+
e("table", {
|
|
1116
|
+
class: s(a(l).e("params-table"))
|
|
1117
|
+
}, [
|
|
1118
|
+
r[1] || (r[1] = e("thead", null, [
|
|
1119
|
+
e("tr", null, [
|
|
1120
|
+
e("th", null, "参数名"),
|
|
1121
|
+
e("th", null, "类型"),
|
|
1122
|
+
e("th", null, "必填"),
|
|
1123
|
+
e("th", null, "默认值"),
|
|
1124
|
+
e("th", null, "说明")
|
|
1125
|
+
])
|
|
1126
|
+
], -1)),
|
|
1127
|
+
e("tbody", null, [
|
|
1128
|
+
(o(!0), c(E, null, z(i.value.parameters, (p) => (o(), c("tr", {
|
|
1129
|
+
key: p.name
|
|
1130
|
+
}, [
|
|
1131
|
+
e("td", Qe, h(p.name), 1),
|
|
1132
|
+
e("td", Ze, h(p.type), 1),
|
|
1133
|
+
e("td", _e, [
|
|
1134
|
+
p.required ? (o(), c("span", et, "必填")) : (o(), c("span", tt, "可选"))
|
|
1135
|
+
]),
|
|
1136
|
+
e("td", lt, h(p.defaultValue || "-"), 1),
|
|
1137
|
+
e("td", at, h(p.description), 1)
|
|
1138
|
+
]))), 128))
|
|
1139
|
+
])
|
|
1140
|
+
], 2)
|
|
1141
|
+
], 2)) : x("", !0),
|
|
1142
|
+
t.showCurlExample ? (o(), c("div", {
|
|
1143
|
+
key: 1,
|
|
1144
|
+
class: s(a(l).e("section"))
|
|
1145
|
+
}, [
|
|
1146
|
+
e("div", {
|
|
1147
|
+
class: s(a(l).e("section-title"))
|
|
1148
|
+
}, [
|
|
1149
|
+
r[2] || (r[2] = j(" curl 示例 ", -1)),
|
|
1150
|
+
e("button", {
|
|
1151
|
+
class: "copy-btn",
|
|
1152
|
+
onClick: r[0] || (r[0] = (p) => g(T(i.value)))
|
|
1153
|
+
}, " 📋 复制 ")
|
|
1154
|
+
], 2),
|
|
1155
|
+
e("div", {
|
|
1156
|
+
class: s(a(l).e("code-block"))
|
|
1157
|
+
}, [
|
|
1158
|
+
e("pre", null, [
|
|
1159
|
+
e("code", null, h(T(i.value)), 1)
|
|
1160
|
+
])
|
|
1161
|
+
], 2)
|
|
1162
|
+
], 2)) : x("", !0),
|
|
1163
|
+
i.value.requestBody ? (o(), c("div", {
|
|
1164
|
+
key: 2,
|
|
1165
|
+
class: s(a(l).e("section"))
|
|
1166
|
+
}, [
|
|
1167
|
+
e("div", {
|
|
1168
|
+
class: s(a(l).e("section-title"))
|
|
1169
|
+
}, "请求体示例", 2),
|
|
1170
|
+
e("div", {
|
|
1171
|
+
class: s(a(l).e("code-block"))
|
|
1172
|
+
}, [
|
|
1173
|
+
e("pre", null, [
|
|
1174
|
+
e("code", null, h(i.value.requestBody), 1)
|
|
1175
|
+
])
|
|
1176
|
+
], 2)
|
|
1177
|
+
], 2)) : x("", !0),
|
|
1178
|
+
i.value.responseExample ? (o(), c("div", {
|
|
1179
|
+
key: 3,
|
|
1180
|
+
class: s(a(l).e("section"))
|
|
1181
|
+
}, [
|
|
1182
|
+
e("div", {
|
|
1183
|
+
class: s(a(l).e("section-title"))
|
|
1184
|
+
}, "响应示例", 2),
|
|
1185
|
+
e("div", {
|
|
1186
|
+
class: s(a(l).e("code-block"))
|
|
1187
|
+
}, [
|
|
1188
|
+
e("pre", null, [
|
|
1189
|
+
e("code", null, h(i.value.responseExample), 1)
|
|
1190
|
+
])
|
|
1191
|
+
], 2)
|
|
1192
|
+
], 2)) : x("", !0)
|
|
1193
|
+
], 64)) : (o(), c("div", {
|
|
1194
|
+
key: 1,
|
|
1195
|
+
class: s(a(l).e("empty"))
|
|
1196
|
+
}, " 请选择一个 API 端点查看详情 ", 2))
|
|
1197
|
+
], 2)
|
|
1198
|
+
], 2);
|
|
1199
|
+
};
|
|
1200
|
+
}
|
|
1201
|
+
}), yt = /* @__PURE__ */ I({
|
|
1202
|
+
name: "XVarTag",
|
|
1203
|
+
__name: "index",
|
|
1204
|
+
props: {
|
|
1205
|
+
name: { default: "" },
|
|
1206
|
+
type: { default: "string" },
|
|
1207
|
+
value: { default: void 0 },
|
|
1208
|
+
showValue: { type: Boolean, default: !1 },
|
|
1209
|
+
copyable: { type: Boolean, default: !1 },
|
|
1210
|
+
disabled: { type: Boolean, default: !1 },
|
|
1211
|
+
size: { default: "default" },
|
|
1212
|
+
showTypeIcon: { type: Boolean, default: !0 }
|
|
1213
|
+
},
|
|
1214
|
+
emits: ["click", "copy"],
|
|
1215
|
+
setup(t, { emit: v }) {
|
|
1216
|
+
const n = t, u = v, l = A("var-tag"), i = B(() => {
|
|
1217
|
+
const y = {
|
|
1218
|
+
string: { icon: "📝", color: "#409eff", label: "文本" },
|
|
1219
|
+
number: { icon: "🔢", color: "#67c23a", label: "数字" },
|
|
1220
|
+
boolean: { icon: "✓", color: "#e6a23c", label: "布尔" },
|
|
1221
|
+
object: { icon: "📦", color: "#909399", label: "对象" },
|
|
1222
|
+
array: { icon: "📚", color: "#909399", label: "数组" },
|
|
1223
|
+
file: { icon: "📁", color: "#f56c6c", label: "文件" }
|
|
1224
|
+
};
|
|
1225
|
+
return y[n.type] || y.string;
|
|
1226
|
+
}), $ = B(() => [
|
|
1227
|
+
l.b(),
|
|
1228
|
+
l.m(n.size),
|
|
1229
|
+
l.m(n.type),
|
|
1230
|
+
l.is("disabled", n.disabled),
|
|
1231
|
+
l.is("copyable", n.copyable)
|
|
1232
|
+
]), b = B(() => n.value === void 0 || n.value === null ? "-" : n.type === "object" || n.type === "array" ? JSON.stringify(n.value) : String(n.value)), T = () => {
|
|
1233
|
+
n.disabled || u("click", n.name);
|
|
1234
|
+
}, g = async () => {
|
|
1235
|
+
if (!n.disabled && n.copyable)
|
|
1236
|
+
try {
|
|
1237
|
+
const y = n.showValue ? `${n.name}: ${b.value}` : n.name;
|
|
1238
|
+
await navigator.clipboard.writeText(y), u("copy", n.name, n.value);
|
|
1239
|
+
} catch (y) {
|
|
1240
|
+
console.error("复制失败:", y);
|
|
1241
|
+
}
|
|
1242
|
+
};
|
|
1243
|
+
return (y, d) => (o(), c("span", {
|
|
1244
|
+
class: s($.value),
|
|
1245
|
+
onClick: T
|
|
1246
|
+
}, [
|
|
1247
|
+
t.showTypeIcon ? (o(), c("span", {
|
|
1248
|
+
key: 0,
|
|
1249
|
+
class: s(a(l).e("icon"))
|
|
1250
|
+
}, h(i.value.icon), 3)) : x("", !0),
|
|
1251
|
+
e("span", {
|
|
1252
|
+
class: s(a(l).e("name"))
|
|
1253
|
+
}, h(t.name), 3),
|
|
1254
|
+
t.showValue ? (o(), c("span", {
|
|
1255
|
+
key: 1,
|
|
1256
|
+
class: s(a(l).e("value"))
|
|
1257
|
+
}, h(b.value), 3)) : x("", !0),
|
|
1258
|
+
t.showValue ? x("", !0) : (o(), c("span", {
|
|
1259
|
+
key: 2,
|
|
1260
|
+
class: s(a(l).e("type")),
|
|
1261
|
+
style: H({ color: i.value.color })
|
|
1262
|
+
}, h(i.value.label), 7)),
|
|
1263
|
+
t.copyable ? (o(), c("button", {
|
|
1264
|
+
key: 3,
|
|
1265
|
+
class: s(a(l).e("copy-btn")),
|
|
1266
|
+
onClick: _(g, ["stop"])
|
|
1267
|
+
}, " 📋 ", 2)) : x("", !0)
|
|
1268
|
+
], 2));
|
|
1269
|
+
}
|
|
654
1270
|
});
|
|
655
1271
|
export {
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
1272
|
+
gt as ApiDoc,
|
|
1273
|
+
mt as AppCard,
|
|
1274
|
+
ft as Chat,
|
|
1275
|
+
pt as Export,
|
|
1276
|
+
vt as LogTable,
|
|
1277
|
+
ht as MarkdownEditor,
|
|
1278
|
+
dt as ProTable,
|
|
1279
|
+
rt as SearchForm,
|
|
1280
|
+
ut as Statistic,
|
|
1281
|
+
yt as VarTag
|
|
661
1282
|
};
|