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