@lambo-design/pro-layout 1.0.0-beta.20 → 1.0.0-beta.200

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lambo-design/pro-layout",
3
- "version": "1.0.0-beta.20",
3
+ "version": "1.0.0-beta.200",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "author": "lambo",
@@ -9,9 +9,9 @@
9
9
  "access": "public",
10
10
  "registry": "https://registry.npmjs.org/"
11
11
  },
12
- "dependencies": {
13
- "@lambo-design/core": "4.7.1-beta.35",
14
- "@lambo-design/shared": "1.0.0-beta.15"
12
+ "devDependencies": {
13
+ "@lambo-design/core": "^4.7.1-beta.116",
14
+ "@lambo-design/shared": "^1.0.0-beta.110"
15
15
  },
16
16
  "scripts": {}
17
17
  }
@@ -4,14 +4,26 @@
4
4
  <LamboProTrigger></LamboProTrigger>
5
5
  </div>
6
6
  <div class="logo-box">
7
- <LamboProLogo></LamboProLogo>
7
+ <LamboProLogo @clickLogo="handleClick"></LamboProLogo>
8
8
  </div>
9
9
  <div class="nav-box">
10
- <LamboProNav></LamboProNav>
10
+ <LamboProNav :accept-app-id="acceptAppId"></LamboProNav>
11
11
  </div>
12
12
  <div class="tools-box">
13
13
  <LamboProTools></LamboProTools>
14
14
  </div>
15
+ <!--<div class="search-box" v-if="isShowSearch === '1'" >-->
16
+ <!-- <FastSearch-->
17
+ <!-- style="margin-right: 10px"-->
18
+ <!-- :searchType="1"-->
19
+ <!-- @on-select="handleSelect"-->
20
+ <!-- ></FastSearch>-->
21
+ <!-- </div>-->
22
+ <!-- <Menu ref="menu"-->
23
+ <!-- :active-name="activeName"-->
24
+ <!-- :open-names="openedNames"-->
25
+ <!-- @on-select="handleSelect">-->
26
+ <!-- </Menu>-->
15
27
  </div>
16
28
  </template>
17
29
 
@@ -20,13 +32,255 @@ import LamboProTrigger from './pro-layout-trigger'
20
32
  import LamboProLogo from './pro-layout-logo'
21
33
  import LamboProNav from './pro-layout-nav'
22
34
  import LamboProTools from './pro-layout-tools'
35
+ import FastSearch from "./search-fast";
36
+ import Bus from "@lambo-design/shared/utils/bus";
37
+ import {deepCopy} from "@lambo-design/shared/utils/assist";
38
+ import generatorMenuList from "@lambo-design/shared/utils/menu";
39
+ import {filterMenuName, filterMenuUri, tagExists} from "@lambo-design/shared/utils/platform";
40
+ import {findComponentsDownward} from "@lambo-design/core/src/utils/assist";
23
41
  export default {
24
42
  name: "pro-layout-header",
43
+ props:{
44
+ acceptAppId: {
45
+ type: String,
46
+ default:''
47
+ }
48
+ },
49
+ data(){
50
+ return {
51
+ systemInfo: {},
52
+ isShowSearch:'1',
53
+ navList: [],
54
+ originMenuList:[],
55
+ menuList: [],
56
+ appId: '',
57
+ primaryColor: '#ff0000',
58
+ collapsed: false,
59
+ accordion: true,
60
+ activeName: '',
61
+ openedNames: [],
62
+ activeMenu: null,
63
+ selectedMenuParent: null,
64
+ activeMenuItem: null,
65
+ openedSubMenu: null,
66
+ currentMenuItem: null,
67
+ selectedTopParent: '',
68
+ activeIcon: null,
69
+ tagValue: '',
70
+ tagList: []
71
+ }
72
+ },
25
73
  components: {
26
74
  LamboProTrigger,
27
75
  LamboProLogo,
28
76
  LamboProNav,
29
- LamboProTools
77
+ LamboProTools,
78
+ FastSearch
79
+ },
80
+ methods:{
81
+
82
+ handleClick(){
83
+ this.$emit('clickLogo')
84
+ },
85
+ initListener(){
86
+ Bus.$on('system-info',(data)=>{
87
+ this.initSystem(data)
88
+ });
89
+ Bus.$on('nav-list',(data)=>{
90
+ this.initNav(data)
91
+ });
92
+ Bus.$on('menu-list',(data)=>{
93
+ this.initMenu(data)
94
+ });
95
+ Bus.$on('trigger-change',(data)=>{
96
+ this.triggerChange(data)
97
+ });
98
+ Bus.$on('change-app', ({appId,appInfo})=> {
99
+ this.changeApp(appId,appInfo)
100
+ })
101
+ Bus.$on('tag-list',(data,current)=>{
102
+ this.initTags(data,current)
103
+ });
104
+ Bus.$on('menu-click',(current)=>{
105
+ this.menuClick(current)
106
+ });
107
+ },
108
+ destroyListener(){
109
+ Bus.$off('nav-list')
110
+ Bus.$off('menu-list')
111
+ Bus.$off('trigger-change')
112
+ Bus.$off('change-app')
113
+ Bus.$off('tag-list')
114
+ Bus.$off('menu-click')
115
+ Bus.$off('system-info')
116
+ },
117
+ initSystem(data){
118
+ if (data) {
119
+ this.systemInfo = data;
120
+ if (data.isShowSearch) {
121
+ // console.log('head中的isShowSearch',data.isShowSearch)
122
+ this.isShowSearch = data.isShowSearch;
123
+ }
124
+ }
125
+ },
126
+ initNav(data){
127
+ if (data.toString() === this.navList.toString()) {
128
+ return;
129
+ }
130
+ this.navList = data;
131
+ },
132
+ handleSelect(name,uri,pid){
133
+ //console.log('head中的handleSelect',name,uri,pid)
134
+ let menu = null;
135
+ if (name.indexOf("isTurnByHref_") > -1) {
136
+ name = name.replace("isTurnByHref_","");
137
+ menu = filterMenuUri(this.menuList,name);
138
+ } else {
139
+ menu = filterMenuName(this.menuList,name);
140
+ }
141
+ let tagList = this.tagList;
142
+ if (menu && menu.name) {
143
+ if (!tagExists(tagList,menu.name)) {
144
+ tagList.push(menu);
145
+ }
146
+ Bus.$emit('tag-list', tagList, menu.name)
147
+ }
148
+ if (menu.meta && Array.isArray(menu.meta.crumbs)) {
149
+ let parentMenu = menu.meta.crumbs[0]
150
+ // console.log('parentMenu',parentMenu)
151
+ this.$set(this, 'selectedTopParent', parentMenu.name);
152
+ } else {
153
+ // 处理没有父菜单的情况
154
+ this.$set(this, 'selectedTopParent', menu.name);
155
+ }
156
+ // 如果 uri 为空,则需要根据 pid 判断是展开父菜单还是同时展开父菜单和当前菜单
157
+ if (!uri) {
158
+ let parentName;
159
+ if (pid === 0) {
160
+ // 如果 pid 为 0,表示是最外层菜单
161
+ parentName = this.getNameOrHref(menu);
162
+ //console.log('parentName',parentName)
163
+ this.openedNames = [parentName]; // 设置最外层父菜单为展开状态
164
+ } else {
165
+ // 如果 pid 不等于 0,查找并打开对应的最外层父菜单
166
+ parentName = this.getTopParent(menu);
167
+ this.openedNames = [parentName]; // 设置最外层父菜单为展开状态
168
+ this.activeName = menu.name; // 设置当前菜单为激活状态
169
+ }
170
+ }
171
+ // console.log("nextTick之前,openedNames:", this.openedNames);
172
+
173
+ },
174
+
175
+ getTopParent(menu) {
176
+ //console.log('menu',menu)
177
+ return menu.parent ? this.getTopParent(menu.parent) : menu.name;
178
+ },
179
+ initMenu(data){
180
+ if (data && data.length > 0) {
181
+ let item = data[0];
182
+ if (item.appId && item.appId !== this.appId) {
183
+ return;
184
+ }
185
+ }
186
+ this.originMenuList = deepCopy(data);
187
+ this.changeMenu()
188
+ },
189
+ changeApp(appId,appInfo){
190
+ this.appId = appId;
191
+ this.changeMenu()
192
+ },
193
+ changeMenu(){
194
+ let treeMenuList = generatorMenuList(this.originMenuList,this.appId);
195
+ if (treeMenuList && treeMenuList.length > 0) {
196
+ this.menuList = treeMenuList;
197
+ } else {
198
+ this.menuList = [];
199
+ }
200
+ this.openedNames = this.getOpenedNamesByActiveName();
201
+ },
202
+ activeIconBackground(item) {
203
+ // console.log('activeBack')
204
+ // 如果当前菜单项是激活的,返回一个颜色值,否则返回空
205
+ return this.selectedMenuParent=== item.parent ? '#ff0000' : '';
206
+ },
207
+ triggerChange(data){
208
+ this.collapsed = data;
209
+ },
210
+ initTags(data,name){
211
+ this.tagList = data;
212
+ this.value = name;
213
+ },
214
+ menuClick(current) {
215
+ let item = this.originMenuList.filter(menu => menu.name === current);
216
+ if (item && item.length > 0){
217
+ let type = item[0].type;
218
+ if (type == 2) {
219
+ this.activeName = current;
220
+ } else {
221
+ let pItem = this.originMenuList.filter(menu => menu.permissionId === item[0].pid);
222
+ if (pItem && pItem.length > 0){
223
+ this.activeName = pItem[0].name;
224
+ }
225
+ }
226
+ } else {
227
+ this.activeName = current;
228
+ }
229
+ },
230
+ getOpenedNamesByActiveName(){
231
+ let res = filterMenuName(this.menuList,this.activeName);
232
+ let openNames = []
233
+ if (res) {
234
+ const crumbs = res.meta.crumbs;
235
+ if (crumbs) {
236
+ crumbs.forEach(item => {
237
+ if (item.type === 1) {
238
+ openNames.push(item.name)
239
+ }
240
+ })
241
+ }
242
+ }
243
+ return openNames
244
+ //console.log('side中getOpenedNamesByActiveNameopenedNames:',openNames)
245
+ },
246
+ updateOpened () {
247
+ const items = findComponentsDownward(this, 'Submenu');
248
+ if (items.length) {
249
+ items.forEach(item => {
250
+ if (this.openedNames.indexOf(item.name) > -1) item.opened = true;
251
+ else item.opened = false;
252
+ });
253
+ }
254
+ },
255
+ updateActiveName () {
256
+ if (this.currentActiveName === undefined) {
257
+ this.currentActiveName = -1;
258
+ }
259
+ // this.broadcast('Submenu', 'on-update-active-name', false);
260
+ // this.broadcast('MenuItem', 'on-update-active-name', this.currentActiveName);
261
+ }
262
+ },
263
+ watch:{
264
+ activeName(){
265
+ this.openedNames = this.getOpenedNamesByActiveName();
266
+ // console.log("head中的gqz1activeName:", this.activeName);
267
+ // console.log("head中的gqz1openedNames:", this.openedNames);
268
+ },
269
+ openedNames() {
270
+ // console.log("head中的gqz3openedNames:", this.openedNames);
271
+ this.$nextTick(() => {
272
+ this.updateOpened()
273
+ this.updateActiveName()
274
+ })
275
+ // console.log("head中的gqz2activeName:", this.activeName);
276
+ // console.log("head中的gqz2openedNames:", this.openedNames);
277
+ }
278
+ },
279
+ created(){
280
+ this.initListener();
281
+ },
282
+ beforeDestroy(){
283
+ this.destroyListener();
30
284
  }
31
285
  }
32
286
  </script>
@@ -49,4 +303,4 @@ export default {
49
303
  float: right;
50
304
  }
51
305
  }
52
- </style>
306
+ </style>
@@ -1,30 +1,100 @@
1
1
  <template>
2
- <div class="pro-layout-logo-wrapper">
3
- <div class="logo" :style="logoStyle"></div>
4
- <div class="divider"></div>
5
- <div class="system-name">{{systemName}}</div>
2
+ <div class="pro-layout-logo-wrapper" @click="handleClick">
3
+ <div class="logo" v-if="systemInfo.systemLogo !='hide'" :style="logoStyle"></div>
4
+ <div class="divider" v-if="systemInfo.systemLogo !='hide'"></div>
5
+ <div class="system-name" :style="nameStyle">{{systemName}}</div>
6
6
  </div>
7
7
  </template>
8
8
 
9
9
  <script>
10
10
  import Bus from '@lambo-design/shared/utils/bus'
11
11
  export default {
12
+
12
13
  name: "pro-layout-logo",
14
+ props:{
15
+ routeName:String,
16
+ default:''
17
+ },
13
18
  data(){
14
19
  return {
15
20
  systemInfo: {},
16
- systemName: '后台管理系统'
21
+ systemName: '后台管理系统',
22
+ isHovered: false,
23
+ src:''
17
24
  }
18
25
  },
19
26
  computed:{
20
- logoStyle(){
27
+ logoStyle() {
28
+ let style = '';
21
29
  if (this.systemInfo && this.systemInfo.systemLogo) {
22
- return 'background: url("' + this.systemInfo.systemLogo + '") no-repeat;background-size: 100%;'
30
+ style += `background: url("${this.systemInfo.systemLogo}") no-repeat; background-size: 100%;`;
31
+ // 如果 systemInfo.logoWidth 存在且不为空,则添加到样式
32
+ if (this.systemInfo.logoWidth && this.systemInfo.logoWidth !== '') {
33
+ style += `width: ${this.systemInfo.logoWidth}px;`;
34
+ }
35
+ // 如果 systemInfo.logoTop 存在且不为空,则添加到样式
36
+ if (this.systemInfo.logoTop && this.systemInfo.logoTop !== '') {
37
+ style += `margin-top: ${this.systemInfo.logoTop}px;`;
38
+ }
39
+ style += `text-align-last: justify;`
23
40
  }
24
- return '';
41
+ return style;
42
+ },
43
+
44
+ // nameStyle() {
45
+ // const fontSize = 20; // 固定的字体大小是 20px
46
+ // const lineHeight = 50; // 固定的行高是 50px
47
+ // const nameSize = this.systemInfo.nameSize || 1; // 默认行数为1,如果未指定则使用1
48
+ // // 计算总高度
49
+ // const height = lineHeight * nameSize; // 确保至少有一行高度,即使nameSize小于1
50
+ // return {
51
+ // 'font-size': `${fontSize}px`, // 应用固定的字体大小
52
+ // 'line-height': `${lineHeight}px`, // 应用固定的行高
53
+ // 'height': `${height}px`, // 应用计算出的总高度
54
+ // 'overflow': 'hidden', // 确保多余的文本被裁剪
55
+ // 'white-space': 'pre-wrap', // 允许换行
56
+ // 'word-break': 'break-all'
57
+ // };
58
+ // }
59
+
60
+ nameStyle() {
61
+ let style = '';
62
+ if (this.systemInfo && this.systemInfo.nameSize) {
63
+ const lines = this.systemInfo.nameSize; // 行数
64
+ const maxHeight = lineHeight * lines; // 计算最大高度
65
+
66
+ // 根据nameSize设置margin-top
67
+ if (lines === '1') {
68
+ style += `margin-top: 12.8px;`;
69
+ } else if (lines === '2') {
70
+ style += `margin-top: 6px; `;
71
+ }
72
+
73
+ // 动态计算字体大小
74
+ const fontSize = Math.max(20 - (lines - 1) * 4, 15); // 字体大小递减
75
+ const lineHeight = fontSize + 5; // 固定行高
76
+ const width = (this.systemName.length / lines) * fontSize + 20;
77
+
78
+ // 组装样式字符串
79
+ style += `line-height: ${lineHeight}px;`;
80
+ style += `font-size: ${fontSize}px;`;
81
+ style += `max-height: ${maxHeight}px;`; // 设置最大高度限制行数
82
+ style += `width: ${width}px;`; // 设置宽度
83
+ style += `overflow: hidden;`; // 超出部分隐藏
84
+ style += `word-wrap: break-word;`; // 允许单词内换行
85
+ style += `white-space: normal;`; // 默认的换行方式
86
+ style += `text-align-last: justify;`;
87
+ style += `text-align: justify;`;
88
+ }
89
+ return style;
25
90
  }
91
+
26
92
  },
27
93
  methods: {
94
+
95
+ handleClick(){
96
+ this.$emit('clickLogo')
97
+ },
28
98
  initListener(){
29
99
  Bus.$on('system-info',(data)=>{
30
100
  this.initSystem(data)
@@ -40,7 +110,8 @@ export default {
40
110
  this.systemName = data.systemName;
41
111
  }
42
112
  }
43
- }
113
+ },
114
+
44
115
  },
45
116
  created(){
46
117
  this.initListener();
@@ -54,13 +125,14 @@ export default {
54
125
  <style scoped lang="less">
55
126
  .pro-layout-logo-wrapper{
56
127
  overflow: hidden;
128
+ cursor:pointer;
57
129
  .logo{
58
130
  width: 150px;
59
131
  height: 55px;
60
- background: url("../styles/images/logo.png") no-repeat;
132
+ background: url("../styles/images/inspur.png") no-repeat;
61
133
  background-size: 100%;
62
134
  float: left;
63
- margin-top: 8px;
135
+ margin-top: 20px;
64
136
  }
65
137
  .divider{
66
138
  height: 33px;
@@ -74,6 +146,7 @@ export default {
74
146
  font-weight: bold;
75
147
  font-size: 20px;
76
148
  margin-right: 15px;
149
+
77
150
  }
78
151
  }
79
- </style>
152
+ </style>