Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mes-ui
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
周远喜
mes-ui
Commits
ed87d995
Commit
ed87d995
authored
Apr 13, 2020
by
renjintao
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'product' of git.mes123.com:zhouyx/mes-ui into product-rjt
parents
68ab455e
094fd58a
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
642 additions
and
616 deletions
+642
-616
product.vue
layouts/basic-layout/product.vue
+54
-47
index.vue
layouts/basic-layout/tabs/index.vue
+193
-185
index.vue
pages/order/quotation/index.vue
+2
-2
page.js
store/admin/page.js
+393
-382
No files found.
layouts/basic-layout/product.vue
View file @
ed87d995
...
@@ -16,14 +16,10 @@
...
@@ -16,14 +16,10 @@
<td>
<td>
<ul
class=
"table_row_ul"
>
<ul
class=
"table_row_ul"
>
<li>
<li>
<a
class=
"a_goIndex"
@
click=
"goIndex"
>
<a
class=
"a_goIndex"
@
click=
"goIndex"
>
首页一
</a>
首页一
</a>
</li>
</li>
<li>
<li>
<a
class=
"a_goIndex"
@
click=
"goIndexTwo"
>
<a
class=
"a_goIndex"
@
click=
"goIndexTwo"
>
首页二
</a>
首页二
</a>
</li>
</li>
</ul>
</ul>
</td>
</td>
...
@@ -35,7 +31,10 @@
...
@@ -35,7 +31,10 @@
<td>
<td>
<ul
class=
"table_row_ul"
>
<ul
class=
"table_row_ul"
>
<li
v-for=
"(li) in item.children"
>
<li
v-for=
"(li) in item.children"
>
<a
@
click=
"goPage(item,li)"
:class=
"
{'active': li.id === isActive}">
{{
li
.
title
}}
</a>
<a
@
click=
"goPage(item,li)"
:class=
"
{'active': li.id === isActive}"
>
{{
li
.
title
}}
</a>
</li>
</li>
</ul>
</ul>
</td>
</td>
...
@@ -55,12 +54,8 @@
...
@@ -55,12 +54,8 @@
<BreadcrumbItem
to=
"/"
class=
"white"
>
<BreadcrumbItem
to=
"/"
class=
"white"
>
<Icon
type=
"ios-home"
/>
首页
<Icon
type=
"ios-home"
/>
首页
</BreadcrumbItem>
</BreadcrumbItem>
<BreadcrumbItem>
<BreadcrumbItem>
{{
homeMenu
}}
</BreadcrumbItem>
{{
homeMenu
}}
<BreadcrumbItem
:to=
"parthto"
class=
"white"
>
{{
homeMenuItem
}}
</BreadcrumbItem>
</BreadcrumbItem>
<BreadcrumbItem
:to=
"parthto"
class=
"white"
>
{{
homeMenuItem
}}
</BreadcrumbItem>
</Breadcrumb>
</Breadcrumb>
<i-header-search
v-if=
"showSearch && !headerMenu && !isMobile && !showBreadcrumb"
/>
<i-header-search
v-if=
"showSearch && !headerMenu && !isMobile && !showBreadcrumb"
/>
<div
class=
"header_right"
>
<div
class=
"header_right"
>
...
@@ -77,6 +72,11 @@
...
@@ -77,6 +72,11 @@
<i-header-setting
v-if=
"enableSetting && !isMobile"
/>
-->
<i-header-setting
v-if=
"enableSetting && !isMobile"
/>
-->
</div>
</div>
</Header>
</Header>
<div
class=
"i-tabs"
>
<transition
name=
"fade-quick"
>
<i-tabs
v-if=
"tabs"
v-show=
"showHeader"
@
on-reload=
"handleReload"
/>
</transition>
</div>
<Content
class=
"i-layout-content"
>
<Content
class=
"i-layout-content"
>
<keep-alive
:include=
"keepAlive"
>
<keep-alive
:include=
"keepAlive"
>
<nuxt
v-if=
"loadRouter"
/>
<nuxt
v-if=
"loadRouter"
/>
...
@@ -137,9 +137,9 @@ export default {
...
@@ -137,9 +137,9 @@ export default {
isDelayHideSider
:
false
,
// hack,当从隐藏侧边栏的 header 切换到正常 header 时,防止 Logo 抖动
isDelayHideSider
:
false
,
// hack,当从隐藏侧边栏的 header 切换到正常 header 时,防止 Logo 抖动
loadRouter
:
true
,
loadRouter
:
true
,
homeMenu
:
''
,
homeMenu
:
""
,
homeMenuItem
:
""
,
homeMenuItem
:
""
,
parthto
:
''
,
parthto
:
""
};
};
},
},
computed
:
{
computed
:
{
...
@@ -248,7 +248,8 @@ export default {
...
@@ -248,7 +248,8 @@ export default {
},
0
);
},
0
);
},
},
$route
(
to
,
from
)
{
$route
(
to
,
from
)
{
if
(
to
.
name
===
from
.
name
)
{
// 相同路由,不同参数,跳转时,重载页面
if
(
to
.
name
===
from
.
name
)
{
// 相同路由,不同参数,跳转时,重载页面
if
(
Setting
.
sameRouteForceUpdate
)
{
if
(
Setting
.
sameRouteForceUpdate
)
{
this
.
handleReload
();
this
.
handleReload
();
}
}
...
@@ -267,7 +268,8 @@ export default {
...
@@ -267,7 +268,8 @@ export default {
},
},
handleScroll
()
{
handleScroll
()
{
if
(
!
this
.
headerHide
)
return
;
if
(
!
this
.
headerHide
)
return
;
const
scrollTop
=
document
.
body
.
scrollTop
+
document
.
documentElement
.
scrollTop
;
const
scrollTop
=
document
.
body
.
scrollTop
+
document
.
documentElement
.
scrollTop
;
if
(
!
this
.
ticking
)
{
if
(
!
this
.
ticking
)
{
this
.
ticking
=
true
;
this
.
ticking
=
true
;
requestAnimation
(()
=>
{
requestAnimation
(()
=>
{
...
@@ -294,7 +296,8 @@ export default {
...
@@ -294,7 +296,8 @@ export default {
// todo $menuHead.handleGetMenuHeight();
// todo $menuHead.handleGetMenuHeight();
}
}
},
},
handleReload
()
{
// 针对缓存的页面也生效
handleReload
()
{
// 针对缓存的页面也生效
const
isCurrentPageCache
=
this
.
keepAlive
.
indexOf
(
this
.
$route
.
name
)
>
-
1
;
const
isCurrentPageCache
=
this
.
keepAlive
.
indexOf
(
this
.
$route
.
name
)
>
-
1
;
const
pageName
=
this
.
$route
.
name
;
const
pageName
=
this
.
$route
.
name
;
if
(
isCurrentPageCache
)
{
if
(
isCurrentPageCache
)
{
...
@@ -308,24 +311,24 @@ export default {
...
@@ -308,24 +311,24 @@ export default {
}
}
});
});
},
},
goPage
(
u
,
li
)
{
goPage
(
u
,
li
)
{
this
.
$router
.
push
(
li
.
path
)
this
.
$router
.
push
(
li
.
path
)
;
this
.
isActive
=
li
.
id
this
.
isActive
=
li
.
id
;
this
.
homeMenu
=
u
.
title
this
.
homeMenu
=
u
.
title
;
this
.
homeMenuItem
=
li
.
title
this
.
homeMenuItem
=
li
.
title
;
this
.
parthto
=
li
.
path
this
.
parthto
=
li
.
path
;
},
},
goIndex
(){
goIndex
()
{
this
.
$router
.
push
(
"/"
)
this
.
$router
.
push
(
"/"
)
;
this
.
homeMenu
=
''
this
.
homeMenu
=
""
;
this
.
homeMenuItem
=
''
this
.
homeMenuItem
=
""
;
this
.
isActive
=
0
this
.
isActive
=
0
;
},
},
goIndexTwo
(){
goIndexTwo
()
{
this
.
$router
.
push
(
"/home"
)
this
.
$router
.
push
(
"/home"
)
;
this
.
homeMenu
=
''
this
.
homeMenu
=
""
;
this
.
homeMenuItem
=
''
this
.
homeMenuItem
=
""
;
this
.
isActive
=
0
this
.
isActive
=
0
;
}
}
},
},
mounted
()
{
mounted
()
{
...
@@ -342,21 +345,25 @@ export default {
...
@@ -342,21 +345,25 @@ export default {
<
style
lang=
"less"
>
<
style
lang=
"less"
>
.i-layout-header-breadcrumb {
.i-layout-header-breadcrumb {
color: #A7B8CC!important;
//wheat
color: #a7b8cc !important;
//wheat
}
}
.i-layout-header-breadcrumb .white .ivu-breadcrumb-item-link {
.i-layout-header-breadcrumb .white .ivu-breadcrumb-item-link {
color: #ffffff!important;
//wheat
color: #ffffff !important;
//wheat
}
}
.ivu-icon-ios-home{
.ivu-icon-ios-home
{
font-size: 20px;
font-size: 20px;
}
}
.white{
.white
{
color: #ffffff!important;
color: #ffffff
!important;
}
}
.product-layout {
.product-layout {
.i-layout-content {
.i-layout-content {
padding: 5px 10px;
padding: 5px 10px;
}
}
.i-tabs {
width: 100% !important;
height: 40px;
}
.ivu-layout-header {
.ivu-layout-header {
height: 50px;
height: 50px;
line-height: 50px;
line-height: 50px;
...
...
layouts/basic-layout/tabs/index.vue
View file @
ed87d995
...
@@ -44,95 +44,99 @@
...
@@ -44,95 +44,99 @@
</div>
</div>
</
template
>
</
template
>
<
script
>
<
script
>
import
{
mapState
,
mapGetters
,
mapActions
}
from
'vuex'
;
import
{
mapState
,
mapGetters
,
mapActions
}
from
"vuex"
;
import
menuSider
from
'@/menu/sider'
;
import
menuSider
from
"@/menu/sider"
;
import
tTitle
from
'../mixins/translate-title'
;
import
tTitle
from
"../mixins/translate-title"
;
import
Setting
from
'@/setting'
;
import
Setting
from
"@/setting"
;
import
{
getAllSiderMenu
}
from
'@/libs/system'
;
import
{
getAllSiderMenu
}
from
"@/libs/system"
;
export
default
{
export
default
{
name
:
'iTabs'
,
name
:
"iTabs"
,
mixins
:
[
tTitle
],
mixins
:
[
tTitle
],
computed
:
{
computed
:
{
...
mapState
(
'admin/page'
,
[
...
mapState
(
"admin/page"
,
[
"opened"
,
"current"
]),
'opened'
,
...
mapState
(
"admin/layout"
,
[
'current'
"showTabsIcon"
,
"tabsFix"
,
"tabsReload"
,
"headerFix"
,
"headerStick"
,
"isMobile"
,
"menuCollapse"
]),
]),
...
mapState
(
'admin/layout'
,
[
...
mapGetters
(
"admin/menu"
,
[
"hideSider"
]),
'showTabsIcon'
,
classes
()
{
'tabsFix'
,
// return {
'tabsReload'
,
// "i-layout-tabs-fix": this.tabsFix
'headerFix'
,
// };
'headerStick'
,
'isMobile'
,
'menuCollapse'
]),
...
mapGetters
(
'admin/menu'
,
[
'hideSider'
]),
classes
()
{
return
{
'i-layout-tabs-fix'
:
this
.
tabsFix
}
},
},
isHeaderStick
()
{
isHeaderStick
()
{
return
this
.
hideSider
;
return
this
.
hideSider
;
},
},
styles
()
{
styles
()
{
let
style
=
{};
let
style
=
{};
if
(
this
.
tabsFix
&&
!
this
.
headerFix
)
{
if
(
this
.
tabsFix
&&
!
this
.
headerFix
)
{
style
.
top
=
`
${
64
-
this
.
scrollTop
}
px`
;
style
.
top
=
`
${
64
-
this
.
scrollTop
}
px`
;
}
}
const
menuWidth
=
this
.
isHeaderStick
?
0
:
this
.
menuCollapse
?
80
:
Setting
.
menuSideWidth
;
const
menuWidth
=
this
.
isHeaderStick
if
(
!
this
.
isMobile
&&
this
.
tabsFix
)
{
?
0
style
.
width
=
`calc(100% -
${
menuWidth
}
px)`
;
:
this
.
menuCollapse
style
.
left
=
`
${
menuWidth
}
px`
;
?
80
}
:
Setting
.
menuSideWidth
;
// if (!this.isMobile && this.tabsFix) {
// style.width = `calc(100% - ${menuWidth}px)`;
// style.left = `${menuWidth}px`;
// }
return
style
;
return
style
;
}
}
},
},
data
()
{
data
()
{
return
{
return
{
// 得到所有侧边菜单,并转为平级,查询图标用
// 得到所有侧边菜单,并转为平级,查询图标用
allSiderMenu
:
getAllSiderMenu
(
menuSider
),
allSiderMenu
:
getAllSiderMenu
(
menuSider
),
scrollTop
:
0
scrollTop
:
0
}
};
},
},
methods
:
{
methods
:
{
...
mapActions
(
'admin/page'
,
[
...
mapActions
(
"admin/page"
,
[
'close'
,
"close"
,
'closeLeft'
,
"closeLeft"
,
'closeRight'
,
"closeRight"
,
'closeOther'
,
"closeOther"
,
'closeAll'
"closeAll"
]),
]),
tabLabel
(
h
,
page
)
{
tabLabel
(
h
,
page
)
{
const
title
=
h
(
'span'
,
this
.
tTitle
(
page
.
meta
.
title
)
||
'未命名'
);
const
title
=
h
(
"span"
,
this
.
tTitle
(
page
.
meta
.
title
)
||
"未命名"
);
let
slot
=
[];
let
slot
=
[];
if
(
this
.
showTabsIcon
)
{
if
(
this
.
showTabsIcon
)
{
const
fullPathWithoutQuery
=
page
.
fullPath
.
indexOf
(
'?'
)
>=
0
?
page
.
fullPath
.
split
(
'?'
)[
0
]
:
page
.
fullPath
;
const
fullPathWithoutQuery
=
const
currentMenu
=
this
.
allSiderMenu
.
find
(
menu
=>
menu
.
path
===
fullPathWithoutQuery
)
||
{};
page
.
fullPath
.
indexOf
(
"?"
)
>=
0
?
page
.
fullPath
.
split
(
"?"
)[
0
]
:
page
.
fullPath
;
const
currentMenu
=
this
.
allSiderMenu
.
find
(
menu
=>
menu
.
path
===
fullPathWithoutQuery
)
||
{};
let
icon
;
let
icon
;
if
(
currentMenu
.
icon
)
{
if
(
currentMenu
.
icon
)
{
icon
=
h
(
'Icon'
,
{
icon
=
h
(
"Icon"
,
{
props
:
{
props
:
{
type
:
currentMenu
.
icon
type
:
currentMenu
.
icon
}
}
});
});
}
else
if
(
currentMenu
.
custom
)
{
}
else
if
(
currentMenu
.
custom
)
{
icon
=
h
(
'Icon'
,
{
icon
=
h
(
"Icon"
,
{
props
:
{
props
:
{
custom
:
currentMenu
.
custom
custom
:
currentMenu
.
custom
}
}
});
});
}
else
if
(
currentMenu
.
img
)
{
}
else
if
(
currentMenu
.
img
)
{
icon
=
h
(
'img'
,
{
icon
=
h
(
"img"
,
{
attrs
:
{
attrs
:
{
src
:
currentMenu
.
img
src
:
currentMenu
.
img
}
}
...
@@ -145,14 +149,18 @@
...
@@ -145,14 +149,18 @@
slot
.
push
(
title
);
slot
.
push
(
title
);
}
}
return
h
(
'div'
,
{
return
h
(
class
:
'i-layout-tabs-title'
"div"
,
},
slot
);
{
class
:
"i-layout-tabs-title"
},
slot
);
},
},
handleClickTab
(
tabName
)
{
handleClickTab
(
tabName
)
{
if
(
tabName
===
this
.
current
)
{
if
(
tabName
===
this
.
current
)
{
if
(
this
.
tabsReload
)
{
if
(
this
.
tabsReload
)
{
this
.
$emit
(
'on-reload'
);
this
.
$emit
(
"on-reload"
);
}
}
}
else
{
}
else
{
const
page
=
this
.
opened
.
find
(
page
=>
page
.
fullPath
===
tabName
);
const
page
=
this
.
opened
.
find
(
page
=>
page
.
fullPath
===
tabName
);
...
@@ -161,43 +169,43 @@
...
@@ -161,43 +169,43 @@
if
(
page
)
this
.
$router
.
push
({
name
,
params
,
query
},
()
=>
{});
if
(
page
)
this
.
$router
.
push
({
name
,
params
,
query
},
()
=>
{});
}
}
},
},
handleClickClose
(
tagName
)
{
handleClickClose
(
tagName
)
{
this
.
close
({
this
.
close
({
tagName
tagName
});
});
},
},
handleScroll
()
{
handleScroll
()
{
if
(
this
.
tabsFix
&&
!
this
.
headerFix
)
{
//
if (this.tabsFix && !this.headerFix) {
const
scrollTop
=
document
.
body
.
scrollTop
+
document
.
documentElement
.
scrollTop
;
//
const scrollTop = document.body.scrollTop + document.documentElement.scrollTop;
this
.
scrollTop
=
scrollTop
>
64
?
64
:
scrollTop
;
//
this.scrollTop = scrollTop > 64 ? 64 : scrollTop;
}
//
}
},
},
handleClose
(
name
)
{
handleClose
(
name
)
{
const
params
=
{
const
params
=
{
pageSelect
:
this
.
current
pageSelect
:
this
.
current
};
};
switch
(
name
)
{
switch
(
name
)
{
case
'left'
:
case
"left"
:
this
.
closeLeft
(
params
);
this
.
closeLeft
(
params
);
break
;
break
;
case
'right'
:
case
"right"
:
this
.
closeRight
(
params
);
this
.
closeRight
(
params
);
break
;
break
;
case
'other'
:
case
"other"
:
this
.
closeOther
(
params
);
this
.
closeOther
(
params
);
break
;
break
;
case
'all'
:
case
"all"
:
this
.
closeAll
();
this
.
closeAll
();
break
;
break
;
}
}
}
}
},
},
mounted
()
{
mounted
()
{
document
.
addEventListener
(
'scroll'
,
this
.
handleScroll
,
{
passive
:
true
});
document
.
addEventListener
(
"scroll"
,
this
.
handleScroll
,
{
passive
:
true
});
this
.
handleScroll
();
this
.
handleScroll
();
},
},
beforeDestroy
()
{
beforeDestroy
()
{
document
.
removeEventListener
(
'scroll'
,
this
.
handleScroll
);
document
.
removeEventListener
(
"scroll"
,
this
.
handleScroll
);
}
}
}
};
</
script
>
</
script
>
pages/order/quotation/index.vue
View file @
ed87d995
...
@@ -363,7 +363,7 @@ export default {
...
@@ -363,7 +363,7 @@ export default {
},
},
created
()
{
created
()
{
this
.
treeHeight
=
window
.
innerHeight
-
140
;
this
.
treeHeight
=
window
.
innerHeight
-
140
;
this
.
tableHeight
=
window
.
innerHeight
-
2
1
0
;
this
.
tableHeight
=
window
.
innerHeight
-
2
5
0
;
this
.
newColumn
=
this
.
column
;
this
.
newColumn
=
this
.
column
;
this
.
tableTata
(
this
.
selectName
);
this
.
tableTata
(
this
.
selectName
);
},
},
...
@@ -376,7 +376,7 @@ export default {
...
@@ -376,7 +376,7 @@ export default {
return
(()
=>
{
return
(()
=>
{
window
.
screenHeight
=
window
.
innerHeight
;
window
.
screenHeight
=
window
.
innerHeight
;
this
.
treeHeight
=
window
.
screenHeight
-
140
;
this
.
treeHeight
=
window
.
screenHeight
-
140
;
this
.
tableHeight
=
window
.
innerHeight
-
2
1
0
;
this
.
tableHeight
=
window
.
innerHeight
-
2
5
0
;
})();
})();
};
};
},
},
...
...
store/admin/page.js
View file @
ed87d995
...
@@ -9,8 +9,8 @@ import { getAllSiderMenu, includeArray } from '@/libs/system';
...
@@ -9,8 +9,8 @@ import { getAllSiderMenu, includeArray } from '@/libs/system';
// 判定是否需要缓存
// 判定是否需要缓存
const
isKeepAlive
=
data
=>
get
(
data
,
'meta.cache'
,
false
);
const
isKeepAlive
=
data
=>
get
(
data
,
'meta.cache'
,
false
);
export
const
strict
=
false
;
export
const
strict
=
false
;
export
const
state
=
()
=>
({
export
const
state
=
()
=>
({
// 可以在多页 tab 模式下显示的页面
// 可以在多页 tab 模式下显示的页面
pool
:
[],
pool
:
[],
// 当前显示的多页面列表
// 当前显示的多页面列表
...
@@ -21,11 +21,11 @@ export const state=()=>({
...
@@ -21,11 +21,11 @@ export const state=()=>({
keepAlive
:
[]
keepAlive
:
[]
})
})
export
const
actions
=
{
export
const
actions
=
{
/**
/**
* @description 从持久化数据载入分页列表
* @description 从持久化数据载入分页列表
*/
*/
openedLoad
({
state
,
commit
,
dispatch
,
rootState
})
{
openedLoad
({
state
,
commit
,
dispatch
,
rootState
})
{
return
new
Promise
(
async
resolve
=>
{
return
new
Promise
(
async
resolve
=>
{
// store 赋值
// store 赋值
const
value
=
await
dispatch
(
'admin/db/get'
,
{
const
value
=
await
dispatch
(
'admin/db/get'
,
{
...
@@ -79,7 +79,7 @@ export const actions={
...
@@ -79,7 +79,7 @@ export const actions={
/**
/**
* 将 opened 属性赋值并持久化 在这之前请先确保已经更新了 state.opened
* 将 opened 属性赋值并持久化 在这之前请先确保已经更新了 state.opened
*/
*/
opened2db
({
state
,
dispatch
})
{
opened2db
({
state
,
dispatch
})
{
return
new
Promise
(
async
resolve
=>
{
return
new
Promise
(
async
resolve
=>
{
// 设置数据
// 设置数据
dispatch
(
'admin/db/set'
,
{
dispatch
(
'admin/db/set'
,
{
...
@@ -96,7 +96,7 @@ export const actions={
...
@@ -96,7 +96,7 @@ export const actions={
* @description 更新页面列表上的某一项
* @description 更新页面列表上的某一项
* @param {Object} param { index, params, query, fullPath } 路由信息
* @param {Object} param { index, params, query, fullPath } 路由信息
*/
*/
openedUpdate
({
state
,
commit
,
dispatch
},
{
index
,
params
,
query
,
fullPath
,
meta
})
{
openedUpdate
({
state
,
commit
,
dispatch
},
{
index
,
params
,
query
,
fullPath
,
meta
})
{
return
new
Promise
(
async
resolve
=>
{
return
new
Promise
(
async
resolve
=>
{
// 更新页面列表某一项
// 更新页面列表某一项
let
page
=
state
.
opened
[
index
];
let
page
=
state
.
opened
[
index
];
...
@@ -115,7 +115,7 @@ export const actions={
...
@@ -115,7 +115,7 @@ export const actions={
* @description 更新页面当前项
* @description 更新页面当前项
* @param {Object} param { params, query, fullPath } 路由信息
* @param {Object} param { params, query, fullPath } 路由信息
*/
*/
currentUpdate
({
state
,
commit
,
dispatch
},
{
params
,
query
,
fullPath
,
meta
})
{
currentUpdate
({
state
,
commit
,
dispatch
},
{
params
,
query
,
fullPath
,
meta
})
{
return
new
Promise
(
async
resolve
=>
{
return
new
Promise
(
async
resolve
=>
{
setTimeout
(
async
()
=>
{
setTimeout
(
async
()
=>
{
// 更新当前项
// 更新当前项
...
@@ -137,7 +137,7 @@ export const actions={
...
@@ -137,7 +137,7 @@ export const actions={
* @description 新增一个 tag (打开一个页面)
* @description 新增一个 tag (打开一个页面)
* @param {Object} param new tag info
* @param {Object} param new tag info
*/
*/
add
({
state
,
commit
,
dispatch
},
{
tag
,
params
,
query
,
fullPath
})
{
add
({
state
,
commit
,
dispatch
},
{
tag
,
params
,
query
,
fullPath
})
{
return
new
Promise
(
async
resolve
=>
{
return
new
Promise
(
async
resolve
=>
{
// 设置新的 tag 在新打开一个以前没打开过的页面时使用
// 设置新的 tag 在新打开一个以前没打开过的页面时使用
let
newTag
=
tag
;
let
newTag
=
tag
;
...
@@ -160,7 +160,7 @@ export const actions={
...
@@ -160,7 +160,7 @@ export const actions={
* @description 打开一个新的页面
* @description 打开一个新的页面
* @param {Object} param 从路由钩子的 to 对象上获取 { name, params, query, fullPath } 路由信息
* @param {Object} param 从路由钩子的 to 对象上获取 { name, params, query, fullPath } 路由信息
*/
*/
open
({
state
,
commit
,
dispatch
},
{
name
,
params
,
query
,
fullPath
})
{
open
({
state
,
commit
,
dispatch
},
{
name
,
params
,
query
,
fullPath
})
{
return
new
Promise
(
async
resolve
=>
{
return
new
Promise
(
async
resolve
=>
{
// 已经打开的页面
// 已经打开的页面
let
opened
=
state
.
opened
;
let
opened
=
state
.
opened
;
...
@@ -201,7 +201,7 @@ export const actions={
...
@@ -201,7 +201,7 @@ export const actions={
* @description 关闭一个 tag (关闭一个页面)
* @description 关闭一个 tag (关闭一个页面)
* @param {Object} param { tagName: 要关闭的标签名字 }
* @param {Object} param { tagName: 要关闭的标签名字 }
*/
*/
close
({
state
,
commit
,
dispatch
},
{
tagName
})
{
close
({
state
,
commit
,
dispatch
},
{
tagName
})
{
return
new
Promise
(
async
resolve
=>
{
return
new
Promise
(
async
resolve
=>
{
// 下个新的页面
// 下个新的页面
let
newPage
=
state
.
opened
[
0
];
let
newPage
=
state
.
opened
[
0
];
...
@@ -245,7 +245,7 @@ export const actions={
...
@@ -245,7 +245,7 @@ export const actions={
params
,
params
,
query
query
};
};
$nuxt
.
$router
.
push
(
routerObj
,
()
=>
{
});
$nuxt
.
$router
.
push
(
routerObj
,
()
=>
{
});
}
}
// end
// end
resolve
();
resolve
();
...
@@ -255,7 +255,8 @@ export const actions={
...
@@ -255,7 +255,8 @@ export const actions={
* @description 关闭当前标签左边的标签
* @description 关闭当前标签左边的标签
* @param {Object} param { pageSelect: 当前选中的tagName }
* @param {Object} param { pageSelect: 当前选中的tagName }
*/
*/
closeLeft
({
state
,
commit
,
dispatch
},
{
pageSelect
}
=
{})
{
closeLeft
({
state
,
commit
,
dispatch
},
{
pageSelect
}
=
{})
{
return
new
Promise
(
async
resolve
=>
{
return
new
Promise
(
async
resolve
=>
{
const
pageAim
=
pageSelect
||
state
.
current
;
const
pageAim
=
pageSelect
||
state
.
current
;
let
currentIndex
=
0
;
let
currentIndex
=
0
;
...
@@ -267,6 +268,10 @@ export const actions={
...
@@ -267,6 +268,10 @@ export const actions={
if
(
currentIndex
>
0
)
{
if
(
currentIndex
>
0
)
{
// 删除打开的页面 并在缓存设置中删除
// 删除打开的页面 并在缓存设置中删除
state
.
opened
.
splice
(
1
,
currentIndex
-
1
).
forEach
(({
name
})
=>
commit
(
'keepAliveRemove'
,
name
));
state
.
opened
.
splice
(
1
,
currentIndex
-
1
).
forEach
(({
name
})
=>
commit
(
'keepAliveRemove'
,
name
));
}
if
(
state
.
opened
.
length
==
2
)
{
state
.
opened
.
splice
(
0
,
1
);
}
}
state
.
current
=
pageAim
;
state
.
current
=
pageAim
;
if
(
$nuxt
.
$router
.
fullPath
!==
pageAim
)
{
if
(
$nuxt
.
$router
.
fullPath
!==
pageAim
)
{
...
@@ -282,7 +287,7 @@ export const actions={
...
@@ -282,7 +287,7 @@ export const actions={
* @description 关闭当前标签右边的标签
* @description 关闭当前标签右边的标签
* @param {Object} param { pageSelect: 当前选中的tagName }
* @param {Object} param { pageSelect: 当前选中的tagName }
*/
*/
closeRight
({
state
,
commit
,
dispatch
},
{
pageSelect
}
=
{})
{
closeRight
({
state
,
commit
,
dispatch
},
{
pageSelect
}
=
{})
{
return
new
Promise
(
async
resolve
=>
{
return
new
Promise
(
async
resolve
=>
{
const
pageAim
=
pageSelect
||
state
.
current
;
const
pageAim
=
pageSelect
||
state
.
current
;
let
currentIndex
=
0
;
let
currentIndex
=
0
;
...
@@ -308,7 +313,7 @@ export const actions={
...
@@ -308,7 +313,7 @@ export const actions={
* @description 关闭当前激活之外的 tag
* @description 关闭当前激活之外的 tag
* @param {Object} param { pageSelect: 当前选中的tagName }
* @param {Object} param { pageSelect: 当前选中的tagName }
*/
*/
closeOther
({
state
,
commit
,
dispatch
},
{
pageSelect
}
=
{})
{
closeOther
({
state
,
commit
,
dispatch
},
{
pageSelect
}
=
{})
{
return
new
Promise
(
async
resolve
=>
{
return
new
Promise
(
async
resolve
=>
{
const
pageAim
=
pageSelect
||
state
.
current
;
const
pageAim
=
pageSelect
||
state
.
current
;
let
currentIndex
=
0
;
let
currentIndex
=
0
;
...
@@ -324,6 +329,9 @@ export const actions={
...
@@ -324,6 +329,9 @@ export const actions={
state
.
opened
.
splice
(
currentIndex
+
1
).
forEach
(({
name
})
=>
commit
(
'keepAliveRemove'
,
name
));
state
.
opened
.
splice
(
currentIndex
+
1
).
forEach
(({
name
})
=>
commit
(
'keepAliveRemove'
,
name
));
state
.
opened
.
splice
(
1
,
currentIndex
-
1
).
forEach
(({
name
})
=>
commit
(
'keepAliveRemove'
,
name
));
state
.
opened
.
splice
(
1
,
currentIndex
-
1
).
forEach
(({
name
})
=>
commit
(
'keepAliveRemove'
,
name
));
}
}
if
(
state
.
opened
.
length
==
2
)
{
state
.
opened
.
splice
(
0
,
1
);
}
// 设置新的页面
// 设置新的页面
state
.
current
=
pageAim
;
state
.
current
=
pageAim
;
if
(
$nuxt
.
$router
.
fullPath
!==
pageAim
)
{
if
(
$nuxt
.
$router
.
fullPath
!==
pageAim
)
{
...
@@ -339,31 +347,31 @@ export const actions={
...
@@ -339,31 +347,31 @@ export const actions={
* @description 关闭所有 tag
* @description 关闭所有 tag
* @param {Object} state vuex state
* @param {Object} state vuex state
*/
*/
closeAll
({
state
,
commit
,
dispatch
})
{
closeAll
({
state
,
commit
,
dispatch
})
{
return
new
Promise
(
async
resolve
=>
{
return
new
Promise
(
async
resolve
=>
{
// 删除打开的页面 并在缓存设置中删除
// 删除打开的页面 并在缓存设置中删除
state
.
opened
.
splice
(
1
).
forEach
(({
name
})
=>
commit
(
'keepAliveRemove'
,
name
));
state
.
opened
.
splice
(
0
).
forEach
(({
name
})
=>
commit
(
'keepAliveRemove'
,
name
));
// 持久化
// 持久化
await
dispatch
(
'opened2db'
);
await
dispatch
(
'opened2db'
);
// 关闭所有的标签页后需要判断一次现在是不是在首页
// 关闭所有的标签页后需要判断一次现在是不是在首页
if
(
$nuxt
.
$router
.
name
!==
'index'
)
{
//
if ($nuxt.$router.name !== 'index') {
$nuxt
.
$router
.
push
({
//
$nuxt.$router.push({
name
:
'index'
//
name: 'index'
},
()
=>
{
});
// }, () => {
});
}
//
}
// end
// end
resolve
();
resolve
();
});
});
}
}
}
}
export
const
mutations
=
{
export
const
mutations
=
{
/**
/**
* @class keepAlive
* @class keepAlive
* @description 从已经打开的页面记录中更新需要缓存的页面记录
* @description 从已经打开的页面记录中更新需要缓存的页面记录
* @param {Object} state vuex state
* @param {Object} state vuex state
*/
*/
keepAliveRefresh
(
state
)
{
keepAliveRefresh
(
state
)
{
state
.
keepAlive
=
state
.
opened
.
filter
(
item
=>
isKeepAlive
(
item
)).
map
(
e
=>
e
.
name
);
state
.
keepAlive
=
state
.
opened
.
filter
(
item
=>
isKeepAlive
(
item
)).
map
(
e
=>
e
.
name
);
},
},
/**
/**
...
@@ -371,22 +379,25 @@ export const mutations={
...
@@ -371,22 +379,25 @@ export const mutations={
* @param {Object} state vuex state
* @param {Object} state vuex state
* @param {String} name name
* @param {String} name name
*/
*/
keepAliveRemove
(
state
,
name
)
{
keepAliveRemove
(
state
,
name
)
{
const
list
=
[
...
state
.
keepAlive
];
const
list
=
[...
state
.
keepAlive
];
const
index
=
list
.
findIndex
(
item
=>
item
===
name
);
const
index
=
list
.
findIndex
(
item
=>
item
===
name
);
if
(
index
!==
-
1
)
{
if
(
index
!==
-
1
)
{
list
.
splice
(
index
,
1
);
list
.
splice
(
index
,
1
);
state
.
keepAlive
=
list
;
state
.
keepAlive
=
list
;
}
}
if
(
state
.
opened
.
length
==
2
)
{
state
.
opened
.
splice
(
0
,
1
);
}
},
},
/**
/**
* @description 增加一个页面的缓存设置
* @description 增加一个页面的缓存设置
* @param {Object} state vuex state
* @param {Object} state vuex state
* @param {String} name name
* @param {String} name name
*/
*/
keepAlivePush
(
state
,
name
)
{
keepAlivePush
(
state
,
name
)
{
const
keep
=
[
...
state
.
keepAlive
];
const
keep
=
[...
state
.
keepAlive
];
keep
.
push
(
name
);
keep
.
push
(
name
);
state
.
keepAlive
=
keep
;
state
.
keepAlive
=
keep
;
},
},
...
@@ -394,7 +405,7 @@ export const mutations={
...
@@ -394,7 +405,7 @@ export const mutations={
* @description 清空页面缓存设置
* @description 清空页面缓存设置
* @param {Object} state vuex state
* @param {Object} state vuex state
*/
*/
keepAliveClean
(
state
)
{
keepAliveClean
(
state
)
{
state
.
keepAlive
=
[];
state
.
keepAlive
=
[];
},
},
/**
/**
...
@@ -403,7 +414,7 @@ export const mutations={
...
@@ -403,7 +414,7 @@ export const mutations={
* @param {Object} state vuex state
* @param {Object} state vuex state
* @param {String} fullPath new fullPath
* @param {String} fullPath new fullPath
*/
*/
currentSet
(
state
,
fullPath
)
{
currentSet
(
state
,
fullPath
)
{
state
.
current
=
fullPath
;
state
.
current
=
fullPath
;
},
},
/**
/**
...
@@ -412,7 +423,7 @@ export const mutations={
...
@@ -412,7 +423,7 @@ export const mutations={
* @param {Object} state vuex state
* @param {Object} state vuex state
* @param {Array} routes routes
* @param {Array} routes routes
*/
*/
init
(
state
,
routes
)
{
init
(
state
,
routes
)
{
const
pool
=
[];
const
pool
=
[];
const
push
=
function
(
routes
)
{
const
push
=
function
(
routes
)
{
routes
.
forEach
(
route
=>
{
routes
.
forEach
(
route
=>
{
...
...
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