next-element-vue 0.5.0 → 0.5.1

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/dist/index.js CHANGED
@@ -2,8 +2,8 @@
2
2
  /**
3
3
  * 作  者:huangteng
4
4
  * 邮  箱:htengweb@163.com
5
- * 当前版本:0.5.0 v
6
- * 发布日期:2024-12-26
5
+ * 当前版本:0.5.1 v
6
+ * 发布日期:2024-12-28
7
7
  * 地  址:https://www.npmjs.com/package/next-element-vue
8
8
  */
9
9
 
@@ -1097,9 +1097,13 @@ const localeLang = {
1097
1097
  }, useLanguage = (locale, lang) => {
1098
1098
  const localeRef = isRef(locale) ? locale : ref(locale), nextLang = localeLang[lang] || localeLang["zh-cn"];
1099
1099
  localeRef.value.name = lang, localeRef.value.next = nextLang.next;
1100
- };
1100
+ }, reg_hex = /^#([0-9A-F]{3}|[0-9A-F]{6}|[0-9A-F]{8})$/i, reg_rgba = /^rgba\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*,\s*(0|1|0?\.\d+)\s*\)$/i;
1101
1101
 
1102
1102
  function useChangeColor() {
1103
+ const rgbaToHex = rgba => {
1104
+ const rgbaValues = rgba.replace(/^rgba?\(|\s+|\)$/g, "").split(",").map((value => parseFloat(value))), [r, g, b] = rgbaValues;
1105
+ return `#${[ r, g, b ].map((value => Math.round(value).toString(16).padStart(2, "0"))).join("")}`.toUpperCase();
1106
+ };
1103
1107
  return {
1104
1108
  hexToRgb: str => {
1105
1109
  let hexs = "";
@@ -1123,17 +1127,24 @@ function useChangeColor() {
1123
1127
  for (let i = 0; i < 3; i++) 1 == hexs[i].length && (hexs[i] = `0${hexs[i]}`);
1124
1128
  return `#${hexs.join("")}`;
1125
1129
  },
1130
+ rgbaToHex: rgbaToHex,
1131
+ rgbaToHexAlpha: rgba => {
1132
+ const rgbaValues = rgba.replace(/^rgba?\(|\s+|\)$/g, "").split(",").map((value => parseFloat(value))), [r, g, b, a] = rgbaValues, alpha = Math.round(255 * a).toString(16).padStart(2, "0");
1133
+ return `#${[ r, g, b ].map((value => Math.round(value).toString(16).padStart(2, "0"))).join("")}${alpha}`.toUpperCase();
1134
+ },
1126
1135
  getDarkColor: (color, level) => {
1127
- if (!/^\#?[0-9A-Fa-f]{6}$/.test(color)) return ElMessage.warning("输入错误的hex颜色值"),
1136
+ let _color = color;
1137
+ if (reg_rgba.test(_color) && (_color = rgbaToHex(_color)), !reg_hex.test(_color)) return ElMessage.warning("输入错误的hex颜色值"),
1128
1138
  "";
1129
- let rgb = useChangeColor().hexToRgb(color);
1139
+ let rgb = useChangeColor().hexToRgb(_color);
1130
1140
  for (let i = 0; i < 3; i++) rgb[i] = Math.floor(rgb[i] * (1 - level));
1131
1141
  return useChangeColor().rgbToHex(rgb[0], rgb[1], rgb[2]);
1132
1142
  },
1133
1143
  getLightColor: (color, level) => {
1134
- if (!/^\#?[0-9A-Fa-f]{6}$/.test(color)) return ElMessage.warning("输入错误的hex颜色值"),
1144
+ let _color = color;
1145
+ if (reg_rgba.test(_color) && (_color = rgbaToHex(_color)), !reg_hex.test(_color)) return ElMessage.warning("输入错误的hex颜色值"),
1135
1146
  "";
1136
- let rgb = useChangeColor().hexToRgb(color);
1147
+ let rgb = useChangeColor().hexToRgb(_color);
1137
1148
  for (let i = 0; i < 3; i++) rgb[i] = Math.floor((255 - rgb[i]) * level + rgb[i]);
1138
1149
  return useChangeColor().rgbToHex(rgb[0], rgb[1], rgb[2]);
1139
1150
  }
@@ -1730,6 +1741,7 @@ var warning_default = export_helper_default(warning_vue_vue_type_script_lang_def
1730
1741
  modelValue: settingConfig.themeColor,
1731
1742
  "onUpdate:modelValue": $event => settingConfig.themeColor = $event,
1732
1743
  predefine: [ "#409eff", "#ff4500", "#ff8c00", "#ffd700", "#90ee90", "#00ced1", "#1e90ff", "#c71585", "#FB07A0" ],
1744
+ "show-alpha": !0,
1733
1745
  onChange: _onChangeThemeColor
1734
1746
  }, null) ]) ]), createVNode("div", {
1735
1747
  class: _ns.b("config-bar-item")
@@ -1757,6 +1769,7 @@ var warning_default = export_helper_default(warning_vue_vue_type_script_lang_def
1757
1769
  modelValue: settingConfig.headerBarColor,
1758
1770
  "onUpdate:modelValue": $event => settingConfig.headerBarColor = $event,
1759
1771
  predefine: [ "#282c34", "#ff4500", "#ff8c00", "#ffd700", "#90ee90", "#00ced1", "#1e90ff", "#c71585", "#FB07A0" ],
1772
+ "show-alpha": !0,
1760
1773
  onChange: color => _onChangeColor(color, "headerBarColor", "--next-layout-bg-color")
1761
1774
  }, null) ]) ]), createVNode("div", {
1762
1775
  class: _ns.b("config-bar-item")
@@ -1768,6 +1781,7 @@ var warning_default = export_helper_default(warning_vue_vue_type_script_lang_def
1768
1781
  modelValue: settingConfig.headerBarFontColor,
1769
1782
  "onUpdate:modelValue": $event => settingConfig.headerBarFontColor = $event,
1770
1783
  predefine: [ "#282c34", "#ff4500", "#ff8c00", "#ffd700", "#90ee90", "#00ced1", "#1e90ff", "#c71585", "#FB07A0" ],
1784
+ "show-alpha": !0,
1771
1785
  onChange: color => _onChangeColor(color, "headerBarFontColor", "--next-layout-font-color")
1772
1786
  }, null) ]) ]), createVNode("div", {
1773
1787
  class: _ns.b("config-bar-item")
@@ -3071,15 +3085,16 @@ var classic = defineComponent({
3071
3085
  }
3072
3086
  });
3073
3087
 
3074
- const findParentNode = (path, tree) => {
3075
- for (const node of tree) {
3076
- if (node.children?.some((child => child.path === path))) return node;
3077
- if (node.children) {
3078
- const parent = findParentNode(path, node.children);
3079
- if (parent) return parent;
3088
+ const findGrandfatherNode = (path, tree) => {
3089
+ let parentNode = null;
3090
+ const loopNodes = (nodes, currentParent) => {
3091
+ for (const node of nodes) {
3092
+ if (node.path === path) return parentNode = currentParent, !0;
3093
+ if (node.children && loopNodes(node.children, currentParent ?? node)) return !0;
3080
3094
  }
3081
- }
3082
- return null;
3095
+ return !1;
3096
+ };
3097
+ return loopNodes(tree, null), parentNode;
3083
3098
  }, ns$h = useNamespace("menu");
3084
3099
 
3085
3100
  var MenuTop = defineComponent({
@@ -3099,10 +3114,12 @@ var MenuTop = defineComponent({
3099
3114
  },
3100
3115
  setup(props) {
3101
3116
  provide("ns", ns$h);
3102
- const updateSubmentTree = inject("updateSubmentTree"), router = getCurrentInstance().appContext.config.globalProperties.$router, currentPath = router.currentRoute?.value.fullPath, parentNode = findParentNode(currentPath, props.menuTree), activeMenuId = ref(parentNode?.id);
3103
- parentNode?.id && updateSubmentTree(parentNode.children), watch((() => router.currentRoute?.value), (to => {
3104
- const parentNode = findParentNode(to.fullPath, props.menuTree);
3105
- activeMenuId.value = parentNode?.id, parentNode?.id && 1 === parentNode.meta?.level && updateSubmentTree(parentNode.children);
3117
+ const updateSubmentTree = inject("updateSubmentTree"), router = getCurrentInstance().appContext.config.globalProperties.$router, currentPath = router.currentRoute?.value.fullPath, parentNode = findGrandfatherNode(currentPath, props.menuTree), activeMenuId = ref(parentNode?.id);
3118
+ parentNode?.id && 1 === parentNode.meta?.level && updateSubmentTree(parentNode.children),
3119
+ watch((() => router.currentRoute?.value), (to => {
3120
+ const parentNode = findGrandfatherNode(to.fullPath, props.menuTree);
3121
+ if (activeMenuId.value = parentNode?.id, !parentNode) return updateSubmentTree([]);
3122
+ parentNode?.id && 1 === parentNode.meta?.level && updateSubmentTree(parentNode.children);
3106
3123
  }));
3107
3124
  const findTreeFirst = tree => {
3108
3125
  let result = tree[0];
@@ -8525,7 +8542,7 @@ const zoomDialog = app => {
8525
8542
  }));
8526
8543
  }
8527
8544
  });
8528
- }, version = "0.5.0", install = function(app) {
8545
+ }, version = "0.5.1", install = function(app) {
8529
8546
  Object.keys(components).forEach((key => {
8530
8547
  const component = components[key];
8531
8548
  app.component(component.name, component);
@@ -8535,7 +8552,7 @@ const zoomDialog = app => {
8535
8552
  };
8536
8553
 
8537
8554
  var index = {
8538
- version: "0.5.0",
8555
+ version: "0.5.1",
8539
8556
  install: install
8540
8557
  };
8541
8558