Commit 55707e2c by liimin

优化

1 parent d63e1be3
...@@ -17,15 +17,21 @@ ...@@ -17,15 +17,21 @@
.el-tabs__item:focus.is-active.is-focus:not(:active) { .el-tabs__item:focus.is-active.is-focus:not(:active) {
box-shadow: none !important; box-shadow: none !important;
} }
.el-tabs__nav-scroll{
padding-left: 20px;
}
.el-color-picker__trigger{ .el-color-picker__trigger{
border-color:rgba(255,255,255,.1) border-color:rgba(255,255,255,.1)
} }
.el-table{ .el-table{
&--medium td{ &--medium td{
padding: 5px 0 !important; padding: 10px 0 !important;
.el-button--text{
padding: 0px 0px;
}
.cell{
.el-tag{
width: 80px;
font-size: 13px;
}
}
} }
margin:4px 0 !important; margin:4px 0 !important;
} }
...@@ -39,7 +45,7 @@ ...@@ -39,7 +45,7 @@
} }
&__footer { &__footer {
.el-button { .el-button {
width: 200px; width: 150px;
} }
} }
} }
......
...@@ -130,7 +130,7 @@ ...@@ -130,7 +130,7 @@
} }
// 折叠侧边栏切换按钮 // 折叠侧边栏切换按钮
.toggle-aside-btn { .toggle-aside-btn {
margin-left: 26px; margin-left: 21px;
} }
// [菜单] 顶栏 // [菜单] 顶栏
.el-menu { .el-menu {
...@@ -245,6 +245,16 @@ ...@@ -245,6 +245,16 @@
.el-tabs__header.is-top { .el-tabs__header.is-top {
margin: 0px; margin: 0px;
} }
.el-tabs__nav-wrap{
.el-tabs__nav-scroll{
padding-left: 20px;
}
}
.el-tabs__nav-wrap.is-scrollable{
.el-tabs__nav-scroll{
padding-left: 0;
}
}
.el-tabs__nav { .el-tabs__nav {
overflow: hidden; overflow: hidden;
.el-tabs__item{ .el-tabs__item{
...@@ -257,20 +267,19 @@ ...@@ -257,20 +267,19 @@
} }
.d2-multiple-page-control-btn { .d2-multiple-page-control-btn {
position: relative; position: relative;
bottom: -1px; // .el-dropdown {
.el-dropdown {
.el-button-group { .el-button-group {
.el-button{ .el-button{
padding: 9px 20px; border-bottom: none ;
padding: 10px 20px;
&:first-child { &:first-child {
border-bottom-left-radius: 0px; border-bottom-left-radius: 0px;
} }
&:last-child { &:last-child {
border-bottom-right-radius: 0px; border-bottom-right-radius: 0px;
padding: 9px 5px;
}
} }
} }
// }
} }
} }
} }
......
...@@ -83,10 +83,10 @@ ...@@ -83,10 +83,10 @@
// 切换按钮 // 切换按钮
.toggle-aside-btn { .toggle-aside-btn {
// i { // i {
fill: $theme-header-hamberg-color; color: $theme-header-hamberg-color;
background: $theme-header-item-background-color; background: $theme-header-item-background-color;
&:hover { &:hover {
fill: $theme-header-hamberg-color-hover; color: $theme-header-hamberg-color-hover;
} }
// } // }
} }
......
...@@ -4,7 +4,8 @@ ...@@ -4,7 +4,8 @@
class="d2-header-switch" class="d2-header-switch"
:class="{ 'd2-header-switch--active': isActive }" :class="{ 'd2-header-switch--active': isActive }"
@click="handleClick"> @click="handleClick">
<li :class="$store.state.d2admin.tsearch.active?'fa fa-compress':'fa fa-expand'"></li> <d2-el-icon :name="name"/>
<!-- <li :class="$store.state.d2admin.tsearch.active?'fa fa-compress':'fa fa-expand'"></li> -->
</div> </div>
</template> </template>
...@@ -20,6 +21,9 @@ export default { ...@@ -20,6 +21,9 @@ export default {
computed: { computed: {
show() { show() {
return true return true
},
name() {
return this.$store.state.d2admin.tsearch.active ? 'top-right' : 'bottom-left'
} }
}, },
mounted() { mounted() {
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
:data-value="item.value" :data-value="item.value"
class="d2-contentmenu-item" class="d2-contentmenu-item"
flex="cross:center main:center"> flex="cross:center main:center">
<d2-icon <d2-el-icon
v-if="item.icon" v-if="item.icon"
:name="item.icon"/> :name="item.icon"/>
<div <div
......
...@@ -62,7 +62,7 @@ export default { ...@@ -62,7 +62,7 @@ export default {
.d2-contextmenu { .d2-contextmenu {
position: absolute; position: absolute;
padding: 5px 0; padding: 5px 0;
z-index: 2018; z-index: 2019;
background: #FFF; background: #FFF;
border: 1px solid #cfd7e5; border: 1px solid #cfd7e5;
border-radius: 4px; border-radius: 4px;
......
<template> <template>
<svg t="1492500959545" @click="click" class="hamburger" :class="{'is-active':isActive}" viewBox="0 0 1024 1024" <!-- <svg t="1492500959545" @click="click" class="hamburger" :class="{'is-active':isActive}" viewBox="0 0 1024 1024"
version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1691" xmlns:xlink="http://www.w3.org/1999/xlink" width="64" height="64"> version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1691" xmlns:xlink="http://www.w3.org/1999/xlink" width="64" height="64">
<path d="M966.8023 568.849776 57.196677 568.849776c-31.397081 0-56.850799-25.452695-56.850799-56.850799l0 0c0-31.397081 25.452695-56.849776 56.850799-56.849776l909.605623 0c31.397081 0 56.849776 25.452695 56.849776 56.849776l0 0C1023.653099 543.397081 998.200404 568.849776 966.8023 568.849776z" <path d="M966.8023 568.849776 57.196677 568.849776c-31.397081 0-56.850799-25.452695-56.850799-56.850799l0 0c0-31.397081 25.452695-56.849776 56.850799-56.849776l909.605623 0c31.397081 0 56.849776 25.452695 56.849776 56.849776l0 0C1023.653099 543.397081 998.200404 568.849776 966.8023 568.849776z"
p-id="1692"></path> p-id="1692"></path>
...@@ -7,7 +7,10 @@ ...@@ -7,7 +7,10 @@
p-id="1693"></path> p-id="1693"></path>
<path d="M966.8023 256.17345 57.196677 256.17345c-31.397081 0-56.850799-25.452695-56.850799-56.849776l0 0c0-31.397081 25.452695-56.850799 56.850799-56.850799l909.605623 0c31.397081 0 56.849776 25.452695 56.849776 56.850799l0 0C1023.653099 230.720755 998.200404 256.17345 966.8023 256.17345z" <path d="M966.8023 256.17345 57.196677 256.17345c-31.397081 0-56.850799-25.452695-56.850799-56.849776l0 0c0-31.397081 25.452695-56.850799 56.850799-56.850799l909.605623 0c31.397081 0 56.849776 25.452695 56.849776 56.850799l0 0C1023.653099 230.720755 998.200404 256.17345 966.8023 256.17345z"
p-id="1694"></path> p-id="1694"></path>
</svg> </svg> -->
<div @click="click" class="hamburger" :class="{'is-active':isActive}">
<d2-el-icon name="s-fold" />
</div>
</template> </template>
<script> <script>
...@@ -31,16 +34,18 @@ export default { ...@@ -31,16 +34,18 @@ export default {
} }
</script> </script>
<style scoped> <style scoped lang="scss">
.hamburger { .hamburger {
display: inline-block; height: 58px;
cursor: pointer; cursor: pointer;
width: 22px;
height: 60px;
transition: .38s; transition: .38s;
transform-origin: 50% 50%; transform-origin: 50% 50%;
i{
line-height: 58px;
font-size: 28px;
}
} }
.hamburger.is-active { .hamburger.is-active {
transform: rotate(90deg); transform: rotate(180deg);
} }
</style> </style>
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
:content="active ? '退出全屏' : '全屏'" :content="active ? '退出全屏' : '全屏'"
placement="bottom"> placement="bottom">
<el-button class="d2-mr btn-text can-hover" type="text" @click="toggle"> <el-button class="d2-mr btn-text can-hover" type="text" @click="toggle">
<d2-icon v-if="active" name="compress"/> <d2-el-icon v-if="active" name="aim"/>
<d2-el-icon v-else name="full-screen" style="font-size: 16px"/> <d2-el-icon v-else name="full-screen" style="font-size: 16px"/>
</el-button> </el-button>
</el-tooltip> </el-tooltip>
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
</el-dropdown-menu> </el-dropdown-menu>
</el-dropdown>--> </el-dropdown>-->
<div v-popover:popover-personal class="d2-mr personal-wrap"> <div v-popover:popover-personal class="d2-mr personal-wrap">
<span class="btn-text">{{info && info.userName ? `${info.userName}` : '未登录'}}</span> <span class="btn-text">{{info && info.userName ? `${info.userName}` : '未登录'}} <d2-el-icon name="caret-bottom"/></span>
<el-popover ref="popover-personal" placement="bottom-end" trigger="hover"> <el-popover ref="popover-personal" placement="bottom-end" trigger="hover">
<personal-panel :user="info"></personal-panel> <personal-panel :user="info"></personal-panel>
</el-popover> </el-popover>
...@@ -40,8 +40,5 @@ export default { ...@@ -40,8 +40,5 @@ export default {
<style lang="scss" scoped> <style lang="scss" scoped>
.personal-wrap{ .personal-wrap{
transform: translateY(-3px); transform: translateY(-3px);
.btn-text{
text-shadow: 0 1px 1px#666;
}
} }
</style> </style>
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
</div> </div>
<div class="registe-info"> <div class="registe-info">
<span class="registe-info"> <span class="registe-info">
<li class="fa fa-clock-o"></li> <d2-el-icon name="time"/>
有效期:{{user.validTime || '未知' }} 有效期:{{user.validTime || '未知' }}
</span> </span>
</div> </div>
...@@ -25,21 +25,21 @@ ...@@ -25,21 +25,21 @@
</div>--> </div>-->
<div class="main-operation"> <div class="main-operation">
<span class="main-operation-item"> <span class="main-operation-item">
<el-button size="small" icon="fa fa-male" @click="openPersonalDialog"> 个人信息</el-button> <el-button size="small" icon="el-icon-user" @click="openPersonalDialog"> 个人信息</el-button>
</span> </span>
<span class="main-operation-item"> <span class="main-operation-item">
<el-button size="small" icon="fa fa-key" @click="openPasswordDialog"> 修改密码</el-button> <el-button size="small" icon="el-icon-key" @click="openPasswordDialog"> 修改密码</el-button>
</span> </span>
</div> </div>
<div class="other-operation" @click="clear"> <div class="other-operation" @click="clear">
<div class="other-operation-item"> <div class="other-operation-item">
<i class="fa fa-eraser"></i> <d2-el-icon name="delete"/>
清空本地缓存 清空本地缓存
</div> </div>
</div> </div>
<div class="personal-footer" @click="logOut"> <div class="personal-footer" @click="logOut">
<el-button type="text"> <el-button type="text">
<i class="fa fa-sign-out"></i>退出 <d2-el-icon name="switch-button"/> 退出
</el-button> </el-button>
</div> </div>
</div> </div>
...@@ -205,7 +205,7 @@ export default { ...@@ -205,7 +205,7 @@ export default {
color: rgb(19, 138, 156); color: rgb(19, 138, 156);
} }
.main-operation { .main-operation {
padding: 8px; padding: 2px 0;
/* background: rgba(175, 182, 179, 0.3); */ /* background: rgba(175, 182, 179, 0.3); */
border-color: rgba(201, 206, 206, 0.2); border-color: rgba(201, 206, 206, 0.2);
border-top-width: 1px; border-top-width: 1px;
......
...@@ -30,37 +30,52 @@ ...@@ -30,37 +30,52 @@
<div <div
class="d2-multiple-page-control-btn" class="d2-multiple-page-control-btn"
flex-box="0"> flex-box="0">
<el-dropdown <el-button-group>
<el-button icon="el-icon-error" @click="closeAll"></el-button>
<el-button icon="el-icon-refresh" @click="reload" :disabled="current==='/index'"></el-button>
</el-button-group>
<!-- <el-dropdown
size="default" size="default"
split-button split-button
@click="closeAll" @click="closeAll"
@command="command => handleControlItemClick(command)"> @command="command => handleControlItemClick(command)">
<d2-icon name="times-circle"/> <d2-el-icon name="error"/>
<el-dropdown-menu slot="dropdown"> <el-dropdown-menu slot="dropdown">
<el-dropdown-item command="reload">
<d2-el-icon name="refresh"/>
刷新
</el-dropdown-item>
<el-dropdown-item command="left"> <el-dropdown-item command="left">
<d2-icon name="arrow-left" class="d2-mr-10"/> <d2-el-icon name="back" class="d2-mr-10"/>
关闭左侧 关闭左侧
</el-dropdown-item> </el-dropdown-item>
<el-dropdown-item command="right"> <el-dropdown-item command="right">
<d2-icon name="arrow-right" class="d2-mr-10"/> <d2-el-icon name="right" class="d2-mr-10"/>
关闭右侧 关闭右侧
</el-dropdown-item> </el-dropdown-item>
<el-dropdown-item command="other"> <el-dropdown-item command="other">
<d2-icon name="times" class="d2-mr-10"/> <d2-el-icon name="circle-close" class="d2-mr-10"/>
关闭其它 关闭其它
</el-dropdown-item> </el-dropdown-item>
<el-dropdown-item command="all"> <el-dropdown-item command="all">
<d2-icon name="times-circle" class="d2-mr-10"/> <d2-el-icon name="error" class="d2-mr-10"/>
全部关闭 全部关闭
</el-dropdown-item> </el-dropdown-item>
</el-dropdown-menu> </el-dropdown-menu>
</el-dropdown> </el-dropdown>-->
</div> </div>
</div> </div>
</template> </template>
<script> <script>
import { mapState, mapActions } from 'vuex' import { mapState, mapActions, mapMutations } from 'vuex'
const CMD_MAP = {
'left': 'closeLeft',
'right': 'closeRight',
'other': 'closeOther',
'all': 'closeAll',
'reload': 'reload'
}
export default { export default {
components: { components: {
D2Contextmenu: () => import('../contextmenu'), D2Contextmenu: () => import('../contextmenu'),
...@@ -72,13 +87,13 @@ export default { ...@@ -72,13 +87,13 @@ export default {
contentmenuX: 0, contentmenuX: 0,
contentmenuY: 0, contentmenuY: 0,
contextmenuListIndex: [ contextmenuListIndex: [
{ icon: 'times-circle', title: '关闭全部', value: 'all' } { icon: 'error', title: '关闭全部', value: 'all' }
], ],
contextmenuList: [ contextmenuList: [
{ icon: 'arrow-left', title: '关闭左侧', value: 'left' }, { icon: 'back', title: '关闭左侧', value: 'left' },
{ icon: 'arrow-right', title: '关闭右侧', value: 'right' }, { icon: 'right', title: '关闭右侧', value: 'right' },
{ icon: 'times', title: '关闭其它', value: 'other' }, { icon: 'circle-close', title: '关闭其它', value: 'other' },
{ icon: 'times-circle', title: '关闭全部', value: 'all' } { icon: 'error', title: '关闭全部', value: 'all' }
], ],
tagName: '/index' tagName: '/index'
} }
...@@ -97,6 +112,7 @@ export default { ...@@ -97,6 +112,7 @@ export default {
'closeOther', 'closeOther',
'closeAll' 'closeAll'
]), ]),
...mapMutations('d2admin/page', ['keepAliveRemove', 'keepAlivePush']),
/** /**
* @description 右键菜单功能点击 * @description 右键菜单功能点击
*/ */
...@@ -134,23 +150,7 @@ export default { ...@@ -134,23 +150,7 @@ export default {
const params = { const params = {
pageSelect: tagName pageSelect: tagName
} }
switch (command) { this[CMD_MAP[command]](params)
case 'left':
this.closeLeft(params)
break
case 'right':
this.closeRight(params)
break
case 'other':
this.closeOther(params)
break
case 'all':
this.closeAll()
break
default:
this.$message.error('无效的操作')
break
}
}, },
/** /**
* @description 接收点击 tab 标签的事件 * @description 接收点击 tab 标签的事件
...@@ -163,6 +163,17 @@ export default { ...@@ -163,6 +163,17 @@ export default {
this.$router.push({ name, params, query }) this.$router.push({ name, params, query })
} }
}, },
async reload() {
const name = this.$router.currentRoute.name
await this.keepAliveRemove(name)
await this.$router.replace('/refresh')
var __timer = setInterval(() => {
if (this.$router.currentRoute.name === name) {
clearInterval(__timer)
this.keepAlivePush(name)
}
}, 10)
},
/** /**
* @description 点击 tab 上的删除按钮触发这里 首页的删除按钮已经隐藏 因此这里不用判断是 index * @description 点击 tab 上的删除按钮触发这里 首页的删除按钮已经隐藏 因此这里不用判断是 index
*/ */
......
...@@ -48,20 +48,20 @@ export const sys = [ ...@@ -48,20 +48,20 @@ export const sys = [
// }, // },
// component: _import('system/log') // component: _import('system/log')
// }, // },
// // 刷新页面 必须保留 // 刷新页面 必须保留
// { {
// path: '/refresh', path: '/refresh',
// name: 'refresh', name: 'refresh',
// hidden: true, hidden: true,
// component: _import('system/function/refresh') component: _import('system/function/refresh')
// }, },
// // 页面重定向 必须保留 // 页面重定向 必须保留
// { {
// path: 'redirect/:route*', path: 'redirect/:route*',
// name: 'redirect', name: 'redirect',
// hidden: true, hidden: true,
// component: _import('system/function/redirect') component: _import('system/function/redirect')
// } }
] ]
/** /**
......
...@@ -13,14 +13,7 @@ export default { ...@@ -13,14 +13,7 @@ export default {
*/ */
listen({ commit }) { listen({ commit }) {
return new Promise(resolve => { return new Promise(resolve => {
if (screenfull.enabled) { screenfull.enabled && screenfull.on('change', () => !screenfull.isFullscreen && commit('set', false))
screenfull.on('change', () => {
console.log('1')
if (!screenfull.isFullscreen) {
commit('set', false)
}
})
}
// end // end
resolve() resolve()
}) })
......
...@@ -42,20 +42,27 @@ export default { ...@@ -42,20 +42,27 @@ export default {
openedLoad({ state, commit, dispatch }) { openedLoad({ state, commit, dispatch }) {
return new Promise(async resolve => { return new Promise(async resolve => {
// store 赋值 // store 赋值
const value = await dispatch('d2admin/db/get', { const value = await dispatch(
'd2admin/db/get',
{
dbName: 'sys', dbName: 'sys',
path: 'page.opened', path: 'page.opened',
defaultValue: [home], defaultValue: [home],
user: true user: true
}, { root: true }) },
{ root: true }
)
// 在处理函数中进行数据优化 过滤掉现在已经失效的页签或者已经改变了信息的页签 // 在处理函数中进行数据优化 过滤掉现在已经失效的页签或者已经改变了信息的页签
// 以 fullPath 字段为准 // 以 fullPath 字段为准
// 如果页面过多的话可能需要优化算法 // 如果页面过多的话可能需要优化算法
// valid 有效列表 1, 1, 0, 1 => 有效, 有效, 失效, 有效 // valid 有效列表 1, 1, 0, 1 => 有效, 有效, 失效, 有效
const valid = [] const valid = []
const __oSource = await dispatch('d2admin/auth/load', null, { root: true }) const __oSource = await dispatch('d2admin/auth/load', null, {
root: true
})
// 处理数据 // 处理数据
state.opened = value.map(opened => { state.opened = value
.map(opened => {
// 忽略首页 // 忽略首页
if (opened.fullPath === '/index') { if (opened.fullPath === '/index') {
valid.push(1) valid.push(1)
...@@ -64,14 +71,18 @@ export default { ...@@ -64,14 +71,18 @@ export default {
} }
// 尝试在所有的支持多标签页的页面里找到 name 匹配的页面 // 尝试在所有的支持多标签页的页面里找到 name 匹配的页面
const find = state.pool.find(item => { const find = state.pool.find(item => {
return item.name === opened.name && __oSource.some(obj => obj.authId === item.meta.authId) return (
item.name === opened.name &&
__oSource.some(obj => obj.authId === item.meta.authId)
)
}) })
// 记录有效或无效信息 // 记录有效或无效信息
valid.push(find ? 1 : 0) valid.push(find ? 1 : 0)
// 返回合并后的数据 新的覆盖旧的 // 返回合并后的数据 新的覆盖旧的
// 新的数据中一般不会携带 params 和 query, 所以旧的参数会留存 // 新的数据中一般不会携带 params 和 query, 所以旧的参数会留存
return Object.assign({}, opened, find) return Object.assign({}, opened, find)
}).filter((opened, index) => valid[index] === 1) })
.filter((opened, index) => valid[index] === 1)
// 标记已经加载多标签页数据 https://github.com/d2-projects/d2-admin/issues/201 // 标记已经加载多标签页数据 https://github.com/d2-projects/d2-admin/issues/201
state.openedLoaded = true state.openedLoaded = true
// 根据 opened 数据生成缓存设置 // 根据 opened 数据生成缓存设置
...@@ -87,12 +98,16 @@ export default { ...@@ -87,12 +98,16 @@ export default {
opend2db({ state, dispatch }) { opend2db({ state, dispatch }) {
return new Promise(async resolve => { return new Promise(async resolve => {
// 设置数据 // 设置数据
dispatch('d2admin/db/set', { dispatch(
'd2admin/db/set',
{
dbName: 'sys', dbName: 'sys',
path: 'page.opened', path: 'page.opened',
value: state.opened, value: state.opened,
user: true user: true
}, { root: true }) },
{ root: true }
)
// end // end
resolve() resolve()
}) })
...@@ -103,7 +118,10 @@ export default { ...@@ -103,7 +118,10 @@ export default {
* @param {Object} context * @param {Object} context
* @param {Object} payload { index, params, query, fullPath } 路由信息 * @param {Object} payload { index, params, query, fullPath } 路由信息
*/ */
openedUpdate({ state, commit, dispatch }, { index, params, query, fullPath }) { openedUpdate(
{ state, commit, dispatch },
{ index, params, query, fullPath }
) {
return new Promise(async resolve => { return new Promise(async resolve => {
// 更新页面列表某一项 // 更新页面列表某一项
const page = state.opened[index] const page = state.opened[index]
...@@ -242,25 +260,20 @@ export default { ...@@ -242,25 +260,20 @@ export default {
* @param {Object} context * @param {Object} context
* @param {Object} payload { pageSelect: 当前选中的tagName } * @param {Object} payload { pageSelect: 当前选中的tagName }
*/ */
closeLeft({ state, commit, dispatch }, { pageSelect } = {}) { closeLeft({ dispatch }, { pageSelect } = {}) {
return new Promise(async resolve => {
await dispatch('do', {
pageSelect,
call: currentIndex => {
return new Promise(async resolve => { return new Promise(async resolve => {
const pageAim = pageSelect || state.current
let currentIndex = 0
state.opened.forEach((page, index) => {
if (page.fullPath === pageAim) {
currentIndex = index
}
})
if (currentIndex > 0) { if (currentIndex > 0) {
// 删除打开的页面 并在缓存设置中删除 // 删除打开的页面 并在缓存设置中删除
state.opened.splice(1, currentIndex - 1).forEach(({ name }) => commit('keepAliveRemove', name)) await dispatch('splice', { index: 1, howmany: currentIndex - 1 })
} }
state.current = pageAim resolve()
if (router.app.$route.fullPath !== pageAim) { })
router.push(pageAim)
} }
// 持久化 })
await dispatch('opend2db')
// end // end
resolve() resolve()
}) })
...@@ -273,23 +286,16 @@ export default { ...@@ -273,23 +286,16 @@ export default {
*/ */
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 await dispatch('do', {
let currentIndex = 0 pageSelect,
state.opened.forEach((page, index) => { call: currentIndex => {
if (page.fullPath === pageAim) { return new Promise(async resolve => {
currentIndex = index
}
})
// 删除打开的页面 并在缓存设置中删除 // 删除打开的页面 并在缓存设置中删除
state.opened.splice(currentIndex + 1).forEach(({ name }) => commit('keepAliveRemove', name)) await dispatch('splice', { index: currentIndex + 1 })
// 设置当前的页面 resolve()
state.current = pageAim })
if (router.app.$route.fullPath !== pageAim) {
router.push(pageAim)
} }
// 持久化 })
await dispatch('opend2db')
// end
resolve() resolve()
}) })
}, },
...@@ -301,27 +307,21 @@ export default { ...@@ -301,27 +307,21 @@ export default {
*/ */
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 await dispatch('do', {
let currentIndex = 0 pageSelect,
state.opened.forEach((page, index) => { call: currentIndex => {
if (page.fullPath === pageAim) { return new Promise(async resolve => {
currentIndex = index
}
})
// 删除打开的页面数据 并更新缓存设置 // 删除打开的页面数据 并更新缓存设置
if (currentIndex === 0) { if (currentIndex === 0) {
state.opened.splice(1).forEach(({ name }) => commit('keepAliveRemove', name)) await dispatch('splice', { index: 1 })
} else { } else {
state.opened.splice(currentIndex + 1).forEach(({ name }) => commit('keepAliveRemove', name)) await dispatch('splice', { index: currentIndex + 1 })
state.opened.splice(1, currentIndex - 1).forEach(({ name }) => commit('keepAliveRemove', name)) await dispatch('splice', { index: 1, howmany: currentIndex - 1 })
} }
// 设置新的页面 resolve()
state.current = pageAim })
if (router.app.$route.fullPath !== pageAim) {
router.push(pageAim)
} }
// 持久化 })
await dispatch('opend2db')
// end // end
resolve() resolve()
}) })
...@@ -334,7 +334,10 @@ export default { ...@@ -334,7 +334,10 @@ export default {
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)) await dispatch('splice', { index: 1 })
// state.opened
// .splice(1)
// .forEach(({ name }) => commit('keepAliveRemove', name))
// 持久化 // 持久化
await dispatch('opend2db') await dispatch('opend2db')
// 关闭所有的标签页后需要判断一次现在是不是在首页 // 关闭所有的标签页后需要判断一次现在是不是在首页
...@@ -346,7 +349,50 @@ export default { ...@@ -346,7 +349,50 @@ export default {
// end // end
resolve() resolve()
}) })
},
/**
* @class opened
* @description 私有公共方法
* @param {Object} context
*/
async do({ state, commit, dispatch }, { pageSelect, call }) {
return new Promise(async resolve => {
const pageAim = pageSelect || state.current
let currentIndex = 0
state.opened.forEach((page, index) => {
if (page.fullPath === pageAim) {
currentIndex = index
}
})
await call(currentIndex)
// 设置当前的页面
state.current = pageAim
if (router.app.$route.fullPath !== pageAim) {
router.push(pageAim)
}
// 持久化
await dispatch('opend2db')
// end
resolve()
})
},
/**
* @class opened
* @description 私有公共方法
* @param {Object} context
*/
splice({ state, commit }, { index, howmany }) {
return new Promise(resolve => {
if (howmany !== undefined) {
state.opened.splice(index, howmany)
} else {
state.opened.splice(index)
} }
state.opened.forEach(({ name }) => commit('keepAliveRemove', name))
resolve()
})
}
}, },
mutations: { mutations: {
/** /**
...@@ -355,7 +401,9 @@ export default { ...@@ -355,7 +401,9 @@ export default {
* @param {Object} state state * @param {Object} state 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)
}, },
/** /**
* @description 删除一个页面的缓存设置 * @description 删除一个页面的缓存设置
......
...@@ -10,9 +10,6 @@ export default { ...@@ -10,9 +10,6 @@ export default {
versionShow() { versionShow() {
util.log.capsule(process.env.VUE_APP_TITLE, `v${process.env.VUE_APP_VERSION}`) util.log.capsule(process.env.VUE_APP_TITLE, `v${process.env.VUE_APP_VERSION}`)
console.log('广联赛讯 http://www.glsx.com.cn') console.log('广联赛讯 http://www.glsx.com.cn')
// console.log('D2 Crud https://github.com/d2-projects/d2-crud')
// console.log('Document https://doc.d2admin.fairyever.com/zh/')
// console.log('请不要吝啬您的 star,谢谢 ~')
} }
} }
} }
...@@ -73,7 +73,6 @@ ...@@ -73,7 +73,6 @@
<template slot-scope="scope"> <template slot-scope="scope">
<template v-if="item.prop === 'status'"> <template v-if="item.prop === 'status'">
<el-tag <el-tag
style="width:80px; font-size: 14px;"
:type="tag.type[scope.row.status]" :type="tag.type[scope.row.status]"
>{{tag.label[scope.row.status]}}</el-tag> >{{tag.label[scope.row.status]}}</el-tag>
</template> </template>
......
...@@ -82,7 +82,6 @@ ...@@ -82,7 +82,6 @@
<template v-if="item.prop" slot-scope="scope"> <template v-if="item.prop" slot-scope="scope">
<template v-if="item.prop == 'onlineStatus'"> <template v-if="item.prop == 'onlineStatus'">
<el-tag <el-tag
style="width: 80px; font-size: 14px;"
:type="tag.type[scope.row.onlineStatus]" :type="tag.type[scope.row.onlineStatus]"
>{{tag.label[scope.row.onlineStatus]}}</el-tag> >{{tag.label[scope.row.onlineStatus]}}</el-tag>
</template> </template>
......
...@@ -72,7 +72,7 @@ ...@@ -72,7 +72,7 @@
<el-table-column label="有效期" prop="validTime" width="200" align="center" ></el-table-column> <el-table-column label="有效期" prop="validTime" width="200" align="center" ></el-table-column>
<el-table-column label="状态" prop="status" width="100" align="center"> <el-table-column label="状态" prop="status" width="100" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<el-tag style="width:80px; font-size: 14px;" :type="tag.type[scope.row.status]">{{tag.label[scope.row.status]}}</el-tag> <el-tag :type="tag.type[scope.row.status]">{{tag.label[scope.row.status]}}</el-tag>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="姓名" prop="userName" width="120" align="center" ></el-table-column> <el-table-column label="姓名" prop="userName" width="120" align="center" ></el-table-column>
...@@ -245,7 +245,7 @@ export default { ...@@ -245,7 +245,7 @@ export default {
} }
this.openDialog(row) this.openDialog(row)
}, },
handleSearch() { async handleSearch() {
this.loadUserList() this.loadUserList()
}, },
// 页码 // 页码
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!