@lambo-design/pro-layout 1.0.0-beta.45 → 1.0.0-beta.450
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/package.json +11 -4
- package/src/components/pro-layout-header/index.vue +220 -0
- package/src/components/pro-layout-header/pro-layout-logo/index.vue +206 -0
- package/src/components/pro-layout-header/pro-layout-nav/components/pro-layout-nav-slide-menu.vue +399 -0
- package/src/components/pro-layout-header/pro-layout-nav/index-slide.vue +226 -0
- package/src/components/pro-layout-header/pro-layout-nav/index.vue +565 -0
- package/src/components/pro-layout-header/pro-layout-slogan/index.vue +40 -0
- package/src/components/pro-layout-header/pro-layout-tools/components/pro-layout-tools-quick-collect.vue +79 -0
- package/src/components/pro-layout-header/pro-layout-tools/components/pro-layout-tools-quick-document.vue +116 -0
- package/src/components/pro-layout-header/pro-layout-tools/components/pro-layout-tools-quick-fullscreen.vue +144 -0
- package/src/components/pro-layout-header/pro-layout-tools/components/pro-layout-tools-quick-icons.vue +99 -0
- package/src/components/pro-layout-header/pro-layout-tools/components/pro-layout-tools-quick-intl.vue +110 -0
- package/src/components/pro-layout-header/pro-layout-tools/components/pro-layout-tools-quick-notice.vue +133 -0
- package/src/components/pro-layout-header/pro-layout-tools/components/pro-layout-tools-quick-search.vue +305 -0
- package/src/components/pro-layout-header/pro-layout-tools/components/pro-layout-tools-quick-todo.vue +145 -0
- package/src/components/pro-layout-header/pro-layout-tools/components/pro-layout-tools-user.vue +64 -0
- package/src/components/pro-layout-header/pro-layout-tools/index.vue +38 -0
- package/src/components/pro-layout-header/pro-layout-trigger/index.vue +84 -0
- package/src/components/{pro-layout-sider-collapsed-menu.vue → pro-layout-sider/components/pro-layout-sider-collapsed-menu.vue} +30 -11
- package/src/components/{pro-layout-sider-icon.vue → pro-layout-sider/components/pro-layout-sider-icon.vue} +2 -2
- package/src/components/pro-layout-sider/components/pro-layout-sider-menu-item.vue +137 -0
- package/src/components/pro-layout-sider/components/pro-layout-sider-other-menu.vue +140 -0
- package/src/components/pro-layout-sider/components/pro-layout-sider-search.vue +345 -0
- package/src/components/pro-layout-sider/index.vue +477 -0
- package/src/components/{pro-layout-tabs.vue → pro-layout-tabs/index.vue} +118 -23
- package/src/index.vue +306 -40
- package/src/styles/color.less +267 -0
- package/src/styles/images/xiaoxitongzhi.png +0 -0
- package/src/styles/other-menu.less +63 -111
- package/src/utils/menuItem.js +10 -0
- package/src/utils/sider.js +16 -1
- package/src/components/pro-layout-header.vue +0 -52
- package/src/components/pro-layout-logo.vue +0 -79
- package/src/components/pro-layout-nav.vue +0 -150
- package/src/components/pro-layout-other-menu.vue +0 -138
- package/src/components/pro-layout-sider-menu-item.vue +0 -37
- package/src/components/pro-layout-sider.vue +0 -240
- package/src/components/pro-layout-tools-user.vue +0 -84
- package/src/components/pro-layout-tools.vue +0 -21
- package/src/components/pro-layout-trigger.vue +0 -48
|
@@ -0,0 +1,565 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="pro-layout-nav-wrapper">
|
|
3
|
+
<Menu
|
|
4
|
+
ref="topNav"
|
|
5
|
+
mode="horizontal"
|
|
6
|
+
theme="dark"
|
|
7
|
+
:active-name="getActiveName()"
|
|
8
|
+
@on-select="selectApp"
|
|
9
|
+
>
|
|
10
|
+
<template v-for="item in topMenList">
|
|
11
|
+
<MenuItem v-if="!item.children" :key="item.appId" :name="item.appId" class="top-menu">
|
|
12
|
+
<Icon
|
|
13
|
+
v-bind="getIcon(item)"
|
|
14
|
+
:size="20"
|
|
15
|
+
v-show="systemInfo.navLogo === '1'"
|
|
16
|
+
></Icon
|
|
17
|
+
>{{ item.name }}
|
|
18
|
+
<div class="line"></div>
|
|
19
|
+
</MenuItem>
|
|
20
|
+
<Submenu
|
|
21
|
+
class="ibp-nav-sub-menu"
|
|
22
|
+
v-else
|
|
23
|
+
:name="item.name"
|
|
24
|
+
:key="item.name"
|
|
25
|
+
>
|
|
26
|
+
<template slot="title">
|
|
27
|
+
{{ item.name }}
|
|
28
|
+
</template>
|
|
29
|
+
<MenuItem
|
|
30
|
+
v-for="itemL2 in item.children"
|
|
31
|
+
:key="itemL2.appId"
|
|
32
|
+
:name="itemL2.appId"
|
|
33
|
+
><Icon
|
|
34
|
+
:type="itemL2.icon"
|
|
35
|
+
:size="20"
|
|
36
|
+
v-show="systemInfo.navLogo === '1'"
|
|
37
|
+
></Icon
|
|
38
|
+
>{{ itemL2.name }}</MenuItem
|
|
39
|
+
>
|
|
40
|
+
</Submenu>
|
|
41
|
+
</template>
|
|
42
|
+
<Submenu name="other" v-if="otherList.length > 0">
|
|
43
|
+
<template slot="title"> ... </template>
|
|
44
|
+
<MenuItem
|
|
45
|
+
:name="item.appId"
|
|
46
|
+
v-for="item in otherList"
|
|
47
|
+
:key="item.appId"
|
|
48
|
+
>
|
|
49
|
+
<Icon
|
|
50
|
+
v-bind="getIcon(item)"
|
|
51
|
+
:size="20"
|
|
52
|
+
v-show="systemInfo.navLogo === '1'"
|
|
53
|
+
></Icon
|
|
54
|
+
>{{ item.name }}
|
|
55
|
+
</MenuItem>
|
|
56
|
+
</Submenu>
|
|
57
|
+
</Menu>
|
|
58
|
+
</div>
|
|
59
|
+
</template>
|
|
60
|
+
|
|
61
|
+
<script>
|
|
62
|
+
import Bus from "@lambo-design/shared/utils/bus";
|
|
63
|
+
import { deepCopy } from "@lambo-design/shared/utils/assist";
|
|
64
|
+
import { arraysEqual } from "@lambo-design/shared/utils/platform";
|
|
65
|
+
import _ from "lodash";
|
|
66
|
+
import {getSessionStorage} from "@lambo-design/shared/utils/n";
|
|
67
|
+
|
|
68
|
+
export default {
|
|
69
|
+
name: "pro-layout-nav",
|
|
70
|
+
props: {
|
|
71
|
+
availableWidth: {
|
|
72
|
+
type: Number,
|
|
73
|
+
default: 800
|
|
74
|
+
},
|
|
75
|
+
notHomeIndex: {
|
|
76
|
+
type: Boolean,
|
|
77
|
+
default: true
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
data() {
|
|
81
|
+
return {
|
|
82
|
+
systemInfo: {},
|
|
83
|
+
originNavList: [], // 原始顶部菜单列表,用于判断是否要重复触发initNav
|
|
84
|
+
navList: [],
|
|
85
|
+
topMenList: [],
|
|
86
|
+
otherList: [],
|
|
87
|
+
activeName: "",
|
|
88
|
+
topMenuNum: 4,
|
|
89
|
+
lastTopMenuNum: -1,
|
|
90
|
+
acceptAppId: "",
|
|
91
|
+
originMenuList: [],
|
|
92
|
+
// 新增响应式相关状态
|
|
93
|
+
resizeObserver: null,
|
|
94
|
+
menuActualWidth: 0,
|
|
95
|
+
shouldShowMore: false,
|
|
96
|
+
autoCalculateWidth: true
|
|
97
|
+
};
|
|
98
|
+
},
|
|
99
|
+
methods: {
|
|
100
|
+
initListener() {
|
|
101
|
+
Bus.$on("system-info", (data) => {
|
|
102
|
+
this.initSystemInfo(data);
|
|
103
|
+
});
|
|
104
|
+
Bus.$on("nav-list", (data) => {
|
|
105
|
+
this.initNav(data);
|
|
106
|
+
});
|
|
107
|
+
Bus.$on("change-app", ({ appId, appInfo }) => {
|
|
108
|
+
this.changeApp(appId, appInfo);
|
|
109
|
+
});
|
|
110
|
+
Bus.$on("menu-list", (data) => {
|
|
111
|
+
this.initMenu(data);
|
|
112
|
+
});
|
|
113
|
+
// 初始化响应式监听
|
|
114
|
+
this.initResizeObserver();
|
|
115
|
+
},
|
|
116
|
+
destroyListener() {
|
|
117
|
+
Bus.$off("system-info");
|
|
118
|
+
Bus.$off("nav-list");
|
|
119
|
+
Bus.$off("menu-list");
|
|
120
|
+
Bus.$off("change-app");
|
|
121
|
+
// 清理 ResizeObserver
|
|
122
|
+
if (this.resizeObserver) {
|
|
123
|
+
this.resizeObserver.disconnect();
|
|
124
|
+
this.resizeObserver = null;
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
initSystemInfo(data) {
|
|
128
|
+
if (data) {
|
|
129
|
+
this.systemInfo = data;
|
|
130
|
+
this.topMenuNum = Number.isInteger(data.topMenu) ? data.topMenu : 4;
|
|
131
|
+
this.acceptAppId = data.acceptAppId ? data.acceptAppId : "";
|
|
132
|
+
if (!this.activeName && this.notHomeIndex) {
|
|
133
|
+
this.activeName = this.acceptAppId;
|
|
134
|
+
}
|
|
135
|
+
this.initNav(this.navList);
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
initNav(data) {
|
|
139
|
+
// 过滤掉首页项,获取真实的业务数据
|
|
140
|
+
const realData = data.filter(item => item.appId !== 'backHome');
|
|
141
|
+
if (
|
|
142
|
+
_.some(realData, (app) => app.children?.length) || // 分组以后会死循环调用,中断一下
|
|
143
|
+
(arraysEqual(this.originNavList, realData) &&
|
|
144
|
+
this.topMenuNum === this.lastTopMenuNum)
|
|
145
|
+
) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
this.originNavList = realData;
|
|
149
|
+
let dataClone = _.cloneDeep(realData);
|
|
150
|
+
|
|
151
|
+
// 如果配置了显示首页且显示样式是应用式,在列表最前面添加首页项
|
|
152
|
+
if (dataClone && dataClone.length > 0 && this.systemInfo.backToHome === "1" && this.systemInfo.backToHomeStyle === "app") {
|
|
153
|
+
const homeItem = {
|
|
154
|
+
appId: 'backHome',
|
|
155
|
+
name: this.systemInfo.backToHomeText || '首页',
|
|
156
|
+
icon: 'ios-home',
|
|
157
|
+
selected: false
|
|
158
|
+
};
|
|
159
|
+
dataClone.unshift(homeItem);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
let parentNameEnum = {};
|
|
163
|
+
_.forEach(dataClone, (app) => {
|
|
164
|
+
let extendProps = app.extendProps;
|
|
165
|
+
let extendPropsL2 = extendProps?.extendProps;
|
|
166
|
+
if (extendPropsL2) {
|
|
167
|
+
parentNameEnum[app.appId] = JSON.parse(extendPropsL2)?.parentName;
|
|
168
|
+
}
|
|
169
|
+
// app.parentName = extendPropsL2
|
|
170
|
+
// ? JSON.parse(extendPropsL2)?.parentName
|
|
171
|
+
// : "";
|
|
172
|
+
});
|
|
173
|
+
// 如果组织了二级菜单展现,则对菜单进行分组
|
|
174
|
+
if (!_.isEmpty(parentNameEnum)) {
|
|
175
|
+
let rlt = _.reduce(
|
|
176
|
+
dataClone,
|
|
177
|
+
(acc, cur) => {
|
|
178
|
+
let parentName = parentNameEnum[cur.appId];
|
|
179
|
+
if (parentName) {
|
|
180
|
+
let curApp = _.find(acc, { name: parentName });
|
|
181
|
+
if (curApp) {
|
|
182
|
+
curApp.children.push(cur);
|
|
183
|
+
} else {
|
|
184
|
+
acc.push({
|
|
185
|
+
name: parentName,
|
|
186
|
+
children: [cur],
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
} else {
|
|
190
|
+
acc.push(cur);
|
|
191
|
+
}
|
|
192
|
+
return acc;
|
|
193
|
+
},
|
|
194
|
+
[]
|
|
195
|
+
);
|
|
196
|
+
this.navList = rlt;
|
|
197
|
+
} else {
|
|
198
|
+
this.navList = dataClone;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
this.lastTopMenuNum = this.topMenuNum;
|
|
202
|
+
if (this.navList.length > this.topMenuNum) {
|
|
203
|
+
let navList = deepCopy(this.navList);
|
|
204
|
+
this.topMenList = navList.splice(0, this.topMenuNum);
|
|
205
|
+
this.otherList = navList;
|
|
206
|
+
} else {
|
|
207
|
+
this.topMenList = this.navList;
|
|
208
|
+
this.otherList = [];
|
|
209
|
+
}
|
|
210
|
+
if (this.navList.length > 0) {
|
|
211
|
+
let appId = this.navList[0].appId;
|
|
212
|
+
if (this.systemInfo.backToHome === "1" && this.systemInfo.backToHomeStyle === "app") {
|
|
213
|
+
appId = this.navList[1].appId;
|
|
214
|
+
}
|
|
215
|
+
for (let i = 0; i < this.navList.length; i++) {
|
|
216
|
+
if (this.navList[i].selected == true) {
|
|
217
|
+
appId = this.navList[i].appId;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
if (this.activeName) {
|
|
221
|
+
appId = this.activeName;
|
|
222
|
+
}
|
|
223
|
+
if (this.notHomeIndex) {
|
|
224
|
+
this.selectApp(appId);
|
|
225
|
+
} else if (this.systemInfo.backToHome === "1" && this.systemInfo.backToHomeStyle === "app") {
|
|
226
|
+
this.activeName = 'backHome'
|
|
227
|
+
sessionStorage.setItem('fromHomeIndex', 'true')
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
setTimeout(() => {
|
|
231
|
+
this.calcTopMenus();
|
|
232
|
+
}, 10);
|
|
233
|
+
},
|
|
234
|
+
initMenu(data) {
|
|
235
|
+
this.originMenuList = deepCopy(data);
|
|
236
|
+
},
|
|
237
|
+
selectApp(appId) {
|
|
238
|
+
if (appId) {
|
|
239
|
+
if (appId === 'backHome') {
|
|
240
|
+
Bus.$emit("change-app", {
|
|
241
|
+
appId,
|
|
242
|
+
appInfo: {}
|
|
243
|
+
});
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
let res = this.originNavList.filter((app) => app.appId == appId);
|
|
247
|
+
if (res && res.length > 0) {
|
|
248
|
+
Bus.$emit("change-app", { appId, appInfo: res[0] });
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
},
|
|
252
|
+
changeApp(appId, appInfo) {
|
|
253
|
+
if (appId) {
|
|
254
|
+
this.activeName = appId;
|
|
255
|
+
this.$nextTick(() => {
|
|
256
|
+
this.$refs.topNav.updateActiveName();
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
},
|
|
260
|
+
// 顶部导航的导航配置多的话,分辨率低的场景下,需要计算一下剩余空间能展示多少,动态计算topMenuNum
|
|
261
|
+
calcTopMenus() {
|
|
262
|
+
// this.$nextTick(() => {
|
|
263
|
+
if (!this.autoCalculateWidth) {
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
// 计算可用宽度
|
|
268
|
+
// this.calculateAvailableWidth();
|
|
269
|
+
|
|
270
|
+
// 计算实际菜单宽度
|
|
271
|
+
this.calculateMenuActualWidth();
|
|
272
|
+
|
|
273
|
+
// 预留"更多"按钮空间
|
|
274
|
+
const moreButtonSpace = 76.2;
|
|
275
|
+
const effectiveWidth = this.availableWidth - moreButtonSpace;
|
|
276
|
+
|
|
277
|
+
// 判断是否需要显示"更多"按钮
|
|
278
|
+
this.shouldShowMore = this.menuActualWidth > effectiveWidth;
|
|
279
|
+
|
|
280
|
+
// 根据可用宽度计算能显示的菜单数量
|
|
281
|
+
this.calculateTopMenuNum();
|
|
282
|
+
|
|
283
|
+
// 更新显示列表
|
|
284
|
+
this.updateMenuLists();
|
|
285
|
+
|
|
286
|
+
// 触发宽度变化事件
|
|
287
|
+
this.$emit('width-change', {
|
|
288
|
+
available: this.availableWidth,
|
|
289
|
+
actual: this.menuActualWidth,
|
|
290
|
+
needMore: this.shouldShowMore
|
|
291
|
+
});
|
|
292
|
+
// });
|
|
293
|
+
},
|
|
294
|
+
|
|
295
|
+
// 计算可用宽度
|
|
296
|
+
// calculateAvailableWidth() {
|
|
297
|
+
// const appElement = document.getElementById("app");
|
|
298
|
+
// if (!appElement) return;
|
|
299
|
+
//
|
|
300
|
+
// const docWidth = appElement.clientWidth;
|
|
301
|
+
// const triggerBoxWidth = this.getElementWidth("trigger-box");
|
|
302
|
+
// const logoBoxWidth = this.getElementWidth("logo-box");
|
|
303
|
+
// const toolsBoxWidth = this.getElementWidth("tools-box");
|
|
304
|
+
// const othersWidth = 80; // 其他按钮的宽度
|
|
305
|
+
//
|
|
306
|
+
// this.availableWidth = docWidth - triggerBoxWidth - logoBoxWidth - toolsBoxWidth - othersWidth;
|
|
307
|
+
// },
|
|
308
|
+
|
|
309
|
+
// 计算实际菜单宽度
|
|
310
|
+
calculateMenuActualWidth() {
|
|
311
|
+
const navWrapper = this.$el;
|
|
312
|
+
if (!navWrapper) return;
|
|
313
|
+
|
|
314
|
+
const menuContainer = navWrapper.querySelector('.ivu-menu');
|
|
315
|
+
if (menuContainer) {
|
|
316
|
+
// 计算所有菜单项的实际宽度
|
|
317
|
+
let totalWidth = 0;
|
|
318
|
+
const menuItems = menuContainer.querySelectorAll('li');
|
|
319
|
+
menuItems.forEach(item => {
|
|
320
|
+
totalWidth += item.offsetWidth;
|
|
321
|
+
});
|
|
322
|
+
this.menuActualWidth = totalWidth;
|
|
323
|
+
}
|
|
324
|
+
},
|
|
325
|
+
|
|
326
|
+
// 计算顶部菜单数量
|
|
327
|
+
calculateTopMenuNum() {
|
|
328
|
+
if (!this.navList || this.navList.length === 0) return;
|
|
329
|
+
let topMenuNum = 0;
|
|
330
|
+
let sumWidth = 0;
|
|
331
|
+
|
|
332
|
+
//加上submenu按钮宽度,避免submenu存在一个,浪费宽度
|
|
333
|
+
let availableWidth = this.availableWidth
|
|
334
|
+
|
|
335
|
+
// 模拟计算每个菜单项的宽度
|
|
336
|
+
this.navList.forEach((item, index) => {
|
|
337
|
+
// 估算每个菜单项的宽度(包括图标、文字、边距等)
|
|
338
|
+
const estimatedWidth = this.estimateMenuItemWidth(item);
|
|
339
|
+
if (sumWidth + estimatedWidth < availableWidth) {
|
|
340
|
+
topMenuNum++;
|
|
341
|
+
sumWidth += estimatedWidth;
|
|
342
|
+
if(sumWidth + 95 > availableWidth){
|
|
343
|
+
sumWidth -= estimatedWidth;
|
|
344
|
+
topMenuNum--;
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
});
|
|
349
|
+
// 如果计算值为0,就不要触发事件,如果系统配置要展示少量,也不要触发事件
|
|
350
|
+
if (topMenuNum && (!this.systemInfo?.topMenu || this.systemInfo?.topMenu > topMenuNum)) {
|
|
351
|
+
this.topMenuNum = topMenuNum;
|
|
352
|
+
}else{
|
|
353
|
+
this.topMenuNum = this.systemInfo.topMenu;
|
|
354
|
+
}
|
|
355
|
+
},
|
|
356
|
+
|
|
357
|
+
// 估算菜单项宽度
|
|
358
|
+
estimateMenuItemWidth(item) {
|
|
359
|
+
// 基础宽度:内边距 + 边框
|
|
360
|
+
let baseWidth = 40;
|
|
361
|
+
|
|
362
|
+
// 图标宽度
|
|
363
|
+
if (item.icon && this.systemInfo.navLogo === '1') {
|
|
364
|
+
baseWidth += 26;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
// 文字宽度估算(每个字符约14px)
|
|
368
|
+
// const fontSize = parseInt(window.getComputedStyle(document.querySelector('#customVars')).getPropertyValue('--font-size-base').replace("px",""))
|
|
369
|
+
var customVars=window.getComputedStyle(document.querySelector('#customVars'));
|
|
370
|
+
var fontSizeVar=customVars.getPropertyValue('--font-size-base');
|
|
371
|
+
var fontSize=parseInt(fontSizeVar.replace("px",""));
|
|
372
|
+
|
|
373
|
+
const textWidth = (item.name || '').length * fontSize;
|
|
374
|
+
|
|
375
|
+
return baseWidth + textWidth;
|
|
376
|
+
},
|
|
377
|
+
|
|
378
|
+
// 更新菜单列表
|
|
379
|
+
updateMenuLists() {
|
|
380
|
+
if (this.navList.length > this.topMenuNum) {
|
|
381
|
+
const navList = deepCopy(this.navList);
|
|
382
|
+
this.topMenList = navList.splice(0, this.topMenuNum);
|
|
383
|
+
this.otherList = navList;
|
|
384
|
+
} else {
|
|
385
|
+
this.topMenList = this.navList;
|
|
386
|
+
this.otherList = [];
|
|
387
|
+
}
|
|
388
|
+
// console.log("topMenList",this.topMenList.length)
|
|
389
|
+
// console.log("otherList",this.otherList.length)
|
|
390
|
+
},
|
|
391
|
+
|
|
392
|
+
// 获取元素宽度的辅助方法
|
|
393
|
+
getElementWidth(className) {
|
|
394
|
+
const element = document.getElementsByClassName(className)[0];
|
|
395
|
+
return element ? element.clientWidth : 0;
|
|
396
|
+
},
|
|
397
|
+
|
|
398
|
+
// 初始化 ResizeObserver
|
|
399
|
+
initResizeObserver() {
|
|
400
|
+
if (window.ResizeObserver) {
|
|
401
|
+
this.resizeObserver = new ResizeObserver(() => {
|
|
402
|
+
this.calcTopMenus();
|
|
403
|
+
});
|
|
404
|
+
}
|
|
405
|
+
},
|
|
406
|
+
|
|
407
|
+
// 开始监听容器大小变化
|
|
408
|
+
startResizeObserving() {
|
|
409
|
+
if (this.resizeObserver && this.$el) {
|
|
410
|
+
this.resizeObserver.observe(this.$el);
|
|
411
|
+
|
|
412
|
+
// 同时监听父容器
|
|
413
|
+
const appElement = document.getElementById("app");
|
|
414
|
+
if (appElement) {
|
|
415
|
+
this.resizeObserver.observe(appElement);
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
},
|
|
419
|
+
|
|
420
|
+
// 停止监听容器大小变化
|
|
421
|
+
stopResizeObserving() {
|
|
422
|
+
if (this.resizeObserver) {
|
|
423
|
+
this.resizeObserver.disconnect();
|
|
424
|
+
}
|
|
425
|
+
},
|
|
426
|
+
|
|
427
|
+
//获取icon图标
|
|
428
|
+
getIcon(item){
|
|
429
|
+
const icon = item.icon
|
|
430
|
+
if(!icon) return
|
|
431
|
+
if(icon.indexOf('iconfont')>=0){
|
|
432
|
+
return {
|
|
433
|
+
custom:this.activeName === item.appId?`${item.icon}-active`:item.icon
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
return {
|
|
437
|
+
type:item.icon
|
|
438
|
+
}
|
|
439
|
+
},
|
|
440
|
+
getActiveName() {
|
|
441
|
+
// 如果不是首页模式,直接返回 activeName
|
|
442
|
+
if (this.notHomeIndex) {
|
|
443
|
+
return this.activeName;
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
// 如果是首页模式,检查当前 activeName 对应的应用是否隐藏了左侧菜单
|
|
447
|
+
const appList = getSessionStorage('appList');
|
|
448
|
+
if (appList && Array.isArray(appList) && appList.length > 0) {
|
|
449
|
+
// 查找当前 activeName 对应的应用
|
|
450
|
+
const currentApp = appList.find(app => app.appId === this.activeName);
|
|
451
|
+
// 如果找到应用且隐藏了左侧菜单,返回 activeName
|
|
452
|
+
if (currentApp) {
|
|
453
|
+
let isHideLeftMenu;
|
|
454
|
+
if (currentApp.extendProps) {
|
|
455
|
+
if (typeof currentApp.extendProps === 'string') {
|
|
456
|
+
isHideLeftMenu = JSON.parse(currentApp.extendProps)?.is_hide_left_menu;
|
|
457
|
+
} else {
|
|
458
|
+
isHideLeftMenu = currentApp.extendProps.is_hide_left_menu;
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
if (!isHideLeftMenu && currentApp.setting) {
|
|
462
|
+
if (typeof currentApp.setting === 'string') {
|
|
463
|
+
isHideLeftMenu = JSON.parse(currentApp.setting)?.is_hide_left_menu;
|
|
464
|
+
} else {
|
|
465
|
+
isHideLeftMenu = currentApp.setting.is_hide_left_menu;
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
if (isHideLeftMenu === '1' || isHideLeftMenu === 1) {
|
|
469
|
+
return this.activeName;
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
// 否则返回首页
|
|
475
|
+
return 'backHome';
|
|
476
|
+
}
|
|
477
|
+
},
|
|
478
|
+
watch: {
|
|
479
|
+
activeName() {
|
|
480
|
+
this.$nextTick(() => {
|
|
481
|
+
this.$refs.topNav.updateActiveName();
|
|
482
|
+
});
|
|
483
|
+
},
|
|
484
|
+
// 监听可用宽度变化
|
|
485
|
+
availableWidth(newVal) {
|
|
486
|
+
this.calcTopMenus();
|
|
487
|
+
},
|
|
488
|
+
// 监听系统信息变化
|
|
489
|
+
systemInfo: {
|
|
490
|
+
handler() {
|
|
491
|
+
this.calcTopMenus();
|
|
492
|
+
},
|
|
493
|
+
deep: true
|
|
494
|
+
}
|
|
495
|
+
},
|
|
496
|
+
created() {
|
|
497
|
+
this.initListener();
|
|
498
|
+
},
|
|
499
|
+
mounted() {
|
|
500
|
+
this.$nextTick(() => {
|
|
501
|
+
this.calcTopMenus();
|
|
502
|
+
this.startResizeObserving();
|
|
503
|
+
});
|
|
504
|
+
},
|
|
505
|
+
beforeDestroy() {
|
|
506
|
+
this.destroyListener();
|
|
507
|
+
this.stopResizeObserving();
|
|
508
|
+
},
|
|
509
|
+
};
|
|
510
|
+
</script>
|
|
511
|
+
|
|
512
|
+
<style scoped lang="less">
|
|
513
|
+
@import "@lambo-design/core/src/styles/default.less";
|
|
514
|
+
.pro-layout-nav-wrapper {
|
|
515
|
+
.ivu-menu {
|
|
516
|
+
.ivu-menu-item {
|
|
517
|
+
&:hover {
|
|
518
|
+
.line {
|
|
519
|
+
position: absolute;
|
|
520
|
+
left: 0;
|
|
521
|
+
right: 0;
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
&.ivu-menu-item-active,
|
|
525
|
+
&.ivu-menu-item-selected {
|
|
526
|
+
.line {
|
|
527
|
+
position: absolute;
|
|
528
|
+
left: 0;
|
|
529
|
+
right: 0;
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
</style>
|
|
536
|
+
|
|
537
|
+
<style lang="less">
|
|
538
|
+
.pro-layout .pro-layout-header .pro-layout-nav-wrapper .ibp-nav-sub-menu .ivu-menu-dark .ivu-menu-submenu .ivu-select-dropdown .ivu-menu-item{
|
|
539
|
+
color: var(--text-color, #333) !important;
|
|
540
|
+
border-radius: 4px !important;
|
|
541
|
+
background-color: var(--background-color-base, #f5f7f9) !important;
|
|
542
|
+
margin-right: 10px !important;
|
|
543
|
+
}
|
|
544
|
+
.pro-layout-nav-wrapper {
|
|
545
|
+
.ibp-nav-sub-menu {
|
|
546
|
+
.ivu-select-dropdown {
|
|
547
|
+
margin-top: 0 !important;
|
|
548
|
+
width: fit-content !important;
|
|
549
|
+
}
|
|
550
|
+
.ivu-menu-drop-list {
|
|
551
|
+
padding: 10px !important;
|
|
552
|
+
display: flex !important;
|
|
553
|
+
}
|
|
554
|
+
.ivu-menu-item {
|
|
555
|
+
color: var(--text-color, #333) !important;
|
|
556
|
+
border-radius: 4px !important;
|
|
557
|
+
background-color: var(--background-color-base, #f5f7f9) !important;
|
|
558
|
+
margin-right: 10px !important;
|
|
559
|
+
&:hover {
|
|
560
|
+
color: var(--layout-active-color, #488aff) !important;
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
</style>
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="pro-layout-slogan-wrapper">
|
|
3
|
+
<div class="slogan-content">正直豁达 智慧精微</div>
|
|
4
|
+
</div>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script>
|
|
8
|
+
import Locale from '@lambo-design/core/src/mixins/locale';
|
|
9
|
+
|
|
10
|
+
export default {
|
|
11
|
+
name: "pro-layout-slogan",
|
|
12
|
+
mixins: [Locale],
|
|
13
|
+
props:{
|
|
14
|
+
default:''
|
|
15
|
+
},
|
|
16
|
+
data(){
|
|
17
|
+
return {
|
|
18
|
+
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
computed:{
|
|
22
|
+
},
|
|
23
|
+
methods: {
|
|
24
|
+
},
|
|
25
|
+
created(){
|
|
26
|
+
},
|
|
27
|
+
beforeDestroy(){
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
</script>
|
|
31
|
+
|
|
32
|
+
<style scoped lang="less">
|
|
33
|
+
@import "@lambo-design/core/src/styles/default";
|
|
34
|
+
.pro-layout-slogan-wrapper{
|
|
35
|
+
overflow: hidden;
|
|
36
|
+
.slogan-content{
|
|
37
|
+
font-size: 16px;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
</style>
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<Tooltip v-if="currentItem && currentItem.type == 2" :content="t('pro-layout.header.collect')" placement="bottom">
|
|
3
|
+
<Icon @click="collectEvent" :type=" isCollected ? 'ios-star' : 'ios-star-outline'" size="16" style="cursor: pointer"/>
|
|
4
|
+
</Tooltip>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script>
|
|
8
|
+
import Bus from '@lambo-design/shared/utils/bus'
|
|
9
|
+
import { deepCopy } from '@lambo-design/shared/utils/assist'
|
|
10
|
+
import Locale from '@lambo-design/core/src/mixins/locale';
|
|
11
|
+
|
|
12
|
+
export default {
|
|
13
|
+
name: 'pro-layout-tools-quick-collect',
|
|
14
|
+
mixins: [Locale],
|
|
15
|
+
data() {
|
|
16
|
+
return {
|
|
17
|
+
menuList: [],
|
|
18
|
+
currentName: '',
|
|
19
|
+
currentItem: {},
|
|
20
|
+
collectMenuList: [],
|
|
21
|
+
isCollected:false
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
watch: {
|
|
25
|
+
collectMenuList(){
|
|
26
|
+
this.changeCollectMenu();
|
|
27
|
+
},
|
|
28
|
+
currentName(){
|
|
29
|
+
this.changeCollectMenu();
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
methods: {
|
|
33
|
+
initListener() {
|
|
34
|
+
Bus.$on('menu-list', (data) => {
|
|
35
|
+
this.initMenu(data);
|
|
36
|
+
})
|
|
37
|
+
Bus.$on('menu-click',(name,item) => {
|
|
38
|
+
this.initMenuClick(name, item)
|
|
39
|
+
})
|
|
40
|
+
Bus.$on('collect-menu-list',(data)=>{
|
|
41
|
+
this.initCollectMenu(data)
|
|
42
|
+
});
|
|
43
|
+
},
|
|
44
|
+
destroyListener() {
|
|
45
|
+
Bus.$off('menu-list')
|
|
46
|
+
Bus.$off('menu-click')
|
|
47
|
+
Bus.$off('collect-menu-list')
|
|
48
|
+
},
|
|
49
|
+
initMenu(data){
|
|
50
|
+
this.menuList = deepCopy(data);
|
|
51
|
+
},
|
|
52
|
+
initMenuClick(name, item){
|
|
53
|
+
this.currentName = name
|
|
54
|
+
if(item) {
|
|
55
|
+
this.currentItem = item;
|
|
56
|
+
} else {
|
|
57
|
+
this.currentItem = this.menuList.find(menu => menu.name == name)
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
initCollectMenu(data){
|
|
61
|
+
this.collectMenuList = deepCopy(data);
|
|
62
|
+
},
|
|
63
|
+
changeCollectMenu(){
|
|
64
|
+
this.isCollected = false
|
|
65
|
+
let collectMenu = this.collectMenuList.find(item => item.name == this.currentName)
|
|
66
|
+
this.isCollected = !!collectMenu;
|
|
67
|
+
},
|
|
68
|
+
collectEvent(){
|
|
69
|
+
Bus.$emit('toggle-collect-menu',!this.isCollected,this.currentItem)
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
created() {
|
|
73
|
+
this.initListener()
|
|
74
|
+
},
|
|
75
|
+
beforeDestroy() {
|
|
76
|
+
this.destroyListener()
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
</script>
|