@minilo/ui 0.0.6 → 0.0.7

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 (47) hide show
  1. package/minilo/dist/index.full.js +186 -214
  2. package/minilo/dist/index.full.min.js +1 -1
  3. package/minilo/dist/index.full.min.js.map +1 -1
  4. package/minilo/dist/index.full.min.mjs +1 -1
  5. package/minilo/dist/index.full.min.mjs.map +1 -1
  6. package/minilo/dist/index.full.mjs +186 -214
  7. package/minilo/es/components/image-upload-pro/index.vue2.mjs +2 -2
  8. package/minilo/es/components/search/index.vue2.mjs +0 -1
  9. package/minilo/es/components/search-table/index.vue.d.ts +16 -0
  10. package/minilo/es/components/search-table/index.vue2.mjs +6 -3
  11. package/minilo/es/components/tree-select/index.d.ts +4 -2
  12. package/minilo/es/components/tree-select/index.vue.d.ts +5 -2
  13. package/minilo/es/components/tree-select/index.vue2.mjs +8 -5
  14. package/minilo/es/components/tree-select-dialog/index.d.ts +2 -0
  15. package/minilo/es/components/tree-select-dialog/index.vue.d.ts +3 -0
  16. package/minilo/es/components/tree-select-dialog/index.vue2.mjs +14 -6
  17. package/minilo/es/components/tree-select-drawer/index.d.ts +2 -0
  18. package/minilo/es/components/tree-select-drawer/index.vue.d.ts +3 -0
  19. package/minilo/es/components/tree-select-drawer/index.vue2.mjs +14 -6
  20. package/minilo/es/components/virtual-list/index.vue2.mjs +3 -1
  21. package/minilo/es/packages/utils/dist/request/index.mjs +105 -0
  22. package/minilo/es/resolver/index.mjs +1 -4
  23. package/minilo/lib/components/image-upload-pro/index.vue2.js +2 -2
  24. package/minilo/lib/components/search/index.vue2.js +0 -1
  25. package/minilo/lib/components/search-table/index.vue.d.ts +16 -0
  26. package/minilo/lib/components/search-table/index.vue2.js +6 -3
  27. package/minilo/lib/components/tree-select/index.d.ts +4 -2
  28. package/minilo/lib/components/tree-select/index.vue.d.ts +5 -2
  29. package/minilo/lib/components/tree-select/index.vue2.js +7 -4
  30. package/minilo/lib/components/tree-select-dialog/index.d.ts +2 -0
  31. package/minilo/lib/components/tree-select-dialog/index.vue.d.ts +3 -0
  32. package/minilo/lib/components/tree-select-dialog/index.vue2.js +14 -6
  33. package/minilo/lib/components/tree-select-drawer/index.d.ts +2 -0
  34. package/minilo/lib/components/tree-select-drawer/index.vue.d.ts +3 -0
  35. package/minilo/lib/components/tree-select-drawer/index.vue2.js +14 -6
  36. package/minilo/lib/components/virtual-list/index.vue2.js +3 -1
  37. package/minilo/lib/packages/utils/dist/request/index.js +115 -0
  38. package/minilo/lib/resolver/index.js +1 -4
  39. package/package.json +2 -2
  40. package/minilo/es/components/search-table/index.d.ts +0 -274
  41. package/minilo/es/index.d.ts +0 -1724
  42. package/minilo/es/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 -110
  43. package/minilo/lib/components/search-table/index.d.ts +0 -274
  44. package/minilo/lib/index.d.ts +0 -1724
  45. package/minilo/lib/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 -120
  46. /package/minilo/es/{node_modules/.pnpm/@minilo_utils@0.0.2_vue@3.5.26_typescript@5.9.3_/node_modules/@minilo → packages}/utils/dist/func/common.mjs +0 -0
  47. /package/minilo/lib/{node_modules/.pnpm/@minilo_utils@0.0.2_vue@3.5.26_typescript@5.9.3_/node_modules/@minilo → packages}/utils/dist/func/common.js +0 -0
@@ -2183,7 +2183,6 @@ var _sfc_main$b = /* @__PURE__ */ defineComponent({
2183
2183
  emit("reset");
2184
2184
  };
2185
2185
  onMounted(() => {
2186
- console.log(props);
2187
2186
  const itemProps = props.item.map((item) => ({
2188
2187
  type: SearchTypeEnum.ITEM,
2189
2188
  ...item
@@ -5473,14 +5472,10 @@ class TinyColor {
5473
5472
  }
5474
5473
  }
5475
5474
 
5476
- // 将颜色转换为HSL格式
5477
5475
  function convertToHsl(color) {
5478
- // 使用TinyColor库将颜色转换为HSL格式
5479
5476
  const { a, h, l, s } = new TinyColor(color).toHsl();
5480
- // 将HSL格式转换为字符串
5481
5477
  const hsl = `hsl(${Math.round(h)} ${Math.round(s * 100)}% ${Math.round(l * 100)}%)`;
5482
- // 如果颜色的透明度小于1,则返回带有透明度的HSL格式
5483
- return a < 1 ? `${hsl} ${a}` : hsl
5478
+ return a < 1 ? `${hsl} ${a}` : hsl;
5484
5479
  }
5485
5480
 
5486
5481
  function isPlainObject(value) {
@@ -5539,54 +5534,34 @@ function createDefu(merger) {
5539
5534
  }
5540
5535
  const defu = createDefu();
5541
5536
 
5542
- /**
5543
- * @description 判断url是否是http或https
5544
- * @author xieshuhong
5545
- * @export
5546
- * @param {string} url
5547
- * @return {*}
5548
- */
5549
- /**
5550
- * @description 根据多层级键路径从对象中获取值
5551
- * @author xieshuhong
5552
- * @param {Object} obj - 要查询的对象
5553
- * @param {string} path - 键路径,如 'a.b' 或 'a.b.c'
5554
- * @param {any} [defaultValue] - 可选,路径不存在时返回的默认值
5555
- * @returns {any} 路径对应的 value 或 defaultValue
5556
- */
5557
5537
  function getNestedValue(obj, path, defaultValue) {
5558
- // 处理边界情况:如果obj不是对象或path为空,直接返回默认值
5559
- if (typeof obj !== 'object' || obj === null || !path) {
5560
- return defaultValue
5538
+ if (typeof obj !== "object" || obj === null || !path) {
5539
+ return defaultValue;
5561
5540
  }
5562
- // 将路径按 '.' 分割成数组(支持处理空字符串和连续点的情况)
5563
- const keys = path.split('.').filter((key) => key !== '');
5564
- // 逐层访问对象属性
5541
+ const keys = path.split(".").filter((key) => key !== "");
5565
5542
  return keys.reduce((current, key) => {
5566
- // 如果当前值不是对象,直接返回默认值(避免访问非对象的属性)
5567
- if (typeof current !== 'object' || current === null) {
5568
- return defaultValue
5543
+ if (typeof current !== "object" || current === null) {
5544
+ return defaultValue;
5569
5545
  }
5570
- // 访问下一级属性
5571
- return current[key] !== undefined ? current[key] : defaultValue
5572
- }, obj)
5546
+ return current[key] !== void 0 ? current[key] : defaultValue;
5547
+ }, obj);
5573
5548
  }
5574
5549
 
5575
5550
  const config = {
5576
5551
  theme: {
5577
- colorDestructive: 'hsl(348 100% 61%)',
5578
- colorPrimary: 'hsl(212 100% 45%)',
5579
- colorSuccess: 'hsl(144 57% 58%)',
5580
- colorWarning: 'hsl(42 84% 61%)'
5552
+ colorDestructive: "hsl(348 100% 61%)",
5553
+ colorPrimary: "hsl(212 100% 45%)",
5554
+ colorSuccess: "hsl(144 57% 58%)",
5555
+ colorWarning: "hsl(42 84% 61%)"
5581
5556
  },
5582
5557
  sidebar: {
5583
5558
  collapse: false
5584
5559
  },
5585
5560
  app: {
5586
- locale: 'zh-CN',
5587
- name: 'Minilo Adminss',
5588
- logo: '',
5589
- defaultHomePath: '/'
5561
+ locale: "zh-CN",
5562
+ name: "Minilo Adminss",
5563
+ logo: "",
5564
+ defaultHomePath: "/"
5590
5565
  },
5591
5566
  transition: {
5592
5567
  progress: true
@@ -5594,14 +5569,20 @@ const config = {
5594
5569
  };
5595
5570
 
5596
5571
  class StorageManager {
5597
- constructor({ prefix = '', storageType = 'localStorage' } = {}) {
5572
+ constructor({ prefix = "", storageType = "localStorage" } = {}) {
5598
5573
  this.prefix = prefix;
5599
- this.storage = storageType === 'localStorage' ? window.localStorage : window.sessionStorage;
5574
+ if (typeof window !== "undefined") {
5575
+ this.storage = storageType === "localStorage" ? window.localStorage : window.sessionStorage;
5576
+ } else {
5577
+ this.storage = null;
5578
+ }
5600
5579
  }
5601
5580
  /**
5602
5581
  * 清除所有带前缀的存储项
5603
5582
  */
5604
5583
  clear() {
5584
+ if (!this.storage)
5585
+ return;
5605
5586
  const keysToRemove = [];
5606
5587
  for (let i = 0; i < this.storage.length; i++) {
5607
5588
  const key = this.storage.key(i);
@@ -5609,17 +5590,19 @@ class StorageManager {
5609
5590
  keysToRemove.push(key);
5610
5591
  }
5611
5592
  }
5612
- keysToRemove.forEach((key) => this.storage.removeItem(key));
5593
+ keysToRemove.forEach((key) => this.storage?.removeItem(key));
5613
5594
  }
5614
5595
  /**
5615
5596
  * 清除所有过期的存储项
5616
5597
  */
5617
5598
  clearExpiredItems() {
5599
+ if (!this.storage)
5600
+ return;
5618
5601
  for (let i = 0; i < this.storage.length; i++) {
5619
5602
  const key = this.storage.key(i);
5620
5603
  if (key && key.startsWith(this.prefix)) {
5621
- const shortKey = key.replace(this.prefix, '');
5622
- this.getItem(shortKey); // 调用 getItem 方法检查并移除过期项
5604
+ const shortKey = key.replace(this.prefix, "");
5605
+ this.getItem(shortKey);
5623
5606
  }
5624
5607
  }
5625
5608
  }
@@ -5630,22 +5613,24 @@ class StorageManager {
5630
5613
  * @returns 值,如果项已过期或解析错误则返回默认值
5631
5614
  */
5632
5615
  getItem(key, defaultValue = null) {
5616
+ if (!this.storage)
5617
+ return defaultValue;
5633
5618
  const fullKey = this.getFullKey(key);
5634
5619
  const itemStr = this.storage.getItem(fullKey);
5635
5620
  if (!itemStr) {
5636
- return defaultValue
5621
+ return defaultValue;
5637
5622
  }
5638
5623
  try {
5639
5624
  const item = JSON.parse(itemStr);
5640
5625
  if (item.expiry && Date.now() > item.expiry) {
5641
5626
  this.storage.removeItem(fullKey);
5642
- return defaultValue
5627
+ return defaultValue;
5643
5628
  }
5644
- return item.value
5629
+ return item.value;
5645
5630
  } catch (error) {
5646
5631
  console.error(`Error parsing item with key "${fullKey}":`, error);
5647
- this.storage.removeItem(fullKey); // 如果解析失败,删除该项
5648
- return defaultValue
5632
+ this.storage.removeItem(fullKey);
5633
+ return defaultValue;
5649
5634
  }
5650
5635
  }
5651
5636
  /**
@@ -5653,6 +5638,8 @@ class StorageManager {
5653
5638
  * @param key 键
5654
5639
  */
5655
5640
  removeItem(key) {
5641
+ if (!this.storage)
5642
+ return;
5656
5643
  const fullKey = this.getFullKey(key);
5657
5644
  this.storage.removeItem(fullKey);
5658
5645
  }
@@ -5663,8 +5650,10 @@ class StorageManager {
5663
5650
  * @param ttl 存活时间(毫秒)
5664
5651
  */
5665
5652
  setItem(key, value, ttl) {
5653
+ if (!this.storage)
5654
+ return;
5666
5655
  const fullKey = this.getFullKey(key);
5667
- const expiry = ttl ? Date.now() + ttl : undefined;
5656
+ const expiry = ttl ? Date.now() + ttl : void 0;
5668
5657
  const item = { expiry, value };
5669
5658
  try {
5670
5659
  this.storage.setItem(fullKey, JSON.stringify(item));
@@ -5678,7 +5667,7 @@ class StorageManager {
5678
5667
  * @returns 带前缀的完整键
5679
5668
  */
5680
5669
  getFullKey(key) {
5681
- return `${this.prefix}-${key}`
5670
+ return `${this.prefix}-${key}`;
5682
5671
  }
5683
5672
  }
5684
5673
 
@@ -5733,34 +5722,29 @@ function getColors(color, variants = _variants) {
5733
5722
  return colors;
5734
5723
  }
5735
5724
 
5736
- function executeUpdateCSSVariables(variables, id = '__minilo-styles__') {
5737
- // 获取或创建内联样式表元素
5738
- const styleElement = document.querySelector(`#${id}`) || document.createElement('style');
5725
+ function executeUpdateCSSVariables(variables, id = "__minilo-styles__") {
5726
+ const styleElement = document.querySelector(`#${id}`) || document.createElement("style");
5739
5727
  styleElement.id = id;
5740
- // 构建要更新的 CSS 变量的样式文本
5741
- let cssText = ':root {';
5728
+ let cssText = ":root {";
5742
5729
  for (const key in variables) {
5743
5730
  if (Object.prototype.hasOwnProperty.call(variables, key)) {
5744
5731
  cssText += `${key}: ${variables[key]};`;
5745
5732
  }
5746
5733
  }
5747
- cssText += '}';
5748
- // 将样式文本赋值给内联样式表
5734
+ cssText += "}";
5749
5735
  styleElement.textContent = cssText;
5750
- // 将内联样式表添加到文档头部
5751
5736
  if (!document.querySelector(`#${id}`)) {
5752
5737
  setTimeout(() => {
5753
5738
  document.head.append(styleElement);
5754
5739
  });
5755
5740
  }
5756
5741
  }
5757
- // 根据某个色值生成色值阶梯对象,key=500时为其默认初始值,也就是默认参数
5758
5742
  function generatorColorVariables(colorItems) {
5759
5743
  const colorVariables = {};
5760
5744
  colorItems.forEach(({ alias, color, name }) => {
5761
5745
  if (color) {
5762
5746
  const colorsMap = getColors(new TinyColor(color).toHexString());
5763
- let mainColor = colorsMap['500'];
5747
+ let mainColor = colorsMap["500"];
5764
5748
  const colorKeys = Object.keys(colorsMap);
5765
5749
  colorKeys.forEach((key) => {
5766
5750
  const colorValue = colorsMap[key];
@@ -5770,7 +5754,7 @@ function generatorColorVariables(colorItems) {
5770
5754
  if (alias) {
5771
5755
  colorVariables[`--${alias}-${key}`] = hslColor;
5772
5756
  }
5773
- if (key === '500') {
5757
+ if (key === "500") {
5774
5758
  mainColor = hslColor;
5775
5759
  }
5776
5760
  }
@@ -5780,38 +5764,31 @@ function generatorColorVariables(colorItems) {
5780
5764
  }
5781
5765
  }
5782
5766
  });
5783
- return colorVariables
5767
+ return colorVariables;
5784
5768
  }
5785
5769
  function updateCSSVariables(config) {
5786
5770
  const theme = config?.theme ?? {};
5787
- if (
5788
- Reflect.has(theme, 'colorPrimary') ||
5789
- Reflect.has(theme, 'colorDestructive') ||
5790
- Reflect.has(theme, 'colorSuccess') ||
5791
- Reflect.has(theme, 'colorWarning')
5792
- ) {
5771
+ if (Reflect.has(theme, "colorPrimary") || Reflect.has(theme, "colorDestructive") || Reflect.has(theme, "colorSuccess") || Reflect.has(theme, "colorWarning")) {
5793
5772
  updateMainColorVariables(config);
5794
5773
  }
5795
5774
  }
5796
5775
  function updateMainColorVariables(config) {
5797
5776
  if (!config.theme) {
5798
- return
5777
+ return;
5799
5778
  }
5800
5779
  const { colorDestructive, colorPrimary, colorSuccess, colorWarning } = config.theme;
5801
5780
  const colorVariables = generatorColorVariables([
5802
- { color: colorPrimary, name: 'primary' },
5803
- { alias: 'warning', color: colorWarning, name: 'yellow' },
5804
- { alias: 'success', color: colorSuccess, name: 'green' },
5805
- { alias: 'destructive', color: colorDestructive, name: 'red' }
5781
+ { color: colorPrimary, name: "primary" },
5782
+ { alias: "warning", color: colorWarning, name: "yellow" },
5783
+ { alias: "success", color: colorSuccess, name: "green" },
5784
+ { alias: "destructive", color: colorDestructive, name: "red" }
5806
5785
  ]);
5807
- // 要设置的 CSS 变量映射
5808
5786
  const colorMappings = {
5809
- '--green-500': '--success',
5810
- '--primary-500': '--primary',
5811
- '--red-500': '--destructive',
5812
- '--yellow-500': '--warning'
5787
+ "--green-500": "--success",
5788
+ "--primary-500": "--primary",
5789
+ "--red-500": "--destructive",
5790
+ "--yellow-500": "--warning"
5813
5791
  };
5814
- // 统一处理颜色变量的更新
5815
5792
  Object.entries(colorMappings).forEach(([sourceVar, targetVar]) => {
5816
5793
  const colorValue = colorVariables[sourceVar];
5817
5794
  if (colorValue) {
@@ -5821,20 +5798,23 @@ function updateMainColorVariables(config) {
5821
5798
  executeUpdateCSSVariables(colorVariables);
5822
5799
  }
5823
5800
 
5824
- const STORAGE_KEY = 'config';
5825
- // 用户配置引导类
5801
+ const STORAGE_KEY = "config";
5826
5802
  class Guider {
5827
5803
  constructor() {
5828
5804
  this.isInitialized = false;
5829
5805
  this.state = reactive({
5830
5806
  ...this.loadConfig()
5831
5807
  });
5832
- this.cache = new StorageManager();
5808
+ if (typeof window !== "undefined") {
5809
+ this.cache = new StorageManager();
5810
+ } else {
5811
+ this.cache = null;
5812
+ }
5833
5813
  }
5834
5814
  // 初始化配置
5835
5815
  initConfig({ config: config$1, namespace }) {
5836
5816
  if (this.isInitialized) {
5837
- return
5817
+ return;
5838
5818
  }
5839
5819
  this.cache = new StorageManager({ prefix: namespace });
5840
5820
  const mergeDefaultConfig = defu({}, config$1, config);
@@ -5851,148 +5831,116 @@ class Guider {
5851
5831
  }
5852
5832
  // 保存配置
5853
5833
  saveConfig(config) {
5854
- this.cache?.setItem(STORAGE_KEY, config);
5834
+ if (!this.cache)
5835
+ return;
5836
+ this.cache.setItem(STORAGE_KEY, config);
5855
5837
  }
5856
5838
  // 加载配置
5857
5839
  loadConfig() {
5858
- return this.cache?.getItem(STORAGE_KEY)
5840
+ if (!this.cache)
5841
+ return void 0;
5842
+ return this.cache.getItem(STORAGE_KEY);
5859
5843
  }
5860
5844
  // 获取配置
5861
5845
  getConfig() {
5862
- return readonly(this.state)
5846
+ return readonly(this.state);
5863
5847
  }
5864
5848
  }
5865
5849
  const guider = new Guider();
5866
5850
  guider.getConfig();
5867
5851
 
5868
- // 创建请求实例
5869
- const initRequestInstance = (
5870
- extendConfig = {},
5871
- interceptorsRequestFn = () => {},
5872
- interceptorsResponseFn = () => {}
5873
- ) => {
5852
+ const initRequestInstance = (extendConfig = {}, options = {}) => {
5853
+ const { interceptorsRequestFn = () => {
5854
+ }, interceptorsResponseFn = () => {
5855
+ }, isSuccess = (data) => data?.code === 200, getData = (data) => data?.data, getMessage = (data) => data?.msg || "\u8BF7\u6C42\u5931\u8D25" } = options;
5874
5856
  const axiosConfig = defu({}, extendConfig, {
5875
- baseURL: '/', // 从环境变量获取基础URL
5876
- timeout: 10000, // 超时时间
5857
+ baseURL: "/",
5858
+ // 从环境变量获取基础URL
5859
+ timeout: 1e4,
5860
+ // 超时时间
5877
5861
  headers: {
5878
- 'Content-Type': 'application/json;charset=utf-8'
5862
+ "Content-Type": "application/json;charset=utf-8"
5879
5863
  }
5880
5864
  });
5881
5865
  const instance = axios.create(axiosConfig);
5882
- // 请求拦截器
5883
- instance.interceptors.request.use(
5884
- (config) => {
5885
- interceptorsRequestFn(config);
5886
- // 添加请求到pending列表,处理重复请求
5887
- addPendingRequest(config);
5888
- // 可以在这里添加其他请求处理逻辑,如请求加载动画等
5889
- return config
5890
- },
5891
- (error) => {
5892
- // 请求错误处理
5893
- return Promise.reject(error)
5894
- }
5895
- );
5896
- // 响应拦截器
5897
- instance.interceptors.response.use(
5898
- (response) => {
5899
- interceptorsResponseFn(response);
5900
- // 从pending列表移除请求
5901
- removePendingRequest(response.config);
5902
- const data = response.data;
5903
- console.log(data);
5904
- // 根据实际后端接口规范处理响应
5905
- if (data.code === 200) {
5906
- return Promise.resolve({
5907
- ...response,
5908
- ...data,
5909
- data: data.data
5910
- })
5911
- } else {
5912
- // 非成功状态,显示错误信息
5913
- ElMessage.error(data.msg || '请求失败');
5914
- return Promise.reject(new Error(data.msg || '请求失败'))
5915
- }
5916
- },
5917
- (error) => {
5918
- console.log('请求发生错误>>>>>>>>>>>>>>>>>>:', error);
5919
- // 请求完成后从pending列表移除
5920
- if (error.config) {
5921
- removePendingRequest(error.config);
5922
- }
5923
- // 处理取消请求的错误
5924
- if (axios.isCancel(error)) {
5925
- console.warn('请求已被取消:', error.message);
5926
- return Promise.reject(new Error('请求已被取消'))
5927
- }
5928
- // 处理网络错误
5929
- if (!window.navigator.onLine) {
5930
- ElMessage.error('网络连接已断开,请检查网络');
5931
- return Promise.reject(new Error('网络连接已断开'))
5932
- }
5933
- // 处理HTTP错误状态码
5934
- const { response } = error;
5935
- if (response) {
5936
- switch (response.status) {
5937
- case 401:
5938
- ElMessage.error('身份验证失败,请重新登录');
5939
- // 可以在这里添加跳转到登录页的逻辑
5940
- break
5941
- case 403:
5942
- ElMessage.error('没有权限执行此操作');
5943
- break
5944
- case 404:
5945
- ElMessage.error('请求的资源不存在');
5946
- break
5947
- case 500:
5948
- ElMessage.error('服务器内部错误');
5949
- break
5950
- default:
5951
- ElMessage.error(`请求错误: ${response.status}`);
5952
- }
5953
- } else {
5954
- ElMessage.error('请求失败,请稍后重试');
5866
+ instance.interceptors.request.use((config) => {
5867
+ interceptorsRequestFn(config);
5868
+ addPendingRequest(config);
5869
+ return config;
5870
+ }, (error) => {
5871
+ return Promise.reject(error);
5872
+ });
5873
+ instance.interceptors.response.use((response) => {
5874
+ interceptorsResponseFn(response);
5875
+ removePendingRequest(response.config);
5876
+ const data = response.data;
5877
+ if (isSuccess(data)) {
5878
+ return Promise.resolve({
5879
+ ...response,
5880
+ ...data,
5881
+ data: getData(data)
5882
+ });
5883
+ } else {
5884
+ const msg = getMessage(data);
5885
+ ElMessage.error(msg);
5886
+ return Promise.reject(new Error(msg));
5887
+ }
5888
+ }, (error) => {
5889
+ console.log("\u8BF7\u6C42\u53D1\u751F\u9519\u8BEF>>>>>>>>>>>>>>>>>>\uFF1A", error);
5890
+ if (error.config) {
5891
+ removePendingRequest(error.config);
5892
+ }
5893
+ if (axios.isCancel(error)) {
5894
+ console.warn("\u8BF7\u6C42\u5DF2\u88AB\u53D6\u6D88:", error.message);
5895
+ return Promise.reject(new Error("\u8BF7\u6C42\u5DF2\u88AB\u53D6\u6D88"));
5896
+ }
5897
+ if (!window.navigator.onLine) {
5898
+ ElMessage.error("\u7F51\u7EDC\u8FDE\u63A5\u5DF2\u65AD\u5F00\uFF0C\u8BF7\u68C0\u67E5\u7F51\u7EDC");
5899
+ return Promise.reject(new Error("\u7F51\u7EDC\u8FDE\u63A5\u5DF2\u65AD\u5F00"));
5900
+ }
5901
+ const { response } = error;
5902
+ if (response) {
5903
+ switch (response.status) {
5904
+ case 401:
5905
+ ElMessage.error("\u8EAB\u4EFD\u9A8C\u8BC1\u5931\u8D25\uFF0C\u8BF7\u91CD\u65B0\u767B\u5F55");
5906
+ break;
5907
+ case 403:
5908
+ ElMessage.error("\u6CA1\u6709\u6743\u9650\u6267\u884C\u6B64\u64CD\u4F5C");
5909
+ break;
5910
+ case 404:
5911
+ ElMessage.error("\u8BF7\u6C42\u7684\u8D44\u6E90\u4E0D\u5B58\u5728");
5912
+ break;
5913
+ case 500:
5914
+ ElMessage.error("\u670D\u52A1\u5668\u5185\u90E8\u9519\u8BEF");
5915
+ break;
5916
+ default:
5917
+ ElMessage.error(`\u8BF7\u6C42\u9519\u8BEF: ${response.status}`);
5955
5918
  }
5956
- return Promise.reject(error)
5919
+ } else {
5920
+ ElMessage.error("\u8BF7\u6C42\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5");
5957
5921
  }
5958
- );
5959
- return instance
5922
+ return Promise.reject(error);
5923
+ });
5924
+ return instance;
5960
5925
  };
5961
- // 存储当前正在进行的请求
5962
- const pendingRequests = new Map();
5963
- /**
5964
- * 生成请求唯一标识
5965
- * @param {Object} config 请求配置
5966
- * @returns {String} 唯一标识
5967
- */
5926
+ const pendingRequests = /* @__PURE__ */ new Map();
5968
5927
  const generateRequestKey = (config) => {
5969
5928
  const { method, url, params, data } = config;
5970
- // 序列化参数,确保相同参数生成相同key
5971
- const paramsStr = params ? JSON.stringify(params) : '';
5972
- const dataStr = data ? JSON.stringify(data) : '';
5973
- return `${method}-${url}-${paramsStr}-${dataStr}`
5929
+ const paramsStr = params ? JSON.stringify(params) : "";
5930
+ const dataStr = data ? JSON.stringify(data) : "";
5931
+ return `${method}-${url}-${paramsStr}-${dataStr}`;
5974
5932
  };
5975
- /**
5976
- * 添加请求到pending列表
5977
- * @param {Object} config 请求配置
5978
- */
5979
5933
  const addPendingRequest = (config) => {
5980
5934
  const requestKey = generateRequestKey(config);
5981
- // 如果存在相同请求,则取消之前的请求
5982
5935
  if (pendingRequests.has(requestKey)) {
5983
5936
  const cancelToken = pendingRequests.get(requestKey);
5984
- cancelToken.cancel(`重复请求被取消: ${config.url}`);
5937
+ cancelToken.cancel(`\u91CD\u590D\u8BF7\u6C42\u88AB\u53D6\u6D88: ${config.url}`);
5985
5938
  pendingRequests.delete(requestKey);
5986
5939
  }
5987
- // 创建新的取消令牌
5988
5940
  const source = axios.CancelToken.source();
5989
5941
  config.cancelToken = source.token;
5990
5942
  pendingRequests.set(requestKey, source);
5991
5943
  };
5992
- /**
5993
- * 从pending列表移除请求
5994
- * @param {Object} config 请求配置
5995
- */
5996
5944
  const removePendingRequest = (config) => {
5997
5945
  const requestKey = generateRequestKey(config);
5998
5946
  if (pendingRequests.has(requestKey)) {
@@ -6087,7 +6035,10 @@ var _sfc_main$a = /* @__PURE__ */ defineComponent({
6087
6035
  handleSearch();
6088
6036
  });
6089
6037
  __expose({
6090
- handleSearch
6038
+ handleSearch,
6039
+ data,
6040
+ loading,
6041
+ pagination
6091
6042
  });
6092
6043
  const tableListeners = Object.keys(attrs).reduce((listeners, key) => {
6093
6044
  if (key.startsWith("on")) {
@@ -6656,9 +6607,11 @@ var _sfc_main$5 = /* @__PURE__ */ defineComponent({
6656
6607
  resizeObserver.disconnect();
6657
6608
  }
6658
6609
  resizeObserver = new ResizeObserver((entries) => {
6610
+ console.log("\u5916\u90E8entries:", entries);
6659
6611
  let needUpdate = false;
6660
6612
  const changedIndices = [];
6661
6613
  for (const entry of entries) {
6614
+ console.log("entry:", entry);
6662
6615
  const target = entry.target;
6663
6616
  const index = parseInt(target.dataset.index || "0");
6664
6617
  const pos = positions.value[index];
@@ -6696,7 +6649,7 @@ var _sfc_main$5 = /* @__PURE__ */ defineComponent({
6696
6649
  const observeVisibleItems = () => {
6697
6650
  if (!resizeObserver || props.itemEqual) return;
6698
6651
  resizeObserver.disconnect();
6699
- const nodes = containerRef.value?.querySelectorAll(".virtual-list-item");
6652
+ const nodes = containerRef.value?.querySelectorAll(`.${bem("virtual-list", "item")}`);
6700
6653
  if (!nodes) return;
6701
6654
  nodes.forEach((node) => {
6702
6655
  resizeObserver.observe(node);
@@ -7107,7 +7060,7 @@ var _sfc_main$3 = /* @__PURE__ */ defineComponent({
7107
7060
  name: "MlTreeSelect"
7108
7061
  },
7109
7062
  __name: "index",
7110
- props: {
7063
+ props: /* @__PURE__ */ mergeModels({
7111
7064
  treeData: { type: Array, required: true },
7112
7065
  treeProps: { type: Object, required: false, default: () => ({ label: "label", children: "children" }) },
7113
7066
  multiple: { type: Boolean, required: false, default: false },
@@ -7117,12 +7070,15 @@ var _sfc_main$3 = /* @__PURE__ */ defineComponent({
7117
7070
  showSearch: { type: Boolean, required: false, default: true },
7118
7071
  expandOnClickNode: { type: Boolean, required: false },
7119
7072
  placeholder: { type: String, required: false, default: "\u8BF7\u8F93\u5165\u5173\u952E\u8BCD\u641C\u7D22" }
7120
- },
7121
- emits: ["confirm", "cancel", "input"],
7073
+ }, {
7074
+ "searchText": { type: String, ...{ default: "" } },
7075
+ "searchTextModifiers": {}
7076
+ }),
7077
+ emits: /* @__PURE__ */ mergeModels(["confirm", "cancel", "input"], ["update:searchText"]),
7122
7078
  setup(__props, { expose: __expose, emit: __emit }) {
7123
7079
  const props = __props;
7124
7080
  const emit = __emit;
7125
- const searchKeyword = ref("");
7081
+ const searchKeyword = useModel(__props, "searchText");
7126
7082
  const treeRef = ref();
7127
7083
  const selectedKeys = ref([]);
7128
7084
  const selectedData = ref(props.multiple ? [] : {});
@@ -7433,9 +7389,13 @@ var _sfc_main$2 = /* @__PURE__ */ defineComponent({
7433
7389
  return result;
7434
7390
  });
7435
7391
  const treeSelectRef = ref();
7392
+ const searchText = ref("");
7436
7393
  watch(visible, (val) => {
7437
- if (!val && treeSelectRef.value) {
7438
- treeSelectRef.value.reset();
7394
+ if (!val) {
7395
+ searchText.value = "";
7396
+ if (treeSelectRef.value) {
7397
+ treeSelectRef.value.reset();
7398
+ }
7439
7399
  }
7440
7400
  });
7441
7401
  const handleBeforeClose = () => {
@@ -7449,27 +7409,31 @@ var _sfc_main$2 = /* @__PURE__ */ defineComponent({
7449
7409
  visible.value = false;
7450
7410
  };
7451
7411
  __expose({
7452
- input: (value) => emit("input", value)
7412
+ input: (value) => emit("input", value),
7413
+ searchText,
7414
+ treeRef: treeSelectRef
7453
7415
  });
7454
7416
  return (_ctx, _cache) => {
7455
7417
  const _component_el_dialog = resolveComponent("el-dialog");
7456
7418
  return openBlock(), createBlock(_component_el_dialog, mergeProps({
7457
7419
  modelValue: visible.value,
7458
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => visible.value = $event)
7420
+ "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => visible.value = $event)
7459
7421
  }, dialogAttrs.value, {
7460
7422
  class: unref(bem)("tree-select-dialog"),
7461
7423
  "before-close": handleBeforeClose,
7462
- onClose: _cache[1] || (_cache[1] = ($event) => emit("close"))
7424
+ onClose: _cache[2] || (_cache[2] = ($event) => emit("close"))
7463
7425
  }), {
7464
7426
  default: withCtx(() => [
7465
7427
  createVNode(unref(MlTreeSelect), mergeProps({
7466
7428
  ref_key: "treeSelectRef",
7467
7429
  ref: treeSelectRef,
7430
+ "search-text": searchText.value,
7431
+ "onUpdate:searchText": _cache[0] || (_cache[0] = ($event) => searchText.value = $event),
7468
7432
  "tree-data": props.treeData
7469
7433
  }, treeSelectAttrs.value, toHandlers(_ctx.$attrs), {
7470
7434
  onConfirm: handleConfirm,
7471
7435
  onCancel: handleCancel
7472
- }), null, 16, ["tree-data"])
7436
+ }), null, 16, ["search-text", "tree-data"])
7473
7437
  ]),
7474
7438
  _: 1
7475
7439
  /* STABLE */
@@ -7590,9 +7554,13 @@ var _sfc_main$1 = /* @__PURE__ */ defineComponent({
7590
7554
  return result;
7591
7555
  });
7592
7556
  const treeSelectRef = ref();
7557
+ const searchText = ref("");
7593
7558
  watch(visible, (val) => {
7594
- if (!val && treeSelectRef.value) {
7595
- treeSelectRef.value.reset();
7559
+ if (!val) {
7560
+ searchText.value = "";
7561
+ if (treeSelectRef.value) {
7562
+ treeSelectRef.value.reset();
7563
+ }
7596
7564
  }
7597
7565
  });
7598
7566
  const handleBeforeClose = (done) => {
@@ -7607,27 +7575,31 @@ var _sfc_main$1 = /* @__PURE__ */ defineComponent({
7607
7575
  visible.value = false;
7608
7576
  };
7609
7577
  __expose({
7610
- input: (value) => emit("input", value)
7578
+ input: (value) => emit("input", value),
7579
+ searchText,
7580
+ treeRef: treeSelectRef
7611
7581
  });
7612
7582
  return (_ctx, _cache) => {
7613
7583
  const _component_el_drawer = resolveComponent("el-drawer");
7614
7584
  return openBlock(), createBlock(_component_el_drawer, mergeProps({
7615
7585
  modelValue: visible.value,
7616
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => visible.value = $event)
7586
+ "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => visible.value = $event)
7617
7587
  }, drawerAttrs.value, {
7618
7588
  class: unref(bem)("tree-select-drawer"),
7619
7589
  "before-close": handleBeforeClose,
7620
- onClose: _cache[1] || (_cache[1] = ($event) => emit("close"))
7590
+ onClose: _cache[2] || (_cache[2] = ($event) => emit("close"))
7621
7591
  }), {
7622
7592
  default: withCtx(() => [
7623
7593
  createVNode(_sfc_main$3, mergeProps({
7624
7594
  ref_key: "treeSelectRef",
7625
7595
  ref: treeSelectRef,
7596
+ "search-text": searchText.value,
7597
+ "onUpdate:searchText": _cache[0] || (_cache[0] = ($event) => searchText.value = $event),
7626
7598
  "tree-data": __props.treeData
7627
7599
  }, treeSelectAttrs.value, toHandlers(_ctx.$attrs), {
7628
7600
  onConfirm: handleConfirm,
7629
7601
  onCancel: handleCancel
7630
- }), null, 16, ["tree-data"])
7602
+ }), null, 16, ["search-text", "tree-data"])
7631
7603
  ]),
7632
7604
  _: 1
7633
7605
  /* STABLE */