Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
najiu-admin-template
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
najiu-frontend
najiu-admin-template
Commits
beb4c3a3
Commit
beb4c3a3
authored
Oct 13, 2020
by
nebv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: fix routing switch, tab is not activated
parent
177010bf
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
42 additions
and
26 deletions
+42
-26
BasicMenu.tsx
src/components/Menu/src/BasicMenu.tsx
+7
-8
usePage.ts
src/hooks/web/usePage.ts
+1
-0
useTabs.ts
src/hooks/web/useTabs.ts
+7
-3
Logo.vue
src/layouts/Logo.vue
+2
-2
LayoutMenu.tsx
src/layouts/default/LayoutMenu.tsx
+1
-1
index.less
src/layouts/default/index.less
+1
-1
index.tsx
src/layouts/default/multitabs/index.tsx
+22
-10
projectSetting.ts
src/settings/projectSetting.ts
+1
-1
No files found.
src/components/Menu/src/BasicMenu.tsx
View file @
beb4c3a3
...
@@ -239,14 +239,13 @@ export default defineComponent({
...
@@ -239,14 +239,13 @@ export default defineComponent({
)
:
(
)
:
(
<
section
class=
{
`basic-menu-wrap`
}
>
<
section
class=
{
`basic-menu-wrap`
}
>
{
getSlot
(
slots
,
'
header
'
)
}
{
getSlot
(
slots
,
'
header
'
)
}
{
props
.
search
&&
(
<
SearchInput
<
SearchInput
class=
{
!
props
.
search
?
'
hidden
'
:
''
}
theme=
{
props
.
theme
}
theme=
{
props
.
theme
}
onChange=
{
handleInputChange
}
onChange=
{
handleInputChange
}
onClick=
{
handleInputClick
}
onClick=
{
handleInputClick
}
collapsed=
{
getCollapsedState
}
collapsed=
{
getCollapsedState
}
/>
/>
)
}
<
section
style=
{
unref
(
getMenuWrapStyle
)
}
>
<
section
style=
{
unref
(
getMenuWrapStyle
)
}
>
<
ScrollContainer
>
{
()
=>
renderMenu
()
}
</
ScrollContainer
>
<
ScrollContainer
>
{
()
=>
renderMenu
()
}
</
ScrollContainer
>
</
section
>
</
section
>
...
...
src/hooks/web/usePage.ts
View file @
beb4c3a3
...
@@ -10,6 +10,7 @@ export type RouteLocationRawEx = Omit<RouteLocationRaw, 'path'> & { path: PageEn
...
@@ -10,6 +10,7 @@ export type RouteLocationRawEx = Omit<RouteLocationRaw, 'path'> & { path: PageEn
function
handleError
(
e
:
Error
)
{
function
handleError
(
e
:
Error
)
{
console
.
error
(
e
);
console
.
error
(
e
);
// 101是为了 大于 打开时候设置的100延时防止闪动
setTimeout
(()
=>
{
setTimeout
(()
=>
{
appStore
.
commitPageLoadingState
(
false
);
appStore
.
commitPageLoadingState
(
false
);
},
101
);
},
101
);
...
...
src/hooks/web/useTabs.ts
View file @
beb4c3a3
...
@@ -3,6 +3,9 @@ import { PageEnum } from '/@/enums/pageEnum';
...
@@ -3,6 +3,9 @@ import { PageEnum } from '/@/enums/pageEnum';
import
{
TabItem
,
tabStore
}
from
'
/@/store/modules/tab
'
;
import
{
TabItem
,
tabStore
}
from
'
/@/store/modules/tab
'
;
import
{
appStore
}
from
'
/@/store/modules/app
'
;
import
{
appStore
}
from
'
/@/store/modules/app
'
;
import
router
from
'
/@/router
'
;
import
router
from
'
/@/router
'
;
import
{
ref
}
from
'
vue
'
;
const
activeKeyRef
=
ref
<
string
>
(
''
);
type
Fn
=
()
=>
void
;
type
Fn
=
()
=>
void
;
type
RouteFn
=
(
tabItem
:
TabItem
)
=>
void
;
type
RouteFn
=
(
tabItem
:
TabItem
)
=>
void
;
...
@@ -70,12 +73,13 @@ export function useTabs() {
...
@@ -70,12 +73,13 @@ export function useTabs() {
closeOther
:
()
=>
canIUseFn
()
&&
closeOther
(
tabStore
.
getCurrentTab
),
closeOther
:
()
=>
canIUseFn
()
&&
closeOther
(
tabStore
.
getCurrentTab
),
closeCurrent
:
()
=>
canIUseFn
()
&&
closeCurrent
(
tabStore
.
getCurrentTab
),
closeCurrent
:
()
=>
canIUseFn
()
&&
closeCurrent
(
tabStore
.
getCurrentTab
),
resetCache
:
()
=>
canIUseFn
()
&&
resetCache
(),
resetCache
:
()
=>
canIUseFn
()
&&
resetCache
(),
addTab
:
(
path
:
PageEnum
,
goTo
=
false
)
=>
{
addTab
:
(
path
:
PageEnum
,
goTo
=
false
,
replace
=
false
)
=>
{
useTimeout
(()
=>
{
useTimeout
(()
=>
{
tabStore
.
addTabByPathAction
(
path
);
tabStore
.
addTabByPathAction
(
path
);
},
0
);
},
0
);
activeKeyRef
.
value
=
path
;
goTo
&&
router
.
push
(
path
);
goTo
&&
r
eplace
?
router
.
replace
:
r
outer
.
push
(
path
);
},
},
activeKeyRef
,
};
};
}
}
src/layouts/Logo.vue
View file @
beb4c3a3
<
template
>
<
template
>
<div
class=
"app-logo"
@
click=
"handleGoHome"
>
<div
class=
"app-logo"
@
click=
"handleGoHome"
>
<img
:src=
"logo"
/>
<img
:src=
"logo"
/>
<div
v-if=
"show"
class=
"logo-title ml-
2
ellipsis"
>
{{
globSetting
.
title
}}
</div>
<div
v-if=
"show"
class=
"logo-title ml-
1
ellipsis"
>
{{
globSetting
.
title
}}
</div>
</div>
</div>
</
template
>
</
template
>
<
script
lang=
"ts"
>
<
script
lang=
"ts"
>
...
@@ -62,7 +62,7 @@
...
@@ -62,7 +62,7 @@
.logo-title {
.logo-title {
display: none;
display: none;
font-family: Georgia, serif;
font-family: Georgia, serif;
font-size: 1
8
px;
font-size: 1
6
px;
.respond-to(medium,{
.respond-to(medium,{
display: block;
display: block;
});
});
...
...
src/layouts/default/LayoutMenu.tsx
View file @
beb4c3a3
...
@@ -193,7 +193,7 @@ export default defineComponent({
...
@@ -193,7 +193,7 @@ export default defineComponent({
class=
"layout-menu"
class=
"layout-menu"
theme=
{
themeData
}
theme=
{
themeData
}
showLogo=
{
isShowLogo
}
showLogo=
{
isShowLogo
}
search=
{
unref
(
showSearchRef
)
}
search=
{
unref
(
showSearchRef
)
&&
!
collapsed
}
items=
{
unref
(
menusRef
)
}
items=
{
unref
(
menusRef
)
}
flatItems=
{
unref
(
flatMenusRef
)
}
flatItems=
{
unref
(
flatMenusRef
)
}
onClickSearchInput=
{
handleClickSearchInput
}
onClickSearchInput=
{
handleClickSearchInput
}
...
...
src/layouts/default/index.less
View file @
beb4c3a3
...
@@ -48,7 +48,7 @@
...
@@ -48,7 +48,7 @@
.layout-menu {
.layout-menu {
&__logo {
&__logo {
height: @header-height;
height: @header-height;
padding: 10px;
padding: 10px
4px
;
img {
img {
width: @logo-width;
width: @logo-width;
...
...
src/layouts/default/multitabs/index.tsx
View file @
beb4c3a3
...
@@ -2,7 +2,14 @@ import type { TabContentProps } from './tab.data';
...
@@ -2,7 +2,14 @@ import type { TabContentProps } from './tab.data';
import
type
{
TabItem
}
from
'
/@/store/modules/tab
'
;
import
type
{
TabItem
}
from
'
/@/store/modules/tab
'
;
import
type
{
AppRouteRecordRaw
}
from
'
/@/router/types
'
;
import
type
{
AppRouteRecordRaw
}
from
'
/@/router/types
'
;
import
{
defineComponent
,
watch
,
computed
,
ref
,
unref
,
onMounted
}
from
'
vue
'
;
import
{
defineComponent
,
watch
,
computed
,
// ref,
unref
,
onMounted
,
}
from
'
vue
'
;
import
{
Tabs
}
from
'
ant-design-vue
'
;
import
{
Tabs
}
from
'
ant-design-vue
'
;
import
TabContent
from
'
./TabContent
'
;
import
TabContent
from
'
./TabContent
'
;
...
@@ -12,41 +19,43 @@ import { TabContentEnum } from './tab.data';
...
@@ -12,41 +19,43 @@ import { TabContentEnum } from './tab.data';
import
{
useRouter
}
from
'
vue-router
'
;
import
{
useRouter
}
from
'
vue-router
'
;
import
'
./index.less
'
;
import
{
tabStore
}
from
'
/@/store/modules/tab
'
;
import
{
tabStore
}
from
'
/@/store/modules/tab
'
;
import
{
closeTab
}
from
'
./useTabDropdown
'
;
import
{
closeTab
}
from
'
./useTabDropdown
'
;
import
router
from
'
/@/router
'
;
import
router
from
'
/@/router
'
;
import
{
useTabs
}
from
'
/@/hooks/web/useTabs
'
;
import
{
useTabs
}
from
'
/@/hooks/web/useTabs
'
;
import
{
PageEnum
}
from
'
/@/enums/pageEnum
'
;
import
{
PageEnum
}
from
'
/@/enums/pageEnum
'
;
import
'
./index.less
'
;
export
default
defineComponent
({
export
default
defineComponent
({
name
:
'
MultiTabs
'
,
name
:
'
MultiTabs
'
,
setup
()
{
setup
()
{
let
isAddAffix
=
false
;
let
isAddAffix
=
false
;
const
go
=
useGo
();
const
go
=
useGo
();
const
{
currentRoute
}
=
useRouter
();
const
{
currentRoute
}
=
useRouter
();
const
{
addTab
,
activeKeyRef
}
=
useTabs
();
onMounted
(()
=>
{
onMounted
(()
=>
{
const
{
addTab
}
=
useTabs
();
addTab
(
unref
(
currentRoute
).
path
as
PageEnum
);
addTab
(
unref
(
currentRoute
).
path
as
PageEnum
);
});
});
// 当前激活tab
// 当前激活tab
const
activeKeyRef
=
ref
<
string
>
(
''
);
// const activeKeyRef = ref<string>('');
// 当前tab列表
// 当前tab列表
const
getTabsState
=
computed
(()
=>
{
const
getTabsState
=
computed
(()
=>
{
return
tabStore
.
getTabsState
;
return
tabStore
.
getTabsState
;
});
});
if
(
!
isAddAffix
)
{
addAffixTabs
();
isAddAffix
=
true
;
}
watch
(
watch
(
()
=>
unref
(
currentRoute
).
path
,
()
=>
unref
(
currentRoute
).
path
,
(
path
)
=>
{
(
path
)
=>
{
if
(
!
isAddAffix
)
{
if
(
activeKeyRef
.
value
!==
path
)
{
addAffixTabs
();
activeKeyRef
.
value
=
path
;
isAddAffix
=
true
;
}
}
activeKeyRef
.
value
=
path
;
// 监听路由的话虽然可以,但是路由切换的时间会造成卡顿现象?
// 监听路由的话虽然可以,但是路由切换的时间会造成卡顿现象?
// 使用useTab的addTab的话,当用户手动调转,需要自行调用addTab
// 使用useTab的addTab的话,当用户手动调转,需要自行调用addTab
// tabStore.commitAddTab((unref(currentRoute) as unknown) as AppRouteRecordRaw);
// tabStore.commitAddTab((unref(currentRoute) as unknown) as AppRouteRecordRaw);
...
@@ -55,6 +64,7 @@ export default defineComponent({
...
@@ -55,6 +64,7 @@ export default defineComponent({
immediate
:
true
,
immediate
:
true
,
}
}
);
);
/**
/**
* @description: 过滤所有固定路由
* @description: 过滤所有固定路由
*/
*/
...
@@ -72,6 +82,7 @@ export default defineComponent({
...
@@ -72,6 +82,7 @@ export default defineComponent({
});
});
return
tabs
;
return
tabs
;
}
}
/**
/**
* @description: 设置固定tabs
* @description: 设置固定tabs
*/
*/
...
@@ -87,6 +98,7 @@ export default defineComponent({
...
@@ -87,6 +98,7 @@ export default defineComponent({
activeKeyRef
.
value
=
activeKey
;
activeKeyRef
.
value
=
activeKey
;
go
(
activeKey
,
false
);
go
(
activeKey
,
false
);
}
}
// 关闭当前ab
// 关闭当前ab
function
handleEdit
(
targetKey
:
string
)
{
function
handleEdit
(
targetKey
:
string
)
{
// 新增操作隐藏,目前只使用删除操作
// 新增操作隐藏,目前只使用删除操作
...
...
src/settings/projectSetting.ts
View file @
beb4c3a3
...
@@ -51,7 +51,7 @@ const setting: ProjectConfig = {
...
@@ -51,7 +51,7 @@ const setting: ProjectConfig = {
// 是否显示搜索框
// 是否显示搜索框
showSearch
:
true
,
showSearch
:
true
,
// 菜单宽度
// 菜单宽度
menuWidth
:
20
0
,
menuWidth
:
18
0
,
// 菜单模式
// 菜单模式
mode
:
MenuModeEnum
.
INLINE
,
mode
:
MenuModeEnum
.
INLINE
,
// 菜单类型
// 菜单类型
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment