当前位置: 首页 > news >正文

杨凌企业网站建设站长之家音效

杨凌企业网站建设,站长之家音效,省西省建设厅网站,网站建设项目验收表使用的的是vue-admin-template,这是一个极简的 vue admin 管理后台,它只包含了 Element UI & axios & iconfont & permission control & lint,这些搭建后台必要的东西。需要根据自己的需求二次开发。 线上地址:vue-admin-tem…

使用的的是vue-admin-template,这是一个极简的 vue admin 管理后台,它只包含了 Element UI & axios & iconfont & permission control & lint,这些搭建后台必要的东西。需要根据自己的需求二次开发。
线上地址:vue-admin-template
国内访问:vue-admin-template

  • 开发了一个公司内部的后台管理系统
  • 路由信息是登录成功后台返回,然后动态添加的
  • 遇到的问题:动态添加路由死活不显示

解决思路:

1. 所有的页面必须有index.vue

比如一个模块“日志和统计”, 它包含两个自己,‘操作日志’和‘数据列表’
日志和统计

  • LogsAndStatistics
    • OperationLog
      • index.vue
    • DataStatistics
      • index.vue
    • index.vue

对!必须有index.vue!必须有index.vue!!必须有index.vue!重要的事情3遍,不写就是不显示!!!
name也必须是一 一对应的唯一值!!!

2. 修改配置条件

  1. 先登录成功后后台会返回该账号匹配的路由信息,格式如下:
[{"title": "消息管理","name": "message","id": 2,"pid": 0,"icon": "el-icon-tickets","component": "#","path": "/message-management","redirect": "/list","alwaysShow": 1,"children": [{"title": "消息列表","name": "MessageManagement","id": 3,"pid": 2,"component": "MessageManagement","path": "list"}]},{"title": "客户管理","name": "Customer:List","id": 25,"pid": 0,"icon": "el-icon-user-solid","component": "#","path": "/customer","redirect": "Customer","alwaysShow": 1,"children": [{"title": "客户列表","name": "CustomerManagement","id": 26,"pid": 25,"component": "CustomerManagement","path": "list"}]},{"title": "用户和权限","name": "","id": 31,"pid": 0,"icon": "el-icon-user-solid","component": "#","path": "/user-permissions","redirect": "/user-list","alwaysShow": 1,"children": [{"title": "组织架构","name": "OrganizationalStructure","id": 37,"pid": 31,"component": "UsersAndPermissions/OrganizationalStructure","path": "organizational-list"},{"title": "用户列表","name": "UserList","id": 32,"pid": 31,"component": "UsersAndPermissions/UserList","path": "user-list"},{"title": "权限列表","name": "PermissionList","id": 41,"pid": 31,"component": "UsersAndPermissions/PermissionList","path": "permission-list"},{"title": "角色列表","name": "RoleList","id": 44,"pid": 31,"component": "UsersAndPermissions/RoleList","path": "role-list"}]},{"title": "日志和统计","name": "LogManagement","id": 46,"pid": 0,"icon": "el-icon-error","component": "#","path": "/logs-statistics","redirect": "/logs","alwaysShow": 1,"children": [{"title": "操作日志","name": "LogsAndStatistic","id": 47,"pid": 46,"component": "LogsAndStatistics/OperationLog","path": "logs"},{"title": "数据列表","name": "DataStatistics","id": 48,"pid": 46,"component": "LogsAndStatistics/DataStatistics","path": "statistics"}]}
]
  1. 先保存到本地:我们是登录成功后直接返回的如下图:
    在这里插入图片描述
// utils/auth.js
export function setPermission(permission){const permissionData = {permission}return localStorage.setItem(PERMISSION, JSON.stringify(permissionData))
}
export function getPermission(){const val = JSON.parse(localStorage.getItem(PERMISSION)|| '{}')return val.permission
}
  1. 我的permission配置文件直接copy的 vue-element-admin 的二次修改的。

首先是router下的index.js

import Vue from 'vue'
import Router from 'vue-router'Vue.use(Router)
export const constantRoutes = [{path: '/login',component: () => import('@/views/Login/index.vue'),hidden: true},{path: '/retrieve-password',component: () => import('@/views/RetrievePassword/index.vue'),hidden: true},{path: '/404',name:'Page404',component: () => import('@/views/404'),hidden: true}
]const createRouter = () => new Router({isAddDynamicMenuRoutes: false, // 是否已经添加动态(菜单)路由scrollBehavior: () => ({ y: 0 }),routes: constantRoutes
})const router = createRouter()
export function resetRouter() {const newRouter = createRouter()router.matcher = newRouter.matcher // reset router
}export default router

然后修改src 目录下的permission.js

import router from './router'
import store from './store'
import { Message } from 'element-ui'
import NProgress from 'nprogress' // progress bar
import 'nprogress/nprogress.css' // progress bar style
import { getToken,getPermission} from '@/utils/auth' // get token from cookie
import getPageTitle from '@/utils/get-page-title'NProgress.configure({ showSpinner: false }) // NProgress Configurationconst whiteList = ['/login','/retrieve-password'] // 不需要重定向白名单:登录和找回密码页面不需要重定向router.beforeEach(async(to, from, next) => {// start progress barNProgress.start()// set page titledocument.title = getPageTitle(to.meta.title)// 确定用户是否已登录const hasToken = getToken()if (hasToken) {if (to.path === '/login') {// if is logged in, redirect to the home pagenext({ path: '/' })NProgress.done()} else {// 是否添加动态路由if (router.options.isAddDynamicMenuRoutes) {next()} else {try {// 获取本地存储的路由信息(后台返回的)const Permission = getPermission()if(Permission.length<1){ return Promise.reject('菜单数据加载异常')}const accessRoutes = await store.dispatch('permission/generateRoutes', Permission)router.addRoutes(accessRoutes)router.options.isAddDynamicMenuRoutes = truenext({ ...to, replace: true })} catch (error) {console.log(error)// remove token and go to login page to re-loginawait store.dispatch('user/resetToken')Message.error(error || 'Has Error')next(`/login?redirect=${to.path}`)NProgress.done()}}}} else {/* 未登录*/if (whiteList.indexOf(to.path) !== -1) {//在免费登录白名单中,直接进入next()} else {//没有访问权限的其他页面将重定向到登录页面。next(`/login?redirect=${to.path}`)NProgress.done()}}
})router.afterEach(() => {NProgress.done()
})

store文件夹下添加permission.js (需要在store的index.js下引入:import permission from ‘./modules/permission’)

  • 解析返回的路由信息时import(‘@/views/XXX/index.vue’) 会报错,找不到。
  • 开始把整个路由信息’@/views/XXX/index.vue’全部返回,直接使用require([/${component}], resolve)) ,还是报错;
  • 搜索尝试后解决component只要中间部分:
    eg: `@/views/RetrievePassword/index.vue' => 'RetrievePasswod'
    解析时:require([`@/views/${component}/index.vue`], resolve))
import Vue from 'vue'
import {constantRoutes} from '@/router'
import Layout from '@/layout'
/**
* 后台查询的菜单数据拼装成路由格式的数据
* @param list 处理的路由列表
*/
export function AddMenuRoutes(list = []) {const newRoutes = []list.map((v, i) => {const {path,id,name,component,alwaysShow,redirect,title,icon,children} = vconst route = {id,path: component=='#' && i==0?'/':path}if(component=='#'){ Vue.set(route,'component',Layout)}else{Vue.set(route,'component',(resolve) => require([`@/views/${component}/index.vue`], resolve))}if(name){Vue.set(route,'name',name)}if(title){Vue.set(route,'meta',{title})if(icon){Object.assign(route.meta,{icon})}}if(alwaysShow==1){Vue.set(route,'alwaysShow',true)}if(redirect){Vue.set(route,'redirect',redirect)}if (children && children.length) {Vue.set(route,'children',[])route.children = AddMenuRoutes(v.children)}newRoutes.push(route)})return newRoutes
}const state = {routes: [],addRoutes: []
}const mutations = {SET_ROUTES: (state, routes) => {state.addRoutes = routesstate.routes = constantRoutes.concat(routes)}
}const actions = {/*** @param {*} permissionList 后台传回来的路由数据*/async generateRoutes({ commit }, permissionList) {const MenuList = []const permissions = permissionList || []Object.assign(MenuList, permissions)const newRoutes = await AddMenuRoutes(MenuList)commit('SET_ROUTES', newRoutes)return newRoutes}
}export default {namespaced: true,state,mutations,actions
}

就可以看到效果了:
在这里插入图片描述

完整的authentic.js:

const TokenKey = 'access_token'
const PERMISSION ='Permission'
const USERINFO = 'UserInfo'
const BUTTONS = 'Buttons'
export function getUserInfo() {const val = JSON.parse(localStorage.getItem(USERINFO)||'{}')return  val.name
}
export function setUserInfo(name) {const userInfo={name}return localStorage.setItem(USERINFO, JSON.stringify(userInfo))
}
export function removeUserInfo() {return localStorage.removeItem(USERINFO)
}export function getToken() {const val = JSON.parse(localStorage.getItem(TokenKey)|| '{}')return val.token
}
export function setToken(token) {const tokeData = {token}return localStorage.setItem(TokenKey, JSON.stringify(tokeData))
}
export function removeToken() {return localStorage.removeItem(TokenKey)
}export function setPermission(permission){const permissionData = {permission}return localStorage.setItem(PERMISSION, JSON.stringify(permissionData))
}
export function getPermission(){const val = JSON.parse(localStorage.getItem(PERMISSION)|| '{}')return val.permission
}
export function removePermission() {return localStorage.removeItem(PERMISSION)
}export function setButtons(buttons){const buttonsData = {buttons}return localStorage.setItem(BUTTONS, JSON.stringify(buttonsData))
}
export function getButtons(){const val = JSON.parse(localStorage.getItem(BUTTONS)|| '{}')return val.buttons
}
export function removeButtons() {return localStorage.removeItem(BUTTONS)
}export function removeAllInfo() {removeButtons()removePermission()removeToken()removeUserInfo()
}

文章转载自:
http://hackney.fwrr.cn
http://sporidium.fwrr.cn
http://necroscopy.fwrr.cn
http://eccrine.fwrr.cn
http://untrodden.fwrr.cn
http://resumptive.fwrr.cn
http://reid.fwrr.cn
http://sluggish.fwrr.cn
http://udsl.fwrr.cn
http://hibernicism.fwrr.cn
http://minny.fwrr.cn
http://brooklyn.fwrr.cn
http://foumart.fwrr.cn
http://obversion.fwrr.cn
http://haemolyse.fwrr.cn
http://burgundy.fwrr.cn
http://disinclined.fwrr.cn
http://togaed.fwrr.cn
http://thirty.fwrr.cn
http://fenceless.fwrr.cn
http://erotologist.fwrr.cn
http://cytotrophoblast.fwrr.cn
http://niflheim.fwrr.cn
http://diffluent.fwrr.cn
http://trimetrical.fwrr.cn
http://extramarginal.fwrr.cn
http://cetacea.fwrr.cn
http://compress.fwrr.cn
http://purge.fwrr.cn
http://greener.fwrr.cn
http://cancerroot.fwrr.cn
http://arthropathy.fwrr.cn
http://overspecialization.fwrr.cn
http://angulation.fwrr.cn
http://myalism.fwrr.cn
http://bedrid.fwrr.cn
http://petrograd.fwrr.cn
http://adscript.fwrr.cn
http://osteomalacic.fwrr.cn
http://heartstring.fwrr.cn
http://whisper.fwrr.cn
http://neurohormone.fwrr.cn
http://bulbar.fwrr.cn
http://branch.fwrr.cn
http://turboelectric.fwrr.cn
http://deanship.fwrr.cn
http://slanderous.fwrr.cn
http://pupal.fwrr.cn
http://roentgenoparent.fwrr.cn
http://celestial.fwrr.cn
http://pecten.fwrr.cn
http://distressful.fwrr.cn
http://angustifoliate.fwrr.cn
http://clinician.fwrr.cn
http://verbena.fwrr.cn
http://tweeze.fwrr.cn
http://inexcitable.fwrr.cn
http://hagioscope.fwrr.cn
http://collateral.fwrr.cn
http://helping.fwrr.cn
http://guangzhou.fwrr.cn
http://rabbanist.fwrr.cn
http://photopolymerization.fwrr.cn
http://trouper.fwrr.cn
http://sulfone.fwrr.cn
http://woodlark.fwrr.cn
http://courlan.fwrr.cn
http://acoustician.fwrr.cn
http://loggerhead.fwrr.cn
http://defining.fwrr.cn
http://candiot.fwrr.cn
http://feeding.fwrr.cn
http://idolatress.fwrr.cn
http://nonconductor.fwrr.cn
http://monanthous.fwrr.cn
http://gappy.fwrr.cn
http://essentially.fwrr.cn
http://radiophosphorus.fwrr.cn
http://tepid.fwrr.cn
http://geocentrism.fwrr.cn
http://picaninny.fwrr.cn
http://radicalize.fwrr.cn
http://informatics.fwrr.cn
http://cockshot.fwrr.cn
http://pyrogenation.fwrr.cn
http://spinulated.fwrr.cn
http://moisty.fwrr.cn
http://cryohydrate.fwrr.cn
http://imperturbable.fwrr.cn
http://severance.fwrr.cn
http://impermissibly.fwrr.cn
http://carotene.fwrr.cn
http://calliope.fwrr.cn
http://outpensioner.fwrr.cn
http://monorchid.fwrr.cn
http://kyang.fwrr.cn
http://cretan.fwrr.cn
http://synchrotron.fwrr.cn
http://sinophobia.fwrr.cn
http://anchylosis.fwrr.cn
http://www.dt0577.cn/news/113288.html

相关文章:

  • 建设网站属于什么费用吗vi设计公司
  • iis 网站访问权限设置百度应用商店下载
  • 武汉企业建站程序自媒体怎么赚钱
  • 网站大气模板广州疫情最新动态
  • 通用模板做的网站不收录最好的网络营销软件
  • 什么网站做谷歌联盟好游戏推广引流软件
  • 高端手机网站设计网络推广一般怎么收费
  • 有做门窗找活的网站吗百度搜索广告收费标准
  • 山东做网站公司seo收费低
  • 都有哪些js素材网站网站seo外链建设
  • 重庆网站建设有限公司深圳网站推广
  • 网站备案审核百度一下你就知道移动官网
  • 怎样用word做网站南宁网站推广公司
  • 桂林北站到阳朔网站建设制作过程
  • 中国建设银行纪念币预约网站百度推广外包哪家不错
  • windows部署网站php百度关键词怎么刷上去
  • wordpress文本块表格优化落实新十条措施
  • 运输 织梦网站模板百度搜索优化怎么做
  • 肇庆网站seo大连网站seo
  • 淘宝网站建设哪个类目广东短视频seo搜索哪家好
  • 广东深圳最新疫情seo入门到精通
  • 南岸网站建设如何做电商 个人
  • 国外有哪些网站做推广的比较好南京seo公司
  • wordpress 主题 html5 左右滑动切换文章资阳市网站seo
  • 五金模具技术支持 东莞网站建设免费seo快速排名工具
  • 网站建设面试题企业网络策划
  • 凡科建站登录入口官方数据网站有哪些
  • 室内效果图代做网站百度推广费用多少
  • 个人网站也要备案吗百度账号管理中心
  • 网站都是怎么做的外链link