yc-vep-ui 0.3.52 → 0.3.55

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.
@@ -46,7 +46,7 @@ declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {
46
46
  readonly fileList: import('./type').IUploadRawFile[];
47
47
  readonly action?: string | undefined;
48
48
  readonly onChange?: ((file: any, files: import('./type').IUploadRawFile[]) => void) | undefined;
49
- readonly accept?: string[] | undefined;
49
+ readonly accept?: string | undefined;
50
50
  readonly showSuccessStatus?: boolean | undefined;
51
51
  } & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps;
52
52
  $attrs: import('vue').Attrs;
@@ -2392,10 +2392,20 @@ var _hoisted_1$4 = { style: {
2392
2392
  "remove"
2393
2393
  ],
2394
2394
  setup(e, { emit: n }) {
2395
- let r = n, i = e, { type: a = "file", onChange: o, limit: s, action: c, data: l, prop: u, fileList: d, accept: f, ...p } = i, m = c || baseUrl + "/attachment/uploadAttachment", g = reactive({ token: localStorage.getItem("TOKEN") || "" }), _ = computed(() => f?.length ? new Set(f.map((e) => e.startsWith(".") ? e.toLowerCase() : `.${e.toLowerCase()}`)) : null), v = (e) => {
2396
- if (g.token = localStorage.getItem("TOKEN") || "", !_.value) return !0;
2397
- let n = "." + e.name.split(".").pop().toLowerCase();
2398
- return _.value.has(n) ? !0 : (VepMessage.warning(`只能上传 ${f?.join("、")} 格式的文件`), !1);
2395
+ let r = n, i = e, { type: a = "file", onChange: o, limit: s, action: c, data: l, prop: u, fileList: d, accept: f, ...p } = i, m = c || baseUrl + "/attachment/uploadAttachment", g = { token: localStorage.getItem("TOKEN") || "" }, _ = computed(() => {
2396
+ if (!f) return null;
2397
+ let e = [], n = [];
2398
+ return f.split(",").forEach((r) => {
2399
+ let i = r.trim().toLowerCase();
2400
+ i.startsWith(".") ? e.push(i) : i.includes("/*") && n.push(i.replace("/*", ""));
2401
+ }), {
2402
+ extensions: e,
2403
+ mimePrefixes: n
2404
+ };
2405
+ }), v = (e) => {
2406
+ if (!_.value) return !0;
2407
+ let { extensions: n, mimePrefixes: r } = _.value, i = "." + (e.name.split(".").pop() || "").toLowerCase(), a = n.length === 0 || n.includes(i), o = r.length === 0 || r.some((n) => e.type.startsWith(n));
2408
+ return !a || !o ? (VepMessage.warning(`只能上传 ${f} 格式的文件`), !1) : !0;
2399
2409
  }, y = computed(() => l && u && l[u] ? l[u] : i.fileList || []), b = computed(() => y.value.length);
2400
2410
  function x(e) {
2401
2411
  r("update:fileList", e);
@@ -2412,7 +2422,7 @@ var _hoisted_1$4 = { style: {
2412
2422
  }
2413
2423
  function T(e, n) {
2414
2424
  if (e?.code !== "ok") return VepMessage.error(e?.message);
2415
- let a = baseUrl + `/attachment/downloadAttachment?objectKey=${e.data?.objectKey}&fileName=${e.data?.fileName}&token=${g.token}`, o = l && u && l[u] ? l[u] : i.fileList || [], s = o.some((r) => r?.uid === n.uid || r?.objectKey === e.data?.objectKey), c;
2425
+ let a = baseUrl + `/attachment/downloadAttachment?objectKey=${e.data?.objectKey}&fileName=${e.data?.fileName}&token=${localStorage.getItem("TOKEN") || ""}`, o = l && u && l[u] ? l[u] : i.fileList || [], s = o.some((r) => r?.uid === n.uid || r?.objectKey === e.data?.objectKey), c;
2416
2426
  c = s ? o.map((r) => r.uid === n.uid ? {
2417
2427
  ...r,
2418
2428
  status: "success",
@@ -2444,68 +2454,62 @@ var _hoisted_1$4 = { style: {
2444
2454
  "onUpdate:fileList": x,
2445
2455
  count: b.value,
2446
2456
  limit: unref(s),
2447
- "before-upload": v
2457
+ "before-upload": v,
2458
+ accept: unref(f)
2448
2459
  }, p), null, 16, [
2449
2460
  "action",
2450
- "headers",
2451
2461
  "file-list",
2452
2462
  "count",
2453
- "limit"
2463
+ "limit",
2464
+ "accept"
2454
2465
  ]));
2455
2466
  }
2456
2467
  }), Upload_exports = /* @__PURE__ */ __exportAll$1({ default: () => Upload_default }), Upload_default = index_vue_vue_type_script_setup_true_lang_default$2;
2457
2468
  //#endregion
2458
2469
  //#region src/hooks/useFetch.ts
2459
2470
  function useFetch(e, n = {}) {
2460
- let { immediate: r = !0, method: i = "GET", onBefore: a, onSuccess: o, onError: s, onFinally: c, ...l } = n, u = {
2461
- method: i,
2462
- headers: new Headers({
2463
- "Content-Type": "application/json",
2464
- token: localStorage.getItem("TOKEN") ?? "",
2465
- ...l.headers || {}
2466
- })
2467
- }, d = ref(!1), f = ref(null), p = ref(null), m = reactive({}), g = !1;
2468
- async function _() {
2469
- if (g) return Promise.reject(/* @__PURE__ */ Error("请求正在进行中,请勿重复触发"));
2470
- g = !0, d.value = !0, p.value = null;
2471
+ let { immediate: r = !0, method: i = "GET", onBefore: a, onSuccess: o, onError: s, onFinally: c, ...l } = n, u = ref(!1), d = ref(null), f = ref(null), p = reactive({}), m = !1;
2472
+ async function g() {
2473
+ if (m) return Promise.reject(/* @__PURE__ */ Error("请求正在进行中,请勿重复触发"));
2474
+ m = !0, u.value = !0, f.value = null;
2471
2475
  try {
2472
- y = JSON.stringify(toRaw(m)), b = isRef(n.ready) ? n.ready.value : n.ready ?? !0;
2473
- let r = baseUrl + e;
2474
- if (a?.(u) === !1) return Promise.reject(/* @__PURE__ */ Error("请求被 onBefore 钩子取消"));
2476
+ v = JSON.stringify(toRaw(p)), y = isRef(n.ready) ? n.ready.value : n.ready ?? !0;
2477
+ let r = e, s = {};
2478
+ if (a?.(p) === !1) return Promise.reject(/* @__PURE__ */ Error("请求被 onBefore 钩子取消"));
2475
2479
  if (i === "GET") {
2476
- let e = new URLSearchParams(toRaw(m)).toString();
2480
+ let e = new URLSearchParams(toRaw(p)).toString();
2477
2481
  e && (r = `${r}?${e}`);
2478
- } else u.body = JSON.stringify(toRaw(m));
2479
- let s = await (await fetch(r, u)).json();
2480
- return s.code ? ["return.optSuccess", "ok"].includes(s.code) || VepMessage.error(s.message || "未知错误!") : s.data?.success || VepMessage.error(s.message || "未知错误!"), f.value = s, o?.(s), s;
2482
+ } else s = toRaw(p);
2483
+ let c = await request_default?.[i?.toLocaleLowerCase?.()](r, s);
2484
+ return c.code ? ["return.optSuccess", "ok"].includes(c.code) || VepMessage.error(c.message || "未知错误!") : c.data?.success || VepMessage.error(c.message || "未知错误!"), d.value = c, o?.(c), c;
2481
2485
  } catch (e) {
2482
2486
  let n = e instanceof Error ? e : Error(String(e));
2483
- throw p.value = n, console.error("请求发生错误:", n), s?.(n), n;
2487
+ throw f.value = n, console.error("请求发生错误:", n), s?.(n), n;
2484
2488
  } finally {
2485
- d.value = !1, g = !1, c?.();
2489
+ u.value = !1, m = !1, c?.();
2486
2490
  }
2487
2491
  }
2488
- let v = null, y = "", b;
2492
+ let _ = null, v = "", y;
2489
2493
  watchEffect(() => {
2490
2494
  let e = toValue(l.defaultParams);
2491
- Object.keys(m).forEach((e) => delete m[e]), Object.assign(m, e || {});
2495
+ Object.keys(p).forEach((e) => delete p[e]), Object.assign(p, e || {});
2492
2496
  let i = isRef(n.ready) ? n.ready.value : n.ready ?? !0;
2493
- i && b === !1 && (y = ""), b = i, v && clearTimeout(v), v = setTimeout(() => {
2494
- let e = JSON.stringify(toRaw(m));
2495
- r && b && !g && e !== y && (y = e, nextTick(() => _()));
2497
+ i && y === !1 && (v = ""), y = i, _ && clearTimeout(_), _ = setTimeout(() => {
2498
+ let e = JSON.stringify(toRaw(p));
2499
+ r && y && !m && e !== v && (v = e, nextTick(() => g()));
2496
2500
  }, 10);
2497
2501
  });
2498
- function x(e) {
2499
- for (let e in m) m[e] = void 0;
2500
- Object.assign(m, e);
2502
+ function b(e) {
2503
+ for (let e in p) p[e] = void 0;
2504
+ Object.assign(p, e);
2501
2505
  }
2502
2506
  return {
2503
- execute: _,
2504
- loading: d,
2505
- data: f,
2506
- error: p,
2507
- params: m,
2508
- setParams: x
2507
+ execute: g,
2508
+ loading: u,
2509
+ data: d,
2510
+ error: f,
2511
+ params: p,
2512
+ setParams: b
2509
2513
  };
2510
2514
  }
2511
2515
  //#endregion
@@ -1,2 +1,2 @@
1
- import { c as e, d as t, f as n, l as r, s as i, u as a } from "../entry-DI2J71Zx.js";
1
+ import { c as e, d as t, f as n, l as r, s as i, u as a } from "../entry-BxTCv3y1.js";
2
2
  export { e as useDictionary, n as useFetch, r as useRoute, a as useRouter, t as useTable, i as useUser };
@@ -1,2 +1,2 @@
1
- import { O as e, _ as t, b as n, v as r, y as i } from "../entry-DI2J71Zx.js";
1
+ import { O as e, _ as t, b as n, v as r, y as i } from "../entry-BxTCv3y1.js";
2
2
  export { t as baseUrl, n as request, e as tempToRender, r as uniq, i as uniqBy };
package/dist/vep-ui.js CHANGED
@@ -1,2 +1,2 @@
1
- import { A as e, C as t, D as n, E as r, S as i, T as a, a as o, g as s, h as c, i as l, k as u, m as d, n as f, o as p, p as m, r as h, t as g, w as _, x as v } from "./entry-DI2J71Zx.js";
1
+ import { A as e, C as t, D as n, E as r, S as i, T as a, a as o, g as s, h as c, i as l, k as u, m as d, n as f, o as p, p as m, r as h, t as g, w as _, x as v } from "./entry-BxTCv3y1.js";
2
2
  export { e as UiCard, i as UiDescriptions, v as UiDialog, a as UiEditor, n as UiFilter, r as UiForm, t as UiInfiniteScroll, d as UiStaffSelect, u as UiTable, _ as UiTree, m as UiUpload, s as WcUtils, o as YcApproval, c as YcMessage, l as YcPageAgent, h as default, h as ycPlugin, g as getHostVue, p as hooks, f as setHostVue };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yc-vep-ui",
3
- "version": "0.3.52",
3
+ "version": "0.3.55",
4
4
  "type": "module",
5
5
  "description": "基于 Vue 3 + Element Plus 的企业级 UI 组件库",
6
6
  "keywords": [