zhytech-ui-mobile 1.0.7 → 1.0.9

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.
@@ -5,6 +5,7 @@ var __publicField = (obj, key, value) => {
5
5
  return value;
6
6
  };
7
7
  import { inject, ref, getCurrentInstance, createVNode, mergeProps, withModifiers, defineComponent, Fragment, renderSlot, openBlock, createBlock, withCtx, Comment, createTextVNode, provide, reactive, watchEffect, onActivated, computed, onBeforeUnmount, onMounted, watch, withDirectives, vModelDynamic, vShow, nextTick, renderList, isReactive, onUnmounted, shallowRef, isVNode as isVNode$1, onBeforeMount, createApp, Transition, effectScope, markRaw, normalizeClass, normalizeStyle, createCommentVNode, onDeactivated, createElementBlock, toDisplayString, useSlots, toRefs, resolveDynamicComponent, unref, Teleport, createSlots, resolveComponent, useCssVars, isRef } from "vue";
8
+ const iconfont = "";
8
9
  const __uno = "";
9
10
  const view = "";
10
11
  const toast = "";
@@ -13896,7 +13897,7 @@ const _sfc_main$o = /* @__PURE__ */ defineComponent({
13896
13897
  default: withCtx(() => [
13897
13898
  createVNode(_component_wd_icon, {
13898
13899
  "custom-class": "description-tip",
13899
- "class-prefix": "iconfont zhy",
13900
+ "class-prefix": "iconfont icon",
13900
13901
  name: "tip",
13901
13902
  color: "#ff0000",
13902
13903
  onClick: _cache[1] || (_cache[1] = ($event) => displayAnswerDescription.value = !unref(displayAnswerDescription))
@@ -16335,6 +16336,37 @@ function useUtils() {
16335
16336
  }
16336
16337
  return true;
16337
16338
  },
16339
+ /**
16340
+ * @description: 将数据对象转换为文件对象
16341
+ * @param files
16342
+ * @return
16343
+ */
16344
+ async dataToFile(files2) {
16345
+ const fileInstances = await Promise.all(
16346
+ files2.map(async (file) => {
16347
+ if (file instanceof File) {
16348
+ return file;
16349
+ }
16350
+ if (file.path && file.path.startsWith("blob:")) {
16351
+ try {
16352
+ let blob = new Blob();
16353
+ let fileObject = void 0;
16354
+ const response = await fetch(file.path);
16355
+ blob = await response.blob();
16356
+ fileObject = new File([blob], file.name || "file", {
16357
+ type: file.type || blob.type || "application/octet-stream",
16358
+ lastModified: file.lastModified || Date.now()
16359
+ });
16360
+ return fileObject;
16361
+ } catch (error) {
16362
+ console.error("Blob URL转换失败:", error);
16363
+ return null;
16364
+ }
16365
+ }
16366
+ })
16367
+ );
16368
+ return fileInstances;
16369
+ },
16338
16370
  /**
16339
16371
  * @description: 将对象格式化为页面跳转参数字符串
16340
16372
  * @param params
@@ -16411,21 +16443,12 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
16411
16443
  setup(__props) {
16412
16444
  const props = __props;
16413
16445
  const formType = inject("formType");
16414
- const { checkFile } = useUtils();
16446
+ const { checkFile, dataToFile } = useUtils();
16415
16447
  const upload = ref();
16416
16448
  const uploadOptions = inject("uploadOptions");
16417
16449
  const { datas, componentProps } = toRefs(props);
16418
16450
  const fileList = ref(datas.value[props.componentID] ?? []);
16419
- const { confirm } = useMessage();
16420
- const beforeRemove = ({ file, resolve }) => {
16421
- confirm("确定删除该文件吗?", "提示", (flag) => {
16422
- if (flag) {
16423
- datas.value[props.componentID] = datas.value[props.componentID].filter((item) => item.name !== file.name);
16424
- }
16425
- resolve(flag);
16426
- });
16427
- };
16428
- const beforeUpload = ({ files: files2, fileList: fileList2, resolve }) => {
16451
+ const beforeUpload = async ({ files: files2, fileList: fileList2, resolve }) => {
16429
16452
  let errorNumber = 0;
16430
16453
  files2.forEach((file) => {
16431
16454
  const checkPass = checkFile(file, fileList2, componentProps.value.fileSize, componentProps.value.fileSizeUnit, false);
@@ -16437,11 +16460,21 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
16437
16460
  if (!datas.value[props.componentID]) {
16438
16461
  datas.value[props.componentID] = [];
16439
16462
  }
16440
- datas.value[props.componentID] = [...datas.value[props.componentID], ...files2];
16463
+ const fileInstances = await dataToFile(files2);
16464
+ datas.value[props.componentID] = [...datas.value[props.componentID], ...fileInstances];
16441
16465
  resolve(true);
16442
16466
  }
16443
16467
  resolve(false);
16444
16468
  };
16469
+ const { confirm } = useMessage();
16470
+ const beforeRemove = ({ file, resolve }) => {
16471
+ confirm("确定删除该文件吗?", "提示", (flag) => {
16472
+ if (flag) {
16473
+ datas.value[props.componentID] = datas.value[props.componentID].filter((item) => item.name !== file.name);
16474
+ }
16475
+ resolve(flag);
16476
+ });
16477
+ };
16445
16478
  return (_ctx, _cache) => {
16446
16479
  var _a, _b;
16447
16480
  const _component_wd_button = resolveEasycom(resolveDynamicComponent("wd-button"), __easycom_1$3);
@@ -16528,21 +16561,12 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
16528
16561
  setup(__props) {
16529
16562
  const props = __props;
16530
16563
  const formType = inject("formType");
16531
- const { checkFile } = useUtils();
16564
+ const { checkFile, dataToFile } = useUtils();
16532
16565
  const upload = ref();
16533
16566
  const uploadOptions = inject("uploadOptions");
16534
16567
  const { datas, componentProps } = toRefs(props);
16535
16568
  const fileList = ref(datas.value[props.componentID] ?? []);
16536
- const { confirm } = useMessage();
16537
- const beforeRemove = ({ file, resolve }) => {
16538
- confirm("确定删除该文件吗?", "提示", (flag) => {
16539
- if (flag) {
16540
- datas.value[props.componentID] = datas.value[props.componentID].filter((item) => item.name !== file.name);
16541
- }
16542
- resolve(flag);
16543
- });
16544
- };
16545
- const beforeUpload = ({ files: files2, fileList: fileList2, resolve }) => {
16569
+ const beforeUpload = async ({ files: files2, fileList: fileList2, resolve }) => {
16546
16570
  let errorNumber = 0;
16547
16571
  files2.forEach((file) => {
16548
16572
  const checkPass = checkFile(file, fileList2, componentProps.value.fileSize, componentProps.value.fileSizeUnit, false);
@@ -16554,11 +16578,22 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
16554
16578
  if (!datas.value[props.componentID]) {
16555
16579
  datas.value[props.componentID] = [];
16556
16580
  }
16557
- datas.value[props.componentID] = [...datas.value[props.componentID], ...files2];
16581
+ const fileInstances = await dataToFile(files2);
16582
+ console.log(fileInstances);
16583
+ datas.value[props.componentID] = [...datas.value[props.componentID], ...fileInstances];
16558
16584
  resolve(true);
16559
16585
  }
16560
16586
  resolve(false);
16561
16587
  };
16588
+ const { confirm } = useMessage();
16589
+ const beforeRemove = ({ file, resolve }) => {
16590
+ confirm("确定删除该文件吗?", "提示", (flag) => {
16591
+ if (flag) {
16592
+ datas.value[props.componentID] = datas.value[props.componentID].filter((item) => item.name !== file.name);
16593
+ }
16594
+ resolve(flag);
16595
+ });
16596
+ };
16562
16597
  return (_ctx, _cache) => {
16563
16598
  var _a, _b;
16564
16599
  const _component_wd_upload = resolveEasycom(resolveDynamicComponent("wd-upload"), __easycom_0);
@@ -16576,6 +16611,7 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
16576
16611
  "auto-upload": (_a = unref(uploadOptions)) == null ? void 0 : _a.autoUpload,
16577
16612
  extension: (_b = unref(componentProps).fileType) == null ? void 0 : _b.split(","),
16578
16613
  accept: "media",
16614
+ "image-mode": "aspectFill",
16579
16615
  "before-upload": beforeUpload,
16580
16616
  "before-remove": beforeRemove
16581
16617
  }, null, 8, ["file-list", "action", "multiple", "limit", "auto-upload", "extension"]),
@@ -19279,7 +19315,14 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
19279
19315
  initComponents(formData.value.components);
19280
19316
  });
19281
19317
  const theme2 = inject("theme", ref({}));
19282
- const themeVars = computed(() => ({ ...theme2.value }));
19318
+ const themeVars = ref({});
19319
+ watch(
19320
+ theme2,
19321
+ () => {
19322
+ themeVars.value = { ...theme2.value };
19323
+ },
19324
+ { deep: true, immediate: true }
19325
+ );
19283
19326
  onMounted(() => initComponents(formData.value.components));
19284
19327
  const initComponents = (components2) => {
19285
19328
  if (components2 == null ? void 0 : components2.length) {
@@ -19662,7 +19705,8 @@ _sfc_main.install = function(app) {
19662
19705
  app.component(_sfc_main.name, _sfc_main);
19663
19706
  };
19664
19707
  const setTheme = (options) => theme.value = { ...theme.value, ...options };
19665
- const theme = ref({
19708
+ const theme = ref({});
19709
+ const defaultTheme = {
19666
19710
  // 主题色
19667
19711
  colorTheme: "#4d80f0",
19668
19712
  // 成功色
@@ -19671,16 +19715,14 @@ const theme = ref({
19671
19715
  colorWarning: "#f0883a",
19672
19716
  // 危险出错色
19673
19717
  colorDanger: "#fa4350"
19674
- });
19718
+ };
19675
19719
  const components = [_sfc_main];
19676
19720
  const install = function(app, options) {
19677
19721
  components.forEach((component) => {
19678
19722
  app.component(component.name, component);
19679
19723
  });
19680
- if (options == null ? void 0 : options.theme) {
19681
- theme.value = options.theme;
19682
- }
19683
19724
  app.provide("theme", theme);
19725
+ setTheme((options == null ? void 0 : options.theme) ?? defaultTheme);
19684
19726
  };
19685
19727
  const index = { install };
19686
19728
  export {