SpringBoot整合SpringSecurity實(shí)現(xiàn)權(quán)限控制之實(shí)現(xiàn)多標(biāo)簽頁(yè)
一、需求描述
多標(biāo)簽頁(yè) (Tabs) 的設(shè)計(jì)對(duì)于多窗口多任務(wù)管理有著無(wú)與倫比的高效率與方便性
在上面的文章中已經(jīng)實(shí)現(xiàn)了后臺(tái)管理的基本權(quán)限功能,包括用戶(hù)、角色、菜單管理及權(quán)限分配。
用戶(hù)通過(guò)單擊側(cè)邊欄的菜單,就可以調(diào)出對(duì)應(yīng)的功能頁(yè)面進(jìn)行使用。但在使用的過(guò)程中,我們發(fā)現(xiàn)程序只能在同一時(shí)間打開(kāi)一個(gè)頁(yè)面。我們更希望打開(kāi)多個(gè)功能頁(yè)面時(shí),這些頁(yè)面以標(biāo)簽的形式集成在同一個(gè)窗口顯示,要想切換到某個(gè)頁(yè)面或是關(guān)閉某個(gè)頁(yè)面,我們只需要操作相應(yīng)的標(biāo)簽即可,非常方便快捷。

二、前端實(shí)現(xiàn)
1.使用element tabs組件搭建基礎(chǔ)的多標(biāo)簽頁(yè),示例如下:
<template>
<div class="tabbar-container">
<el-tabs v-model="pageCurrent" type="card" closable @tab-click="tabChange" @tab-remove="removeTab">
<el-tab-pane
v-for="(item) in pageList"
:key="item.name"
:name="item.name"
class="tabbar-item"
>
<span slot="label">
<span><i :class="item.icon" />{{ }} {{ item.label }}</span>
</span>
</el-tab-pane>
</el-tabs>
</div>
</template>

2. 監(jiān)控路由變化情況,將路由信息與tabs panel列表進(jìn)行關(guān)聯(lián)
watch: {
$route: {
handler(to, form = null) {
// 當(dāng)路由改變時(shí),檢測(cè)該路由是否已經(jīng)在打開(kāi)的頁(yè)面之中,如果不在,就添加進(jìn)去
if (to.meta) {
this.pageCurrent = to.path
var index = this.pageList.findIndex(value => {
return value.name === to.path
})
if (index < 0) {
this.pageList.push({ name: to.path, label: to.meta.title, icon: to.meta.icon })
}
}
},
immediate: true
}
},
增加移除tab頁(yè)與切換tab頁(yè)事件
methods: {
// 移除tab頁(yè)
removeTab(targetName) {
if (targetName === '/dashboard') return
const tabs = this.pageList
let activeName = this.pageCurrent
if (activeName === targetName) {
tabs.forEach((tab, index) => {
if (tab.name === targetName) {
const nextTab = tabs[index + 1] || tabs[index - 1]
if (nextTab) {
activeName = nextTab.name
}
}
})
}
this.pageCurrent = activeName
this.pageList = tabs.filter(tab => tab.name !== targetName)
this.$router.push({ path: activeName })
},
// 切換標(biāo)簽頁(yè)
tabChange(tab, event) {
this.$router.push({ path: tab.name })
}
}
在布局主界面中加入多標(biāo)簽組件
<template>
<div :class="classObj" class="app-wrapper">
<div v-if="device==='mobile'&&sidebar.opened" class="drawer-bg" @click="handleClickOutside" />
<sidebar class="sidebar-container" />
<div class="main-container">
<div :class="{'fixed-header':fixedHeader}">
<navbar />
<!-- 加入多標(biāo)簽組件 -->
<tabbar />
</div>
<app-main />
</div>
</div>
</template>
<script>
import { Navbar, Sidebar, AppMain, Tabbar } from './components'
...
</script>
三、效果演示

四、源碼
前端
https://gitee.com/zhuhuix/startup-frontend
https://github.com/zhuhuix/startup-frontend
后端
https://gitee.com/zhuhuix/startup-backend
https://github.com/zhuhuix/startup-backend
到此這篇關(guān)于SpringBoot整合SpringSecurity實(shí)現(xiàn)權(quán)限控制之實(shí)現(xiàn)多標(biāo)簽頁(yè)的文章就介紹到這了,更多相關(guān)SpringBoot整合SpringSecurity實(shí)現(xiàn)多標(biāo)簽頁(yè)內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
- SpringBoot整合SpringSecurityOauth2實(shí)現(xiàn)鑒權(quán)動(dòng)態(tài)權(quán)限問(wèn)題
- SpringBoot如何整合Springsecurity實(shí)現(xiàn)數(shù)據(jù)庫(kù)登錄及權(quán)限控制
- springboot整合springsecurity與mybatis-plus的簡(jiǎn)單實(shí)現(xiàn)
- Springboot安全框架整合SpringSecurity實(shí)現(xiàn)方式
- SpringSecurity整合springBoot、redis實(shí)現(xiàn)登錄互踢功能
- SpringBoot與SpringSecurity整合方法附源碼
- SpringBoot2.0 整合 SpringSecurity 框架實(shí)現(xiàn)用戶(hù)權(quán)限安全管理方法
- 詳解SpringBoot+SpringSecurity+jwt整合及初體驗(yàn)
- Springboot詳解整合SpringSecurity實(shí)現(xiàn)全過(guò)程
相關(guān)文章
SpringBoot項(xiàng)目集成Swagger和swagger-bootstrap-ui及常用注解解讀
這篇文章主要介紹了SpringBoot項(xiàng)目集成Swagger和swagger-bootstrap-ui及常用注解解讀,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-03-03
Spring IOC (DI) 依賴(lài)注入的四種方式示例詳解
這篇文章主要介紹了Spring IOC (DI) 依賴(lài)注入的四種方式,本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2023-06-06
IDEA設(shè)置允許一個(gè)類(lèi)并行的方法
這篇文章主要介紹了IDEA設(shè)置允許一個(gè)類(lèi)并行的方法,本文通過(guò)圖文并茂的形式給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2021-04-04
Java8新特性之StampedLock_動(dòng)力節(jié)點(diǎn)Java學(xué)院整理
本文從synchronized、Lock到Java8新增的StampedLock進(jìn)行對(duì)比分析,對(duì)Java8新特性之StampedLock相關(guān)知識(shí)感興趣的朋友一起看看吧2017-06-06
解決SpringBoot打成jar運(yùn)行后無(wú)法讀取resources里的文件問(wèn)題
這篇文章主要介紹了解決SpringBoot打成jar運(yùn)行后無(wú)法讀取resources里的文件問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2020-08-08
feign調(diào)用第三方接口,編碼定義GBK,響應(yīng)中文亂碼處理方式
這篇文章主要介紹了feign調(diào)用第三方接口,編碼定義GBK,響應(yīng)中文亂碼處理方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2024-01-01
SpringBoot 統(tǒng)一公共返回類(lèi)的實(shí)現(xiàn)
本文主要介紹了SpringBoot 統(tǒng)一公共返回類(lèi)的實(shí)現(xiàn),配置后臺(tái)的統(tǒng)一公共返回類(lèi),這樣做目的是為了統(tǒng)一返回信息,文中示例代碼介紹的很詳細(xì),感興趣的可以了解一下2022-01-01
Spring CGLlB動(dòng)態(tài)代理實(shí)現(xiàn)過(guò)程解析
這篇文章主要介紹了Spring CGLlB動(dòng)態(tài)代理實(shí)現(xiàn)過(guò)程解析,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2019-10-10

