@skyfox2000/webui 1.2.1 → 1.2.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skyfox2000/webui",
3
- "version": "1.2.1",
3
+ "version": "1.2.2",
4
4
  "description": "后台前端通用组件定义",
5
5
  "type": "module",
6
6
  "keywords": [],
@@ -1,7 +1,8 @@
1
- import '../assets/global.css';
1
+ // 基础组件
2
+ export { Button, Tooltip, AppIcon, Fullscreen, Helper, Icon, LayoutIcon, ProjectIcon, ToolIcon } from './common';
2
3
 
3
- import { Button, Tooltip, AppIcon, Fullscreen, Helper, Icon, LayoutIcon, ProjectIcon, ToolIcon } from './common';
4
- import {
4
+ // 内容组件
5
+ export {
5
6
  Dialog,
6
7
  Drawer,
7
8
  Form,
@@ -14,51 +15,9 @@ import {
14
15
  Icontool,
15
16
  Tree,
16
17
  } from './content';
17
- import {
18
- AutoComplete,
19
- Cascader,
20
- Checkbox,
21
- DatePicker,
22
- Input,
23
- InputIcon,
24
- InputPassword,
25
- InputNumber,
26
- PropEditor,
27
- Radio,
28
- RadioStatus,
29
- RangePicker,
30
- Select,
31
- Switch,
32
- Textarea,
33
- Transfer,
34
- TransferTable,
35
- TreeSelect,
36
- UploadList,
37
- } from './form';
38
-
39
- import { Breadcrumb, Content, Datetime, Header, HeaderExits, Menu, MenuTabs } from './layout';
40
18
 
19
+ // 表单组件
41
20
  export {
42
- Button,
43
- Tooltip,
44
- AppIcon,
45
- Fullscreen,
46
- Helper,
47
- Icon,
48
- LayoutIcon,
49
- ProjectIcon,
50
- ToolIcon,
51
- Dialog,
52
- Drawer,
53
- Form,
54
- FormItem,
55
- Search,
56
- SearchItem,
57
- Table,
58
- TableOperate,
59
- Toolbar,
60
- Icontool,
61
- Tree,
62
21
  AutoComplete,
63
22
  Cascader,
64
23
  Checkbox,
@@ -78,11 +37,7 @@ export {
78
37
  TransferTable,
79
38
  TreeSelect,
80
39
  UploadList,
81
- Breadcrumb,
82
- Content,
83
- Datetime,
84
- Header,
85
- HeaderExits,
86
- Menu,
87
- MenuTabs,
88
- };
40
+ } from './form';
41
+
42
+ // 布局组件
43
+ export { Breadcrumb, Content, Datetime, Header, HeaderExits, Menu, MenuTabs } from './layout';
package/src/index.ts CHANGED
@@ -1,3 +1,53 @@
1
+ import '@/assets/global.css';
2
+
3
+ export {
4
+ Button,
5
+ Tooltip,
6
+ AppIcon,
7
+ Fullscreen,
8
+ Helper,
9
+ Icon,
10
+ LayoutIcon,
11
+ ProjectIcon,
12
+ ToolIcon,
13
+ Dialog,
14
+ Drawer,
15
+ Form,
16
+ FormItem,
17
+ Search,
18
+ SearchItem,
19
+ Table,
20
+ TableOperate,
21
+ Toolbar,
22
+ Icontool,
23
+ Tree,
24
+ AutoComplete,
25
+ Cascader,
26
+ Checkbox,
27
+ DatePicker,
28
+ Input,
29
+ InputIcon,
30
+ InputPassword,
31
+ InputNumber,
32
+ PropEditor,
33
+ Radio,
34
+ RadioStatus,
35
+ RangePicker,
36
+ Select,
37
+ Switch,
38
+ Textarea,
39
+ Transfer,
40
+ TransferTable,
41
+ TreeSelect,
42
+ UploadList,
43
+ Breadcrumb,
44
+ Content,
45
+ Datetime,
46
+ Header,
47
+ HeaderExits,
48
+ Menu,
49
+ MenuTabs,
50
+ } from '@/components/index';
1
51
  // 类型定义 - 明确导出
2
52
  export type {
3
53
  // 基础数据类型
package/vite.config.ts CHANGED
@@ -56,7 +56,7 @@ export default defineConfig(({ mode }: ConfigEnv) => {
56
56
  assetsDir: 'assets',
57
57
  lib: {
58
58
  entry: {
59
- index: 'src/components/index.ts',
59
+ index: 'src/index.ts',
60
60
  AceEditor: 'src/components/form/aceEditor/index.vue',
61
61
  ExcelForm: 'src/components/content/dialog/excelForm.vue',
62
62
  UploadForm: 'src/components/content/dialog/uploadForm.vue',
@@ -1,170 +0,0 @@
1
- var E = Object.defineProperty;
2
- var m = (a, r, n) => r in a ? E(a, r, { enumerable: !0, configurable: !0, writable: !0, value: n }) : a[r] = n;
3
- var d = (a, r, n) => m(a, typeof r != "symbol" ? r + "" : r, n);
4
- import { hostUrl as b } from "@skyfox2000/fapi";
5
- import { b as w } from "./settingInfo-BZakNKIN.js";
6
- import { mainAppApis as f } from "@skyfox2000/microbase";
7
- import y from "dayjs";
8
- var c = /* @__PURE__ */ ((a) => (a.Pending = "pending", a.Uploading = "uploading", a.Success = "success", a.Error = "error", a.Online = "online", a.Offline = "offline", a))(c || {});
9
- const g = () => f.value && f.value.getToken ? f.value.getToken() : w().getToken();
10
- class v {
11
- /**
12
- * 连接路径参数,已判断 undefined 或 null 值
13
- * @param args 路径参数数组
14
- * @returns 连接后的路径字符串
15
- */
16
- static join(...r) {
17
- return r.filter((u) => u != null).join("/").replace(/[\/]+/, "/");
18
- }
19
- }
20
- class F {
21
- /**
22
- * AsyncUploader 构造函数
23
- * @param urlInfo 文件上传的 API 配置(IUrlInfo 对象)
24
- * @param maxConcurrent 最大允许并发上传的文件数量
25
- */
26
- constructor(r, n) {
27
- /**
28
- * 设置 API 端点和最大并发数,所有上传文件通过该类控制
29
- */
30
- d(this, "urlInfo");
31
- /**
32
- * 最大并发上传数
33
- */
34
- d(this, "maxConcurrent");
35
- /**
36
- * 控制上传任务的中断信号
37
- */
38
- d(this, "abortController");
39
- this.urlInfo = r, this.maxConcurrent = n;
40
- }
41
- /**
42
- * 上传多个文件,控制并发数量
43
- * @param files 文件列表(File[] 或 FileList)
44
- * @param onProgress 上传进度回调
45
- * @param onComplete 上传完成回调
46
- */
47
- async uploadFiles(r, n, o) {
48
- if (!r.length) return;
49
- const u = Math.min(this.maxConcurrent, r.length), e = [];
50
- for (const t of r)
51
- switch (t.status) {
52
- case c.Success:
53
- case c.Online:
54
- case c.Offline:
55
- break;
56
- default:
57
- t.status = c.Pending, e.push(t);
58
- break;
59
- }
60
- const l = [];
61
- this.abortController = new AbortController();
62
- try {
63
- for (; l.length < u && e.length > 0; ) {
64
- const t = e.shift();
65
- if (!t) break;
66
- l.push(this.handleFileStatus(t, l, e, n));
67
- }
68
- await Promise.all(l), o == null || o(r);
69
- } catch (t) {
70
- console.error("上传失败:", t), r.forEach((h) => {
71
- h.status = c.Error, h.error = t instanceof Error ? t : new Error("上传失败"), n == null || n(h);
72
- }), o == null || o(r);
73
- }
74
- }
75
- /**
76
- * 处理单个文件的上传逻辑
77
- * @param file 当前上传的文件
78
- * @param activeUploads 当前正在上传的文件列表
79
- * @param pendingFiles 等待上传的文件列表
80
- * @param onProgress 上传进度回调
81
- */
82
- async handleFileStatus(r, n, o, u) {
83
- try {
84
- r.status = c.Uploading, await this.uploadFile(r, this.abortController.signal, (e) => {
85
- r.percent = e, u == null || u(r);
86
- }), r.status = c.Success;
87
- } catch (e) {
88
- r.status = c.Error, r.error = e instanceof Error ? e : new Error("上传失败"), console.error(r.error);
89
- } finally {
90
- if (o.length > 0) {
91
- const e = o.shift();
92
- e && n.push(this.handleFileStatus(e, n, o, u));
93
- }
94
- }
95
- }
96
- /**
97
- * 使用 XMLHttpRequest 上传文件
98
- * @param file 文件对象
99
- * @param signal 中断信号
100
- * @param onProgress 上传进度回调
101
- */
102
- async uploadFile(r, n, o) {
103
- return new Promise((u, e) => {
104
- const l = new FormData();
105
- if (l.append("file", r.originFileObj), r.params)
106
- for (const s in r.params)
107
- l.append(s, r.params[s]);
108
- const t = new XMLHttpRequest(), h = b(this.urlInfo);
109
- if (h === !1) return Promise.resolve(null);
110
- if (t.open("POST", h, !0), this.urlInfo.header && typeof this.urlInfo.header == "object" && Object.entries(this.urlInfo.header).forEach(([s, i]) => {
111
- t.setRequestHeader(s, i);
112
- }), this.urlInfo.authorize) {
113
- const s = g();
114
- if (!s) {
115
- e(new Error("未授权或授权过期"));
116
- return;
117
- }
118
- t.setRequestHeader("Authorization", "Bearer " + s);
119
- }
120
- t.upload.addEventListener("progress", (s) => {
121
- if (s.lengthComputable && s.total > 0) {
122
- const i = Math.round(s.loaded / s.total * 100);
123
- o(i);
124
- }
125
- }), t.addEventListener("load", () => {
126
- if (t.status >= 200 && t.status < 300) {
127
- const s = t.getResponseHeader("Content-Type");
128
- if (!s || !s.includes("application/json")) {
129
- e(new Error("返回的结果不是 JSON 格式"));
130
- return;
131
- }
132
- try {
133
- const i = JSON.parse(t.response);
134
- if (i.status === "success")
135
- i.data && (r.minioFile = {
136
- ETag: i.data.ETag,
137
- Bucket: i.data.Bucket,
138
- Key: i.data.Key,
139
- Size: i.data.Size,
140
- UpdateTime: y().format("YYYY-MM-DD HH:mm:ss"),
141
- Status: c.Online
142
- }), u(r);
143
- else {
144
- const p = i.msg;
145
- e(new Error(p));
146
- }
147
- } catch (i) {
148
- e(new Error("无法解析返回的 JSON 数据: " + i));
149
- }
150
- } else
151
- e(new Error(`上传失败,状态码:${t.status}`));
152
- }), t.addEventListener("error", () => {
153
- e(new Error("上传失败,网络异常"));
154
- }), t.send(l), n.addEventListener("abort", () => {
155
- t.abort(), e(new Error("上传已取消"));
156
- });
157
- });
158
- }
159
- /**
160
- * 取消当前所有的上传任务
161
- */
162
- cancelUpload() {
163
- this.abortController && this.abortController.abort();
164
- }
165
- }
166
- export {
167
- F as A,
168
- c as U,
169
- v as p
170
- };
@@ -1,297 +0,0 @@
1
- import { defineComponent as A, useAttrs as _, createElementBlock as $, openBlock as R, createVNode as x, withCtx as b, unref as E, mergeProps as k, renderSlot as T, inject as h, ref as g, provide as S, watch as j, toRaw as K } from "vue";
2
- import { Button as C } from "ant-design-vue";
3
- import { a as M, _ as O } from "./index-DmWrkTXX.js";
4
- import { httpPost as V, ResStatus as Q } from "@skyfox2000/fapi";
5
- import d from "vue-m-message";
6
- import F from "async-validator";
7
- const W = /* @__PURE__ */ A({
8
- inheritAttrs: !1,
9
- __name: "index",
10
- props: {
11
- /**
12
- * 提示标题
13
- * @props
14
- * @name content
15
- * @type {string}
16
- */
17
- tiptext: String,
18
- /**
19
- * 提示显示位置
20
- * @props
21
- * @name placement
22
- * @type {string}
23
- * @default 'top'
24
- */
25
- placement: {
26
- type: String,
27
- default: "top"
28
- },
29
- /**
30
- * 内置图标属性设置
31
- * @props
32
- * @name iconProps
33
- * @type {object}
34
- * @summary 内置图标复杂属性设置,仅支持前置图标
35
- */
36
- iconProps: Object,
37
- /**
38
- * 默认使用框架图标
39
- * 其它图标请自定义
40
- * @props
41
- * @name icon
42
- * @type {string}
43
- */
44
- icon: String
45
- // /**
46
- // * 点击事件
47
- // * @props
48
- // * @name clickEvent
49
- // * @summary 格式 "空间名#事件名",空间名和事件名用#分隔,事件名用.分隔
50
- // * @type {string}
51
- // */
52
- // clickEvent: {
53
- // type: String
54
- // },
55
- // /**
56
- // * 点击传输数据
57
- // * @props
58
- // * @name data
59
- // * @summary 点击事件传输的默认数据
60
- // * @type {object|string}
61
- // */
62
- // data: {
63
- // type: [Object, String]
64
- // }
65
- },
66
- emits: [
67
- /**
68
- * 点击事件
69
- * @emits
70
- * @name click
71
- * @summary 图标按钮点击时触发的事件
72
- */
73
- "click"
74
- ],
75
- setup(e, { emit: r }) {
76
- const a = _(), s = e, t = r, n = () => {
77
- s.iconProps && s.iconProps.icons && (s.iconProps.iconIndex = (s.iconProps.iconIndex + 1) % s.iconProps.icons.length), t("click");
78
- };
79
- return (l, i) => (R(), $("div", null, [
80
- x(M, {
81
- title: s.tiptext,
82
- disabled: s.tiptext ? void 0 : "disabled",
83
- placement: e.placement
84
- }, {
85
- default: b(() => [
86
- x(E(C), k({ class: "px-[10px] py-[4px] flex items-center gap-1" }, E(a), { onClick: n }), {
87
- icon: b(() => [
88
- T(l.$slots, "icon", {}, () => [
89
- x(O, k({
90
- icon: s.icon,
91
- class: [
92
- E(a).type === "primary" ? "ant-btn-primary" : "",
93
- "cursor-pointer w-[17px] h-[17px] mx-auto"
94
- ],
95
- clickable: ""
96
- }, s.iconProps), null, 16, ["icon", "class"])
97
- ])
98
- ]),
99
- default: b(() => [
100
- T(l.$slots, "default")
101
- ]),
102
- _: 3
103
- }, 16)
104
- ]),
105
- _: 3
106
- }, 8, ["title", "disabled", "placement"])
107
- ]));
108
- }
109
- });
110
- var m = /* @__PURE__ */ ((e) => (e.PageControl = "Page.PageControl", e.EditorControl = "Page.EditorControl", e.GridControl = "Page.GridControl", e.LabelText = "FormItem.LabelText", e.RuleKey = "FormItem.RuleKey", e.ErrInfo = "FormItem.ErrInfo", e))(m || {});
111
- const y = (e) => e == null || e === "" ? !0 : Array.isArray(e) ? e.length === 0 : typeof e == "object" ? Object.keys(e).length === 0 : !1, I = (e, r) => {
112
- var t;
113
- return {
114
- url: "",
115
- ...(t = e.page.urls) == null ? void 0 : t[r.urlKey],
116
- ...e.url,
117
- ...r.url,
118
- loadingText: r.loadingText
119
- };
120
- }, P = (e, r) => {
121
- const a = e.page, s = r.url;
122
- if (!s || !s.url) {
123
- const n = `URL未设置: ${r.urlKey}`;
124
- return console.warn(n), Promise.reject(new Error(n));
125
- }
126
- s.api || (s.api = a.api), s.authorize === void 0 && (s.authorize = a.authorize);
127
- let t = JSON.parse(JSON.stringify(r.params));
128
- return r.processParams && (t = r.processParams(t)), r.loadingState && (r.loadingState.value = !0), r.hideErrorToast && (s.hideErrorToast = !0), V(s, t).then((n) => (r.loadingState && (r.loadingState.value = !1), n)).catch((n) => (r.loadingState && (r.loadingState.value = !1), null));
129
- }, H = (e, r) => {
130
- r.params || (r.params = {}), r.params.Query || (r.params.Query = {});
131
- const a = I(e, r);
132
- return r.url = a, P(e, r);
133
- }, X = (e, r = {}) => {
134
- const a = r.primaryKey || "Id";
135
- if (r.params || (r.params = {}), r.params.Query || (r.params.Query = {}), !r.params.Data)
136
- return d.error("错误!无保存数据!"), Promise.resolve(null);
137
- const s = {
138
- ...r,
139
- urlKey: r.urlKey || "save",
140
- loadingText: r.loadingText === !1 ? !1 : r.loadingText || "数据保存中..."
141
- };
142
- s.params.Query[a] = s.params.Data[a];
143
- const t = I(e, s);
144
- return s.url = t, P(e, s).then((n) => ((n == null ? void 0 : n.status) === Q.SUCCESS && (r.hideErrorToast || d.success("保存成功!")), n));
145
- }, Y = (e, r, a = {}) => {
146
- const s = a.primaryKey || "Id";
147
- a.params || (a.params = {}), a.params.Query || (a.params.Query = {});
148
- const t = {
149
- ...a,
150
- urlKey: "delete",
151
- loadingText: a.loadingText === !1 ? !1 : a.loadingText || "数据删除中..."
152
- };
153
- if (Array.isArray(r) ? t.params.Query[s] = r : t.params.Query[s] = r[s], y(t.params.Query) || y(t.params.Query[s]))
154
- return d.error("错误!禁止无条件删除数据!"), Promise.resolve(null);
155
- const n = I(e, t);
156
- return t.url = n, P(e, t).then((l) => ((l == null ? void 0 : l.status) === Q.SUCCESS && (a.hideErrorToast || d.success("删除成功!")), l));
157
- };
158
- let w;
159
- const Z = (e) => {
160
- if (!e || y(e))
161
- return [];
162
- const r = [], a = w.messages(), s = (n, l, i) => {
163
- const u = l.type;
164
- if (u && a.types && u in a.types) {
165
- const o = a.types[u];
166
- t(o, n, { type: u }, i);
167
- }
168
- const c = ["string", "number", "array"];
169
- for (const o of c)
170
- if (u === o && a[o]) {
171
- const f = a[o], v = ["len", "min", "max", "range"];
172
- for (const p of v)
173
- p === "range" && l.min != null && l.max != null && f.range ? t(f.range, n, { min: l.min, max: l.max }, i) : p !== "range" && l[p] != null && f[p] && t(f[p], n, { [p]: l[p] }, i);
174
- }
175
- if (l.required && a.required && t(a.required, n, {}, i), l.pattern && a.pattern && t(l.message, n, {}, i), l.enum && Array.isArray(l.enum) && a.enum) {
176
- const o = l.enum.join(", ");
177
- t(a.enum, n, { enum: o }, i);
178
- }
179
- }, t = (n, l, i, u) => {
180
- if (n)
181
- try {
182
- let c;
183
- if (typeof n == "function") {
184
- const o = [l];
185
- for (const f in i)
186
- o.push(i[f]);
187
- c = n.apply(null, o), c && u.push(c);
188
- } else {
189
- c = String(n);
190
- for (const o in i)
191
- c = c.replace(new RegExp(`\\$\\{${o}\\}`, "g"), i[o]);
192
- c = c.replace(/\$\{label\}/g, ""), c && u.push(c);
193
- }
194
- } catch (c) {
195
- console.error("格式化验证消息出错:", c);
196
- }
197
- };
198
- return Object.keys(e).forEach((n) => {
199
- const l = e[n], i = [];
200
- try {
201
- s(n, l, i), Array.isArray(l) && l.forEach((c) => {
202
- c && typeof c == "object" && s(n, c, i);
203
- }), l && typeof l == "object" && "fields" in l;
204
- } catch (c) {
205
- console.error("处理验证规则出错:", c);
206
- }
207
- const u = Array.from(new Set(i));
208
- n && u.length > 0 && r.push({
209
- field: n,
210
- rules: u
211
- });
212
- }), r;
213
- }, ee = async (e) => {
214
- const r = e.formData.value, a = e.formRules.value;
215
- y(a) || (D(e), e.ruleValidator || (e.ruleValidator = new F({}), e.ruleValidator.messages(w.messages()), e.ruleValidator.define(a)), e.ruleResults.value = await e.ruleValidator.validate(r).then(() => {
216
- }).catch(({ fields: s }) => s));
217
- }, D = (e) => {
218
- e.ruleResults.value = void 0;
219
- }, re = () => {
220
- const e = h(m.EditorControl, void 0), r = g(h(m.LabelText, "")), a = g(h(m.RuleKey, "")), s = h(m.ErrInfo, void 0);
221
- return {
222
- editorCtrl: e,
223
- labelText: r,
224
- ruleKey: a,
225
- errInfo: s
226
- };
227
- }, L = (e, r) => {
228
- let a = g({
229
- msg: "",
230
- errClass: ""
231
- });
232
- if (!e.label || !e.rule)
233
- return a;
234
- const s = r == null ? void 0 : r.ruleResults;
235
- return j(
236
- () => s == null ? void 0 : s.value,
237
- (t) => {
238
- if (a.value.errClass = "", a.value.msg = "", !y(t)) {
239
- const n = q(
240
- {
241
- label: e.label,
242
- rule: e.rule
243
- },
244
- r == null ? void 0 : r.formRules.value,
245
- K(t)
246
- );
247
- a.value.errClass = n.errClass.value, a.value.msg = n.msg.value;
248
- }
249
- },
250
- { deep: !0 }
251
- ), a;
252
- }, q = (e, r, a) => {
253
- const s = g([]), t = g(""), n = g("");
254
- if (!e.rule || !r || !a)
255
- return { msg: t, ruleErrors: s, errClass: n };
256
- e.rule.split("|").forEach((u) => {
257
- if (u = u.trim(), u)
258
- if (a[u])
259
- s.value.push(...a[u]);
260
- else {
261
- const c = [];
262
- for (let o in a)
263
- o !== u && o.startsWith(u + ".") && c.push(...a[o]);
264
- c.length > 0 && s.value.push(...c);
265
- }
266
- });
267
- const i = /\${\w+}/g;
268
- return s.value.forEach((u) => {
269
- t.value && (t.value += " / "), t.value += u.message.replace("${label}", e.label ?? "");
270
- const c = r[u.field];
271
- if (c) {
272
- const o = t.value.match(i);
273
- o && o.forEach((f) => {
274
- const v = f.replace("${", "").replace("}", "");
275
- t.value = t.value.replace(f, c[v] ?? "");
276
- });
277
- }
278
- }), s.value.length > 0 && (n.value = "error"), { msg: t, ruleErrors: s, errClass: n };
279
- }, ae = (e, r) => {
280
- S(m.LabelText, e.label || ""), S(m.RuleKey, e.rule || "");
281
- const a = L(e, r);
282
- return S(m.ErrInfo, a), a;
283
- };
284
- export {
285
- m as P,
286
- W as _,
287
- re as a,
288
- X as b,
289
- Y as c,
290
- H as d,
291
- ee as f,
292
- Z as g,
293
- y as i,
294
- D as r,
295
- ae as u,
296
- w as v
297
- };