Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
B
basic-vue-admin
概览
概览
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Basic
basic-vue-admin
Commits
2f12556d
提交
2f12556d
authored
10月 19, 2020
作者:
vben
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: fix the top menu adaptive failure
上级
5737e478
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
70 行增加
和
22 行删除
+70
-22
App.vue
src/App.vue
+1
-0
BasicMenu.tsx
src/components/Menu/src/BasicMenu.tsx
+2
-1
useOpenKeys.ts
src/components/Menu/src/useOpenKeys.ts
+19
-13
BasicModal.tsx
src/components/Modal/src/BasicModal.tsx
+5
-1
useWindowSize.ts
src/hooks/event/useWindowSize.ts
+6
-1
LayoutHeader.tsx
src/layouts/default/LayoutHeader.tsx
+34
-3
index.less
src/layouts/default/index.less
+3
-3
没有找到文件。
src/App.vue
浏览文件 @
2f12556d
...
...
@@ -18,6 +18,7 @@
import
{
useSetting
}
from
'/@/hooks/core/useSetting'
;
moment
.
locale
(
'zh-cn'
);
export
default
defineComponent
({
name
:
'App'
,
components
:
{
ConfigProvider
},
...
...
src/components/Menu/src/BasicMenu.tsx
浏览文件 @
2f12556d
...
...
@@ -45,7 +45,8 @@ export default defineComponent({
menuState
,
toRef
(
props
,
'items'
),
toRef
(
props
,
'flatItems'
),
toRef
(
props
,
'isAppMenu'
)
toRef
(
props
,
'isAppMenu'
),
toRef
(
props
,
'mode'
)
);
const
getOpenKeys
=
computed
(()
=>
{
...
...
src/components/Menu/src/useOpenKeys.ts
浏览文件 @
2f12556d
import
{
MenuModeEnum
}
from
'/@/enums/menuEnum'
;
import
type
{
Menu
as
MenuType
}
from
'/@/router/types'
;
import
type
{
MenuState
}
from
'./types'
;
import
type
{
Ref
}
from
'vue'
;
...
...
@@ -10,7 +11,8 @@ export function useOpenKeys(
menuState
:
MenuState
,
menus
:
Ref
<
MenuType
[]
>
,
flatMenusRef
:
Ref
<
MenuType
[]
>
,
isAppMenu
:
Ref
<
boolean
>
isAppMenu
:
Ref
<
boolean
>
,
mode
:
Ref
<
MenuModeEnum
>
)
{
/**
* @description:设置展开
...
...
@@ -28,21 +30,25 @@ export function useOpenKeys(
}
function
handleOpenChange
(
openKeys
:
string
[])
{
const
rootSubMenuKeys
:
string
[]
=
[];
for
(
const
{
children
,
path
}
of
unref
(
menus
))
{
if
(
children
&&
children
.
length
>
0
)
{
rootSubMenuKeys
.
push
(
path
);
if
(
unref
(
mode
)
===
MenuModeEnum
.
HORIZONTAL
)
{
menuState
.
openKeys
=
openKeys
;
}
else
{
const
rootSubMenuKeys
:
string
[]
=
[];
for
(
const
{
children
,
path
}
of
unref
(
menus
))
{
if
(
children
&&
children
.
length
>
0
)
{
rootSubMenuKeys
.
push
(
path
);
}
}
}
if
(
!
menuStore
.
getCollapsedState
||
!
unref
(
isAppMenu
))
{
const
latestOpenKey
=
openKeys
.
find
((
key
)
=>
menuState
.
openKeys
.
indexOf
(
key
)
===
-
1
);
if
(
rootSubMenuKeys
.
indexOf
(
latestOpenKey
as
string
)
===
-
1
)
{
menuState
.
openKeys
=
openKeys
;
if
(
!
menuStore
.
getCollapsedState
||
!
unref
(
isAppMenu
))
{
const
latestOpenKey
=
openKeys
.
find
((
key
)
=>
menuState
.
openKeys
.
indexOf
(
key
)
===
-
1
);
if
(
rootSubMenuKeys
.
indexOf
(
latestOpenKey
as
string
)
===
-
1
)
{
menuState
.
openKeys
=
openKeys
;
}
else
{
menuState
.
openKeys
=
latestOpenKey
?
[
latestOpenKey
]
:
[];
}
}
else
{
menuState
.
openKeys
=
latestOpenKey
?
[
latestOpenKey
]
:
[]
;
menuState
.
collapsedOpenKeys
=
openKeys
;
}
}
else
{
menuState
.
collapsedOpenKeys
=
openKeys
;
}
}
return
{
setOpenKeys
,
resetKeys
,
handleOpenChange
};
...
...
src/components/Modal/src/BasicModal.tsx
浏览文件 @
2f12556d
...
...
@@ -217,7 +217,11 @@ export default defineComponent({
const
uuid
=
buildUUID
();
emit
(
'register'
,
modalMethods
,
uuid
);
return
()
=>
(
<
Modal
onCancel=
{
handleCancel
}
{
...
{
...
attrs
,
...
props
,
...
unref
(
getProps
)
}}
>
<
Modal
onCancel=
{
handleCancel
}
{
...
{
...
attrs
,
...
props
,
...
unref
(
getProps
)
}}
getContainer=
{
()
=>
document
.
querySelector
(
'.default-layout__main'
)
}
>
{
{
...
extendSlots
(
slots
,
[
'default'
]),
default
:
()
=>
renderContent
(),
...
...
src/hooks/event/useWindowSize.ts
浏览文件 @
2f12556d
...
...
@@ -4,6 +4,7 @@ import { tryOnMounted, tryOnUnmounted } from '/@/utils/helper/vueHelper';
import
{
ref
}
from
'vue'
;
import
{
useDebounce
}
from
'/@/hooks/core/useDebounce'
;
import
{
CancelFn
}
from
'../core/types'
;
interface
WindowSizeOptions
{
once
?:
boolean
;
...
...
@@ -11,7 +12,7 @@ interface WindowSizeOptions {
listenerOptions
?:
AddEventListenerOptions
|
boolean
;
}
export
function
useWindowSizeFn
<
T
>
(
fn
:
Fn
<
T
>
,
wait
=
150
,
options
?:
WindowSizeOptions
):
void
{
export
function
useWindowSizeFn
<
T
>
(
fn
:
Fn
<
T
>
,
wait
=
150
,
options
?:
WindowSizeOptions
):
CancelFn
{
let
handler
=
()
=>
{
fn
();
};
...
...
@@ -19,6 +20,9 @@ export function useWindowSizeFn<T>(fn: Fn<T>, wait = 150, options?: WindowSizeOp
handler
=
handleSize
;
tryOnMounted
(()
=>
{
if
(
options
&&
options
.
immediate
)
{
handler
();
}
window
.
addEventListener
(
'resize'
,
handler
);
});
...
...
@@ -26,6 +30,7 @@ export function useWindowSizeFn<T>(fn: Fn<T>, wait = 150, options?: WindowSizeOp
window
.
removeEventListener
(
'resize'
,
handler
);
cancel
();
});
return
cancel
;
}
export
const
useWindowSize
=
(
wait
=
150
,
options
?:
WindowSizeOptions
)
=>
{
...
...
src/layouts/default/LayoutHeader.tsx
浏览文件 @
2f12556d
import
{
defineComponent
,
unref
,
computed
}
from
'vue'
;
import
{
defineComponent
,
unref
,
computed
,
ref
}
from
'vue'
;
import
{
Layout
,
Tooltip
,
Badge
}
from
'ant-design-vue'
;
import
Logo
from
'/@/layouts/Logo.vue'
;
import
UserDropdown
from
'./UserDropdown'
;
...
...
@@ -21,17 +21,44 @@ import LockAction from './actions/LockActionItem';
import
{
useModal
}
from
'/@/components/Modal/index'
;
import
{
errorStore
}
from
'/@/store/modules/error'
;
import
{
useGo
}
from
'/@/hooks/web/usePage'
;
import
{
useWindowSizeFn
}
from
'/@/hooks/event/useWindowSize'
;
export
default
defineComponent
({
name
:
'DefaultLayoutHeader'
,
setup
()
{
const
widthRef
=
ref
(
200
);
const
{
refreshPage
}
=
useTabs
();
const
[
register
,
{
openModal
}]
=
useModal
();
const
{
toggleFullscreen
,
isFullscreenRef
}
=
useFullscreen
();
const
go
=
useGo
();
const
getProjectConfigRef
=
computed
(()
=>
{
return
appStore
.
getProjectConfig
;
});
const
showTopMenu
=
computed
(()
=>
{
const
getProjectConfig
=
unref
(
getProjectConfigRef
);
const
{
menuSetting
:
{
mode
,
split
:
splitMenu
},
}
=
getProjectConfig
;
return
mode
===
MenuModeEnum
.
HORIZONTAL
||
splitMenu
;
});
let
logoEl
:
Element
|
null
;
useWindowSizeFn
(
()
=>
{
if
(
!
unref
(
showTopMenu
))
return
;
let
width
=
0
;
if
(
!
logoEl
)
{
logoEl
=
document
.
querySelector
(
'.layout-header__logo'
);
}
if
(
logoEl
)
{
width
+=
logoEl
.
clientWidth
;
}
widthRef
.
value
=
width
+
60
;
},
200
,
{
immediate
:
true
}
);
function
goToGithub
()
{
window
.
open
(
GITHUB_URL
,
'__blank'
);
...
...
@@ -64,6 +91,7 @@ export default defineComponent({
}
=
getProjectConfig
;
const
isSidebarType
=
menuType
===
MenuTypeEnum
.
SIDEBAR
;
const
width
=
unref
(
widthRef
);
return
(
<
Layout
.
Header
class=
{
[
'layout-header'
,
'flex p-0 px-4 '
,
unref
(
headerClass
)]
}
>
{
()
=>
(
...
...
@@ -74,8 +102,11 @@ export default defineComponent({
{
mode
!==
MenuModeEnum
.
HORIZONTAL
&&
showBreadCrumb
&&
!
splitMenu
&&
(
<
LayoutBreadcrumb
/>
)
}
{
(
mode
===
MenuModeEnum
.
HORIZONTAL
||
splitMenu
)
&&
(
<
div
class=
{
[
`layout-header__menu `
,
`justify-${topMenuAlign}`
]
}
>
{
unref
(
showTopMenu
)
&&
(
<
div
class=
{
[
`layout-header__menu `
,
`justify-${topMenuAlign}`
]
}
style=
{
{
width
:
`calc(100% - ${unref(width)}px)`
}
}
>
<
LayoutMenu
theme=
{
headerTheme
}
splitType=
{
splitMenu
?
MenuSplitTyeEnum
.
TOP
:
MenuSplitTyeEnum
.
NONE
}
...
...
src/layouts/default/index.less
浏览文件 @
2f12556d
...
...
@@ -206,7 +206,7 @@
&__content {
flex-grow: 1;
display: flex;
justify-content: center;
//
justify-content: center;
align-items: center;
}
...
...
@@ -346,11 +346,11 @@
}
&__menu {
display: flex;
//
display: flex;
margin-left: 20px;
overflow: hidden;
align-items: center;
flex-grow: 1;
//
flex-grow: 1;
}
&__user-dropdown {
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论