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