tab drag
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
@rowClick="contextmenuClick"/>
|
||||
</d2-contextmenu>
|
||||
<el-tabs
|
||||
class="d2-multiple-page-control"
|
||||
class="d2-multiple-page-control d2-multiple-page-sort"
|
||||
:value="current"
|
||||
type="card"
|
||||
:closable="true"
|
||||
@@ -60,6 +60,7 @@
|
||||
|
||||
<script>
|
||||
import { mapState, mapActions } from 'vuex'
|
||||
import Sortable from 'sortablejs'
|
||||
export default {
|
||||
components: {
|
||||
D2Contextmenu: () => import('../contextmenu'),
|
||||
@@ -94,7 +95,8 @@ export default {
|
||||
'closeLeft',
|
||||
'closeRight',
|
||||
'closeOther',
|
||||
'closeAll'
|
||||
'closeAll',
|
||||
'openedSort'
|
||||
]),
|
||||
/**
|
||||
* @description 右键菜单功能点击
|
||||
@@ -172,6 +174,15 @@ export default {
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted () {
|
||||
const el = document.querySelectorAll('.d2-multiple-page-sort .el-tabs__nav')[0]
|
||||
Sortable.create(el, {
|
||||
onEnd: (evt) => {
|
||||
const { oldIndex, newIndex } = evt
|
||||
this.openedSort({ oldIndex, newIndex })
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -15,10 +15,10 @@
|
||||
}"
|
||||
flex-box="0"
|
||||
flex>
|
||||
<div class="logo-group" :style="{width: asideCollapse ? asideWidthCollapse : asideWidth}" flex-box="0">
|
||||
<router-link to="/index" class="logo-group" :style="{width: asideCollapse ? asideWidthCollapse : asideWidth}" flex-box="0">
|
||||
<img v-if="asideCollapse" :src="`${$baseUrl}image/theme/${themeActiveSetting.name}/logo/icon-only.png`">
|
||||
<img v-else :src="`${$baseUrl}image/theme/${themeActiveSetting.name}/logo/all.png`">
|
||||
</div>
|
||||
</router-link>
|
||||
<div class="toggle-aside-btn" @click="handleToggleAside" flex-box="0">
|
||||
<d2-icon name="bars"/>
|
||||
</div>
|
||||
|
||||
@@ -14,11 +14,11 @@ import routes from './routes'
|
||||
// fix vue-router NavigationDuplicated
|
||||
const VueRouterPush = VueRouter.prototype.push
|
||||
VueRouter.prototype.push = function push (location) {
|
||||
return VueRouterPush.call(this, location)
|
||||
return VueRouterPush.call(this, location).catch(err => err)
|
||||
}
|
||||
const VueRouterReplace = VueRouter.prototype.replace
|
||||
VueRouter.prototype.replace = function replace (location) {
|
||||
return VueRouterReplace.call(this, location)
|
||||
return VueRouterReplace.call(this, location).catch(err => err)
|
||||
}
|
||||
|
||||
Vue.use(VueRouter)
|
||||
|
||||
@@ -26,6 +26,7 @@ const frameIn = [
|
||||
path: 'index',
|
||||
name: 'index',
|
||||
meta: {
|
||||
title: '首页',
|
||||
auth: true
|
||||
},
|
||||
component: _import('system/index')
|
||||
|
||||
@@ -113,6 +113,24 @@ export default {
|
||||
resolve()
|
||||
})
|
||||
},
|
||||
/**
|
||||
* @class opened
|
||||
* @description 重排页面列表上的某一项
|
||||
* @param {Object} context
|
||||
* @param {Object} payload { oldIndex, newIndex } 位置信息
|
||||
*/
|
||||
openedSort ({ state, commit, dispatch }, { oldIndex, newIndex }) {
|
||||
return new Promise(async resolve => {
|
||||
// 重排页面列表某一项
|
||||
let page = state.opened[oldIndex]
|
||||
state.opened.splice(oldIndex, 1)
|
||||
state.opened.splice(newIndex, 0, page)
|
||||
// 持久化
|
||||
await dispatch('opened2db')
|
||||
// end
|
||||
resolve()
|
||||
})
|
||||
},
|
||||
/**
|
||||
* @class opened
|
||||
* @description 新增一个 tag (打开一个页面)
|
||||
|
||||
Reference in New Issue
Block a user