Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
W
WebPublic
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
前端开发小组
WebPublic
Commits
30160d13
提交
30160d13
authored
5月 19, 2022
作者:
钟是志
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
优化代码
上级
42be60e1
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
206 行增加
和
0 行删除
+206
-0
SplitBasicLayout.js
zyd_private/BasicLayout/SplitBasicLayout.js
+195
-0
basiclayout.js
zyd_private/utils/basiclayout.js
+11
-0
没有找到文件。
zyd_private/BasicLayout/SplitBasicLayout.js
0 → 100644
浏览文件 @
30160d13
import
lsz
from
"@/assets/time.gif"
;
import
React
from
"react"
;
import
config
from
"@/config/config"
;
import
{
formatMessage
}
from
"umi/locale"
;
import
{
getSysConfig
}
from
"../utils/basiclayout"
;
import
{
isJSON
}
from
"@/webPublic/zyd_public/utils/utils"
;
const
query
=
{
"screen-xs"
:
{
maxWidth
:
575
},
"screen-sm"
:
{
minWidth
:
576
,
maxWidth
:
767
},
"screen-md"
:
{
minWidth
:
768
,
maxWidth
:
991
},
"screen-lg"
:
{
minWidth
:
992
,
maxWidth
:
1199
},
"screen-xl"
:
{
minWidth
:
1200
,
maxWidth
:
1599
},
"screen-xxl"
:
{
minWidth
:
1600
}
};
const
getSystemConfig
=
()
=>
{
const
urlParams
=
new
URL
(
window
.
location
.
href
);
const
systemList
=
[
"/xg/"
,
"/yx/"
,
"/jy/"
,
"/lx/"
,
"/sg/"
,
"/xl/"
,
"/zs/"
,
"/uaa/"
,
"/tw/"
,
"/ytw/"
,
"/wzb/"
,
"/szcp/"
];
let
findSystem
=
systemList
.
find
((
g
)
=>
{
return
urlParams
.
href
.
indexOf
(
g
)
>
0
;
});
if
(
findSystem
)
{
let
systemX
=
findSystem
.
replace
(
/
[/]
/g
,
""
);
return
config
.
systems
[
systemX
];
}
return
config
.
systems
[
"jc"
];
};
const
antIcon
=
<
div
style
=
{
{
position
:
"absolute"
,
zIndex
:
999999
,
width
:
32
,
left
:
"48%"
}}
>
<
img
src
=
{
lsz
}
style
=
{{
width
:
32
,
height
:
32
}}
/
>
<
/div>
;
const
formatter
=
(
data
,
parentPath
=
""
,
parentAuthority
,
parentName
)
=>
{
return
data
.
map
(
item
=>
{
if
(
config
.
checkPath
)
{
item
.
authority
=
[
item
.
path
];
}
let
locale
=
"menu"
;
if
(
parentName
&&
item
.
name
)
{
locale
=
`
${
parentName
}
.
${
item
.
name
}
`
;
}
else
if
(
item
.
name
)
{
locale
=
`menu.
${
item
.
name
}
`
;
}
else
if
(
parentName
)
{
locale
=
parentName
;
}
const
result
=
{
...
item
,
locale
,
authority
:
item
.
authority
||
parentAuthority
};
if
(
item
.
routes
)
{
const
children
=
formatter
(
item
.
routes
,
`
${
parentPath
}${
item
.
path
}
/`
,
item
.
authority
,
locale
);
// Reduce memory usage
result
.
children
=
children
;
}
delete
result
.
routes
;
return
result
;
});
};
const
getMenuData
=
(
routes
)
=>
{
const
newRoutes
=
formatter
(
routes
);
// console.log(newRoutes); //钟是志 TODO
return
newRoutes
;
};
// 插入动态菜单
const
insertActiveMenus
=
(
routes
=
[],
insertRoutes
=
[])
=>
{
let
deleteIndex
=
[];
if
(
!
insertRoutes
||
!
insertRoutes
.
length
)
{
return
routes
;
}
for
(
let
i
=
0
;
i
<
routes
.
length
;
i
++
)
{
let
item
=
routes
[
i
];
for
(
let
g
=
0
;
g
<
insertRoutes
.
length
;
g
++
)
{
let
targetItem
=
insertRoutes
[
g
];
if
(
targetItem
.
oldBrotherPath
&&
targetItem
.
oldBrotherPath
===
item
.
path
)
{
// 发现哥哥节点 插入
// console.log(targetItem);
// debugger;
routes
.
splice
(
i
+
1
,
0
,
targetItem
);
deleteIndex
.
push
(
g
);
}
if
(
targetItem
.
parentPath
===
item
.
path
&&
!
targetItem
.
oldBrotherPath
)
{
// 没有哥哥节点的路由 插入
if
(
item
.
children
)
{
item
.
children
.
unshift
(
targetItem
);
}
else
{
item
.
children
=
[
targetItem
];
}
deleteIndex
.
push
(
g
);
}
}
if
(
deleteIndex
.
length
)
{
for
(
let
i
=
0
;
i
<
insertRoutes
.
length
;
i
++
){
if
(
deleteIndex
.
includes
(
i
)){
insertRoutes
[
i
].
isDelete
=
true
;
}
}
insertRoutes
=
insertRoutes
.
filter
((
g
)
=>
{
return
!
g
.
isDelete
;
});
deleteIndex
=
[];
// 每次循环完 要清空这个 才行. 不然递归里面会删除多的
}
if
(
Array
.
isArray
(
item
.
children
)
&&
item
.
children
.
length
)
{
insertActiveMenus
(
item
.
children
,
insertRoutes
);
}
}
return
routes
;
};
export
{
antIcon
,
query
,
getSystemConfig
,
formatter
,
getMenuData
,
insertActiveMenus
};
export
const
getDiyChineseMenus
=
()
=>
{
const
menuChineseConfig
=
getSysConfig
().
menuChineseConfig
;
const
menusList
=
isJSON
(
menuChineseConfig
)
&&
JSON
.
parse
(
menuChineseConfig
)
||
{};
return
menusList
;
}
export
const
getChineseName
=
(
item
)
=>
{
// 获取菜单名字
if
(
!
item
){
return
''
;
}
const
menusList
=
getDiyChineseMenus
();
if
(
menusList
[
item
.
path
])
{
return
menusList
[
item
.
path
];
}
return
item
.
chineseLocale
||
formatMessage
({
id
:
item
.
locale
});
};
export
const
insertDetailPath
=
(
res
=
[])
=>
{
// 插入详情路由
for
(
let
item
of
res
){
if
(
item
.
from
===
'onestopApp'
&&
(
item
.
component
===
'Apply'
||
item
.
component
===
'Audit'
)){
// 插入详情路由
const
pathSplit
=
item
.
path
.
split
(
'/'
);
pathSplit
[
pathSplit
.
length
-
1
]
=
'Detail'
;
const
pathDetail
=
pathSplit
.
join
(
'/'
);
// console.log(pathDetail);
let
checkHaveDetail
=
res
.
find
((
g
)
=>
{
return
g
.
path
===
pathDetail
;
});
if
(
!
checkHaveDetail
){
res
.
push
({
...
item
,
component
:
'Detail'
,
path
:
pathDetail
,
id
:
Math
.
random
(),
hideInMenu
:
'1'
,
})
}
}
}
return
res
;
}
export
const
giveAuthority
=
(
res
=
[])
=>
{
for
(
let
item
of
res
){
item
.
authority
=
[
item
.
path
];
item
.
hideInMenu
=
item
.
hideInMenu
===
'1'
;
item
.
exact
=
true
;
if
(
item
.
component
===
'Parent'
){
item
.
children
=
[];
}
}
return
res
;
}
zyd_private/utils/basiclayout.js
0 → 100644
浏览文件 @
30160d13
export
function
setSysConfig
(
data
)
{
return
localStorage
.
setItem
(
'xg-web-sysconfig'
,
JSON
.
stringify
(
data
));
}
export
function
getSysConfig
()
{
const
sysConfig
=
localStorage
.
getItem
(
'xg-web-sysconfig'
);
if
(
sysConfig
)
{
return
JSON
.
parse
(
sysConfig
);
}
return
{};
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论