@deppon/deppon-template 2.3.0 → 2.3.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.
@@ -1,9 +1,9 @@
1
1
  import '../_virtual/_rollup-plugin-inject-process-env.js';
2
2
  import _typeof from '@babel/runtime/helpers/typeof';
3
3
  import _defineProperty from '@babel/runtime/helpers/defineProperty';
4
- import { useSlots, ref, computed, watch, markRaw, onMounted, onUnmounted, openBlock, createBlock, unref, normalizeClass, withCtx, createCommentVNode, createElementVNode, createElementBlock, renderSlot, normalizeStyle, createTextVNode, toDisplayString, createVNode, Fragment, renderList, resolveDynamicComponent, withDirectives, mergeProps, withModifiers, vShow } from 'vue';
4
+ import { useSlots, ref, computed, watch, markRaw, onMounted, onUnmounted, nextTick, openBlock, createBlock, unref, normalizeClass, withCtx, createCommentVNode, createElementVNode, createElementBlock, renderSlot, normalizeStyle, createTextVNode, toDisplayString, createVNode, Fragment, renderList, resolveDynamicComponent, withDirectives, mergeProps, withModifiers, vShow } from 'vue';
5
5
  import { useRouter, useRoute } from '@deppon/deppon-router';
6
- import { ElContainer, ElHeader, ElMenu, ElMenuItem, ElBadge, ElSubMenu, ElInput, ElIcon, ElButton, ElAside, ElScrollbar, ElMain, ElFooter } from '@deppon/deppon-ui';
6
+ import { ElContainer, ElHeader, ElMenu, ElMenuItem, ElBadge, ElSubMenu, ElInput, ElIcon, ElButton, ElAside, ElScrollbar, ElTooltip, ElMain, ElFooter } from '@deppon/deppon-ui';
7
7
  import { Search, Service, Bell, Close, Refresh, Expand, Fold, ArrowRight, ArrowLeft } from '@deppon/deppon-ui/icons-vue';
8
8
  import { isMobile as _isMobile } from '../utils/other.js';
9
9
 
@@ -81,23 +81,17 @@ var _hoisted_20 = {
81
81
  "class": "pro-layout__menu-item-char"
82
82
  };
83
83
  var _hoisted_21 = {
84
- "class": "pro-layout__menu-item-title"
85
- };
86
- var _hoisted_22 = {
87
84
  key: 1,
88
85
  "class": "pro-layout__menu-item-char"
89
86
  };
90
- var _hoisted_23 = {
91
- key: 2
92
- };
93
- var _hoisted_24 = {
87
+ var _hoisted_22 = {
94
88
  key: 1,
95
89
  "class": "pro-layout__menu-item-char"
96
90
  };
97
- var _hoisted_25 = {
91
+ var _hoisted_23 = {
98
92
  "class": "pro-layout__tag-label"
99
93
  };
100
- var _hoisted_26 = {
94
+ var _hoisted_24 = {
101
95
  "class": "pro-layout__tag-actions"
102
96
  };
103
97
  var script = {
@@ -298,6 +292,8 @@ var script = {
298
292
  var windowWidth = ref(typeof window !== 'undefined' ? window.innerWidth : 1920);
299
293
  var menuSearchText = ref('');
300
294
  var headerSearchText = ref('');
295
+ var menuTitleRefs = new Map();
296
+ var menuTitleOverflowMap = ref(new Map());
301
297
 
302
298
  // TagsView 相关
303
299
  var visitedTags = ref([]);
@@ -309,6 +305,43 @@ var script = {
309
305
  return t.path;
310
306
  }).join('-'));
311
307
  });
308
+ var getMenuTitleKey = function getMenuTitleKey(item) {
309
+ var prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
310
+ return "".concat(prefix).concat((item === null || item === void 0 ? void 0 : item.path) || (item === null || item === void 0 ? void 0 : item.key) || (item === null || item === void 0 ? void 0 : item.title) || (item === null || item === void 0 ? void 0 : item.label) || '');
311
+ };
312
+ var checkMenuTitleOverflow = function checkMenuTitleOverflow(key) {
313
+ var titleEl = menuTitleRefs.get(key);
314
+ var isOverflow = Boolean(titleEl && titleEl.scrollWidth > titleEl.clientWidth);
315
+ if (menuTitleOverflowMap.value.get(key) !== isOverflow) {
316
+ var nextMap = new Map(menuTitleOverflowMap.value);
317
+ nextMap.set(key, isOverflow);
318
+ menuTitleOverflowMap.value = nextMap;
319
+ }
320
+ };
321
+ var setMenuTitleRef = function setMenuTitleRef(el, key) {
322
+ if (!key) return;
323
+ if (el) {
324
+ menuTitleRefs.set(key, el);
325
+ nextTick(function () {
326
+ return checkMenuTitleOverflow(key);
327
+ });
328
+ return;
329
+ }
330
+ menuTitleRefs["delete"](key);
331
+ if (menuTitleOverflowMap.value.has(key)) {
332
+ var nextMap = new Map(menuTitleOverflowMap.value);
333
+ nextMap["delete"](key);
334
+ menuTitleOverflowMap.value = nextMap;
335
+ }
336
+ };
337
+ var checkAllMenuTitleOverflow = function checkAllMenuTitleOverflow() {
338
+ menuTitleRefs.forEach(function (_, key) {
339
+ return checkMenuTitleOverflow(key);
340
+ });
341
+ };
342
+ var isMenuTitleOverflow = function isMenuTitleOverflow(key) {
343
+ return menuTitleOverflowMap.value.get(key) === true;
344
+ };
312
345
 
313
346
  // 从 menuItems 中查找标题
314
347
  var _findMenuTitle = function findMenuTitle(path) {
@@ -499,13 +532,19 @@ var script = {
499
532
  collapsed.value = true;
500
533
  }
501
534
  };
535
+ var handleMenuTitleResize = function handleMenuTitleResize() {
536
+ nextTick(checkAllMenuTitleOverflow);
537
+ };
502
538
  onMounted(function () {
503
539
  checkMobile();
540
+ handleMenuTitleResize();
541
+ window.addEventListener('resize', handleMenuTitleResize);
504
542
  if (props.responsive) {
505
543
  window.addEventListener('resize', checkMobile);
506
544
  }
507
545
  });
508
546
  onUnmounted(function () {
547
+ window.removeEventListener('resize', handleMenuTitleResize);
509
548
  if (props.responsive) {
510
549
  window.removeEventListener('resize', checkMobile);
511
550
  }
@@ -659,10 +698,16 @@ var script = {
659
698
  // 监听 menuGroups 变化,初始化展开状态
660
699
  watch(menuGroups, function () {
661
700
  initMenuGroupExpanded();
701
+ nextTick(checkAllMenuTitleOverflow);
662
702
  }, {
663
703
  immediate: true,
664
704
  deep: true
665
705
  });
706
+ watch(function () {
707
+ return collapsed.value;
708
+ }, function () {
709
+ nextTick(checkAllMenuTitleOverflow);
710
+ });
666
711
 
667
712
  // 编辑模式状态
668
713
  var isEditMode = ref(false);
@@ -1013,7 +1058,22 @@ var script = {
1013
1058
  })
1014
1059
  }, {
1015
1060
  title: withCtx(function () {
1016
- return [createElementVNode("span", _hoisted_21, toDisplayString(item.title || item.label), 1 /* TEXT */), group.type === 'common' && !collapsed.value && isEditMode.value ? (openBlock(), createBlock(unref(ElIcon), {
1061
+ return [createVNode(unref(ElTooltip), {
1062
+ content: item.title || item.label,
1063
+ placement: "right",
1064
+ disabled: collapsed.value || !isMenuTitleOverflow(getMenuTitleKey(item, "group-".concat(groupIndex, "-")))
1065
+ }, {
1066
+ "default": withCtx(function () {
1067
+ return [createElementVNode("span", {
1068
+ ref_for: true,
1069
+ ref: function ref(el) {
1070
+ return setMenuTitleRef(el, getMenuTitleKey(item, "group-".concat(groupIndex, "-")));
1071
+ },
1072
+ "class": "pro-layout__menu-item-title"
1073
+ }, toDisplayString(item.title || item.label), 513 /* TEXT, NEED_PATCH */)];
1074
+ }),
1075
+ _: 2 /* DYNAMIC */
1076
+ }, 1032 /* PROPS, DYNAMIC_SLOTS */, ["content", "disabled"]), group.type === 'common' && !collapsed.value && isEditMode.value ? (openBlock(), createBlock(unref(ElIcon), {
1017
1077
  key: 0,
1018
1078
  "class": "pro-layout__menu-item-delete",
1019
1079
  onClick: withModifiers(function ($event) {
@@ -1050,7 +1110,23 @@ var script = {
1050
1110
  return [(openBlock(), createBlock(resolveDynamicComponent(item.icon)))];
1051
1111
  }),
1052
1112
  _: 2 /* DYNAMIC */
1053
- }, 1024 /* DYNAMIC_SLOTS */)) : collapsed.value && !item.icon ? (openBlock(), createElementBlock("span", _hoisted_22, toDisplayString(getFirstChar(item.title || item.label)), 1 /* TEXT */)) : createCommentVNode("v-if", true), !collapsed.value ? (openBlock(), createElementBlock("span", _hoisted_23, toDisplayString(item.title || item.label), 1 /* TEXT */)) : createCommentVNode("v-if", true)];
1113
+ }, 1024 /* DYNAMIC_SLOTS */)) : collapsed.value && !item.icon ? (openBlock(), createElementBlock("span", _hoisted_21, toDisplayString(getFirstChar(item.title || item.label)), 1 /* TEXT */)) : createCommentVNode("v-if", true), !collapsed.value ? (openBlock(), createBlock(unref(ElTooltip), {
1114
+ key: 2,
1115
+ content: item.title || item.label,
1116
+ placement: "right",
1117
+ disabled: !isMenuTitleOverflow(getMenuTitleKey(item, "group-".concat(groupIndex, "-submenu-title-")))
1118
+ }, {
1119
+ "default": withCtx(function () {
1120
+ return [createElementVNode("span", {
1121
+ ref_for: true,
1122
+ ref: function ref(el) {
1123
+ return setMenuTitleRef(el, getMenuTitleKey(item, "group-".concat(groupIndex, "-submenu-title-")));
1124
+ },
1125
+ "class": "pro-layout__menu-item-title"
1126
+ }, toDisplayString(item.title || item.label), 513 /* TEXT, NEED_PATCH */)];
1127
+ }),
1128
+ _: 2 /* DYNAMIC */
1129
+ }, 1032 /* PROPS, DYNAMIC_SLOTS */, ["content", "disabled"])) : createCommentVNode("v-if", true)];
1054
1130
  }),
1055
1131
  "default": withCtx(function () {
1056
1132
  return [(openBlock(true), createElementBlock(Fragment, null, renderList(item.children, function (child) {
@@ -1060,7 +1136,22 @@ var script = {
1060
1136
  disabled: child.disabled
1061
1137
  }, {
1062
1138
  title: withCtx(function () {
1063
- return [createTextVNode(toDisplayString(child.title || child.label), 1 /* TEXT */)];
1139
+ return [createVNode(unref(ElTooltip), {
1140
+ content: child.title || child.label,
1141
+ placement: "right",
1142
+ disabled: collapsed.value || !isMenuTitleOverflow(getMenuTitleKey(child, getMenuTitleKey(item, "group-".concat(groupIndex, "-child-"))))
1143
+ }, {
1144
+ "default": withCtx(function () {
1145
+ return [createElementVNode("span", {
1146
+ ref_for: true,
1147
+ ref: function ref(el) {
1148
+ return setMenuTitleRef(el, getMenuTitleKey(child, getMenuTitleKey(item, "group-".concat(groupIndex, "-child-"))));
1149
+ },
1150
+ "class": "pro-layout__menu-item-title"
1151
+ }, toDisplayString(child.title || child.label), 513 /* TEXT, NEED_PATCH */)];
1152
+ }),
1153
+ _: 2 /* DYNAMIC */
1154
+ }, 1032 /* PROPS, DYNAMIC_SLOTS */, ["content", "disabled"])];
1064
1155
  }),
1065
1156
  "default": withCtx(function () {
1066
1157
  return [child.icon ? (openBlock(), createBlock(unref(ElIcon), {
@@ -1070,7 +1161,7 @@ var script = {
1070
1161
  return [(openBlock(), createBlock(resolveDynamicComponent(child.icon)))];
1071
1162
  }),
1072
1163
  _: 2 /* DYNAMIC */
1073
- }, 1024 /* DYNAMIC_SLOTS */)) : collapsed.value && !child.icon ? (openBlock(), createElementBlock("span", _hoisted_24, toDisplayString(getFirstChar(child.title || child.label)), 1 /* TEXT */)) : createCommentVNode("v-if", true)];
1164
+ }, 1024 /* DYNAMIC_SLOTS */)) : collapsed.value && !child.icon ? (openBlock(), createElementBlock("span", _hoisted_22, toDisplayString(getFirstChar(child.title || child.label)), 1 /* TEXT */)) : createCommentVNode("v-if", true)];
1074
1165
  }),
1075
1166
  _: 2 /* DYNAMIC */
1076
1167
  }, 1032 /* PROPS, DYNAMIC_SLOTS */, ["index", "disabled"]);
@@ -1124,7 +1215,7 @@ var script = {
1124
1215
  "class": "pro-layout__tag-item"
1125
1216
  }, {
1126
1217
  title: withCtx(function () {
1127
- return [createElementVNode("span", _hoisted_25, toDisplayString(tag.title), 1 /* TEXT */), createElementVNode("div", _hoisted_26, [createVNode(unref(ElIcon), {
1218
+ return [createElementVNode("span", _hoisted_23, toDisplayString(tag.title), 1 /* TEXT */), createElementVNode("div", _hoisted_24, [createVNode(unref(ElIcon), {
1128
1219
  "class": "pro-layout__tag-icon",
1129
1220
  onClick: withModifiers(function ($event) {
1130
1221
  return handleTagRefresh(tag);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deppon/deppon-template",
3
- "version": "2.3.0",
3
+ "version": "2.3.1",
4
4
  "main": "es/index.js",
5
5
  "module": "es/index.js",
6
6
  "typings": "es/index.d.ts",
@@ -43,11 +43,11 @@
43
43
  "less": "^4.2.0"
44
44
  },
45
45
  "dependencies": {
46
- "@deppon/deppon-assets": "2.3.0",
47
- "@deppon/deppon-request": "2.3.0",
48
- "@deppon/deppon-router": "2.3.0",
49
- "@deppon/deppon-ui": "2.3.0",
50
- "@deppon/deppon-utils": "2.3.0",
46
+ "@deppon/deppon-assets": "2.3.1",
47
+ "@deppon/deppon-request": "2.3.1",
48
+ "@deppon/deppon-router": "2.3.1",
49
+ "@deppon/deppon-ui": "2.3.1",
50
+ "@deppon/deppon-utils": "2.3.1",
51
51
  "dayjs": "^1.11.10",
52
52
  "lodash-es": "^4.17.21",
53
53
  "mitt": "^3.0.1"