@minilo/ui 0.0.2 → 0.0.3

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.
Files changed (126) hide show
  1. package/minilo/dist/index.css +1 -1
  2. package/minilo/dist/index.full.js +2570 -111
  3. package/minilo/dist/index.full.min.js +7 -1
  4. package/minilo/dist/index.full.min.js.map +1 -1
  5. package/minilo/dist/index.full.min.mjs +7 -1
  6. package/minilo/dist/index.full.min.mjs.map +1 -1
  7. package/minilo/dist/index.full.mjs +2565 -113
  8. package/minilo/es/components/button/index.d.ts +4 -4
  9. package/minilo/es/components/button/index.vue.d.ts +2 -2
  10. package/minilo/es/components/chart/index.d.ts +4 -4
  11. package/minilo/es/components/chart/index.vue.d.ts +2 -2
  12. package/minilo/es/components/chart/index.vue2.mjs +2 -2
  13. package/minilo/es/components/detail/index.vue2.mjs +1 -1
  14. package/minilo/es/components/image-upload-pro/index.d.ts +146 -0
  15. package/minilo/es/components/image-upload-pro/index.mjs +7 -0
  16. package/minilo/es/components/image-upload-pro/index.vue.d.ts +146 -0
  17. package/minilo/es/components/image-upload-pro/index.vue.mjs +5 -0
  18. package/minilo/es/components/image-upload-pro/index.vue2.mjs +667 -0
  19. package/minilo/es/components/image-upload-pro/type.d.ts +146 -0
  20. package/minilo/es/components/image-upload-pro/type.mjs +81 -0
  21. package/minilo/es/components/index.d.ts +4 -0
  22. package/minilo/es/components/index.mjs +7 -0
  23. package/minilo/es/components/number-range-input/index.d.ts +3 -3
  24. package/minilo/es/components/number-range-input/index.vue.d.ts +1 -1
  25. package/minilo/es/components/search/index.d.ts +26 -26
  26. package/minilo/es/components/search/index.vue.d.ts +23 -23
  27. package/minilo/es/components/search/props.d.ts +2 -2
  28. package/minilo/es/components/search-table/index.d.ts +18 -18
  29. package/minilo/es/components/search-table/index.vue.d.ts +9 -9
  30. package/minilo/es/components/search-table/index.vue2.mjs +2 -2
  31. package/minilo/es/components/search-table/props.d.ts +3 -3
  32. package/minilo/es/components/tree-select/index.d.ts +32 -0
  33. package/minilo/es/components/tree-select/index.mjs +6 -0
  34. package/minilo/es/components/tree-select/index.vue.d.ts +20 -0
  35. package/minilo/es/components/tree-select/index.vue.mjs +5 -0
  36. package/minilo/es/components/tree-select/index.vue2.mjs +226 -0
  37. package/minilo/es/components/tree-select/type.d.ts +34 -0
  38. package/minilo/es/components/tree-select/type.mjs +1 -0
  39. package/minilo/es/components/tree-select-dialog/index.d.ts +60 -0
  40. package/minilo/es/components/tree-select-dialog/index.mjs +7 -0
  41. package/minilo/es/components/tree-select-dialog/index.vue.d.ts +23 -0
  42. package/minilo/es/components/tree-select-dialog/index.vue.mjs +5 -0
  43. package/minilo/es/components/tree-select-dialog/index.vue2.mjs +135 -0
  44. package/minilo/es/components/tree-select-dialog/type.d.ts +9 -0
  45. package/minilo/es/components/tree-select-dialog/type.mjs +24 -0
  46. package/minilo/es/components/tree-select-drawer/index.d.ts +64 -0
  47. package/minilo/es/components/tree-select-drawer/index.mjs +7 -0
  48. package/minilo/es/components/tree-select-drawer/index.vue.d.ts +23 -0
  49. package/minilo/es/components/tree-select-drawer/index.vue.mjs +5 -0
  50. package/minilo/es/components/tree-select-drawer/index.vue2.mjs +140 -0
  51. package/minilo/es/components/tree-select-drawer/type.d.ts +10 -0
  52. package/minilo/es/components/tree-select-drawer/type.mjs +20 -0
  53. package/minilo/es/components/virtual-list/index.d.ts +4 -4
  54. package/minilo/es/components/virtual-list/index.vue.d.ts +2 -2
  55. package/minilo/es/index.d.ts +393 -61
  56. package/minilo/es/node_modules/.pnpm/{@element-plus_icons-vue@2.3.1_vue@3.5.17_typescript@5.8.3_ → @element-plus_icons-vue@2.3.1_vue@3.5.26_typescript@5.9.3_}/node_modules/@element-plus/icons-vue/dist/index.mjs +17 -1
  57. package/minilo/es/node_modules/.pnpm/{@vueuse_core@13.6.0_vue@3.5.17_typescript@5.9.3_ → @vueuse_core@13.9.0_vue@3.5.26_typescript@5.9.3_}/node_modules/@vueuse/core/index.mjs +2 -2
  58. package/minilo/es/resolver/index.d.ts +1 -1
  59. package/minilo/lib/components/button/index.d.ts +4 -4
  60. package/minilo/lib/components/button/index.vue.d.ts +2 -2
  61. package/minilo/lib/components/chart/index.d.ts +4 -4
  62. package/minilo/lib/components/chart/index.vue.d.ts +2 -2
  63. package/minilo/lib/components/chart/index.vue2.js +2 -2
  64. package/minilo/lib/components/detail/index.vue2.js +1 -1
  65. package/minilo/lib/components/image-upload-pro/index.d.ts +146 -0
  66. package/minilo/lib/components/image-upload-pro/index.js +13 -0
  67. package/minilo/lib/components/image-upload-pro/index.vue.d.ts +146 -0
  68. package/minilo/lib/components/image-upload-pro/index.vue.js +9 -0
  69. package/minilo/lib/components/image-upload-pro/index.vue2.js +671 -0
  70. package/minilo/lib/components/image-upload-pro/type.d.ts +146 -0
  71. package/minilo/lib/components/image-upload-pro/type.js +83 -0
  72. package/minilo/lib/components/index.d.ts +4 -0
  73. package/minilo/lib/components/index.js +14 -0
  74. package/minilo/lib/components/number-range-input/index.d.ts +3 -3
  75. package/minilo/lib/components/number-range-input/index.vue.d.ts +1 -1
  76. package/minilo/lib/components/search/index.d.ts +26 -26
  77. package/minilo/lib/components/search/index.vue.d.ts +23 -23
  78. package/minilo/lib/components/search/props.d.ts +2 -2
  79. package/minilo/lib/components/search-table/index.d.ts +18 -18
  80. package/minilo/lib/components/search-table/index.vue.d.ts +9 -9
  81. package/minilo/lib/components/search-table/index.vue2.js +2 -2
  82. package/minilo/lib/components/search-table/props.d.ts +3 -3
  83. package/minilo/lib/components/tree-select/index.d.ts +32 -0
  84. package/minilo/lib/components/tree-select/index.js +11 -0
  85. package/minilo/lib/components/tree-select/index.vue.d.ts +20 -0
  86. package/minilo/lib/components/tree-select/index.vue.js +9 -0
  87. package/minilo/lib/components/tree-select/index.vue2.js +230 -0
  88. package/minilo/lib/components/tree-select/type.d.ts +34 -0
  89. package/minilo/lib/components/tree-select/type.js +2 -0
  90. package/minilo/lib/components/tree-select-dialog/index.d.ts +60 -0
  91. package/minilo/lib/components/tree-select-dialog/index.js +13 -0
  92. package/minilo/lib/components/tree-select-dialog/index.vue.d.ts +23 -0
  93. package/minilo/lib/components/tree-select-dialog/index.vue.js +9 -0
  94. package/minilo/lib/components/tree-select-dialog/index.vue2.js +139 -0
  95. package/minilo/lib/components/tree-select-dialog/type.d.ts +9 -0
  96. package/minilo/lib/components/tree-select-dialog/type.js +26 -0
  97. package/minilo/lib/components/tree-select-drawer/index.d.ts +64 -0
  98. package/minilo/lib/components/tree-select-drawer/index.js +13 -0
  99. package/minilo/lib/components/tree-select-drawer/index.vue.d.ts +23 -0
  100. package/minilo/lib/components/tree-select-drawer/index.vue.js +9 -0
  101. package/minilo/lib/components/tree-select-drawer/index.vue2.js +144 -0
  102. package/minilo/lib/components/tree-select-drawer/type.d.ts +10 -0
  103. package/minilo/lib/components/tree-select-drawer/type.js +22 -0
  104. package/minilo/lib/components/virtual-list/index.d.ts +4 -4
  105. package/minilo/lib/components/virtual-list/index.vue.d.ts +2 -2
  106. package/minilo/lib/index.d.ts +393 -61
  107. package/minilo/lib/node_modules/.pnpm/{@element-plus_icons-vue@2.3.1_vue@3.5.17_typescript@5.8.3_ → @element-plus_icons-vue@2.3.1_vue@3.5.26_typescript@5.9.3_}/node_modules/@element-plus/icons-vue/dist/index.js +17 -0
  108. package/minilo/lib/node_modules/.pnpm/{@vueuse_core@13.6.0_vue@3.5.17_typescript@5.9.3_ → @vueuse_core@13.9.0_vue@3.5.26_typescript@5.9.3_}/node_modules/@vueuse/core/index.js +1 -1
  109. package/minilo/lib/resolver/index.d.ts +1 -1
  110. package/minilo/theme-chalk/index.css +1 -1
  111. package/minilo/theme-chalk/ml-image-upload-pro.css +1 -0
  112. package/minilo/theme-chalk/ml-tree-select-dialog.css +0 -0
  113. package/minilo/theme-chalk/ml-tree-select-drawer.css +0 -0
  114. package/minilo/theme-chalk/ml-tree-select.css +1 -0
  115. package/minilo/theme-chalk/src/image-upload-pro.scss +70 -0
  116. package/minilo/theme-chalk/src/index.scss +2 -0
  117. package/minilo/theme-chalk/src/tree-select-dialog.scss +0 -0
  118. package/minilo/theme-chalk/src/tree-select-drawer.scss +0 -0
  119. package/minilo/theme-chalk/src/tree-select.scss +47 -0
  120. package/package.json +18 -5
  121. /package/minilo/es/{packages → node_modules/.pnpm/@minilo_utils@0.0.2_vue@3.5.26_typescript@5.9.3_/node_modules/@minilo}/utils/dist/func/common.mjs +0 -0
  122. /package/minilo/es/{packages → node_modules/.pnpm/@minilo_utils@0.0.2_vue@3.5.26_typescript@5.9.3_/node_modules/@minilo}/utils/dist/request/index.mjs +0 -0
  123. /package/minilo/es/node_modules/.pnpm/{@vueuse_shared@13.6.0_vue@3.5.17_typescript@5.9.3_ → @vueuse_shared@13.9.0_vue@3.5.26_typescript@5.9.3_}/node_modules/@vueuse/shared/index.mjs +0 -0
  124. /package/minilo/lib/{packages → node_modules/.pnpm/@minilo_utils@0.0.2_vue@3.5.26_typescript@5.9.3_/node_modules/@minilo}/utils/dist/func/common.js +0 -0
  125. /package/minilo/lib/{packages → node_modules/.pnpm/@minilo_utils@0.0.2_vue@3.5.26_typescript@5.9.3_/node_modules/@minilo}/utils/dist/request/index.js +0 -0
  126. /package/minilo/lib/node_modules/.pnpm/{@vueuse_shared@13.6.0_vue@3.5.17_typescript@5.9.3_ → @vueuse_shared@13.9.0_vue@3.5.26_typescript@5.9.3_}/node_modules/@vueuse/shared/index.js +0 -0
@@ -1,5 +1,5 @@
1
1
  import { getCurrentScope, onScopeDispose, toValue, computed, watch, shallowRef, getCurrentInstance, onMounted, defineComponent, ref, useAttrs, nextTick, onBeforeUnmount, createElementBlock, openBlock, mergeProps, unref, withDirectives, renderSlot, createCommentVNode, createElementVNode, normalizeClass, vShow, createVNode, markRaw, onUnmounted, h, mergeModels, useModel, withCtx, createBlock, Fragment, renderList, withModifiers, createTextVNode, toDisplayString, reactive, readonly, resolveDirective, createSlots, toHandlers, resolveDynamicComponent, resolveComponent, normalizeStyle, useSlots } from 'vue';
2
- import { ElEmpty, ElForm, ElRow, ElCol, ElFormItem, ElInput, ElSelect, ElOption, ElDatePicker, ElButton, ElLink, ElMessage, ElTable, ElTableColumn, ElPagination, ElDescriptions, ElDescriptionsItem, ElTooltip } from 'element-plus';
2
+ import { ElEmpty, ElForm, ElRow, ElCol, ElFormItem, ElInput, ElSelect, ElOption, ElDatePicker, ElButton, ElLink, ElMessage, ElTable, ElTableColumn, ElPagination, ElDescriptions, ElDescriptionsItem, ElTooltip, ElTree, ElMessageBox } from 'element-plus';
3
3
  import axios from 'axios';
4
4
 
5
5
  const libraryNamePrefix = "ml";
@@ -172,8 +172,8 @@ function useResizeObserver(target, callback, options = {}) {
172
172
  };
173
173
  }
174
174
 
175
- const _hoisted_1$2 = ["id"];
176
- var _sfc_main$8 = /* @__PURE__ */ defineComponent({
175
+ const _hoisted_1$3 = ["id"];
176
+ var _sfc_main$c = /* @__PURE__ */ defineComponent({
177
177
  ...{
178
178
  name: "MlChart"
179
179
  },
@@ -274,7 +274,7 @@ var _sfc_main$8 = /* @__PURE__ */ defineComponent({
274
274
  id: __props.id,
275
275
  ref_key: "echartRef",
276
276
  ref: echartRef
277
- }, null, 10, _hoisted_1$2), [
277
+ }, null, 10, _hoisted_1$3), [
278
278
  [vShow, !formatEmpty.value]
279
279
  ]),
280
280
  formatEmpty.value ? renderSlot(_ctx.$slots, "empty", { key: 0 }, () => [
@@ -289,7 +289,7 @@ var _sfc_main$8 = /* @__PURE__ */ defineComponent({
289
289
  }
290
290
  });
291
291
 
292
- const MlChart = withInstall(_sfc_main$8);
292
+ const MlChart = withInstall(_sfc_main$c);
293
293
 
294
294
  var SearchTypeEnum = /* @__PURE__ */ ((SearchTypeEnum2) => {
295
295
  SearchTypeEnum2[SearchTypeEnum2["ITEM"] = 1] = "ITEM";
@@ -2160,7 +2160,7 @@ const Icon = defineComponent((props, { emit }) => {
2160
2160
  emits: ['load'],
2161
2161
  });
2162
2162
 
2163
- var _sfc_main$7 = /* @__PURE__ */ defineComponent({
2163
+ var _sfc_main$b = /* @__PURE__ */ defineComponent({
2164
2164
  ...{ name: "MlSearch" },
2165
2165
  __name: "index",
2166
2166
  props: /* @__PURE__ */ mergeModels(searchProps, {
@@ -5473,10 +5473,14 @@ class TinyColor {
5473
5473
  }
5474
5474
  }
5475
5475
 
5476
+ // 将颜色转换为HSL格式
5476
5477
  function convertToHsl(color) {
5478
+ // 使用TinyColor库将颜色转换为HSL格式
5477
5479
  const { a, h, l, s } = new TinyColor(color).toHsl();
5480
+ // 将HSL格式转换为字符串
5478
5481
  const hsl = `hsl(${Math.round(h)} ${Math.round(s * 100)}% ${Math.round(l * 100)}%)`;
5479
- return a < 1 ? `${hsl} ${a}` : hsl;
5482
+ // 如果颜色的透明度小于1,则返回带有透明度的HSL格式
5483
+ return a < 1 ? `${hsl} ${a}` : hsl
5480
5484
  }
5481
5485
 
5482
5486
  function isPlainObject(value) {
@@ -5535,34 +5539,54 @@ function createDefu(merger) {
5535
5539
  }
5536
5540
  const defu = createDefu();
5537
5541
 
5542
+ /**
5543
+ * @description 判断url是否是http或https
5544
+ * @author xieshuhong
5545
+ * @export
5546
+ * @param {string} url
5547
+ * @return {*}
5548
+ */
5549
+ /**
5550
+ * @description 根据多层级键路径从对象中获取值
5551
+ * @author xieshuhong
5552
+ * @param {Object} obj - 要查询的对象
5553
+ * @param {string} path - 键路径,如 'a.b' 或 'a.b.c'
5554
+ * @param {any} [defaultValue] - 可选,路径不存在时返回的默认值
5555
+ * @returns {any} 路径对应的 value 或 defaultValue
5556
+ */
5538
5557
  function getNestedValue(obj, path, defaultValue) {
5539
- if (typeof obj !== "object" || obj === null || !path) {
5540
- return defaultValue;
5558
+ // 处理边界情况:如果obj不是对象或path为空,直接返回默认值
5559
+ if (typeof obj !== 'object' || obj === null || !path) {
5560
+ return defaultValue
5541
5561
  }
5542
- const keys = path.split(".").filter((key) => key !== "");
5562
+ // 将路径按 '.' 分割成数组(支持处理空字符串和连续点的情况)
5563
+ const keys = path.split('.').filter((key) => key !== '');
5564
+ // 逐层访问对象属性
5543
5565
  return keys.reduce((current, key) => {
5544
- if (typeof current !== "object" || current === null) {
5545
- return defaultValue;
5566
+ // 如果当前值不是对象,直接返回默认值(避免访问非对象的属性)
5567
+ if (typeof current !== 'object' || current === null) {
5568
+ return defaultValue
5546
5569
  }
5547
- return current[key] !== void 0 ? current[key] : defaultValue;
5548
- }, obj);
5570
+ // 访问下一级属性
5571
+ return current[key] !== undefined ? current[key] : defaultValue
5572
+ }, obj)
5549
5573
  }
5550
5574
 
5551
5575
  const config = {
5552
5576
  theme: {
5553
- colorDestructive: "hsl(348 100% 61%)",
5554
- colorPrimary: "hsl(212 100% 45%)",
5555
- colorSuccess: "hsl(144 57% 58%)",
5556
- colorWarning: "hsl(42 84% 61%)"
5577
+ colorDestructive: 'hsl(348 100% 61%)',
5578
+ colorPrimary: 'hsl(212 100% 45%)',
5579
+ colorSuccess: 'hsl(144 57% 58%)',
5580
+ colorWarning: 'hsl(42 84% 61%)'
5557
5581
  },
5558
5582
  sidebar: {
5559
5583
  collapse: false
5560
5584
  },
5561
5585
  app: {
5562
- locale: "zh-CN",
5563
- name: "Minilo Adminss",
5564
- logo: "",
5565
- defaultHomePath: "/"
5586
+ locale: 'zh-CN',
5587
+ name: 'Minilo Adminss',
5588
+ logo: '',
5589
+ defaultHomePath: '/'
5566
5590
  },
5567
5591
  transition: {
5568
5592
  progress: true
@@ -5570,9 +5594,9 @@ const config = {
5570
5594
  };
5571
5595
 
5572
5596
  class StorageManager {
5573
- constructor({ prefix = "", storageType = "localStorage" } = {}) {
5597
+ constructor({ prefix = '', storageType = 'localStorage' } = {}) {
5574
5598
  this.prefix = prefix;
5575
- this.storage = storageType === "localStorage" ? window.localStorage : window.sessionStorage;
5599
+ this.storage = storageType === 'localStorage' ? window.localStorage : window.sessionStorage;
5576
5600
  }
5577
5601
  /**
5578
5602
  * 清除所有带前缀的存储项
@@ -5594,8 +5618,8 @@ class StorageManager {
5594
5618
  for (let i = 0; i < this.storage.length; i++) {
5595
5619
  const key = this.storage.key(i);
5596
5620
  if (key && key.startsWith(this.prefix)) {
5597
- const shortKey = key.replace(this.prefix, "");
5598
- this.getItem(shortKey);
5621
+ const shortKey = key.replace(this.prefix, '');
5622
+ this.getItem(shortKey); // 调用 getItem 方法检查并移除过期项
5599
5623
  }
5600
5624
  }
5601
5625
  }
@@ -5609,19 +5633,19 @@ class StorageManager {
5609
5633
  const fullKey = this.getFullKey(key);
5610
5634
  const itemStr = this.storage.getItem(fullKey);
5611
5635
  if (!itemStr) {
5612
- return defaultValue;
5636
+ return defaultValue
5613
5637
  }
5614
5638
  try {
5615
5639
  const item = JSON.parse(itemStr);
5616
5640
  if (item.expiry && Date.now() > item.expiry) {
5617
5641
  this.storage.removeItem(fullKey);
5618
- return defaultValue;
5642
+ return defaultValue
5619
5643
  }
5620
- return item.value;
5644
+ return item.value
5621
5645
  } catch (error) {
5622
5646
  console.error(`Error parsing item with key "${fullKey}":`, error);
5623
- this.storage.removeItem(fullKey);
5624
- return defaultValue;
5647
+ this.storage.removeItem(fullKey); // 如果解析失败,删除该项
5648
+ return defaultValue
5625
5649
  }
5626
5650
  }
5627
5651
  /**
@@ -5640,7 +5664,7 @@ class StorageManager {
5640
5664
  */
5641
5665
  setItem(key, value, ttl) {
5642
5666
  const fullKey = this.getFullKey(key);
5643
- const expiry = ttl ? Date.now() + ttl : void 0;
5667
+ const expiry = ttl ? Date.now() + ttl : undefined;
5644
5668
  const item = { expiry, value };
5645
5669
  try {
5646
5670
  this.storage.setItem(fullKey, JSON.stringify(item));
@@ -5654,7 +5678,7 @@ class StorageManager {
5654
5678
  * @returns 带前缀的完整键
5655
5679
  */
5656
5680
  getFullKey(key) {
5657
- return `${this.prefix}-${key}`;
5681
+ return `${this.prefix}-${key}`
5658
5682
  }
5659
5683
  }
5660
5684
 
@@ -5709,29 +5733,34 @@ function getColors(color, variants = _variants) {
5709
5733
  return colors;
5710
5734
  }
5711
5735
 
5712
- function executeUpdateCSSVariables(variables, id = "__minilo-styles__") {
5713
- const styleElement = document.querySelector(`#${id}`) || document.createElement("style");
5736
+ function executeUpdateCSSVariables(variables, id = '__minilo-styles__') {
5737
+ // 获取或创建内联样式表元素
5738
+ const styleElement = document.querySelector(`#${id}`) || document.createElement('style');
5714
5739
  styleElement.id = id;
5715
- let cssText = ":root {";
5740
+ // 构建要更新的 CSS 变量的样式文本
5741
+ let cssText = ':root {';
5716
5742
  for (const key in variables) {
5717
5743
  if (Object.prototype.hasOwnProperty.call(variables, key)) {
5718
5744
  cssText += `${key}: ${variables[key]};`;
5719
5745
  }
5720
5746
  }
5721
- cssText += "}";
5747
+ cssText += '}';
5748
+ // 将样式文本赋值给内联样式表
5722
5749
  styleElement.textContent = cssText;
5750
+ // 将内联样式表添加到文档头部
5723
5751
  if (!document.querySelector(`#${id}`)) {
5724
5752
  setTimeout(() => {
5725
5753
  document.head.append(styleElement);
5726
5754
  });
5727
5755
  }
5728
5756
  }
5757
+ // 根据某个色值生成色值阶梯对象,key=500时为其默认初始值,也就是默认参数
5729
5758
  function generatorColorVariables(colorItems) {
5730
5759
  const colorVariables = {};
5731
5760
  colorItems.forEach(({ alias, color, name }) => {
5732
5761
  if (color) {
5733
5762
  const colorsMap = getColors(new TinyColor(color).toHexString());
5734
- let mainColor = colorsMap["500"];
5763
+ let mainColor = colorsMap['500'];
5735
5764
  const colorKeys = Object.keys(colorsMap);
5736
5765
  colorKeys.forEach((key) => {
5737
5766
  const colorValue = colorsMap[key];
@@ -5741,7 +5770,7 @@ function generatorColorVariables(colorItems) {
5741
5770
  if (alias) {
5742
5771
  colorVariables[`--${alias}-${key}`] = hslColor;
5743
5772
  }
5744
- if (key === "500") {
5773
+ if (key === '500') {
5745
5774
  mainColor = hslColor;
5746
5775
  }
5747
5776
  }
@@ -5751,31 +5780,38 @@ function generatorColorVariables(colorItems) {
5751
5780
  }
5752
5781
  }
5753
5782
  });
5754
- return colorVariables;
5783
+ return colorVariables
5755
5784
  }
5756
5785
  function updateCSSVariables(config) {
5757
5786
  const theme = config?.theme ?? {};
5758
- if (Reflect.has(theme, "colorPrimary") || Reflect.has(theme, "colorDestructive") || Reflect.has(theme, "colorSuccess") || Reflect.has(theme, "colorWarning")) {
5787
+ if (
5788
+ Reflect.has(theme, 'colorPrimary') ||
5789
+ Reflect.has(theme, 'colorDestructive') ||
5790
+ Reflect.has(theme, 'colorSuccess') ||
5791
+ Reflect.has(theme, 'colorWarning')
5792
+ ) {
5759
5793
  updateMainColorVariables(config);
5760
5794
  }
5761
5795
  }
5762
5796
  function updateMainColorVariables(config) {
5763
5797
  if (!config.theme) {
5764
- return;
5798
+ return
5765
5799
  }
5766
5800
  const { colorDestructive, colorPrimary, colorSuccess, colorWarning } = config.theme;
5767
5801
  const colorVariables = generatorColorVariables([
5768
- { color: colorPrimary, name: "primary" },
5769
- { alias: "warning", color: colorWarning, name: "yellow" },
5770
- { alias: "success", color: colorSuccess, name: "green" },
5771
- { alias: "destructive", color: colorDestructive, name: "red" }
5802
+ { color: colorPrimary, name: 'primary' },
5803
+ { alias: 'warning', color: colorWarning, name: 'yellow' },
5804
+ { alias: 'success', color: colorSuccess, name: 'green' },
5805
+ { alias: 'destructive', color: colorDestructive, name: 'red' }
5772
5806
  ]);
5807
+ // 要设置的 CSS 变量映射
5773
5808
  const colorMappings = {
5774
- "--green-500": "--success",
5775
- "--primary-500": "--primary",
5776
- "--red-500": "--destructive",
5777
- "--yellow-500": "--warning"
5809
+ '--green-500': '--success',
5810
+ '--primary-500': '--primary',
5811
+ '--red-500': '--destructive',
5812
+ '--yellow-500': '--warning'
5778
5813
  };
5814
+ // 统一处理颜色变量的更新
5779
5815
  Object.entries(colorMappings).forEach(([sourceVar, targetVar]) => {
5780
5816
  const colorValue = colorVariables[sourceVar];
5781
5817
  if (colorValue) {
@@ -5785,7 +5821,8 @@ function updateMainColorVariables(config) {
5785
5821
  executeUpdateCSSVariables(colorVariables);
5786
5822
  }
5787
5823
 
5788
- const STORAGE_KEY = "config";
5824
+ const STORAGE_KEY = 'config';
5825
+ // 用户配置引导类
5789
5826
  class Guider {
5790
5827
  constructor() {
5791
5828
  this.isInitialized = false;
@@ -5797,7 +5834,7 @@ class Guider {
5797
5834
  // 初始化配置
5798
5835
  initConfig({ config: config$1, namespace }) {
5799
5836
  if (this.isInitialized) {
5800
- return;
5837
+ return
5801
5838
  }
5802
5839
  this.cache = new StorageManager({ prefix: namespace });
5803
5840
  const mergeDefaultConfig = defu({}, config$1, config);
@@ -5818,113 +5855,144 @@ class Guider {
5818
5855
  }
5819
5856
  // 加载配置
5820
5857
  loadConfig() {
5821
- return this.cache?.getItem(STORAGE_KEY);
5858
+ return this.cache?.getItem(STORAGE_KEY)
5822
5859
  }
5823
5860
  // 获取配置
5824
5861
  getConfig() {
5825
- return readonly(this.state);
5862
+ return readonly(this.state)
5826
5863
  }
5827
5864
  }
5828
5865
  const guider = new Guider();
5829
5866
  guider.getConfig();
5830
5867
 
5831
- const initRequestInstance = (extendConfig = {}, interceptorsRequestFn = () => {
5832
- }, interceptorsResponseFn = () => {
5833
- }) => {
5868
+ // 创建请求实例
5869
+ const initRequestInstance = (
5870
+ extendConfig = {},
5871
+ interceptorsRequestFn = () => {},
5872
+ interceptorsResponseFn = () => {}
5873
+ ) => {
5834
5874
  const axiosConfig = defu({}, extendConfig, {
5835
- baseURL: "/",
5836
- // 从环境变量获取基础URL
5837
- timeout: 1e4,
5838
- // 超时时间
5875
+ baseURL: '/', // 从环境变量获取基础URL
5876
+ timeout: 10000, // 超时时间
5839
5877
  headers: {
5840
- "Content-Type": "application/json;charset=utf-8"
5878
+ 'Content-Type': 'application/json;charset=utf-8'
5841
5879
  }
5842
5880
  });
5843
5881
  const instance = axios.create(axiosConfig);
5882
+ // 请求拦截器
5844
5883
  instance.interceptors.request.use(
5845
5884
  (config) => {
5846
5885
  interceptorsRequestFn(config);
5886
+ // 添加请求到pending列表,处理重复请求
5847
5887
  addPendingRequest(config);
5848
- return config;
5888
+ // 可以在这里添加其他请求处理逻辑,如请求加载动画等
5889
+ return config
5849
5890
  },
5850
5891
  (error) => {
5851
- return Promise.reject(error);
5892
+ // 请求错误处理
5893
+ return Promise.reject(error)
5852
5894
  }
5853
5895
  );
5896
+ // 响应拦截器
5854
5897
  instance.interceptors.response.use(
5855
5898
  (response) => {
5856
5899
  interceptorsResponseFn(response);
5900
+ // 从pending列表移除请求
5857
5901
  removePendingRequest(response.config);
5858
5902
  const data = response.data;
5859
5903
  console.log(data);
5904
+ // 根据实际后端接口规范处理响应
5860
5905
  if (data.code === 200) {
5861
5906
  return Promise.resolve({
5862
5907
  ...response,
5863
5908
  ...data,
5864
5909
  data: data.data
5865
- });
5910
+ })
5866
5911
  } else {
5867
- ElMessage.error(data.msg || "\u8BF7\u6C42\u5931\u8D25");
5868
- return Promise.reject(new Error(data.msg || "\u8BF7\u6C42\u5931\u8D25"));
5912
+ // 非成功状态,显示错误信息
5913
+ ElMessage.error(data.msg || '请求失败');
5914
+ return Promise.reject(new Error(data.msg || '请求失败'))
5869
5915
  }
5870
5916
  },
5871
5917
  (error) => {
5872
- console.log("\u8BF7\u6C42\u53D1\u751F\u9519\u8BEF>>>>>>>>>>>>>>>>>>\uFF1A", error);
5918
+ console.log('请求发生错误>>>>>>>>>>>>>>>>>>:', error);
5919
+ // 请求完成后从pending列表移除
5873
5920
  if (error.config) {
5874
5921
  removePendingRequest(error.config);
5875
5922
  }
5923
+ // 处理取消请求的错误
5876
5924
  if (axios.isCancel(error)) {
5877
- console.warn("\u8BF7\u6C42\u5DF2\u88AB\u53D6\u6D88:", error.message);
5878
- return Promise.reject(new Error("\u8BF7\u6C42\u5DF2\u88AB\u53D6\u6D88"));
5925
+ console.warn('请求已被取消:', error.message);
5926
+ return Promise.reject(new Error('请求已被取消'))
5879
5927
  }
5928
+ // 处理网络错误
5880
5929
  if (!window.navigator.onLine) {
5881
- ElMessage.error("\u7F51\u7EDC\u8FDE\u63A5\u5DF2\u65AD\u5F00\uFF0C\u8BF7\u68C0\u67E5\u7F51\u7EDC");
5882
- return Promise.reject(new Error("\u7F51\u7EDC\u8FDE\u63A5\u5DF2\u65AD\u5F00"));
5930
+ ElMessage.error('网络连接已断开,请检查网络');
5931
+ return Promise.reject(new Error('网络连接已断开'))
5883
5932
  }
5933
+ // 处理HTTP错误状态码
5884
5934
  const { response } = error;
5885
5935
  if (response) {
5886
5936
  switch (response.status) {
5887
5937
  case 401:
5888
- ElMessage.error("\u8EAB\u4EFD\u9A8C\u8BC1\u5931\u8D25\uFF0C\u8BF7\u91CD\u65B0\u767B\u5F55");
5889
- break;
5938
+ ElMessage.error('身份验证失败,请重新登录');
5939
+ // 可以在这里添加跳转到登录页的逻辑
5940
+ break
5890
5941
  case 403:
5891
- ElMessage.error("\u6CA1\u6709\u6743\u9650\u6267\u884C\u6B64\u64CD\u4F5C");
5892
- break;
5942
+ ElMessage.error('没有权限执行此操作');
5943
+ break
5893
5944
  case 404:
5894
- ElMessage.error("\u8BF7\u6C42\u7684\u8D44\u6E90\u4E0D\u5B58\u5728");
5895
- break;
5945
+ ElMessage.error('请求的资源不存在');
5946
+ break
5896
5947
  case 500:
5897
- ElMessage.error("\u670D\u52A1\u5668\u5185\u90E8\u9519\u8BEF");
5898
- break;
5948
+ ElMessage.error('服务器内部错误');
5949
+ break
5899
5950
  default:
5900
- ElMessage.error(`\u8BF7\u6C42\u9519\u8BEF: ${response.status}`);
5951
+ ElMessage.error(`请求错误: ${response.status}`);
5901
5952
  }
5902
5953
  } else {
5903
- ElMessage.error("\u8BF7\u6C42\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5");
5954
+ ElMessage.error('请求失败,请稍后重试');
5904
5955
  }
5905
- return Promise.reject(error);
5956
+ return Promise.reject(error)
5906
5957
  }
5907
5958
  );
5908
- return instance;
5959
+ return instance
5909
5960
  };
5910
- const pendingRequests = /* @__PURE__ */ new Map();
5961
+ // 存储当前正在进行的请求
5962
+ const pendingRequests = new Map();
5963
+ /**
5964
+ * 生成请求唯一标识
5965
+ * @param {Object} config 请求配置
5966
+ * @returns {String} 唯一标识
5967
+ */
5911
5968
  const generateRequestKey = (config) => {
5912
5969
  const { method, url, params, data } = config;
5913
- const paramsStr = params ? JSON.stringify(params) : "";
5914
- const dataStr = data ? JSON.stringify(data) : "";
5915
- return `${method}-${url}-${paramsStr}-${dataStr}`;
5970
+ // 序列化参数,确保相同参数生成相同key
5971
+ const paramsStr = params ? JSON.stringify(params) : '';
5972
+ const dataStr = data ? JSON.stringify(data) : '';
5973
+ return `${method}-${url}-${paramsStr}-${dataStr}`
5916
5974
  };
5975
+ /**
5976
+ * 添加请求到pending列表
5977
+ * @param {Object} config 请求配置
5978
+ */
5917
5979
  const addPendingRequest = (config) => {
5918
5980
  const requestKey = generateRequestKey(config);
5981
+ // 如果存在相同请求,则取消之前的请求
5919
5982
  if (pendingRequests.has(requestKey)) {
5920
5983
  const cancelToken = pendingRequests.get(requestKey);
5921
- cancelToken.cancel(`\u91CD\u590D\u8BF7\u6C42\u88AB\u53D6\u6D88: ${config.url}`);
5984
+ cancelToken.cancel(`重复请求被取消: ${config.url}`);
5922
5985
  pendingRequests.delete(requestKey);
5923
5986
  }
5987
+ // 创建新的取消令牌
5924
5988
  const source = axios.CancelToken.source();
5925
5989
  config.cancelToken = source.token;
5926
5990
  pendingRequests.set(requestKey, source);
5927
5991
  };
5992
+ /**
5993
+ * 从pending列表移除请求
5994
+ * @param {Object} config 请求配置
5995
+ */
5928
5996
  const removePendingRequest = (config) => {
5929
5997
  const requestKey = generateRequestKey(config);
5930
5998
  if (pendingRequests.has(requestKey)) {
@@ -5948,7 +6016,7 @@ const Render = defineComponent({
5948
6016
  }
5949
6017
  });
5950
6018
 
5951
- var _sfc_main$6 = /* @__PURE__ */ defineComponent({
6019
+ var _sfc_main$a = /* @__PURE__ */ defineComponent({
5952
6020
  ...{
5953
6021
  name: "MlSearchTable",
5954
6022
  inheritAttrs: false
@@ -6035,7 +6103,7 @@ var _sfc_main$6 = /* @__PURE__ */ defineComponent({
6035
6103
  class: normalizeClass(unref(bem)("search-table"))
6036
6104
  },
6037
6105
  [
6038
- createVNode(_sfc_main$7, mergeProps({
6106
+ createVNode(_sfc_main$b, mergeProps({
6039
6107
  onSubmit: submit,
6040
6108
  onReset: reset,
6041
6109
  modelValue: searchModel.value,
@@ -6133,11 +6201,11 @@ var _sfc_main$6 = /* @__PURE__ */ defineComponent({
6133
6201
  }
6134
6202
  });
6135
6203
 
6136
- const MlSearchTable = withInstall(_sfc_main$6);
6204
+ const MlSearchTable = withInstall(_sfc_main$a);
6137
6205
 
6138
- const MlSearch = withInstall(_sfc_main$7);
6206
+ const MlSearch = withInstall(_sfc_main$b);
6139
6207
 
6140
- var _sfc_main$5 = /* @__PURE__ */ defineComponent({
6208
+ var _sfc_main$9 = /* @__PURE__ */ defineComponent({
6141
6209
  ...{
6142
6210
  name: "RenderTooltip"
6143
6211
  },
@@ -6157,7 +6225,7 @@ var _sfc_main$5 = /* @__PURE__ */ defineComponent({
6157
6225
  }
6158
6226
  });
6159
6227
 
6160
- var _sfc_main$4 = /* @__PURE__ */ defineComponent({
6228
+ var _sfc_main$8 = /* @__PURE__ */ defineComponent({
6161
6229
  ...{
6162
6230
  name: "RenderLabel"
6163
6231
  },
@@ -6179,6 +6247,24 @@ var _sfc_main$4 = /* @__PURE__ */ defineComponent({
6179
6247
 
6180
6248
  /*! Element Plus Icons Vue v2.3.1 */
6181
6249
 
6250
+ var search_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
6251
+ name: "Search",
6252
+ __name: "search",
6253
+ setup(__props) {
6254
+ return (_ctx, _cache) => (openBlock(), createElementBlock("svg", {
6255
+ xmlns: "http://www.w3.org/2000/svg",
6256
+ viewBox: "0 0 1024 1024"
6257
+ }, [
6258
+ createElementVNode("path", {
6259
+ fill: "currentColor",
6260
+ d: "m795.904 750.72 124.992 124.928a32 32 0 0 1-45.248 45.248L750.656 795.904a416 416 0 1 1 45.248-45.248zM480 832a352 352 0 1 0 0-704 352 352 0 0 0 0 704"
6261
+ })
6262
+ ]));
6263
+ }
6264
+ });
6265
+
6266
+ // src/components/search.vue
6267
+ var search_default = search_vue_vue_type_script_setup_true_lang_default;
6182
6268
  var warning_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
6183
6269
  name: "Warning",
6184
6270
  __name: "warning",
@@ -6198,8 +6284,8 @@ var warning_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ define
6198
6284
  // src/components/warning.vue
6199
6285
  var warning_default = warning_vue_vue_type_script_setup_true_lang_default;
6200
6286
 
6201
- const _hoisted_1$1 = { key: 0 };
6202
- const _hoisted_2 = { key: 0 };
6287
+ const _hoisted_1$2 = { key: 0 };
6288
+ const _hoisted_2$1 = { key: 0 };
6203
6289
  const _hoisted_3 = { key: 1 };
6204
6290
  const _hoisted_4 = { key: 0 };
6205
6291
  const _hoisted_5 = { key: 0 };
@@ -6207,7 +6293,7 @@ const _hoisted_6 = { key: 1 };
6207
6293
  const _hoisted_7 = { key: 0 };
6208
6294
  const _hoisted_8 = { key: 1 };
6209
6295
  const _hoisted_9 = { key: 0 };
6210
- var _sfc_main$3 = /* @__PURE__ */ defineComponent({
6296
+ var _sfc_main$7 = /* @__PURE__ */ defineComponent({
6211
6297
  ...{
6212
6298
  name: "MlDetail"
6213
6299
  },
@@ -6241,7 +6327,7 @@ var _sfc_main$3 = /* @__PURE__ */ defineComponent({
6241
6327
  span: item.span || 1
6242
6328
  }, { ref_for: true }, { ...item.bind, ..._ctx.$attrs }), {
6243
6329
  label: withCtx(() => [
6244
- item.labelRender ? (openBlock(), createBlock(_sfc_main$4, {
6330
+ item.labelRender ? (openBlock(), createBlock(_sfc_main$8, {
6245
6331
  key: 0,
6246
6332
  render: item.labelRender,
6247
6333
  item
@@ -6257,7 +6343,7 @@ var _sfc_main$3 = /* @__PURE__ */ defineComponent({
6257
6343
  1
6258
6344
  /* TEXT */
6259
6345
  ),
6260
- __props.isColon ? (openBlock(), createElementBlock("span", _hoisted_1$1, "\uFF1A")) : createCommentVNode("v-if", true)
6346
+ __props.isColon ? (openBlock(), createElementBlock("span", _hoisted_1$2, "\uFF1A")) : createCommentVNode("v-if", true)
6261
6347
  ],
6262
6348
  4
6263
6349
  /* STYLE */
@@ -6281,7 +6367,7 @@ var _sfc_main$3 = /* @__PURE__ */ defineComponent({
6281
6367
  createElementVNode("span", null, [
6282
6368
  item.filters && item.filters.list ? (openBlock(), createElementBlock(
6283
6369
  "span",
6284
- _hoisted_2,
6370
+ _hoisted_2$1,
6285
6371
  toDisplayString(constantEscape(
6286
6372
  item.fieldName ? __props.dataList[item.fieldName] : void 0,
6287
6373
  __props.listTypeInfo[item.filters.list],
@@ -6329,7 +6415,7 @@ var _sfc_main$3 = /* @__PURE__ */ defineComponent({
6329
6415
  toDisplayString(item.tooltip),
6330
6416
  1
6331
6417
  /* TEXT */
6332
- )) : typeof item.tooltip === "function" ? (openBlock(), createBlock(_sfc_main$5, {
6418
+ )) : typeof item.tooltip === "function" ? (openBlock(), createBlock(_sfc_main$9, {
6333
6419
  key: 1,
6334
6420
  render: item.tooltip,
6335
6421
  item
@@ -6384,9 +6470,9 @@ var _sfc_main$3 = /* @__PURE__ */ defineComponent({
6384
6470
  }
6385
6471
  });
6386
6472
 
6387
- const MlDetail = withInstall(_sfc_main$3);
6473
+ const MlDetail = withInstall(_sfc_main$7);
6388
6474
 
6389
- var _sfc_main$2 = /* @__PURE__ */ defineComponent({
6475
+ var _sfc_main$6 = /* @__PURE__ */ defineComponent({
6390
6476
  ...{
6391
6477
  name: "MlButton"
6392
6478
  },
@@ -6448,10 +6534,10 @@ var _sfc_main$2 = /* @__PURE__ */ defineComponent({
6448
6534
  }
6449
6535
  });
6450
6536
 
6451
- const MlButton = withInstall(_sfc_main$2);
6537
+ const MlButton = withInstall(_sfc_main$6);
6452
6538
 
6453
- const _hoisted_1 = ["data-index"];
6454
- var _sfc_main$1 = /* @__PURE__ */ defineComponent({
6539
+ const _hoisted_1$1 = ["data-index"];
6540
+ var _sfc_main$5 = /* @__PURE__ */ defineComponent({
6455
6541
  ...{
6456
6542
  name: "MlVirtualList"
6457
6543
  },
@@ -6795,7 +6881,7 @@ var _sfc_main$1 = /* @__PURE__ */ defineComponent({
6795
6881
  item: item.data,
6796
6882
  index: item.index
6797
6883
  })
6798
- ], 14, _hoisted_1);
6884
+ ], 14, _hoisted_1$1);
6799
6885
  }),
6800
6886
  128
6801
6887
  /* KEYED_FRAGMENT */
@@ -6867,9 +6953,9 @@ var _sfc_main$1 = /* @__PURE__ */ defineComponent({
6867
6953
  }
6868
6954
  });
6869
6955
 
6870
- const MlVirtualList = withInstall(_sfc_main$1);
6956
+ const MlVirtualList = withInstall(_sfc_main$5);
6871
6957
 
6872
- var _sfc_main = /* @__PURE__ */ defineComponent({
6958
+ var _sfc_main$4 = /* @__PURE__ */ defineComponent({
6873
6959
  ...{
6874
6960
  name: "MlNumberRangeInput"
6875
6961
  },
@@ -7014,17 +7100,2383 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
7014
7100
  }
7015
7101
  });
7016
7102
 
7017
- const MlNumberRangeInput = withInstall(_sfc_main);
7103
+ const MlNumberRangeInput = withInstall(_sfc_main$4);
7104
+
7105
+ var _sfc_main$3 = /* @__PURE__ */ defineComponent({
7106
+ ...{
7107
+ name: "MlTreeSelect"
7108
+ },
7109
+ __name: "index",
7110
+ props: {
7111
+ treeData: { type: Array, required: true },
7112
+ treeProps: { type: Object, required: false, default: () => ({ label: "label", children: "children" }) },
7113
+ multiple: { type: Boolean, required: false, default: false },
7114
+ defaultExpandAll: { type: Boolean, required: false, default: true },
7115
+ defaultSelectedKeys: { type: Array, required: false, default: () => [] },
7116
+ nodeKey: { type: String, required: false, default: "id" },
7117
+ showSearch: { type: Boolean, required: false, default: true },
7118
+ expandOnClickNode: { type: Boolean, required: false },
7119
+ placeholder: { type: String, required: false, default: "\u8BF7\u8F93\u5165\u5173\u952E\u8BCD\u641C\u7D22" }
7120
+ },
7121
+ emits: ["confirm", "cancel", "input"],
7122
+ setup(__props, { expose: __expose, emit: __emit }) {
7123
+ const props = __props;
7124
+ const emit = __emit;
7125
+ const searchKeyword = ref("");
7126
+ const treeRef = ref();
7127
+ const selectedKeys = ref([]);
7128
+ const selectedData = ref(props.multiple ? [] : {});
7129
+ const initSelection = () => {
7130
+ selectedKeys.value = [...props.defaultSelectedKeys];
7131
+ nextTick(() => {
7132
+ if (treeRef.value) {
7133
+ if (props.multiple) {
7134
+ treeRef.value.setCheckedKeys(props.defaultSelectedKeys);
7135
+ } else {
7136
+ treeRef.value.setCurrentKey(props.defaultSelectedKeys[0]);
7137
+ }
7138
+ }
7139
+ });
7140
+ };
7141
+ watch(
7142
+ () => props.defaultSelectedKeys,
7143
+ () => {
7144
+ initSelection();
7145
+ },
7146
+ { immediate: true }
7147
+ );
7148
+ const filteredTreeData = computed(() => {
7149
+ if (!searchKeyword.value) return props.treeData;
7150
+ const filterNode = (nodes) => {
7151
+ return nodes.map((node) => {
7152
+ const children = filterNode(node[props.treeProps.children || "children"] || []);
7153
+ const isMatch = node[props.treeProps.label || "label"].includes(
7154
+ searchKeyword.value
7155
+ );
7156
+ if (isMatch || children.length > 0) {
7157
+ return { ...node, [props.treeProps.children || "children"]: children };
7158
+ }
7159
+ return null;
7160
+ }).filter(Boolean);
7161
+ };
7162
+ return filterNode(props.treeData);
7163
+ });
7164
+ const handleCheckChange = (data, checked) => {
7165
+ const nodeKeyField = props.nodeKey;
7166
+ if (checked) {
7167
+ selectedKeys.value.push(data[nodeKeyField]);
7168
+ if (Array.isArray(selectedData.value)) {
7169
+ selectedData.value.push(data);
7170
+ }
7171
+ } else {
7172
+ selectedKeys.value = selectedKeys.value.filter((key) => key !== data[nodeKeyField]);
7173
+ if (Array.isArray(selectedData.value)) {
7174
+ selectedData.value = selectedData.value.filter(
7175
+ (item) => item[nodeKeyField] !== data[nodeKeyField]
7176
+ );
7177
+ }
7178
+ }
7179
+ };
7180
+ const handleNodeClick = (data) => {
7181
+ if (!props.multiple) {
7182
+ const nodeKeyField = props.nodeKey;
7183
+ selectedKeys.value = [data[nodeKeyField]];
7184
+ selectedData.value = data;
7185
+ }
7186
+ };
7187
+ const reset = () => {
7188
+ searchKeyword.value = "";
7189
+ selectedKeys.value = [];
7190
+ selectedData.value = props.multiple ? [] : {};
7191
+ if (treeRef.value) {
7192
+ if (props.multiple) {
7193
+ treeRef.value.setCheckedKeys([]);
7194
+ } else {
7195
+ treeRef.value.setCurrentKey(void 0);
7196
+ }
7197
+ }
7198
+ };
7199
+ const getSelectedData = () => selectedData.value;
7200
+ const getSelectedKeys = () => selectedKeys.value;
7201
+ const handleConfirm = () => {
7202
+ if (selectedKeys.value.length === 0) {
7203
+ ElMessage.warning("\u8BF7\u9009\u62E9\u81F3\u5C11\u4E00\u4E2A\u8282\u70B9");
7204
+ return;
7205
+ }
7206
+ emit("confirm", selectedData.value);
7207
+ };
7208
+ const handleCancel = () => {
7209
+ emit("cancel");
7210
+ };
7211
+ __expose({
7212
+ reset,
7213
+ getSelectedData,
7214
+ getSelectedKeys,
7215
+ // el-tree 方法透传
7216
+ getCheckedNodes: () => treeRef.value?.getCheckedNodes() || [],
7217
+ getCheckedKeys: () => treeRef.value?.getCheckedKeys() || [],
7218
+ getHalfCheckedNodes: () => treeRef.value?.getHalfCheckedNodes() || [],
7219
+ getHalfCheckedKeys: () => treeRef.value?.getHalfCheckedKeys() || [],
7220
+ getCurrentKey: () => treeRef.value?.getCurrentKey() ?? void 0,
7221
+ getCurrentNode: () => treeRef.value?.getCurrentNode(),
7222
+ setCheckedKeys: (keys) => treeRef.value?.setCheckedKeys(keys),
7223
+ setCheckedNodes: (nodes) => treeRef.value?.setCheckedNodes(nodes),
7224
+ setCurrentKey: (key) => treeRef.value?.setCurrentKey(key),
7225
+ setCurrentNode: (node) => treeRef.value?.setCurrentNode(node),
7226
+ getNode: (key) => treeRef.value?.getNode(key),
7227
+ filter: (value) => treeRef.value?.filter(value),
7228
+ updateKeyChildren: (key, children) => treeRef.value?.updateKeyChildren(key, children),
7229
+ remove: (node) => treeRef.value?.remove(node),
7230
+ append: (data, parentNode) => treeRef.value?.append(data, parentNode),
7231
+ insertBefore: (data, refNode) => treeRef.value?.insertBefore(data, refNode),
7232
+ insertAfter: (data, refNode) => treeRef.value?.insertAfter(data, refNode),
7233
+ //
7234
+ input: (value) => emit("input", value)
7235
+ });
7236
+ return (_ctx, _cache) => {
7237
+ const _component_el_input = resolveComponent("el-input");
7238
+ const _component_el_button = resolveComponent("el-button");
7239
+ return openBlock(), createElementBlock(
7240
+ "div",
7241
+ {
7242
+ class: normalizeClass(unref(bem)("tree-select"))
7243
+ },
7244
+ [
7245
+ createCommentVNode(" \u641C\u7D22\u6846 "),
7246
+ __props.showSearch ? (openBlock(), createBlock(_component_el_input, {
7247
+ key: 0,
7248
+ modelValue: searchKeyword.value,
7249
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => searchKeyword.value = $event),
7250
+ placeholder: __props.placeholder,
7251
+ clearable: "",
7252
+ "prefix-icon": unref(search_default),
7253
+ class: normalizeClass(unref(bem)("tree-select", "search")),
7254
+ onInput: _cache[1] || (_cache[1] = (value) => emit("input", value))
7255
+ }, null, 8, ["modelValue", "placeholder", "prefix-icon", "class"])) : createCommentVNode("v-if", true),
7256
+ createCommentVNode(" \u6811\u5F62\u9009\u62E9 "),
7257
+ createElementVNode(
7258
+ "div",
7259
+ {
7260
+ class: normalizeClass(unref(bem)("tree-select", "tree"))
7261
+ },
7262
+ [
7263
+ createVNode(unref(ElTree), mergeProps({
7264
+ ref_key: "treeRef",
7265
+ ref: treeRef,
7266
+ data: filteredTreeData.value,
7267
+ props: __props.treeProps,
7268
+ "show-checkbox": __props.multiple,
7269
+ "default-expand-all": __props.defaultExpandAll,
7270
+ "expand-on-click-node": __props.expandOnClickNode,
7271
+ "node-key": __props.nodeKey,
7272
+ onCheckChange: handleCheckChange,
7273
+ onNodeClick: handleNodeClick
7274
+ }, _ctx.$attrs, toHandlers(_ctx.$attrs)), null, 16, ["data", "props", "show-checkbox", "default-expand-all", "expand-on-click-node", "node-key"])
7275
+ ],
7276
+ 2
7277
+ /* CLASS */
7278
+ ),
7279
+ createCommentVNode(" \u5E95\u90E8\u6309\u94AE\u63D2\u69FD "),
7280
+ createElementVNode(
7281
+ "div",
7282
+ {
7283
+ class: normalizeClass(unref(bem)("tree-select", "footer"))
7284
+ },
7285
+ [
7286
+ renderSlot(_ctx.$slots, "footer", {}, () => [
7287
+ createVNode(_component_el_button, { onClick: handleCancel }, {
7288
+ default: withCtx(() => [..._cache[2] || (_cache[2] = [
7289
+ createTextVNode(
7290
+ "\u53D6\u6D88",
7291
+ -1
7292
+ /* CACHED */
7293
+ )
7294
+ ])]),
7295
+ _: 1
7296
+ /* STABLE */
7297
+ }),
7298
+ createVNode(_component_el_button, {
7299
+ type: "primary",
7300
+ onClick: handleConfirm
7301
+ }, {
7302
+ default: withCtx(() => [..._cache[3] || (_cache[3] = [
7303
+ createTextVNode(
7304
+ "\u786E\u5B9A",
7305
+ -1
7306
+ /* CACHED */
7307
+ )
7308
+ ])]),
7309
+ _: 1
7310
+ /* STABLE */
7311
+ })
7312
+ ])
7313
+ ],
7314
+ 2
7315
+ /* CLASS */
7316
+ )
7317
+ ],
7318
+ 2
7319
+ /* CLASS */
7320
+ );
7321
+ };
7322
+ }
7323
+ });
7324
+
7325
+ const MlTreeSelect = withInstall(_sfc_main$3);
7326
+
7327
+ const dialogPropKeys = [
7328
+ "title",
7329
+ "width",
7330
+ "fullscreen",
7331
+ "top",
7332
+ "modal",
7333
+ "modalClass",
7334
+ "appendToBody",
7335
+ "appendTo",
7336
+ "lockScroll",
7337
+ "closeOnClickModal",
7338
+ "closeOnPressEscape",
7339
+ "showClose",
7340
+ "draggable",
7341
+ "overflow",
7342
+ "center",
7343
+ "alignCenter",
7344
+ "destroyOnClose",
7345
+ "closeIcon",
7346
+ "zIndex",
7347
+ "headerAriaLevel"
7348
+ ];
7349
+
7350
+ var _sfc_main$2 = /* @__PURE__ */ defineComponent({
7351
+ ...{
7352
+ name: "MlTreeSelectDialog"
7353
+ },
7354
+ __name: "index",
7355
+ props: /* @__PURE__ */ mergeModels({
7356
+ treeData: { type: Array, required: true },
7357
+ treeProps: { type: Object, required: false, default: () => ({ label: "label", children: "children" }) },
7358
+ multiple: { type: Boolean, required: false, default: false },
7359
+ defaultExpandAll: { type: Boolean, required: false, default: true },
7360
+ defaultSelectedKeys: { type: Array, required: false, default: () => [] },
7361
+ nodeKey: { type: String, required: false, default: "id" },
7362
+ showSearch: { type: Boolean, required: false, default: true },
7363
+ expandOnClickNode: { type: Boolean, required: false },
7364
+ placeholder: { type: String, required: false },
7365
+ title: { type: String, required: false, default: "\u6811\u5F62\u9009\u62E9" },
7366
+ width: { type: String, required: false, default: "500px" },
7367
+ appendToBody: { type: Boolean, required: false },
7368
+ appendTo: { type: null, required: false },
7369
+ beforeClose: { type: Function, required: false },
7370
+ destroyOnClose: { type: Boolean, required: false },
7371
+ closeOnClickModal: { type: Boolean, required: false },
7372
+ closeOnPressEscape: { type: Boolean, required: false },
7373
+ lockScroll: { type: Boolean, required: false },
7374
+ modal: { type: Boolean, required: false },
7375
+ openDelay: { type: Number, required: false },
7376
+ closeDelay: { type: Number, required: false },
7377
+ top: { type: String, required: false },
7378
+ modelValue: { type: Boolean, required: false },
7379
+ modalClass: { type: String, required: false },
7380
+ headerClass: { type: String, required: false },
7381
+ bodyClass: { type: String, required: false },
7382
+ footerClass: { type: String, required: false },
7383
+ zIndex: { type: Number, required: false },
7384
+ trapFocus: { type: Boolean, required: false },
7385
+ headerAriaLevel: { type: String, required: false },
7386
+ center: { type: Boolean, required: false },
7387
+ alignCenter: { type: Boolean, required: false },
7388
+ closeIcon: { type: null, required: false },
7389
+ draggable: { type: Boolean, required: false },
7390
+ overflow: { type: Boolean, required: false },
7391
+ fullscreen: { type: Boolean, required: false },
7392
+ showClose: { type: Boolean, required: false },
7393
+ ariaLevel: { type: String, required: false }
7394
+ }, {
7395
+ "modelValue": { type: Boolean, ...{ default: false } },
7396
+ "modelModifiers": {}
7397
+ }),
7398
+ emits: /* @__PURE__ */ mergeModels(["confirm", "close", "input"], ["update:modelValue"]),
7399
+ setup(__props, { expose: __expose, emit: __emit }) {
7400
+ const visible = useModel(__props, "modelValue");
7401
+ const props = __props;
7402
+ const emit = __emit;
7403
+ const attrs = useAttrs();
7404
+ const dialogAttrs = computed(() => {
7405
+ const result = {
7406
+ title: props.title,
7407
+ width: props.width
7408
+ };
7409
+ Object.keys(attrs).forEach((key) => {
7410
+ if (dialogPropKeys.includes(key)) {
7411
+ result[key] = attrs[key];
7412
+ }
7413
+ });
7414
+ return result;
7415
+ });
7416
+ const treeSelectAttrs = computed(() => {
7417
+ const result = {
7418
+ treeData: props.treeData,
7419
+ treeProps: props.treeProps,
7420
+ multiple: props.multiple,
7421
+ defaultExpandAll: props.defaultExpandAll,
7422
+ defaultSelectedKeys: props.defaultSelectedKeys,
7423
+ nodeKey: props.nodeKey,
7424
+ showSearch: props.showSearch
7425
+ };
7426
+ Object.keys(attrs).forEach((key) => {
7427
+ if (!dialogPropKeys.includes(key) && !key.startsWith("on")) {
7428
+ result[key] = attrs[key];
7429
+ }
7430
+ });
7431
+ return result;
7432
+ });
7433
+ const treeSelectRef = ref();
7434
+ watch(visible, (val) => {
7435
+ if (!val && treeSelectRef.value) {
7436
+ treeSelectRef.value.reset();
7437
+ }
7438
+ });
7439
+ const handleBeforeClose = () => {
7440
+ visible.value = false;
7441
+ };
7442
+ const handleConfirm = (selectedData) => {
7443
+ emit("confirm", selectedData);
7444
+ visible.value = false;
7445
+ };
7446
+ const handleCancel = () => {
7447
+ visible.value = false;
7448
+ };
7449
+ __expose({
7450
+ input: (value) => emit("input", value)
7451
+ });
7452
+ return (_ctx, _cache) => {
7453
+ const _component_el_dialog = resolveComponent("el-dialog");
7454
+ return openBlock(), createBlock(_component_el_dialog, mergeProps({
7455
+ modelValue: visible.value,
7456
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => visible.value = $event)
7457
+ }, dialogAttrs.value, {
7458
+ class: unref(bem)("tree-select-dialog"),
7459
+ "before-close": handleBeforeClose,
7460
+ onClose: _cache[1] || (_cache[1] = ($event) => emit("close"))
7461
+ }), {
7462
+ default: withCtx(() => [
7463
+ createVNode(unref(MlTreeSelect), mergeProps({
7464
+ ref_key: "treeSelectRef",
7465
+ ref: treeSelectRef,
7466
+ "tree-data": props.treeData
7467
+ }, treeSelectAttrs.value, toHandlers(_ctx.$attrs), {
7468
+ onConfirm: handleConfirm,
7469
+ onCancel: handleCancel
7470
+ }), null, 16, ["tree-data"])
7471
+ ]),
7472
+ _: 1
7473
+ /* STABLE */
7474
+ }, 16, ["modelValue", "class"]);
7475
+ };
7476
+ }
7477
+ });
7478
+
7479
+ const MlTreeSelectDialog = withInstall(_sfc_main$2);
7480
+
7481
+ const drawerPropKeys = [
7482
+ "title",
7483
+ "size",
7484
+ "direction",
7485
+ "appendToBody",
7486
+ "appendTo",
7487
+ "modal",
7488
+ "modalClass",
7489
+ "lockScroll",
7490
+ "closeOnClickModal",
7491
+ "closeOnPressEscape",
7492
+ "showClose",
7493
+ "withHeader",
7494
+ "openDelay",
7495
+ "closeDelay",
7496
+ "destroyOnClose",
7497
+ "zIndex"
7498
+ ];
7499
+
7500
+ var _sfc_main$1 = /* @__PURE__ */ defineComponent({
7501
+ ...{
7502
+ name: "MlTreeSelectDrawer"
7503
+ },
7504
+ __name: "index",
7505
+ props: /* @__PURE__ */ mergeModels({
7506
+ treeData: { type: Array, required: true },
7507
+ treeProps: { type: Object, required: false, default: () => ({ label: "label", children: "children" }) },
7508
+ multiple: { type: Boolean, required: false, default: false },
7509
+ defaultExpandAll: { type: Boolean, required: false, default: true },
7510
+ defaultSelectedKeys: { type: Array, required: false, default: () => [] },
7511
+ nodeKey: { type: String, required: false, default: "id" },
7512
+ showSearch: { type: Boolean, required: false, default: true },
7513
+ expandOnClickNode: { type: Boolean, required: false },
7514
+ placeholder: { type: String, required: false },
7515
+ title: { type: String, required: false, default: "\u6811\u5F62\u9009\u62E9" },
7516
+ size: { type: [String, Number], required: false, default: "400px" },
7517
+ direction: { type: String, required: false, default: "rtl" },
7518
+ withHeader: { type: Boolean, required: false },
7519
+ modalFade: { type: Boolean, required: false },
7520
+ headerAriaLevel: { type: String, required: false },
7521
+ appendToBody: { type: Boolean, required: false },
7522
+ appendTo: { type: null, required: false },
7523
+ beforeClose: { type: Function, required: false },
7524
+ destroyOnClose: { type: Boolean, required: false },
7525
+ closeOnClickModal: { type: Boolean, required: false },
7526
+ closeOnPressEscape: { type: Boolean, required: false },
7527
+ lockScroll: { type: Boolean, required: false },
7528
+ modal: { type: Boolean, required: false },
7529
+ openDelay: { type: Number, required: false },
7530
+ closeDelay: { type: Number, required: false },
7531
+ top: { type: String, required: false },
7532
+ modelValue: { type: Boolean, required: false },
7533
+ modalClass: { type: String, required: false },
7534
+ headerClass: { type: String, required: false },
7535
+ bodyClass: { type: String, required: false },
7536
+ footerClass: { type: String, required: false },
7537
+ width: { type: null, required: false },
7538
+ zIndex: { type: Number, required: false },
7539
+ trapFocus: { type: Boolean, required: false },
7540
+ center: { type: Boolean, required: false },
7541
+ alignCenter: { type: Boolean, required: false },
7542
+ closeIcon: { type: null, required: false },
7543
+ draggable: { type: Boolean, required: false },
7544
+ overflow: { type: Boolean, required: false },
7545
+ fullscreen: { type: Boolean, required: false },
7546
+ showClose: { type: Boolean, required: false },
7547
+ ariaLevel: { type: String, required: false }
7548
+ }, {
7549
+ "modelValue": { type: Boolean, ...{ default: false } },
7550
+ "modelModifiers": {}
7551
+ }),
7552
+ emits: /* @__PURE__ */ mergeModels(["confirm", "close", "input"], ["update:modelValue"]),
7553
+ setup(__props, { expose: __expose, emit: __emit }) {
7554
+ const visible = useModel(__props, "modelValue");
7555
+ const props = __props;
7556
+ const emit = __emit;
7557
+ const attrs = useAttrs();
7558
+ const drawerAttrs = computed(() => {
7559
+ const result = {
7560
+ title: props.title,
7561
+ size: props.size,
7562
+ direction: props.direction
7563
+ };
7564
+ Object.keys(attrs).forEach((key) => {
7565
+ if (drawerPropKeys.includes(key)) {
7566
+ result[key] = attrs[key];
7567
+ }
7568
+ });
7569
+ return result;
7570
+ });
7571
+ const treeSelectAttrs = computed(() => {
7572
+ const result = {
7573
+ treeProps: props.treeProps,
7574
+ multiple: props.multiple,
7575
+ defaultExpandAll: props.defaultExpandAll,
7576
+ defaultSelectedKeys: props.defaultSelectedKeys,
7577
+ nodeKey: props.nodeKey,
7578
+ showSearch: props.showSearch
7579
+ };
7580
+ Object.keys(attrs).forEach((key) => {
7581
+ if (!drawerPropKeys.includes(key) && !key.startsWith("on")) {
7582
+ result[key] = attrs[key];
7583
+ }
7584
+ });
7585
+ return result;
7586
+ });
7587
+ const treeSelectRef = ref();
7588
+ watch(visible, (val) => {
7589
+ if (!val && treeSelectRef.value) {
7590
+ treeSelectRef.value.reset();
7591
+ }
7592
+ });
7593
+ const handleBeforeClose = (done) => {
7594
+ visible.value = false;
7595
+ done();
7596
+ };
7597
+ const handleConfirm = (selectedData) => {
7598
+ emit("confirm", selectedData);
7599
+ visible.value = false;
7600
+ };
7601
+ const handleCancel = () => {
7602
+ visible.value = false;
7603
+ };
7604
+ __expose({
7605
+ input: (value) => emit("input", value)
7606
+ });
7607
+ return (_ctx, _cache) => {
7608
+ const _component_el_drawer = resolveComponent("el-drawer");
7609
+ return openBlock(), createBlock(_component_el_drawer, mergeProps({
7610
+ modelValue: visible.value,
7611
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => visible.value = $event)
7612
+ }, drawerAttrs.value, {
7613
+ class: unref(bem)("tree-select-drawer"),
7614
+ "before-close": handleBeforeClose,
7615
+ onClose: _cache[1] || (_cache[1] = ($event) => emit("close"))
7616
+ }), {
7617
+ default: withCtx(() => [
7618
+ createVNode(_sfc_main$3, mergeProps({
7619
+ ref_key: "treeSelectRef",
7620
+ ref: treeSelectRef,
7621
+ "tree-data": __props.treeData
7622
+ }, treeSelectAttrs.value, toHandlers(_ctx.$attrs), {
7623
+ onConfirm: handleConfirm,
7624
+ onCancel: handleCancel
7625
+ }), null, 16, ["tree-data"])
7626
+ ]),
7627
+ _: 1
7628
+ /* STABLE */
7629
+ }, 16, ["modelValue", "class"]);
7630
+ };
7631
+ }
7632
+ });
7633
+
7634
+ const MlTreeSelectDrawer = withInstall(_sfc_main$1);
7635
+
7636
+ const Y = {};
7637
+ Y.getData = (t) => new Promise((e, i) => {
7638
+ let s = {};
7639
+ L(t).then((r) => {
7640
+ s.arrayBuffer = r;
7641
+ try {
7642
+ s.orientation = N(r);
7643
+ } catch {
7644
+ s.orientation = -1;
7645
+ }
7646
+ e(s);
7647
+ }).catch((r) => {
7648
+ i(r);
7649
+ });
7650
+ });
7651
+ function L(t) {
7652
+ let e = null;
7653
+ return new Promise((i, s) => {
7654
+ if (t.src)
7655
+ if (/^data\:/i.test(t.src))
7656
+ e = k(t.src), i(e);
7657
+ else if (/^blob\:/i.test(t.src)) {
7658
+ var r = new FileReader();
7659
+ r.onload = function(h) {
7660
+ e = h.target.result, i(e);
7661
+ }, E(t.src, function(h) {
7662
+ r.readAsArrayBuffer(h);
7663
+ });
7664
+ } else {
7665
+ var o = new XMLHttpRequest();
7666
+ o.onload = function() {
7667
+ if (this.status == 200 || this.status === 0)
7668
+ e = o.response, i(e);
7669
+ else
7670
+ throw "Could not load image";
7671
+ o = null;
7672
+ }, o.open("GET", t.src, true), o.responseType = "arraybuffer", o.send(null);
7673
+ }
7674
+ else
7675
+ s("img error");
7676
+ });
7677
+ }
7678
+ function E(t, e) {
7679
+ var i = new XMLHttpRequest();
7680
+ i.open("GET", t, true), i.responseType = "blob", i.onload = function(s) {
7681
+ (this.status == 200 || this.status === 0) && e(this.response);
7682
+ }, i.send();
7683
+ }
7684
+ function k(t, e) {
7685
+ e = e || t.match(/^data\:([^\;]+)\;base64,/mi)[1] || "", t = t.replace(/^data\:([^\;]+)\;base64,/gmi, "");
7686
+ for (var i = atob(t), s = i.length % 2 == 0 ? i.length : i.length + 1, r = new ArrayBuffer(s), o = new Uint16Array(r), h = 0; h < s; h++)
7687
+ o[h] = i.charCodeAt(h);
7688
+ return r;
7689
+ }
7690
+ function T(t, e, i) {
7691
+ var s = "", r;
7692
+ for (r = e, i += e; r < i; r++)
7693
+ s += String.fromCharCode(t.getUint8(r));
7694
+ return s;
7695
+ }
7696
+ function N(t) {
7697
+ var e = new DataView(t), i = e.byteLength, s, r, o, h, a, n, c, l, f, p;
7698
+ if (e.getUint8(0) === 255 && e.getUint8(1) === 216)
7699
+ for (f = 2; f < i; ) {
7700
+ if (e.getUint8(f) === 255 && e.getUint8(f + 1) === 225) {
7701
+ c = f;
7702
+ break;
7703
+ }
7704
+ f++;
7705
+ }
7706
+ if (c && (r = c + 4, o = c + 10, T(e, r, 4) === "Exif" && (n = e.getUint16(o), a = n === 18761, (a || n === 19789) && e.getUint16(o + 2, a) === 42 && (h = e.getUint32(o + 4, a), h >= 8 && (l = o + h)))), l) {
7707
+ for (i = e.getUint16(l, a), p = 0; p < i; p++)
7708
+ if (f = l + p * 12 + 2, e.getUint16(f, a) === 274) {
7709
+ f += 8, s = e.getUint16(f, a);
7710
+ break;
7711
+ }
7712
+ }
7713
+ return s;
7714
+ }
7715
+ const $ = (t, e) => {
7716
+ const i = t.__vccOpts || t;
7717
+ for (const [s, r] of e)
7718
+ i[s] = r;
7719
+ return i;
7720
+ }, z = defineComponent({
7721
+ data: function() {
7722
+ return {
7723
+ // 容器高宽
7724
+ w: 0,
7725
+ h: 0,
7726
+ // 图片缩放比例
7727
+ scale: 1,
7728
+ // 图片偏移x轴
7729
+ x: 0,
7730
+ // 图片偏移y轴
7731
+ y: 0,
7732
+ // 图片加载
7733
+ loading: true,
7734
+ // 图片真实宽度
7735
+ trueWidth: 0,
7736
+ // 图片真实高度
7737
+ trueHeight: 0,
7738
+ move: true,
7739
+ // 移动的x
7740
+ moveX: 0,
7741
+ // 移动的y
7742
+ moveY: 0,
7743
+ // 开启截图
7744
+ crop: false,
7745
+ // 正在截图
7746
+ cropping: false,
7747
+ // 裁剪框大小
7748
+ cropW: 0,
7749
+ cropH: 0,
7750
+ cropOldW: 0,
7751
+ cropOldH: 0,
7752
+ // 判断是否能够改变
7753
+ canChangeX: false,
7754
+ canChangeY: false,
7755
+ // 改变的基准点
7756
+ changeCropTypeX: 1,
7757
+ changeCropTypeY: 1,
7758
+ // 裁剪框的坐标轴
7759
+ cropX: 0,
7760
+ cropY: 0,
7761
+ cropChangeX: 0,
7762
+ cropChangeY: 0,
7763
+ cropOffsertX: 0,
7764
+ cropOffsertY: 0,
7765
+ // 支持的滚动事件
7766
+ support: "",
7767
+ // 移动端手指缩放
7768
+ touches: [],
7769
+ touchNow: false,
7770
+ // 图片旋转
7771
+ rotate: 0,
7772
+ isIos: false,
7773
+ orientation: 0,
7774
+ imgs: "",
7775
+ // 图片缩放系数
7776
+ coe: 0.2,
7777
+ // 是否正在多次缩放
7778
+ scaling: false,
7779
+ scalingSet: "",
7780
+ coeStatus: "",
7781
+ // 控制emit触发频率
7782
+ isCanShow: true,
7783
+ // 图片是否等于截图大小
7784
+ imgIsQqualCrop: false
7785
+ };
7786
+ },
7787
+ props: {
7788
+ img: {
7789
+ type: [String, Blob, null, File],
7790
+ default: ""
7791
+ },
7792
+ // 输出图片压缩比
7793
+ outputSize: {
7794
+ type: Number,
7795
+ default: 1
7796
+ },
7797
+ outputType: {
7798
+ type: String,
7799
+ default: "jpeg"
7800
+ },
7801
+ info: {
7802
+ type: Boolean,
7803
+ default: true
7804
+ },
7805
+ // 是否开启滚轮放大缩小
7806
+ canScale: {
7807
+ type: Boolean,
7808
+ default: true
7809
+ },
7810
+ // 是否自成截图框
7811
+ autoCrop: {
7812
+ type: Boolean,
7813
+ default: false
7814
+ },
7815
+ autoCropWidth: {
7816
+ type: [Number, String],
7817
+ default: 0
7818
+ },
7819
+ autoCropHeight: {
7820
+ type: [Number, String],
7821
+ default: 0
7822
+ },
7823
+ // 是否开启固定宽高比
7824
+ fixed: {
7825
+ type: Boolean,
7826
+ default: false
7827
+ },
7828
+ // 宽高比 w/h
7829
+ fixedNumber: {
7830
+ type: Array,
7831
+ default: () => [1, 1]
7832
+ },
7833
+ // 固定大小 禁止改变截图框大小
7834
+ fixedBox: {
7835
+ type: Boolean,
7836
+ default: false
7837
+ },
7838
+ // 输出截图是否缩放
7839
+ full: {
7840
+ type: Boolean,
7841
+ default: false
7842
+ },
7843
+ // 是否可以拖动图片
7844
+ canMove: {
7845
+ type: Boolean,
7846
+ default: true
7847
+ },
7848
+ // 是否可以拖动截图框
7849
+ canMoveBox: {
7850
+ type: Boolean,
7851
+ default: true
7852
+ },
7853
+ // 上传图片按照原始比例显示
7854
+ original: {
7855
+ type: Boolean,
7856
+ default: false
7857
+ },
7858
+ // 截图框能否超过图片
7859
+ centerBox: {
7860
+ type: Boolean,
7861
+ default: false
7862
+ },
7863
+ // 是否根据dpr输出高清图片
7864
+ high: {
7865
+ type: Boolean,
7866
+ default: true
7867
+ },
7868
+ // 截图框展示宽高类型
7869
+ infoTrue: {
7870
+ type: Boolean,
7871
+ default: false
7872
+ },
7873
+ // 可以压缩图片宽高 默认不超过200
7874
+ maxImgSize: {
7875
+ type: [Number, String],
7876
+ default: 2e3
7877
+ },
7878
+ // 倍数 可渲染当前截图框的n倍 0 - 1000;
7879
+ enlarge: {
7880
+ type: [Number, String],
7881
+ default: 1
7882
+ },
7883
+ // 自动预览的固定宽度
7884
+ preW: {
7885
+ type: [Number, String],
7886
+ default: 0
7887
+ },
7888
+ /*
7889
+ 图片布局方式 mode 实现和css背景一样的效果
7890
+ contain 居中布局 默认不会缩放 保证图片在容器里面 mode: 'contain'
7891
+ cover 拉伸布局 填充整个容器 mode: 'cover'
7892
+ 如果仅有一个数值被给定,这个数值将作为宽度值大小,高度值将被设定为auto。 mode: '50px'
7893
+ 如果有两个数值被给定,第一个将作为宽度值大小,第二个作为高度值大小。 mode: '50px 60px'
7894
+ */
7895
+ mode: {
7896
+ type: String,
7897
+ default: "contain"
7898
+ },
7899
+ //限制最小区域,可传1以上的数字和字符串,限制长宽都是这么大
7900
+ // 也可以传数组[90,90]
7901
+ limitMinSize: {
7902
+ type: [Number, Array, String],
7903
+ default: () => 10,
7904
+ validator: function(t) {
7905
+ return Array.isArray(t) ? Number(t[0]) >= 0 && Number(t[1]) >= 0 : Number(t) >= 0;
7906
+ }
7907
+ },
7908
+ // 导出时,填充背景颜色
7909
+ fillColor: {
7910
+ type: String,
7911
+ default: ""
7912
+ }
7913
+ },
7914
+ computed: {
7915
+ cropInfo() {
7916
+ let t = {};
7917
+ if (t.top = this.cropOffsertY > 21 ? "-21px" : "0px", t.width = this.cropW > 0 ? this.cropW : 0, t.height = this.cropH > 0 ? this.cropH : 0, this.infoTrue) {
7918
+ let e = 1;
7919
+ this.high && !this.full && (e = window.devicePixelRatio), this.enlarge !== 1 & !this.full && (e = Math.abs(Number(this.enlarge))), t.width = t.width * e, t.height = t.height * e, this.full && (t.width = t.width / this.scale, t.height = t.height / this.scale);
7920
+ }
7921
+ return t.width = t.width.toFixed(0), t.height = t.height.toFixed(0), t;
7922
+ },
7923
+ isIE() {
7924
+ return !!window.ActiveXObject || "ActiveXObject" in window;
7925
+ },
7926
+ passive() {
7927
+ return this.isIE ? null : {
7928
+ passive: false
7929
+ };
7930
+ },
7931
+ // 是否处于左右旋转
7932
+ isRotateRightOrLeft() {
7933
+ return [1, -1, 3, -3].includes(this.rotate);
7934
+ }
7935
+ },
7936
+ watch: {
7937
+ // 如果图片改变, 重新布局
7938
+ img() {
7939
+ this.checkedImg();
7940
+ },
7941
+ imgs(t) {
7942
+ t !== "" && this.reload();
7943
+ },
7944
+ cropW() {
7945
+ this.showPreview();
7946
+ },
7947
+ cropH() {
7948
+ this.showPreview();
7949
+ },
7950
+ cropOffsertX() {
7951
+ this.showPreview();
7952
+ },
7953
+ cropOffsertY() {
7954
+ this.showPreview();
7955
+ },
7956
+ scale(t, e) {
7957
+ this.showPreview();
7958
+ },
7959
+ x() {
7960
+ this.showPreview();
7961
+ },
7962
+ y() {
7963
+ this.showPreview();
7964
+ },
7965
+ autoCrop(t) {
7966
+ t && this.goAutoCrop();
7967
+ },
7968
+ // 修改了自动截图框
7969
+ autoCropWidth() {
7970
+ this.autoCrop && this.goAutoCrop();
7971
+ },
7972
+ autoCropHeight() {
7973
+ this.autoCrop && this.goAutoCrop();
7974
+ },
7975
+ mode() {
7976
+ this.checkedImg();
7977
+ },
7978
+ rotate() {
7979
+ this.showPreview(), this.autoCrop ? this.goAutoCrop(this.cropW, this.cropH) : (this.cropW > 0 || this.cropH > 0) && this.goAutoCrop(this.cropW, this.cropH);
7980
+ }
7981
+ },
7982
+ methods: {
7983
+ getVersion(t) {
7984
+ var e = navigator.userAgent.split(" "), i = "";
7985
+ let s = 0;
7986
+ const r = new RegExp(t, "i");
7987
+ for (var o = 0; o < e.length; o++)
7988
+ r.test(e[o]) && (i = e[o]);
7989
+ return i ? s = i.split("/")[1].split(".") : s = ["0", "0", "0"], s;
7990
+ },
7991
+ checkOrientationImage(t, e, i, s) {
7992
+ if (this.getVersion("chrome")[0] >= 81)
7993
+ e = -1;
7994
+ else if (this.getVersion("safari")[0] >= 605) {
7995
+ const h = this.getVersion("version");
7996
+ h[0] > 13 && h[1] > 1 && (e = -1);
7997
+ } else {
7998
+ const h = navigator.userAgent.toLowerCase().match(/cpu iphone os (.*?) like mac os/);
7999
+ if (h) {
8000
+ let a = h[1];
8001
+ a = a.split("_"), (a[0] > 13 || a[0] >= 13 && a[1] >= 4) && (e = -1);
8002
+ }
8003
+ }
8004
+ let r = document.createElement("canvas"), o = r.getContext("2d");
8005
+ switch (o.save(), e) {
8006
+ case 2:
8007
+ r.width = i, r.height = s, o.translate(i, 0), o.scale(-1, 1);
8008
+ break;
8009
+ case 3:
8010
+ r.width = i, r.height = s, o.translate(i / 2, s / 2), o.rotate(180 * Math.PI / 180), o.translate(-i / 2, -s / 2);
8011
+ break;
8012
+ case 4:
8013
+ r.width = i, r.height = s, o.translate(0, s), o.scale(1, -1);
8014
+ break;
8015
+ case 5:
8016
+ r.height = i, r.width = s, o.rotate(0.5 * Math.PI), o.scale(1, -1);
8017
+ break;
8018
+ case 6:
8019
+ r.width = s, r.height = i, o.translate(s / 2, i / 2), o.rotate(90 * Math.PI / 180), o.translate(-i / 2, -s / 2);
8020
+ break;
8021
+ case 7:
8022
+ r.height = i, r.width = s, o.rotate(0.5 * Math.PI), o.translate(i, -s), o.scale(-1, 1);
8023
+ break;
8024
+ case 8:
8025
+ r.height = i, r.width = s, o.translate(s / 2, i / 2), o.rotate(-90 * Math.PI / 180), o.translate(-i / 2, -s / 2);
8026
+ break;
8027
+ default:
8028
+ r.width = i, r.height = s;
8029
+ }
8030
+ o.drawImage(t, 0, 0, i, s), o.restore(), r.toBlob(
8031
+ (h) => {
8032
+ let a = URL.createObjectURL(h);
8033
+ URL.revokeObjectURL(this.imgs), this.imgs = a;
8034
+ },
8035
+ "image/" + this.outputType,
8036
+ 1
8037
+ );
8038
+ },
8039
+ // checkout img
8040
+ checkedImg() {
8041
+ if (this.img === null || this.img === "") {
8042
+ this.imgs = "", this.clearCrop();
8043
+ return;
8044
+ }
8045
+ this.loading = true, this.scale = 1, this.rotate = 0, this.imgIsQqualCrop = false, this.clearCrop();
8046
+ let t = new Image();
8047
+ if (t.onload = () => {
8048
+ if (this.img === "")
8049
+ return this.$emit("img-load", new Error("图片不能为空")), false;
8050
+ let i = t.width, s = t.height;
8051
+ Y.getData(t).then((r) => {
8052
+ this.orientation = r.orientation || 1;
8053
+ let o = Number(this.maxImgSize);
8054
+ if (!this.orientation && i < o & s < o) {
8055
+ this.imgs = this.img;
8056
+ return;
8057
+ }
8058
+ i > o && (s = s / i * o, i = o), s > o && (i = i / s * o, s = o), this.checkOrientationImage(t, this.orientation, i, s);
8059
+ }).catch((r) => {
8060
+ this.$emit("img-load", "error"), this.$emit("img-load-error", r);
8061
+ });
8062
+ }, t.onerror = (i) => {
8063
+ this.$emit("img-load", "error"), this.$emit("img-load-error", i);
8064
+ }, this.img.substr(0, 4) !== "data" && (t.crossOrigin = ""), this.isIE) {
8065
+ var e = new XMLHttpRequest();
8066
+ e.onload = function() {
8067
+ var i = URL.createObjectURL(this.response);
8068
+ t.src = i;
8069
+ }, e.open("GET", this.img, true), e.responseType = "blob", e.send();
8070
+ } else
8071
+ t.src = this.img;
8072
+ },
8073
+ // 当按下鼠标键
8074
+ startMove(t) {
8075
+ if (t.preventDefault(), this.move && !this.crop) {
8076
+ if (!this.canMove)
8077
+ return false;
8078
+ this.moveX = ("clientX" in t ? t.clientX : t.touches[0].clientX) - this.x, this.moveY = ("clientY" in t ? t.clientY : t.touches[0].clientY) - this.y, t.touches ? (window.addEventListener("touchmove", this.moveImg), window.addEventListener("touchend", this.leaveImg), t.touches.length == 2 && (this.touches = t.touches, window.addEventListener("touchmove", this.touchScale), window.addEventListener("touchend", this.cancelTouchScale))) : (window.addEventListener("mousemove", this.moveImg), window.addEventListener("mouseup", this.leaveImg)), this.$emit("img-moving", {
8079
+ moving: true,
8080
+ axis: this.getImgAxis()
8081
+ });
8082
+ } else
8083
+ this.cropping = true, window.addEventListener("mousemove", this.createCrop), window.addEventListener("mouseup", this.endCrop), window.addEventListener("touchmove", this.createCrop), window.addEventListener("touchend", this.endCrop), this.cropOffsertX = t.offsetX ? t.offsetX : t.touches[0].pageX - this.$refs.cropper.offsetLeft, this.cropOffsertY = t.offsetY ? t.offsetY : t.touches[0].pageY - this.$refs.cropper.offsetTop, this.cropX = "clientX" in t ? t.clientX : t.touches[0].clientX, this.cropY = "clientY" in t ? t.clientY : t.touches[0].clientY, this.cropChangeX = this.cropOffsertX, this.cropChangeY = this.cropOffsertY, this.cropW = 0, this.cropH = 0;
8084
+ },
8085
+ // 移动端缩放
8086
+ touchScale(t) {
8087
+ t.preventDefault();
8088
+ let e = this.scale;
8089
+ var i = {
8090
+ x: this.touches[0].clientX,
8091
+ y: this.touches[0].clientY
8092
+ }, s = {
8093
+ x: t.touches[0].clientX,
8094
+ y: t.touches[0].clientY
8095
+ }, r = {
8096
+ x: this.touches[1].clientX,
8097
+ y: this.touches[1].clientY
8098
+ }, o = {
8099
+ x: t.touches[1].clientX,
8100
+ y: t.touches[1].clientY
8101
+ }, h = Math.sqrt(
8102
+ Math.pow(i.x - r.x, 2) + Math.pow(i.y - r.y, 2)
8103
+ ), a = Math.sqrt(
8104
+ Math.pow(s.x - o.x, 2) + Math.pow(s.y - o.y, 2)
8105
+ ), n = a - h, c = 1;
8106
+ c = c / this.trueWidth > c / this.trueHeight ? c / this.trueHeight : c / this.trueWidth, c = c > 0.1 ? 0.1 : c;
8107
+ var l = c * n;
8108
+ if (!this.touchNow) {
8109
+ if (this.touchNow = true, n > 0 ? e += Math.abs(l) : n < 0 && e > Math.abs(l) && (e -= Math.abs(l)), this.touches = t.touches, setTimeout(() => {
8110
+ this.touchNow = false;
8111
+ }, 8), !this.checkoutImgAxis(this.x, this.y, e))
8112
+ return false;
8113
+ this.scale = e;
8114
+ }
8115
+ },
8116
+ cancelTouchScale(t) {
8117
+ window.removeEventListener("touchmove", this.touchScale);
8118
+ },
8119
+ // 移动图片
8120
+ moveImg(t) {
8121
+ if (t.preventDefault(), t.touches && t.touches.length === 2)
8122
+ return this.touches = t.touches, window.addEventListener("touchmove", this.touchScale), window.addEventListener("touchend", this.cancelTouchScale), window.removeEventListener("touchmove", this.moveImg), false;
8123
+ let e = "clientX" in t ? t.clientX : t.touches[0].clientX, i = "clientY" in t ? t.clientY : t.touches[0].clientY, s, r;
8124
+ s = e - this.moveX, r = i - this.moveY, this.$nextTick(() => {
8125
+ if (this.centerBox) {
8126
+ let o = this.getImgAxis(s, r, this.scale), h = this.getCropAxis(), a = this.trueHeight * this.scale, n = this.trueWidth * this.scale, c, l, f, p;
8127
+ switch (this.rotate) {
8128
+ case 1:
8129
+ case -1:
8130
+ case 3:
8131
+ case -3:
8132
+ c = this.cropOffsertX - this.trueWidth * (1 - this.scale) / 2 + (a - n) / 2, l = this.cropOffsertY - this.trueHeight * (1 - this.scale) / 2 + (n - a) / 2, f = c - a + this.cropW, p = l - n + this.cropH;
8133
+ break;
8134
+ default:
8135
+ c = this.cropOffsertX - this.trueWidth * (1 - this.scale) / 2, l = this.cropOffsertY - this.trueHeight * (1 - this.scale) / 2, f = c - n + this.cropW, p = l - a + this.cropH;
8136
+ break;
8137
+ }
8138
+ o.x1 >= h.x1 && (s = c), o.y1 >= h.y1 && (r = l), o.x2 <= h.x2 && (s = f), o.y2 <= h.y2 && (r = p);
8139
+ }
8140
+ this.x = s, this.y = r, this.$emit("img-moving", {
8141
+ moving: true,
8142
+ axis: this.getImgAxis()
8143
+ });
8144
+ });
8145
+ },
8146
+ // 移动图片结束
8147
+ leaveImg(t) {
8148
+ window.removeEventListener("mousemove", this.moveImg), window.removeEventListener("touchmove", this.moveImg), window.removeEventListener("mouseup", this.leaveImg), window.removeEventListener("touchend", this.leaveImg), this.$emit("img-moving", {
8149
+ moving: false,
8150
+ axis: this.getImgAxis()
8151
+ });
8152
+ },
8153
+ // 缩放图片
8154
+ scaleImg() {
8155
+ this.canScale && window.addEventListener(this.support, this.changeSize, this.passive);
8156
+ },
8157
+ // 移出框
8158
+ cancelScale() {
8159
+ this.canScale && window.removeEventListener(this.support, this.changeSize);
8160
+ },
8161
+ // 改变大小函数
8162
+ changeSize(t) {
8163
+ t.preventDefault();
8164
+ let e = this.scale;
8165
+ var i = t.deltaY || t.wheelDelta, s = navigator.userAgent.indexOf("Firefox");
8166
+ i = s > 0 ? i * 30 : i, this.isIE && (i = -i);
8167
+ var r = this.coe;
8168
+ r = r / this.trueWidth > r / this.trueHeight ? r / this.trueHeight : r / this.trueWidth;
8169
+ var o = r * i;
8170
+ o < 0 ? e += Math.abs(o) : e > Math.abs(o) && (e -= Math.abs(o));
8171
+ let h = o < 0 ? "add" : "reduce";
8172
+ if (h !== this.coeStatus && (this.coeStatus = h, this.coe = 0.2), this.scaling || (this.scalingSet = setTimeout(() => {
8173
+ this.scaling = false, this.coe = this.coe += 0.01;
8174
+ }, 50)), this.scaling = true, !this.checkoutImgAxis(this.x, this.y, e))
8175
+ return false;
8176
+ this.scale = e;
8177
+ },
8178
+ // 修改图片大小函数
8179
+ changeScale(t) {
8180
+ let e = this.scale;
8181
+ t = t || 1;
8182
+ var i = 20;
8183
+ if (i = i / this.trueWidth > i / this.trueHeight ? i / this.trueHeight : i / this.trueWidth, t = t * i, t > 0 ? e += Math.abs(t) : e > Math.abs(t) && (e -= Math.abs(t)), !this.checkoutImgAxis(this.x, this.y, e))
8184
+ return false;
8185
+ this.scale = e;
8186
+ },
8187
+ // 创建截图框
8188
+ createCrop(t) {
8189
+ t.preventDefault();
8190
+ var e = "clientX" in t ? t.clientX : t.touches ? t.touches[0].clientX : 0, i = "clientY" in t ? t.clientY : t.touches ? t.touches[0].clientY : 0;
8191
+ this.$nextTick(() => {
8192
+ var s = e - this.cropX, r = i - this.cropY;
8193
+ if (s > 0 ? (this.cropW = s + this.cropChangeX > this.w ? this.w - this.cropChangeX : s, this.cropOffsertX = this.cropChangeX) : (this.cropW = this.w - this.cropChangeX + Math.abs(s) > this.w ? this.cropChangeX : Math.abs(s), this.cropOffsertX = this.cropChangeX + s > 0 ? this.cropChangeX + s : 0), !this.fixed)
8194
+ r > 0 ? (this.cropH = r + this.cropChangeY > this.h ? this.h - this.cropChangeY : r, this.cropOffsertY = this.cropChangeY) : (this.cropH = this.h - this.cropChangeY + Math.abs(r) > this.h ? this.cropChangeY : Math.abs(r), this.cropOffsertY = this.cropChangeY + r > 0 ? this.cropChangeY + r : 0);
8195
+ else {
8196
+ var o = this.cropW / this.fixedNumber[0] * this.fixedNumber[1];
8197
+ o + this.cropOffsertY > this.h ? (this.cropH = this.h - this.cropOffsertY, this.cropW = this.cropH / this.fixedNumber[1] * this.fixedNumber[0], s > 0 ? this.cropOffsertX = this.cropChangeX : this.cropOffsertX = this.cropChangeX - this.cropW) : this.cropH = o, this.cropOffsertY = this.cropOffsertY;
8198
+ }
8199
+ });
8200
+ },
8201
+ // 改变截图框大小
8202
+ changeCropSize(t, e, i, s, r) {
8203
+ t.preventDefault(), window.addEventListener("mousemove", this.changeCropNow), window.addEventListener("mouseup", this.changeCropEnd), window.addEventListener("touchmove", this.changeCropNow), window.addEventListener("touchend", this.changeCropEnd), this.canChangeX = e, this.canChangeY = i, this.changeCropTypeX = s, this.changeCropTypeY = r, this.cropX = "clientX" in t ? t.clientX : t.touches[0].clientX, this.cropY = "clientY" in t ? t.clientY : t.touches[0].clientY, this.cropOldW = this.cropW, this.cropOldH = this.cropH, this.cropChangeX = this.cropOffsertX, this.cropChangeY = this.cropOffsertY, this.fixed && this.canChangeX && this.canChangeY && (this.canChangeY = 0), this.$emit("change-crop-size", {
8204
+ width: this.cropW,
8205
+ height: this.cropH
8206
+ });
8207
+ },
8208
+ // 正在改变
8209
+ changeCropNow(t) {
8210
+ t.preventDefault();
8211
+ var e = "clientX" in t ? t.clientX : t.touches ? t.touches[0].clientX : 0, i = "clientY" in t ? t.clientY : t.touches ? t.touches[0].clientY : 0;
8212
+ let s = this.w, r = this.h, o = 0, h = 0;
8213
+ if (this.centerBox) {
8214
+ let c = this.getImgAxis(), l = c.x2, f = c.y2;
8215
+ o = c.x1 > 0 ? c.x1 : 0, h = c.y1 > 0 ? c.y1 : 0, s > l && (s = l), r > f && (r = f);
8216
+ }
8217
+ const [a, n] = this.checkCropLimitSize();
8218
+ this.$nextTick(() => {
8219
+ var c = e - this.cropX, l = i - this.cropY;
8220
+ if (this.canChangeX && (this.changeCropTypeX === 1 ? this.cropOldW - c < a ? (this.cropW = a, this.cropOffsertX = this.cropOldW + this.cropChangeX - o - a) : this.cropOldW - c > 0 ? (this.cropW = s - this.cropChangeX - c <= s - o ? this.cropOldW - c : this.cropOldW + this.cropChangeX - o, this.cropOffsertX = s - this.cropChangeX - c <= s - o ? this.cropChangeX + c : o) : (this.cropW = Math.abs(c) + this.cropChangeX <= s ? Math.abs(c) - this.cropOldW : s - this.cropOldW - this.cropChangeX, this.cropOffsertX = this.cropChangeX + this.cropOldW) : this.changeCropTypeX === 2 && (this.cropOldW + c < a ? this.cropW = a : this.cropOldW + c > 0 ? (this.cropW = this.cropOldW + c + this.cropOffsertX <= s ? this.cropOldW + c : s - this.cropOffsertX, this.cropOffsertX = this.cropChangeX) : (this.cropW = s - this.cropChangeX + Math.abs(c + this.cropOldW) <= s - o ? Math.abs(c + this.cropOldW) : this.cropChangeX - o, this.cropOffsertX = s - this.cropChangeX + Math.abs(c + this.cropOldW) <= s - o ? this.cropChangeX - Math.abs(c + this.cropOldW) : o))), this.canChangeY && (this.changeCropTypeY === 1 ? this.cropOldH - l < n ? (this.cropH = n, this.cropOffsertY = this.cropOldH + this.cropChangeY - h - n) : this.cropOldH - l > 0 ? (this.cropH = r - this.cropChangeY - l <= r - h ? this.cropOldH - l : this.cropOldH + this.cropChangeY - h, this.cropOffsertY = r - this.cropChangeY - l <= r - h ? this.cropChangeY + l : h) : (this.cropH = Math.abs(l) + this.cropChangeY <= r ? Math.abs(l) - this.cropOldH : r - this.cropOldH - this.cropChangeY, this.cropOffsertY = this.cropChangeY + this.cropOldH) : this.changeCropTypeY === 2 && (this.cropOldH + l < n ? this.cropH = n : this.cropOldH + l > 0 ? (this.cropH = this.cropOldH + l + this.cropOffsertY <= r ? this.cropOldH + l : r - this.cropOffsertY, this.cropOffsertY = this.cropChangeY) : (this.cropH = r - this.cropChangeY + Math.abs(l + this.cropOldH) <= r - h ? Math.abs(l + this.cropOldH) : this.cropChangeY - h, this.cropOffsertY = r - this.cropChangeY + Math.abs(l + this.cropOldH) <= r - h ? this.cropChangeY - Math.abs(l + this.cropOldH) : h))), this.canChangeX && this.fixed) {
8221
+ var f = this.cropW / this.fixedNumber[0] * this.fixedNumber[1];
8222
+ f < n ? (this.cropH = n, this.cropW = this.fixedNumber[0] * n / this.fixedNumber[1], this.changeCropTypeX === 1 && (this.cropOffsertX = this.cropChangeX + (this.cropOldW - this.cropW))) : f + this.cropOffsertY > r ? (this.cropH = r - this.cropOffsertY, this.cropW = this.cropH / this.fixedNumber[1] * this.fixedNumber[0], this.changeCropTypeX === 1 && (this.cropOffsertX = this.cropChangeX + (this.cropOldW - this.cropW))) : this.cropH = f;
8223
+ }
8224
+ if (this.canChangeY && this.fixed) {
8225
+ var p = this.cropH / this.fixedNumber[1] * this.fixedNumber[0];
8226
+ p < a ? (this.cropW = a, this.cropH = this.fixedNumber[1] * a / this.fixedNumber[0], this.cropOffsertY = this.cropOldH + this.cropChangeY - this.cropH) : p + this.cropOffsertX > s ? (this.cropW = s - this.cropOffsertX, this.cropH = this.cropW / this.fixedNumber[0] * this.fixedNumber[1]) : this.cropW = p;
8227
+ }
8228
+ });
8229
+ },
8230
+ checkCropLimitSize() {
8231
+ let { cropW: t, cropH: e, limitMinSize: i } = this, s = new Array();
8232
+ return Array.isArray(i) ? s = i : s = [i, i], t = parseFloat(s[0]), e = parseFloat(s[1]), [t, e];
8233
+ },
8234
+ // 结束改变
8235
+ changeCropEnd(t) {
8236
+ window.removeEventListener("mousemove", this.changeCropNow), window.removeEventListener("mouseup", this.changeCropEnd), window.removeEventListener("touchmove", this.changeCropNow), window.removeEventListener("touchend", this.changeCropEnd);
8237
+ },
8238
+ // 根据比例x/y,最小宽度,最小高度,现有宽度,现有高度,得到应该有的宽度和高度
8239
+ calculateSize(t, e, i, s, r, o) {
8240
+ const h = t / e;
8241
+ let a = r, n = o;
8242
+ return a < i && (a = i, n = Math.ceil(a / h)), n < s && (n = s, a = Math.ceil(n * h), a < i && (a = i, n = Math.ceil(a / h))), a < r && (a = r, n = Math.ceil(a / h)), n < o && (n = o, a = Math.ceil(n * h)), { width: a, height: n };
8243
+ },
8244
+ // 创建完成
8245
+ endCrop() {
8246
+ this.cropW === 0 && this.cropH === 0 && (this.cropping = false);
8247
+ let [t, e] = this.checkCropLimitSize();
8248
+ const { width: i, height: s } = this.fixed ? this.calculateSize(
8249
+ this.fixedNumber[0],
8250
+ this.fixedNumber[1],
8251
+ t,
8252
+ e,
8253
+ this.cropW,
8254
+ this.cropH
8255
+ ) : { width: t, height: e };
8256
+ i > this.cropW && (this.cropW = i, this.cropOffsertX + i > this.w && (this.cropOffsertX = this.w - i)), s > this.cropH && (this.cropH = s, this.cropOffsertY + s > this.h && (this.cropOffsertY = this.h - s)), window.removeEventListener("mousemove", this.createCrop), window.removeEventListener("mouseup", this.endCrop), window.removeEventListener("touchmove", this.createCrop), window.removeEventListener("touchend", this.endCrop);
8257
+ },
8258
+ // 开始截图
8259
+ startCrop() {
8260
+ this.crop = true;
8261
+ },
8262
+ // 停止截图
8263
+ stopCrop() {
8264
+ this.crop = false;
8265
+ },
8266
+ // 清除截图
8267
+ clearCrop() {
8268
+ this.cropping = false, this.cropW = 0, this.cropH = 0;
8269
+ },
8270
+ // 截图移动
8271
+ cropMove(t) {
8272
+ if (t.preventDefault(), !this.canMoveBox)
8273
+ return this.crop = false, this.startMove(t), false;
8274
+ if (t.touches && t.touches.length === 2)
8275
+ return this.crop = false, this.startMove(t), this.leaveCrop(), false;
8276
+ window.addEventListener("mousemove", this.moveCrop), window.addEventListener("mouseup", this.leaveCrop), window.addEventListener("touchmove", this.moveCrop), window.addEventListener("touchend", this.leaveCrop);
8277
+ let e = "clientX" in t ? t.clientX : t.touches[0].clientX, i = "clientY" in t ? t.clientY : t.touches[0].clientY, s, r;
8278
+ s = e - this.cropOffsertX, r = i - this.cropOffsertY, this.cropX = s, this.cropY = r, this.$emit("crop-moving", {
8279
+ moving: true,
8280
+ axis: this.getCropAxis()
8281
+ });
8282
+ },
8283
+ moveCrop(t, e) {
8284
+ let i = 0, s = 0;
8285
+ t && (t.preventDefault(), i = "clientX" in t ? t.clientX : t.touches[0].clientX, s = "clientY" in t ? t.clientY : t.touches[0].clientY), this.$nextTick(() => {
8286
+ let r, o, h = i - this.cropX, a = s - this.cropY;
8287
+ if (e && (h = this.cropOffsertX, a = this.cropOffsertY), h <= 0 ? r = 0 : h + this.cropW > this.w ? r = this.w - this.cropW : r = h, a <= 0 ? o = 0 : a + this.cropH > this.h ? o = this.h - this.cropH : o = a, this.centerBox) {
8288
+ let n = this.getImgAxis();
8289
+ r <= n.x1 && (r = n.x1), r + this.cropW > n.x2 && (r = n.x2 - this.cropW), o <= n.y1 && (o = n.y1), o + this.cropH > n.y2 && (o = n.y2 - this.cropH);
8290
+ }
8291
+ this.cropOffsertX = r, this.cropOffsertY = o, this.$emit("crop-moving", {
8292
+ moving: true,
8293
+ axis: this.getCropAxis()
8294
+ });
8295
+ });
8296
+ },
8297
+ // 算出不同场景下面 图片相对于外层容器的坐标轴
8298
+ getImgAxis(t, e, i) {
8299
+ t = t || this.x, e = e || this.y, i = i || this.scale;
8300
+ let s = {
8301
+ x1: 0,
8302
+ x2: 0,
8303
+ y1: 0,
8304
+ y2: 0
8305
+ }, r = this.trueWidth * i, o = this.trueHeight * i;
8306
+ switch (this.rotate) {
8307
+ case 0:
8308
+ s.x1 = t + this.trueWidth * (1 - i) / 2, s.x2 = s.x1 + this.trueWidth * i, s.y1 = e + this.trueHeight * (1 - i) / 2, s.y2 = s.y1 + this.trueHeight * i;
8309
+ break;
8310
+ case 1:
8311
+ case -1:
8312
+ case 3:
8313
+ case -3:
8314
+ s.x1 = t + this.trueWidth * (1 - i) / 2 + (r - o) / 2, s.x2 = s.x1 + this.trueHeight * i, s.y1 = e + this.trueHeight * (1 - i) / 2 + (o - r) / 2, s.y2 = s.y1 + this.trueWidth * i;
8315
+ break;
8316
+ default:
8317
+ s.x1 = t + this.trueWidth * (1 - i) / 2, s.x2 = s.x1 + this.trueWidth * i, s.y1 = e + this.trueHeight * (1 - i) / 2, s.y2 = s.y1 + this.trueHeight * i;
8318
+ break;
8319
+ }
8320
+ return s;
8321
+ },
8322
+ // 获取截图框的坐标轴
8323
+ getCropAxis() {
8324
+ let t = {
8325
+ x1: 0,
8326
+ x2: 0,
8327
+ y1: 0,
8328
+ y2: 0
8329
+ };
8330
+ return t.x1 = this.cropOffsertX, t.x2 = t.x1 + this.cropW, t.y1 = this.cropOffsertY, t.y2 = t.y1 + this.cropH, t;
8331
+ },
8332
+ leaveCrop(t) {
8333
+ window.removeEventListener("mousemove", this.moveCrop), window.removeEventListener("mouseup", this.leaveCrop), window.removeEventListener("touchmove", this.moveCrop), window.removeEventListener("touchend", this.leaveCrop), this.$emit("crop-moving", {
8334
+ moving: false,
8335
+ axis: this.getCropAxis()
8336
+ });
8337
+ },
8338
+ getCropChecked(t) {
8339
+ let e = document.createElement("canvas"), i = e.getContext("2d"), s = new Image(), r = this.rotate, o = this.trueWidth, h = this.trueHeight, a = this.cropOffsertX, n = this.cropOffsertY;
8340
+ s.onload = () => {
8341
+ if (this.cropW !== 0) {
8342
+ let p = 1;
8343
+ this.high & !this.full && (p = window.devicePixelRatio), this.enlarge !== 1 & !this.full && (p = Math.abs(Number(this.enlarge)));
8344
+ let d = this.cropW * p, C = this.cropH * p, u = o * this.scale * p, g = h * this.scale * p, m = (this.x - a + this.trueWidth * (1 - this.scale) / 2) * p, v = (this.y - n + this.trueHeight * (1 - this.scale) / 2) * p;
8345
+ switch (f(d, C), i.save(), r) {
8346
+ case 0:
8347
+ this.full ? (f(d / this.scale, C / this.scale), i.drawImage(
8348
+ s,
8349
+ m / this.scale,
8350
+ v / this.scale,
8351
+ u / this.scale,
8352
+ g / this.scale
8353
+ )) : i.drawImage(s, m, v, u, g);
8354
+ break;
8355
+ case 1:
8356
+ case -3:
8357
+ this.full ? (f(d / this.scale, C / this.scale), m = m / this.scale + (u / this.scale - g / this.scale) / 2, v = v / this.scale + (g / this.scale - u / this.scale) / 2, i.rotate(r * 90 * Math.PI / 180), i.drawImage(
8358
+ s,
8359
+ v,
8360
+ -m - g / this.scale,
8361
+ u / this.scale,
8362
+ g / this.scale
8363
+ )) : (m = m + (u - g) / 2, v = v + (g - u) / 2, i.rotate(r * 90 * Math.PI / 180), i.drawImage(s, v, -m - g, u, g));
8364
+ break;
8365
+ case 2:
8366
+ case -2:
8367
+ this.full ? (f(d / this.scale, C / this.scale), i.rotate(r * 90 * Math.PI / 180), m = m / this.scale, v = v / this.scale, i.drawImage(
8368
+ s,
8369
+ -m - u / this.scale,
8370
+ -v - g / this.scale,
8371
+ u / this.scale,
8372
+ g / this.scale
8373
+ )) : (i.rotate(r * 90 * Math.PI / 180), i.drawImage(s, -m - u, -v - g, u, g));
8374
+ break;
8375
+ case 3:
8376
+ case -1:
8377
+ this.full ? (f(d / this.scale, C / this.scale), m = m / this.scale + (u / this.scale - g / this.scale) / 2, v = v / this.scale + (g / this.scale - u / this.scale) / 2, i.rotate(r * 90 * Math.PI / 180), i.drawImage(
8378
+ s,
8379
+ -v - u / this.scale,
8380
+ m,
8381
+ u / this.scale,
8382
+ g / this.scale
8383
+ )) : (m = m + (u - g) / 2, v = v + (g - u) / 2, i.rotate(r * 90 * Math.PI / 180), i.drawImage(s, -v - u, m, u, g));
8384
+ break;
8385
+ default:
8386
+ this.full ? (f(d / this.scale, C / this.scale), i.drawImage(
8387
+ s,
8388
+ m / this.scale,
8389
+ v / this.scale,
8390
+ u / this.scale,
8391
+ g / this.scale
8392
+ )) : i.drawImage(s, m, v, u, g);
8393
+ }
8394
+ i.restore();
8395
+ } else {
8396
+ let p = o * this.scale, d = h * this.scale;
8397
+ switch (i.save(), r) {
8398
+ case 0:
8399
+ f(p, d), i.drawImage(s, 0, 0, p, d);
8400
+ break;
8401
+ case 1:
8402
+ case -3:
8403
+ f(d, p), i.rotate(r * 90 * Math.PI / 180), i.drawImage(s, 0, -d, p, d);
8404
+ break;
8405
+ case 2:
8406
+ case -2:
8407
+ f(p, d), i.rotate(r * 90 * Math.PI / 180), i.drawImage(s, -p, -d, p, d);
8408
+ break;
8409
+ case 3:
8410
+ case -1:
8411
+ f(d, p), i.rotate(r * 90 * Math.PI / 180), i.drawImage(s, -p, 0, p, d);
8412
+ break;
8413
+ default:
8414
+ f(p, d), i.drawImage(s, 0, 0, p, d);
8415
+ }
8416
+ i.restore();
8417
+ }
8418
+ t(e);
8419
+ };
8420
+ var c = this.img.substr(0, 4);
8421
+ c !== "data" && (s.crossOrigin = "Anonymous"), s.src = this.imgs;
8422
+ const l = this.fillColor;
8423
+ function f(p, d) {
8424
+ e.width = Math.round(p), e.height = Math.round(d), l && (i.fillStyle = l, i.fillRect(0, 0, e.width, e.height));
8425
+ }
8426
+ },
8427
+ // 获取转换成base64 的图片信息
8428
+ getCropData(t) {
8429
+ this.getCropChecked((e) => {
8430
+ t(e.toDataURL("image/" + this.outputType, this.outputSize));
8431
+ });
8432
+ },
8433
+ //canvas获取为blob对象
8434
+ getCropBlob(t) {
8435
+ this.getCropChecked((e) => {
8436
+ e.toBlob(
8437
+ (i) => t(i),
8438
+ "image/" + this.outputType,
8439
+ this.outputSize
8440
+ );
8441
+ });
8442
+ },
8443
+ // 自动预览函数
8444
+ showPreview() {
8445
+ if (this.isCanShow)
8446
+ this.isCanShow = false, setTimeout(() => {
8447
+ this.isCanShow = true;
8448
+ }, 16);
8449
+ else
8450
+ return false;
8451
+ let t = this.cropW, e = this.cropH, i = this.scale;
8452
+ var s = {};
8453
+ s.div = {
8454
+ width: `${t}px`,
8455
+ height: `${e}px`
8456
+ };
8457
+ let r = (this.x - this.cropOffsertX) / i, o = (this.y - this.cropOffsertY) / i, h = 0;
8458
+ s.w = t, s.h = e, s.url = this.imgs, s.img = {
8459
+ width: `${this.trueWidth}px`,
8460
+ height: `${this.trueHeight}px`,
8461
+ transform: `scale(${i})translate3d(${r}px, ${o}px, ${h}px)rotateZ(${this.rotate * 90}deg)`
8462
+ }, s.html = `
8463
+ <div class="show-preview" style="width: ${s.w}px; height: ${s.h}px,; overflow: hidden">
8464
+ <div style="width: ${t}px; height: ${e}px">
8465
+ <img src=${s.url} style="width: ${this.trueWidth}px; height: ${this.trueHeight}px; transform:
8466
+ scale(${i})translate3d(${r}px, ${o}px, ${h}px)rotateZ(${this.rotate * 90}deg)">
8467
+ </div>
8468
+ </div>`, this.$emit("real-time", s);
8469
+ },
8470
+ // reload 图片布局函数
8471
+ reload() {
8472
+ let t = new Image();
8473
+ t.onload = () => {
8474
+ this.w = parseFloat(window.getComputedStyle(this.$refs.cropper).width), this.h = parseFloat(window.getComputedStyle(this.$refs.cropper).height), this.trueWidth = t.width, this.trueHeight = t.height, this.original ? this.scale = 1 : this.scale = this.checkedMode(), this.$nextTick(() => {
8475
+ this.x = -(this.trueWidth - this.trueWidth * this.scale) / 2 + (this.w - this.trueWidth * this.scale) / 2, this.y = -(this.trueHeight - this.trueHeight * this.scale) / 2 + (this.h - this.trueHeight * this.scale) / 2, this.loading = false, this.autoCrop && this.goAutoCrop(), this.$emit("img-load", "success"), setTimeout(() => {
8476
+ this.showPreview();
8477
+ }, 20);
8478
+ });
8479
+ }, t.onerror = () => {
8480
+ this.$emit("img-load", "error");
8481
+ }, t.src = this.imgs;
8482
+ },
8483
+ // 背景布局的函数
8484
+ checkedMode() {
8485
+ let t = 1, e = this.trueWidth, i = this.trueHeight;
8486
+ const s = this.mode.split(" ");
8487
+ switch (s[0]) {
8488
+ case "contain":
8489
+ this.trueWidth > this.w && (t = this.w / this.trueWidth), this.trueHeight * t > this.h && (t = this.h / this.trueHeight);
8490
+ break;
8491
+ case "cover":
8492
+ e = this.w, t = e / this.trueWidth, i = i * t, i < this.h && (i = this.h, t = i / this.trueHeight);
8493
+ break;
8494
+ default:
8495
+ try {
8496
+ let r = s[0];
8497
+ if (r.search("px") !== -1) {
8498
+ r = r.replace("px", ""), e = parseFloat(r);
8499
+ const o = e / this.trueWidth;
8500
+ let h = 1, a = s[1];
8501
+ a.search("px") !== -1 && (a = a.replace("px", ""), i = parseFloat(a), h = i / this.trueHeight), t = Math.min(o, h);
8502
+ }
8503
+ if (r.search("%") !== -1 && (r = r.replace("%", ""), e = parseFloat(r) / 100 * this.w, t = e / this.trueWidth), s.length === 2 && r === "auto") {
8504
+ let o = s[1];
8505
+ o.search("px") !== -1 && (o = o.replace("px", ""), i = parseFloat(o), t = i / this.trueHeight), o.search("%") !== -1 && (o = o.replace("%", ""), i = parseFloat(o) / 100 * this.h, t = i / this.trueHeight);
8506
+ }
8507
+ } catch {
8508
+ t = 1;
8509
+ }
8510
+ }
8511
+ return t;
8512
+ },
8513
+ // 自动截图函数
8514
+ goAutoCrop(t, e) {
8515
+ if (this.imgs === "" || this.imgs === null)
8516
+ return;
8517
+ this.clearCrop(), this.cropping = true;
8518
+ let i = this.w, s = this.h;
8519
+ if (this.centerBox) {
8520
+ const h = Math.abs(this.rotate) % 2 > 0;
8521
+ let a = (h ? this.trueHeight : this.trueWidth) * this.scale, n = (h ? this.trueWidth : this.trueHeight) * this.scale;
8522
+ i = a < i ? a : i, s = n < s ? n : s;
8523
+ }
8524
+ var r = t || parseFloat(this.autoCropWidth), o = e || parseFloat(this.autoCropHeight);
8525
+ (r === 0 || o === 0) && (r = i * 0.8, o = s * 0.8), r = r > i ? i : r, o = o > s ? s : o, this.fixed && (o = r / this.fixedNumber[0] * this.fixedNumber[1]), o > this.h && (o = this.h, r = o / this.fixedNumber[1] * this.fixedNumber[0]), this.changeCrop(r, o);
8526
+ },
8527
+ // 手动改变截图框大小函数
8528
+ changeCrop(t, e) {
8529
+ if (this.centerBox) {
8530
+ let i = this.getImgAxis();
8531
+ t > i.x2 - i.x1 && (t = i.x2 - i.x1, e = t / this.fixedNumber[0] * this.fixedNumber[1]), e > i.y2 - i.y1 && (e = i.y2 - i.y1, t = e / this.fixedNumber[1] * this.fixedNumber[0]);
8532
+ }
8533
+ this.cropW = t, this.cropH = e, this.checkCropLimitSize(), this.$nextTick(() => {
8534
+ this.cropOffsertX = (this.w - this.cropW) / 2, this.cropOffsertY = (this.h - this.cropH) / 2, this.centerBox && this.moveCrop(null, true);
8535
+ });
8536
+ },
8537
+ // 重置函数, 恢复组件置初始状态
8538
+ refresh() {
8539
+ this.img, this.imgs = "", this.scale = 1, this.crop = false, this.rotate = 0, this.w = 0, this.h = 0, this.trueWidth = 0, this.trueHeight = 0, this.imgIsQqualCrop = false, this.clearCrop(), this.$nextTick(() => {
8540
+ this.checkedImg();
8541
+ });
8542
+ },
8543
+ // 向左边旋转
8544
+ rotateLeft() {
8545
+ this.rotate = this.rotate <= -3 ? 0 : this.rotate - 1;
8546
+ },
8547
+ // 向右边旋转
8548
+ rotateRight() {
8549
+ this.rotate = this.rotate >= 3 ? 0 : this.rotate + 1;
8550
+ },
8551
+ // 清除旋转
8552
+ rotateClear() {
8553
+ this.rotate = 0;
8554
+ },
8555
+ // 图片坐标点校验
8556
+ checkoutImgAxis(t, e, i) {
8557
+ t = t || this.x, e = e || this.y, i = i || this.scale;
8558
+ let s = true;
8559
+ if (this.centerBox) {
8560
+ let r = this.getImgAxis(t, e, i), o = this.getCropAxis();
8561
+ r.x1 >= o.x1 && (s = false), r.x2 <= o.x2 && (s = false), r.y1 >= o.y1 && (s = false), r.y2 <= o.y2 && (s = false), s || this.changeImgScale(r, o, i);
8562
+ }
8563
+ return s;
8564
+ },
8565
+ // 缩放图片,将图片坐标适配截图框坐标
8566
+ changeImgScale(t, e, i) {
8567
+ let s = this.trueWidth, r = this.trueHeight, o = s * i, h = r * i;
8568
+ if (o >= this.cropW && h >= this.cropH)
8569
+ this.scale = i;
8570
+ else {
8571
+ const a = this.cropW / s, n = this.cropH / r, c = this.cropH <= r * a ? a : n;
8572
+ this.scale = c, o = s * c, h = r * c;
8573
+ }
8574
+ this.imgIsQqualCrop || (t.x1 >= e.x1 && (this.isRotateRightOrLeft ? this.x = e.x1 - (s - o) / 2 - (o - h) / 2 : this.x = e.x1 - (s - o) / 2), t.x2 <= e.x2 && (this.isRotateRightOrLeft ? this.x = e.x1 - (s - o) / 2 - (o - h) / 2 - h + this.cropW : this.x = e.x2 - (s - o) / 2 - o), t.y1 >= e.y1 && (this.isRotateRightOrLeft ? this.y = e.y1 - (r - h) / 2 - (h - o) / 2 : this.y = e.y1 - (r - h) / 2), t.y2 <= e.y2 && (this.isRotateRightOrLeft ? this.y = e.y2 - (r - h) / 2 - (h - o) / 2 - o : this.y = e.y2 - (r - h) / 2 - h)), (o < this.cropW || h < this.cropH) && (this.imgIsQqualCrop = true);
8575
+ }
8576
+ },
8577
+ mounted() {
8578
+ this.support = "onwheel" in document.createElement("div") ? "wheel" : document.onmousewheel !== void 0 ? "mousewheel" : "DOMMouseScroll";
8579
+ let t = this;
8580
+ var e = navigator.userAgent;
8581
+ this.isIOS = !!e.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), HTMLCanvasElement.prototype.toBlob || Object.defineProperty(HTMLCanvasElement.prototype, "toBlob", {
8582
+ value: function(i, s, r) {
8583
+ for (var o = atob(this.toDataURL(s, r).split(",")[1]), h = o.length, a = new Uint8Array(h), n = 0; n < h; n++)
8584
+ a[n] = o.charCodeAt(n);
8585
+ i(new Blob([a], { type: t.type || "image/png" }));
8586
+ }
8587
+ }), this.showPreview(), this.checkedImg();
8588
+ },
8589
+ unmounted() {
8590
+ window.removeEventListener("mousemove", this.moveCrop), window.removeEventListener("mouseup", this.leaveCrop), window.removeEventListener("touchmove", this.moveCrop), window.removeEventListener("touchend", this.leaveCrop), this.cancelScale();
8591
+ }
8592
+ }), A = {
8593
+ key: 0,
8594
+ class: "cropper-box"
8595
+ }, B = ["src"], P = { class: "cropper-view-box" }, R = ["src"], D = { key: 1 };
8596
+ function U(t, e, i, s, r, o) {
8597
+ return openBlock(), createElementBlock("div", {
8598
+ class: "vue-cropper",
8599
+ ref: "cropper",
8600
+ onMouseover: e[28] || (e[28] = (...h) => t.scaleImg && t.scaleImg(...h)),
8601
+ onMouseout: e[29] || (e[29] = (...h) => t.cancelScale && t.cancelScale(...h))
8602
+ }, [
8603
+ t.imgs ? (openBlock(), createElementBlock("div", A, [
8604
+ withDirectives(createElementVNode("div", {
8605
+ class: "cropper-box-canvas",
8606
+ style: normalizeStyle({
8607
+ width: t.trueWidth + "px",
8608
+ height: t.trueHeight + "px",
8609
+ transform: "scale(" + t.scale + "," + t.scale + ") translate3d(" + t.x / t.scale + "px," + t.y / t.scale + "px,0)rotateZ(" + t.rotate * 90 + "deg)"
8610
+ })
8611
+ }, [
8612
+ createElementVNode("img", {
8613
+ src: t.imgs,
8614
+ alt: "cropper-img",
8615
+ ref: "cropperImg"
8616
+ }, null, 8, B)
8617
+ ], 4), [
8618
+ [vShow, !t.loading]
8619
+ ])
8620
+ ])) : createCommentVNode("", true),
8621
+ createElementVNode("div", {
8622
+ class: normalizeClass(["cropper-drag-box", { "cropper-move": t.move && !t.crop, "cropper-crop": t.crop, "cropper-modal": t.cropping }]),
8623
+ onMousedown: e[0] || (e[0] = (...h) => t.startMove && t.startMove(...h)),
8624
+ onTouchstart: e[1] || (e[1] = (...h) => t.startMove && t.startMove(...h))
8625
+ }, null, 34),
8626
+ withDirectives(createElementVNode("div", {
8627
+ class: "cropper-crop-box",
8628
+ style: normalizeStyle({
8629
+ width: t.cropW + "px",
8630
+ height: t.cropH + "px",
8631
+ transform: "translate3d(" + t.cropOffsertX + "px," + t.cropOffsertY + "px,0)"
8632
+ })
8633
+ }, [
8634
+ createElementVNode("span", P, [
8635
+ createElementVNode("img", {
8636
+ style: normalizeStyle({
8637
+ width: t.trueWidth + "px",
8638
+ height: t.trueHeight + "px",
8639
+ transform: "scale(" + t.scale + "," + t.scale + ") translate3d(" + (t.x - t.cropOffsertX) / t.scale + "px," + (t.y - t.cropOffsertY) / t.scale + "px,0)rotateZ(" + t.rotate * 90 + "deg)"
8640
+ }),
8641
+ src: t.imgs,
8642
+ alt: "cropper-img"
8643
+ }, null, 12, R)
8644
+ ]),
8645
+ createElementVNode("span", {
8646
+ class: "cropper-face cropper-move",
8647
+ onMousedown: e[2] || (e[2] = (...h) => t.cropMove && t.cropMove(...h)),
8648
+ onTouchstart: e[3] || (e[3] = (...h) => t.cropMove && t.cropMove(...h))
8649
+ }, null, 32),
8650
+ t.info ? (openBlock(), createElementBlock("span", {
8651
+ key: 0,
8652
+ class: "crop-info",
8653
+ style: normalizeStyle({ top: t.cropInfo.top })
8654
+ }, toDisplayString(t.cropInfo.width) + " × " + toDisplayString(t.cropInfo.height), 5)) : createCommentVNode("", true),
8655
+ t.fixedBox ? createCommentVNode("", true) : (openBlock(), createElementBlock("span", D, [
8656
+ createElementVNode("span", {
8657
+ class: "crop-line line-w",
8658
+ onMousedown: e[4] || (e[4] = (h) => t.changeCropSize(h, false, true, 0, 1)),
8659
+ onTouchstart: e[5] || (e[5] = (h) => t.changeCropSize(h, false, true, 0, 1))
8660
+ }, null, 32),
8661
+ createElementVNode("span", {
8662
+ class: "crop-line line-a",
8663
+ onMousedown: e[6] || (e[6] = (h) => t.changeCropSize(h, true, false, 1, 0)),
8664
+ onTouchstart: e[7] || (e[7] = (h) => t.changeCropSize(h, true, false, 1, 0))
8665
+ }, null, 32),
8666
+ createElementVNode("span", {
8667
+ class: "crop-line line-s",
8668
+ onMousedown: e[8] || (e[8] = (h) => t.changeCropSize(h, false, true, 0, 2)),
8669
+ onTouchstart: e[9] || (e[9] = (h) => t.changeCropSize(h, false, true, 0, 2))
8670
+ }, null, 32),
8671
+ createElementVNode("span", {
8672
+ class: "crop-line line-d",
8673
+ onMousedown: e[10] || (e[10] = (h) => t.changeCropSize(h, true, false, 2, 0)),
8674
+ onTouchstart: e[11] || (e[11] = (h) => t.changeCropSize(h, true, false, 2, 0))
8675
+ }, null, 32),
8676
+ createElementVNode("span", {
8677
+ class: "crop-point point1",
8678
+ onMousedown: e[12] || (e[12] = (h) => t.changeCropSize(h, true, true, 1, 1)),
8679
+ onTouchstart: e[13] || (e[13] = (h) => t.changeCropSize(h, true, true, 1, 1))
8680
+ }, null, 32),
8681
+ createElementVNode("span", {
8682
+ class: "crop-point point2",
8683
+ onMousedown: e[14] || (e[14] = (h) => t.changeCropSize(h, false, true, 0, 1)),
8684
+ onTouchstart: e[15] || (e[15] = (h) => t.changeCropSize(h, false, true, 0, 1))
8685
+ }, null, 32),
8686
+ createElementVNode("span", {
8687
+ class: "crop-point point3",
8688
+ onMousedown: e[16] || (e[16] = (h) => t.changeCropSize(h, true, true, 2, 1)),
8689
+ onTouchstart: e[17] || (e[17] = (h) => t.changeCropSize(h, true, true, 2, 1))
8690
+ }, null, 32),
8691
+ createElementVNode("span", {
8692
+ class: "crop-point point4",
8693
+ onMousedown: e[18] || (e[18] = (h) => t.changeCropSize(h, true, false, 1, 0)),
8694
+ onTouchstart: e[19] || (e[19] = (h) => t.changeCropSize(h, true, false, 1, 0))
8695
+ }, null, 32),
8696
+ createElementVNode("span", {
8697
+ class: "crop-point point5",
8698
+ onMousedown: e[20] || (e[20] = (h) => t.changeCropSize(h, true, false, 2, 0)),
8699
+ onTouchstart: e[21] || (e[21] = (h) => t.changeCropSize(h, true, false, 2, 0))
8700
+ }, null, 32),
8701
+ createElementVNode("span", {
8702
+ class: "crop-point point6",
8703
+ onMousedown: e[22] || (e[22] = (h) => t.changeCropSize(h, true, true, 1, 2)),
8704
+ onTouchstart: e[23] || (e[23] = (h) => t.changeCropSize(h, true, true, 1, 2))
8705
+ }, null, 32),
8706
+ createElementVNode("span", {
8707
+ class: "crop-point point7",
8708
+ onMousedown: e[24] || (e[24] = (h) => t.changeCropSize(h, false, true, 0, 2)),
8709
+ onTouchstart: e[25] || (e[25] = (h) => t.changeCropSize(h, false, true, 0, 2))
8710
+ }, null, 32),
8711
+ createElementVNode("span", {
8712
+ class: "crop-point point8",
8713
+ onMousedown: e[26] || (e[26] = (h) => t.changeCropSize(h, true, true, 2, 2)),
8714
+ onTouchstart: e[27] || (e[27] = (h) => t.changeCropSize(h, true, true, 2, 2))
8715
+ }, null, 32)
8716
+ ]))
8717
+ ], 4), [
8718
+ [vShow, t.cropping]
8719
+ ])
8720
+ ], 544);
8721
+ }
8722
+ const M = /* @__PURE__ */ $(z, [["render", U], ["__scopeId", "data-v-a742df44"]]);
8723
+
8724
+ const imageUploadProProps = {
8725
+ /**
8726
+ * 已上传图片列表(用于回显)
8727
+ * v-model 绑定的值
8728
+ */
8729
+ modelValue: {
8730
+ type: Array,
8731
+ default: () => []
8732
+ },
8733
+ /**
8734
+ * 允许上传的图片格式
8735
+ * 默认支持 jpg、png、webp
8736
+ */
8737
+ acceptType: {
8738
+ type: String,
8739
+ default: "image/jpeg,image/jpg,image/png,image/webp"
8740
+ },
8741
+ /**
8742
+ * 尺寸限制配置
8743
+ * width/height 为 0 表示不限制
8744
+ * size 为最大文件大小(MB)
8745
+ */
8746
+ sizeLimit: {
8747
+ type: Object,
8748
+ default: () => ({
8749
+ width: 0,
8750
+ height: 0,
8751
+ size: 2
8752
+ })
8753
+ },
8754
+ /**
8755
+ * 最大上传数量
8756
+ * 默认 9 张
8757
+ */
8758
+ maxCount: {
8759
+ type: Number,
8760
+ default: 9
8761
+ },
8762
+ /**
8763
+ * 是否允许裁剪图片
8764
+ * 启用后会在上传时弹出裁剪对话框
8765
+ */
8766
+ allowCrop: {
8767
+ type: Boolean,
8768
+ default: true
8769
+ },
8770
+ /**
8771
+ * 是否支持封面标记
8772
+ * 允许用户标记某张图片为封面
8773
+ */
8774
+ allowCover: {
8775
+ type: Boolean,
8776
+ default: true
8777
+ },
8778
+ /**
8779
+ * 是否支持拖拽排序
8780
+ * 启用后可以通过拖拽调整图片顺序
8781
+ */
8782
+ allowSort: {
8783
+ type: Boolean,
8784
+ default: true
8785
+ },
8786
+ /**
8787
+ * 上传 API 配置
8788
+ * 配置后,每次选择或裁剪图片时会自动上传到服务器
8789
+ */
8790
+ uploadApi: {
8791
+ type: Object,
8792
+ default: null
8793
+ },
8794
+ /**
8795
+ * 是否自动上传
8796
+ * 启用后,选择或裁剪图片时自动调用上传接口
8797
+ */
8798
+ autoUpload: {
8799
+ type: Boolean,
8800
+ default: false
8801
+ }
8802
+ };
8803
+
8804
+ const _hoisted_1 = { key: 0 };
8805
+ const _hoisted_2 = ["onDragstart", "onDrop"];
8806
+ var _sfc_main = /* @__PURE__ */ defineComponent({
8807
+ ...{
8808
+ name: "MlImageUploadPro"
8809
+ },
8810
+ __name: "index",
8811
+ props: imageUploadProProps,
8812
+ emits: ["update:modelValue", "change", "upload"],
8813
+ setup(__props, { expose: __expose, emit: __emit }) {
8814
+ const ASPECT_RATIO_OPTIONS = [
8815
+ { label: "\u81EA\u7531\u6BD4\u4F8B", value: "free" },
8816
+ { label: "1:1", value: "1:1" },
8817
+ { label: "4:3", value: "4:3" },
8818
+ { label: "16:9", value: "16:9" }
8819
+ ];
8820
+ const props = __props;
8821
+ const uploadRef = ref();
8822
+ const cropperRef = ref();
8823
+ const fileList = ref([]);
8824
+ const previewList = ref([]);
8825
+ const cropDialogVisible = ref(false);
8826
+ const cropImageUrl = ref("");
8827
+ const cropTargetItem = ref();
8828
+ const dragIndex = ref(-1);
8829
+ const cropForm = reactive({
8830
+ aspectRatio: "free"
8831
+ // 裁剪比例
8832
+ });
8833
+ const cropWidth = ref(props.sizeLimit.width || 400);
8834
+ const cropHeight = ref(props.sizeLimit.height || 400);
8835
+ const displayWidth = ref(props.sizeLimit.width || 400);
8836
+ const displayHeight = ref(props.sizeLimit.height || 400);
8837
+ const aspectRatio = reactive({
8838
+ fixed: false,
8839
+ value: [1, 1]
8840
+ });
8841
+ const axios = computed(() => {
8842
+ if (!props.uploadApi) return null;
8843
+ return initRequestInstance({
8844
+ baseURL: "",
8845
+ headers: props.uploadApi.headers || {}
8846
+ });
8847
+ });
8848
+ const acceptDesc = computed(() => {
8849
+ return props.acceptType.split(",").map((type) => type.replace("image/", ".")).join("\u3001");
8850
+ });
8851
+ watch(
8852
+ () => props.modelValue,
8853
+ (val) => {
8854
+ if (val.length) {
8855
+ previewList.value = val.map((item) => ({
8856
+ ...item,
8857
+ url: item.url || item.response?.url || ""
8858
+ }));
8859
+ fileList.value = val;
8860
+ }
8861
+ },
8862
+ { immediate: true, deep: true }
8863
+ );
8864
+ const uploadSingleFile = async (file) => {
8865
+ if (!props.uploadApi || !axios.value) {
8866
+ throw new Error("\u672A\u914D\u7F6E\u4E0A\u4F20 API");
8867
+ }
8868
+ const formData = new FormData();
8869
+ formData.append(props.uploadApi.fieldName || "file", file);
8870
+ if (props.uploadApi.data) {
8871
+ Object.keys(props.uploadApi.data).forEach((key) => {
8872
+ formData.append(key, props.uploadApi.data[key]);
8873
+ });
8874
+ }
8875
+ const method = props.uploadApi.method || "post";
8876
+ const response = await axios.value[method](props.uploadApi.url, formData, {
8877
+ headers: {
8878
+ "Content-Type": "multipart/form-data"
8879
+ }
8880
+ });
8881
+ const urlField = props.uploadApi.responseUrlField || "data.url";
8882
+ return getNestedValue(response, urlField);
8883
+ };
8884
+ const handleBeforeUpload = (file) => {
8885
+ const isAccept = props.acceptType.includes(file.type);
8886
+ if (!isAccept) {
8887
+ ElMessage.error(`\u4EC5\u652F\u6301\u4E0A\u4F20${acceptDesc.value}\u683C\u5F0F\u7684\u56FE\u7247`);
8888
+ return false;
8889
+ }
8890
+ const isOverSize = file.size / 1024 / 1024 > props.sizeLimit.size;
8891
+ if (isOverSize) {
8892
+ ElMessage.error(`\u5355\u6587\u4EF6\u5927\u5C0F\u4E0D\u80FD\u8D85\u8FC7${props.sizeLimit.size}MB`);
8893
+ return false;
8894
+ }
8895
+ if (previewList.value.length >= props.maxCount) {
8896
+ ElMessage.error(`\u6700\u591A\u53EA\u80FD\u4E0A\u4F20${props.maxCount}\u5F20\u56FE\u7247`);
8897
+ return false;
8898
+ }
8899
+ if (props.sizeLimit.width || props.sizeLimit.height) {
8900
+ return new Promise((resolve) => {
8901
+ const img = new Image();
8902
+ img.onload = () => {
8903
+ const isOverWidth = props.sizeLimit.width && img.width < props.sizeLimit.width;
8904
+ const isOverHeight = props.sizeLimit.height && img.height < props.sizeLimit.height;
8905
+ if (isOverWidth || isOverHeight) {
8906
+ ElMessage.error(
8907
+ `\u56FE\u7247\u5C3A\u5BF8\u8981\u6C42\uFF1A\u5BBD\u2265${props.sizeLimit.width}px \u9AD8\u2265${props.sizeLimit.height}px\uFF0C\u5F53\u524D\u56FE\u7247\u5BBD${img.width}px \u9AD8${img.height}px`
8908
+ );
8909
+ resolve(false);
8910
+ } else {
8911
+ resolve(true);
8912
+ }
8913
+ };
8914
+ img.src = URL.createObjectURL(file);
8915
+ });
8916
+ }
8917
+ return true;
8918
+ };
8919
+ const handleFileChange = async (file, files) => {
8920
+ if (file.status === "ready") {
8921
+ const blobUrl = URL.createObjectURL(file.raw);
8922
+ const newItem = {
8923
+ ...file,
8924
+ rawFile: file.raw,
8925
+ blobUrl,
8926
+ // 保存 blob URL 用于裁剪
8927
+ url: blobUrl
8928
+ // 初始显示使用 blob URL
8929
+ };
8930
+ if (props.allowCrop) {
8931
+ ElMessageBox.confirm("\u662F\u5426\u9700\u8981\u88C1\u526A\u8BE5\u56FE\u7247\uFF1F", "\u63D0\u793A", {
8932
+ type: "info",
8933
+ confirmButtonText: "\u88C1\u526A",
8934
+ cancelButtonText: "\u76F4\u63A5\u4E0A\u4F20"
8935
+ }).then(() => {
8936
+ handleCropImage(newItem);
8937
+ }).catch(async () => {
8938
+ if (props.autoUpload && props.uploadApi) {
8939
+ try {
8940
+ const uploadedUrl = await uploadSingleFile(file.raw);
8941
+ newItem.serverUrl = uploadedUrl;
8942
+ newItem.url = uploadedUrl;
8943
+ ElMessage.success("\u56FE\u7247\u4E0A\u4F20\u6210\u529F");
8944
+ } catch (error) {
8945
+ ElMessage.error("\u56FE\u7247\u4E0A\u4F20\u5931\u8D25");
8946
+ console.error(error);
8947
+ return;
8948
+ }
8949
+ }
8950
+ previewList.value.push(newItem);
8951
+ syncModelValue();
8952
+ });
8953
+ } else {
8954
+ if (props.autoUpload && props.uploadApi) {
8955
+ try {
8956
+ const uploadedUrl = await uploadSingleFile(file.raw);
8957
+ newItem.serverUrl = uploadedUrl;
8958
+ newItem.url = uploadedUrl;
8959
+ ElMessage.success("\u56FE\u7247\u4E0A\u4F20\u6210\u529F");
8960
+ } catch (error) {
8961
+ ElMessage.error("\u56FE\u7247\u4E0A\u4F20\u5931\u8D25");
8962
+ console.error(error);
8963
+ return;
8964
+ }
8965
+ }
8966
+ previewList.value.push(newItem);
8967
+ syncModelValue();
8968
+ }
8969
+ }
8970
+ fileList.value = files;
8971
+ };
8972
+ const handleFileRemove = (file) => {
8973
+ previewList.value = previewList.value.filter((item) => item.uid !== file.uid);
8974
+ syncModelValue();
8975
+ };
8976
+ const handleCropImage = (item) => {
8977
+ console.log(item);
8978
+ if (!props.allowCrop) return;
8979
+ cropTargetItem.value = item;
8980
+ cropImageUrl.value = item.blobUrl || item.url || "";
8981
+ cropDialogVisible.value = true;
8982
+ nextTick(() => {
8983
+ cropForm.aspectRatio = "free";
8984
+ cropWidth.value = props.sizeLimit.width || 400;
8985
+ cropHeight.value = props.sizeLimit.height || 400;
8986
+ displayWidth.value = props.sizeLimit.width || 400;
8987
+ displayHeight.value = props.sizeLimit.height || 400;
8988
+ aspectRatio.fixed = false;
8989
+ });
8990
+ };
8991
+ const handleAspectRatioChange = (val) => {
8992
+ if (val === "free") {
8993
+ aspectRatio.fixed = false;
8994
+ } else {
8995
+ aspectRatio.fixed = true;
8996
+ const parts = val.split(":").map(Number);
8997
+ const w = parts[0] ?? 1;
8998
+ const h = parts[1] ?? 1;
8999
+ aspectRatio.value = [w, h];
9000
+ }
9001
+ };
9002
+ const handleCropRealTime = (data) => {
9003
+ if (data && data.w && data.h) {
9004
+ displayWidth.value = Math.round(data.w);
9005
+ displayHeight.value = Math.round(data.h);
9006
+ }
9007
+ };
9008
+ const handleSizeChange = () => {
9009
+ cropWidth.value = displayWidth.value;
9010
+ cropHeight.value = displayHeight.value;
9011
+ };
9012
+ const handleCropConfirm = () => {
9013
+ if (!cropperRef.value || !cropTargetItem.value) return;
9014
+ cropperRef.value.getCropBlob(async (blob) => {
9015
+ const croppedFile = new File([blob], cropTargetItem.value.name || "cropped.jpg", {
9016
+ type: cropTargetItem.value.rawFile?.type || "image/jpeg"
9017
+ });
9018
+ const newBlobUrl = URL.createObjectURL(croppedFile);
9019
+ let displayUrl = newBlobUrl;
9020
+ if (props.autoUpload && props.uploadApi) {
9021
+ try {
9022
+ const serverUrl = await uploadSingleFile(croppedFile);
9023
+ displayUrl = serverUrl;
9024
+ ElMessage.success("\u56FE\u7247\u4E0A\u4F20\u6210\u529F");
9025
+ const index = previewList.value.findIndex((item) => item.uid === cropTargetItem.value.uid);
9026
+ const targetItem = previewList.value[index];
9027
+ if (index > -1 && targetItem) {
9028
+ targetItem.url = displayUrl;
9029
+ targetItem.blobUrl = newBlobUrl;
9030
+ targetItem.serverUrl = serverUrl;
9031
+ targetItem.rawFile = croppedFile;
9032
+ } else {
9033
+ previewList.value.push({
9034
+ ...cropTargetItem.value,
9035
+ name: cropTargetItem.value.name ?? "cropped.jpg",
9036
+ url: displayUrl,
9037
+ blobUrl: newBlobUrl,
9038
+ serverUrl,
9039
+ rawFile: croppedFile
9040
+ });
9041
+ }
9042
+ } catch (error) {
9043
+ ElMessage.error("\u56FE\u7247\u4E0A\u4F20\u5931\u8D25");
9044
+ console.error(error);
9045
+ return;
9046
+ }
9047
+ } else {
9048
+ const index = previewList.value.findIndex((item) => item.uid === cropTargetItem.value.uid);
9049
+ const targetItem = previewList.value[index];
9050
+ if (index > -1 && targetItem) {
9051
+ targetItem.url = newBlobUrl;
9052
+ targetItem.blobUrl = newBlobUrl;
9053
+ targetItem.rawFile = croppedFile;
9054
+ } else {
9055
+ previewList.value.push({
9056
+ ...cropTargetItem.value,
9057
+ name: cropTargetItem.value.name ?? "cropped.jpg",
9058
+ url: newBlobUrl,
9059
+ blobUrl: newBlobUrl,
9060
+ rawFile: croppedFile
9061
+ });
9062
+ }
9063
+ }
9064
+ syncModelValue();
9065
+ cropDialogVisible.value = false;
9066
+ ElMessage.success("\u56FE\u7247\u88C1\u526A\u6210\u529F");
9067
+ });
9068
+ };
9069
+ const resetCropper = () => {
9070
+ cropTargetItem.value = void 0;
9071
+ cropImageUrl.value = "";
9072
+ };
9073
+ const handleRemovePreview = (item) => {
9074
+ ElMessageBox.confirm("\u786E\u5B9A\u8981\u5220\u9664\u8BE5\u56FE\u7247\u5417\uFF1F", "\u63D0\u793A", {
9075
+ type: "warning",
9076
+ confirmButtonText: "\u786E\u5B9A",
9077
+ cancelButtonText: "\u53D6\u6D88"
9078
+ }).then(() => {
9079
+ previewList.value = previewList.value.filter((i) => i.uid !== item.uid);
9080
+ fileList.value = fileList.value.filter((i) => i.uid !== item.uid);
9081
+ syncModelValue();
9082
+ ElMessage.success("\u56FE\u7247\u5220\u9664\u6210\u529F");
9083
+ });
9084
+ };
9085
+ const handleDragStart = (index) => {
9086
+ if (!props.allowSort) return;
9087
+ dragIndex.value = index;
9088
+ };
9089
+ const handleDragOver = (e) => {
9090
+ e.preventDefault();
9091
+ };
9092
+ const handleDrop = (index) => {
9093
+ if (!props.allowSort || dragIndex.value === -1 || dragIndex.value === index) return;
9094
+ const temp = previewList.value[dragIndex.value];
9095
+ if (!temp) return;
9096
+ previewList.value.splice(dragIndex.value, 1);
9097
+ previewList.value.splice(index, 0, temp);
9098
+ dragIndex.value = -1;
9099
+ syncModelValue();
9100
+ };
9101
+ const syncModelValue = () => {
9102
+ emit("update:modelValue", [...previewList.value]);
9103
+ emit("change", [...previewList.value]);
9104
+ };
9105
+ const emit = __emit;
9106
+ const uploadToServer = async (uploadApi) => {
9107
+ const uploadPromises = previewList.value.map(async (item) => {
9108
+ if (item.rawFile) {
9109
+ const url = await uploadApi(item.rawFile);
9110
+ item.url = url;
9111
+ return item;
9112
+ }
9113
+ return item;
9114
+ });
9115
+ const result = await Promise.all(uploadPromises);
9116
+ previewList.value = result;
9117
+ syncModelValue();
9118
+ return result;
9119
+ };
9120
+ __expose({
9121
+ uploadToServer,
9122
+ // 暴露上传到服务器的方法
9123
+ clear: () => {
9124
+ previewList.value = [];
9125
+ fileList.value = [];
9126
+ syncModelValue();
9127
+ }
9128
+ });
9129
+ return (_ctx, _cache) => {
9130
+ const _component_el_button = resolveComponent("el-button");
9131
+ const _component_el_upload = resolveComponent("el-upload");
9132
+ const _component_el_image = resolveComponent("el-image");
9133
+ const _component_el_option = resolveComponent("el-option");
9134
+ const _component_el_select = resolveComponent("el-select");
9135
+ const _component_el_form_item = resolveComponent("el-form-item");
9136
+ const _component_el_col = resolveComponent("el-col");
9137
+ const _component_el_input_number = resolveComponent("el-input-number");
9138
+ const _component_el_row = resolveComponent("el-row");
9139
+ const _component_el_form = resolveComponent("el-form");
9140
+ const _component_el_dialog = resolveComponent("el-dialog");
9141
+ return openBlock(), createElementBlock(
9142
+ "div",
9143
+ {
9144
+ class: normalizeClass(unref(bem)("image-upload-pro"))
9145
+ },
9146
+ [
9147
+ createCommentVNode(" \u6838\u5FC3\u4E0A\u4F20\u533A\u57DF "),
9148
+ createVNode(_component_el_upload, {
9149
+ ref_key: "uploadRef",
9150
+ ref: uploadRef,
9151
+ class: normalizeClass(unref(bem)("image-upload-pro", "upload-container")),
9152
+ action: "",
9153
+ "auto-upload": false,
9154
+ "file-list": fileList.value,
9155
+ "before-upload": handleBeforeUpload,
9156
+ "on-change": handleFileChange,
9157
+ "on-remove": handleFileRemove,
9158
+ accept: _ctx.acceptType,
9159
+ "show-file-list": false
9160
+ }, {
9161
+ tip: withCtx(() => [
9162
+ createElementVNode(
9163
+ "div",
9164
+ {
9165
+ class: normalizeClass(unref(bem)("image-upload-pro", "upload-text"))
9166
+ },
9167
+ [
9168
+ createTextVNode(
9169
+ " \u652F\u6301\u683C\u5F0F\uFF1A" + toDisplayString(acceptDesc.value) + " | \u5355\u6587\u4EF6\u5927\u5C0F\u2264" + toDisplayString(props.sizeLimit.size) + "MB ",
9170
+ 1
9171
+ /* TEXT */
9172
+ ),
9173
+ props.sizeLimit.width || props.sizeLimit.height ? (openBlock(), createElementBlock(
9174
+ "span",
9175
+ _hoisted_1,
9176
+ " | \u5C3A\u5BF8\u8981\u6C42\uFF1A\u5BBD\u2265" + toDisplayString(props.sizeLimit.width) + "px \u9AD8\u2265" + toDisplayString(props.sizeLimit.height) + "px ",
9177
+ 1
9178
+ /* TEXT */
9179
+ )) : createCommentVNode("v-if", true)
9180
+ ],
9181
+ 2
9182
+ /* CLASS */
9183
+ )
9184
+ ]),
9185
+ default: withCtx(() => [
9186
+ createVNode(_component_el_button, {
9187
+ disabled: fileList.value.length === props.maxCount,
9188
+ type: "primary"
9189
+ }, {
9190
+ default: withCtx(() => [..._cache[6] || (_cache[6] = [
9191
+ createTextVNode(
9192
+ "\u9009\u62E9\u56FE\u7247",
9193
+ -1
9194
+ /* CACHED */
9195
+ )
9196
+ ])]),
9197
+ _: 1
9198
+ /* STABLE */
9199
+ }, 8, ["disabled"])
9200
+ ]),
9201
+ _: 1
9202
+ /* STABLE */
9203
+ }, 8, ["class", "file-list", "accept"]),
9204
+ createCommentVNode(" \u5DF2\u4E0A\u4F20\u56FE\u7247\u9884\u89C8\u5217\u8868 "),
9205
+ previewList.value.length ? (openBlock(), createElementBlock(
9206
+ "div",
9207
+ {
9208
+ key: 0,
9209
+ class: normalizeClass(unref(bem)("image-upload-pro", "preview-list"))
9210
+ },
9211
+ [
9212
+ (openBlock(true), createElementBlock(
9213
+ Fragment,
9214
+ null,
9215
+ renderList(previewList.value, (item, index) => {
9216
+ return openBlock(), createElementBlock("div", {
9217
+ class: normalizeClass([unref(bem)("image-upload-pro", "preview-item"), { active: item.isCover }]),
9218
+ key: item.uid,
9219
+ draggable: "true",
9220
+ onDragstart: ($event) => handleDragStart(index),
9221
+ onDragover: _cache[0] || (_cache[0] = ($event) => handleDragOver($event)),
9222
+ onDrop: ($event) => handleDrop(index)
9223
+ }, [
9224
+ createCommentVNode(" \u56FE\u7247\u9884\u89C8 "),
9225
+ createElementVNode(
9226
+ "div",
9227
+ {
9228
+ class: normalizeClass(unref(bem)("image-upload-pro", "preview-img"))
9229
+ },
9230
+ [
9231
+ createVNode(_component_el_image, {
9232
+ src: item.url,
9233
+ "preview-src-list": previewList.value.map((i) => i.url),
9234
+ "preview-current-index": index,
9235
+ fit: "cover"
9236
+ }, null, 8, ["src", "preview-src-list", "preview-current-index"])
9237
+ ],
9238
+ 2
9239
+ /* CLASS */
9240
+ ),
9241
+ createCommentVNode(" \u64CD\u4F5C\u6309\u94AE\u7EC4 "),
9242
+ createElementVNode(
9243
+ "div",
9244
+ {
9245
+ class: normalizeClass(unref(bem)("image-upload-pro", "preview-actions"))
9246
+ },
9247
+ [
9248
+ createVNode(_component_el_button, {
9249
+ type: "primary",
9250
+ text: "",
9251
+ size: "small",
9252
+ onClick: ($event) => handleCropImage(item)
9253
+ }, {
9254
+ default: withCtx(() => [..._cache[7] || (_cache[7] = [
9255
+ createTextVNode(
9256
+ "\u88C1\u526A",
9257
+ -1
9258
+ /* CACHED */
9259
+ )
9260
+ ])]),
9261
+ _: 1
9262
+ /* STABLE */
9263
+ }, 8, ["onClick"]),
9264
+ createVNode(_component_el_button, {
9265
+ text: "",
9266
+ size: "small",
9267
+ type: "danger",
9268
+ onClick: ($event) => handleRemovePreview(item)
9269
+ }, {
9270
+ default: withCtx(() => [..._cache[8] || (_cache[8] = [
9271
+ createTextVNode(
9272
+ "\u5220\u9664",
9273
+ -1
9274
+ /* CACHED */
9275
+ )
9276
+ ])]),
9277
+ _: 1
9278
+ /* STABLE */
9279
+ }, 8, ["onClick"])
9280
+ ],
9281
+ 2
9282
+ /* CLASS */
9283
+ )
9284
+ ], 42, _hoisted_2);
9285
+ }),
9286
+ 128
9287
+ /* KEYED_FRAGMENT */
9288
+ ))
9289
+ ],
9290
+ 2
9291
+ /* CLASS */
9292
+ )) : createCommentVNode("v-if", true),
9293
+ createCommentVNode(" \u88C1\u526A\u5F39\u7A97 "),
9294
+ createVNode(_component_el_dialog, {
9295
+ modelValue: cropDialogVisible.value,
9296
+ "onUpdate:modelValue": _cache[5] || (_cache[5] = ($event) => cropDialogVisible.value = $event),
9297
+ title: "\u56FE\u7247\u88C1\u526A",
9298
+ width: "900px",
9299
+ "close-on-click-modal": false,
9300
+ "destroy-on-close": "",
9301
+ onClose: resetCropper
9302
+ }, {
9303
+ footer: withCtx(() => [
9304
+ createVNode(_component_el_button, {
9305
+ onClick: _cache[4] || (_cache[4] = ($event) => cropDialogVisible.value = false)
9306
+ }, {
9307
+ default: withCtx(() => [..._cache[10] || (_cache[10] = [
9308
+ createTextVNode(
9309
+ "\u53D6\u6D88",
9310
+ -1
9311
+ /* CACHED */
9312
+ )
9313
+ ])]),
9314
+ _: 1
9315
+ /* STABLE */
9316
+ }),
9317
+ createVNode(_component_el_button, {
9318
+ type: "primary",
9319
+ onClick: handleCropConfirm
9320
+ }, {
9321
+ default: withCtx(() => [..._cache[11] || (_cache[11] = [
9322
+ createTextVNode(
9323
+ "\u786E\u8BA4\u88C1\u526A",
9324
+ -1
9325
+ /* CACHED */
9326
+ )
9327
+ ])]),
9328
+ _: 1
9329
+ /* STABLE */
9330
+ })
9331
+ ]),
9332
+ default: withCtx(() => [
9333
+ createElementVNode(
9334
+ "div",
9335
+ {
9336
+ class: normalizeClass(unref(bem)("image-upload-pro", "cropper-container"))
9337
+ },
9338
+ [
9339
+ createCommentVNode(" \u88C1\u526A\u533A\u57DF "),
9340
+ createVNode(unref(M), {
9341
+ ref_key: "cropperRef",
9342
+ ref: cropperRef,
9343
+ img: cropImageUrl.value,
9344
+ info: true,
9345
+ "auto-crop": true,
9346
+ "auto-crop-width": cropWidth.value,
9347
+ "auto-crop-height": cropHeight.value,
9348
+ fixed: aspectRatio.fixed,
9349
+ "fixed-number": aspectRatio.value,
9350
+ "can-move": true,
9351
+ "can-scale": true,
9352
+ "can-rotate": false,
9353
+ onRealTime: handleCropRealTime
9354
+ }, null, 8, ["img", "auto-crop-width", "auto-crop-height", "fixed", "fixed-number"])
9355
+ ],
9356
+ 2
9357
+ /* CLASS */
9358
+ ),
9359
+ createElementVNode(
9360
+ "div",
9361
+ {
9362
+ class: normalizeClass(unref(bem)("image-upload-pro", "cropper-config"))
9363
+ },
9364
+ [
9365
+ createVNode(_component_el_form, { model: cropForm }, {
9366
+ default: withCtx(() => [
9367
+ createVNode(_component_el_row, { gutter: 10 }, {
9368
+ default: withCtx(() => [
9369
+ createVNode(_component_el_col, { span: 8 }, {
9370
+ default: withCtx(() => [
9371
+ createVNode(_component_el_form_item, { label: "\u88C1\u526A\u6BD4\u4F8B" }, {
9372
+ default: withCtx(() => [
9373
+ createVNode(_component_el_select, {
9374
+ style: { "width": "100%" },
9375
+ modelValue: cropForm.aspectRatio,
9376
+ "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => cropForm.aspectRatio = $event),
9377
+ onChange: handleAspectRatioChange
9378
+ }, {
9379
+ default: withCtx(() => [
9380
+ (openBlock(), createElementBlock(
9381
+ Fragment,
9382
+ null,
9383
+ renderList(ASPECT_RATIO_OPTIONS, (option) => {
9384
+ return createVNode(_component_el_option, {
9385
+ key: option.value,
9386
+ label: option.label,
9387
+ value: option.value
9388
+ }, null, 8, ["label", "value"]);
9389
+ }),
9390
+ 64
9391
+ /* STABLE_FRAGMENT */
9392
+ ))
9393
+ ]),
9394
+ _: 1
9395
+ /* STABLE */
9396
+ }, 8, ["modelValue"])
9397
+ ]),
9398
+ _: 1
9399
+ /* STABLE */
9400
+ })
9401
+ ]),
9402
+ _: 1
9403
+ /* STABLE */
9404
+ }),
9405
+ createVNode(_component_el_col, { span: 16 }, {
9406
+ default: withCtx(() => [
9407
+ createVNode(_component_el_form_item, { label: "\u88C1\u526A\u5C3A\u5BF8" }, {
9408
+ default: withCtx(() => [
9409
+ createVNode(_component_el_input_number, {
9410
+ modelValue: displayWidth.value,
9411
+ "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => displayWidth.value = $event),
9412
+ placeholder: "\u5BBD\u5EA6",
9413
+ min: props.sizeLimit.width || 100,
9414
+ onChange: handleSizeChange
9415
+ }, null, 8, ["modelValue", "min"]),
9416
+ _cache[9] || (_cache[9] = createElementVNode(
9417
+ "span",
9418
+ { style: { "margin": "0 8px" } },
9419
+ "*",
9420
+ -1
9421
+ /* CACHED */
9422
+ )),
9423
+ createVNode(_component_el_input_number, {
9424
+ modelValue: displayHeight.value,
9425
+ "onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => displayHeight.value = $event),
9426
+ placeholder: "\u9AD8\u5EA6",
9427
+ min: props.sizeLimit.height || 100,
9428
+ onChange: handleSizeChange
9429
+ }, null, 8, ["modelValue", "min"])
9430
+ ]),
9431
+ _: 1
9432
+ /* STABLE */
9433
+ })
9434
+ ]),
9435
+ _: 1
9436
+ /* STABLE */
9437
+ })
9438
+ ]),
9439
+ _: 1
9440
+ /* STABLE */
9441
+ })
9442
+ ]),
9443
+ _: 1
9444
+ /* STABLE */
9445
+ }, 8, ["model"])
9446
+ ],
9447
+ 2
9448
+ /* CLASS */
9449
+ )
9450
+ ]),
9451
+ _: 1
9452
+ /* STABLE */
9453
+ }, 8, ["modelValue"])
9454
+ ],
9455
+ 2
9456
+ /* CLASS */
9457
+ );
9458
+ };
9459
+ }
9460
+ });
9461
+
9462
+ const MlImageUploadPro = withInstall(_sfc_main);
7018
9463
 
7019
9464
  var components = /*#__PURE__*/Object.freeze({
7020
9465
  __proto__: null,
7021
9466
  MlButton: MlButton,
7022
9467
  MlChart: MlChart,
7023
9468
  MlDetail: MlDetail,
9469
+ MlImageUploadPro: MlImageUploadPro,
7024
9470
  MlNumberRangeInput: MlNumberRangeInput,
7025
9471
  MlSearch: MlSearch,
7026
9472
  MlSearchTable: MlSearchTable,
7027
- MlVirtualList: MlVirtualList
9473
+ MlTreeSelect: MlTreeSelect,
9474
+ MlTreeSelectDialog: MlTreeSelectDialog,
9475
+ MlTreeSelectDrawer: MlTreeSelectDrawer,
9476
+ MlVirtualList: MlVirtualList,
9477
+ dialogPropKeys: dialogPropKeys,
9478
+ drawerPropKeys: drawerPropKeys,
9479
+ imageUploadProProps: imageUploadProProps
7028
9480
  });
7029
9481
 
7030
9482
  const MsUIComponentsInstance = Object.values(components);
@@ -7038,4 +9490,4 @@ var index = {
7038
9490
  }
7039
9491
  };
7040
9492
 
7041
- export { MlButton, MlChart, MlDetail, MlNumberRangeInput, MlSearch, MlSearchTable, MlVirtualList, MsUIComponentsInstance, MsUIComponentsName, index as default };
9493
+ export { MlButton, MlChart, MlDetail, MlImageUploadPro, MlNumberRangeInput, MlSearch, MlSearchTable, MlTreeSelect, MlTreeSelectDialog, MlTreeSelectDrawer, MlVirtualList, MsUIComponentsInstance, MsUIComponentsName, index as default, dialogPropKeys, drawerPropKeys, imageUploadProProps };