yc-vep-ui 0.3.52 → 0.3.54

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,25 +2392,27 @@ 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);
2399
- }, y = computed(() => l && u && l[u] ? l[u] : i.fileList || []), b = computed(() => y.value.length);
2400
- function x(e) {
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") || "" }), _ = (e) => {
2396
+ if (g.token = localStorage.getItem("TOKEN") || "", f) {
2397
+ let n = "." + e.name.split(".").pop().toLowerCase();
2398
+ if (!f.split(",").map((e) => e.trim().toLowerCase()).some((r) => r.startsWith(".") ? n === r : r.includes("/*") ? e.type.startsWith(r.replace("/*", "")) : !1)) return VepMessage.warning(`只能上传 ${f} 格式的文件`), !1;
2399
+ }
2400
+ return !0;
2401
+ }, v = computed(() => l && u && l[u] ? l[u] : i.fileList || []), y = computed(() => v.value.length);
2402
+ function b(e) {
2401
2403
  r("update:fileList", e);
2402
2404
  }
2403
- function S(e, n) {
2405
+ function x(e, n) {
2404
2406
  let i = Array.isArray(n) ? n : [];
2405
2407
  o?.(i, e), r("update:fileList", i), r("update:modelValue", i), r("change", i);
2406
2408
  }
2407
- function C() {
2409
+ function S() {
2408
2410
  s && VepMessage.warning(`最多只能上传 ${s} 个文件`);
2409
2411
  }
2410
- function w(e, n) {
2412
+ function C(e, n) {
2411
2413
  r("update:fileList", n), r("update:modelValue", n), r("remove", n);
2412
2414
  }
2413
- function T(e, n) {
2415
+ function w(e, n) {
2414
2416
  if (e?.code !== "ok") return VepMessage.error(e?.message);
2415
2417
  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;
2416
2418
  c = s ? o.map((r) => r.uid === n.uid ? {
@@ -2427,7 +2429,7 @@ var _hoisted_1$4 = { style: {
2427
2429
  url: a
2428
2430
  }], r("update:fileList", c), r("update:modelValue", c), r("success", c);
2429
2431
  }
2430
- function E(e, n, i) {
2432
+ function T(e, n, i) {
2431
2433
  r("update:fileList", i), r("update:modelValue", i);
2432
2434
  }
2433
2435
  return (e, n) => (openBlock(), createBlock(resolveDynamicComponent(unref(a) === "image" ? image_default : file_default), mergeProps({
@@ -2435,16 +2437,16 @@ var _hoisted_1$4 = { style: {
2435
2437
  name: "file",
2436
2438
  action: unref(m),
2437
2439
  headers: g,
2438
- "on-change": S,
2439
- "on-exceed": C,
2440
- "on-remove": w,
2441
- "on-success": T,
2442
- "on-error": E,
2443
- "file-list": y.value,
2444
- "onUpdate:fileList": x,
2445
- count: b.value,
2440
+ "on-change": x,
2441
+ "on-exceed": S,
2442
+ "on-remove": C,
2443
+ "on-success": w,
2444
+ "on-error": T,
2445
+ "file-list": v.value,
2446
+ "onUpdate:fileList": b,
2447
+ count: y.value,
2446
2448
  limit: unref(s),
2447
- "before-upload": v
2449
+ "before-upload": _
2448
2450
  }, p), null, 16, [
2449
2451
  "action",
2450
2452
  "headers",
@@ -2457,55 +2459,48 @@ var _hoisted_1$4 = { style: {
2457
2459
  //#endregion
2458
2460
  //#region src/hooks/useFetch.ts
2459
2461
  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;
2462
+ 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;
2463
+ async function g() {
2464
+ if (m) return Promise.reject(/* @__PURE__ */ Error("请求正在进行中,请勿重复触发"));
2465
+ m = !0, u.value = !0, f.value = null;
2471
2466
  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 钩子取消"));
2467
+ v = JSON.stringify(toRaw(p)), y = isRef(n.ready) ? n.ready.value : n.ready ?? !0;
2468
+ let r = e, s = {};
2469
+ if (a?.(p) === !1) return Promise.reject(/* @__PURE__ */ Error("请求被 onBefore 钩子取消"));
2475
2470
  if (i === "GET") {
2476
- let e = new URLSearchParams(toRaw(m)).toString();
2471
+ let e = new URLSearchParams(toRaw(p)).toString();
2477
2472
  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;
2473
+ } else s = toRaw(p);
2474
+ let c = await request_default?.[i?.toLocaleLowerCase?.()](r, s);
2475
+ 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
2476
  } catch (e) {
2482
2477
  let n = e instanceof Error ? e : Error(String(e));
2483
- throw p.value = n, console.error("请求发生错误:", n), s?.(n), n;
2478
+ throw f.value = n, console.error("请求发生错误:", n), s?.(n), n;
2484
2479
  } finally {
2485
- d.value = !1, g = !1, c?.();
2480
+ u.value = !1, m = !1, c?.();
2486
2481
  }
2487
2482
  }
2488
- let v = null, y = "", b;
2483
+ let _ = null, v = "", y;
2489
2484
  watchEffect(() => {
2490
2485
  let e = toValue(l.defaultParams);
2491
- Object.keys(m).forEach((e) => delete m[e]), Object.assign(m, e || {});
2486
+ Object.keys(p).forEach((e) => delete p[e]), Object.assign(p, e || {});
2492
2487
  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(() => _()));
2488
+ i && y === !1 && (v = ""), y = i, _ && clearTimeout(_), _ = setTimeout(() => {
2489
+ let e = JSON.stringify(toRaw(p));
2490
+ r && y && !m && e !== v && (v = e, nextTick(() => g()));
2496
2491
  }, 10);
2497
2492
  });
2498
- function x(e) {
2499
- for (let e in m) m[e] = void 0;
2500
- Object.assign(m, e);
2493
+ function b(e) {
2494
+ for (let e in p) p[e] = void 0;
2495
+ Object.assign(p, e);
2501
2496
  }
2502
2497
  return {
2503
- execute: _,
2504
- loading: d,
2505
- data: f,
2506
- error: p,
2507
- params: m,
2508
- setParams: x
2498
+ execute: g,
2499
+ loading: u,
2500
+ data: d,
2501
+ error: f,
2502
+ params: p,
2503
+ setParams: b
2509
2504
  };
2510
2505
  }
2511
2506
  //#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-kohyVfPD.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-kohyVfPD.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-kohyVfPD.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.54",
4
4
  "type": "module",
5
5
  "description": "基于 Vue 3 + Element Plus 的企业级 UI 组件库",
6
6
  "keywords": [