欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

SpringBoot整合SpringSecurity實現(xiàn)權限控制之實現(xiàn)多標簽頁

 更新時間:2021年11月12日 10:24:09   作者:智慧zhuhuix  
這篇文章主要介紹了SpringBoot整合SpringSecurity實現(xiàn)權限控制之實現(xiàn)多標簽頁,本文通過實例代碼給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下

一、需求描述

多標簽頁 (Tabs) 的設計對于多窗口多任務管理有著無與倫比的高效率與方便性

在上面的文章中已經(jīng)實現(xiàn)了后臺管理的基本權限功能,包括用戶、角色、菜單管理及權限分配。

用戶通過單擊側邊欄的菜單,就可以調(diào)出對應的功能頁面進行使用。但在使用的過程中,我們發(fā)現(xiàn)程序只能在同一時間打開一個頁面。我們更希望打開多個功能頁面時,這些頁面以標簽的形式集成在同一個窗口顯示,要想切換到某個頁面或是關閉某個頁面,我們只需要操作相應的標簽即可,非常方便快捷。

在這里插入圖片描述

二、前端實現(xiàn)

1.使用element tabs組件搭建基礎的多標簽頁,示例如下:

<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列表進行關聯(lián)

  watch: {
    $route: {
      handler(to, form = null) {
        // 當路由改變時,檢測該路由是否已經(jīng)在打開的頁面之中,如果不在,就添加進去
        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頁與切換tab頁事件

  methods: {
    // 移除tab頁
    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 })
    },
    // 切換標簽頁
    tabChange(tab, event) {
      this.$router.push({ path: tab.name })
    }
  }

在布局主界面中加入多標簽組件

<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 />
        <!-- 加入多標簽組件 -->
        <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

到此這篇關于SpringBoot整合SpringSecurity實現(xiàn)權限控制之實現(xiàn)多標簽頁的文章就介紹到這了,更多相關SpringBoot整合SpringSecurity實現(xiàn)多標簽頁內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!

相關文章

最新評論