component: () => import(‘@/views/home/index’),
meta: { title: ‘AI业务培训管理系统’, icon: ‘’ }
}]
},
{
path: ‘/addrole’,
hidden: true,
component: Layout,
children: [
{
path: ‘index/:id’,
name: ‘Addrole’,
component: () => import(‘@/views/usermanage/addrole/index’),
meta: { title: ‘添加角色’, icon: ‘’ }
}
]
},
{
path: ‘/addaccount’,
hidden: true,
component: Layout,
children: [
{
path: ‘index/:id’,
name: ‘AddAccount’,
component: () => import(‘@/views/usermanage/addaccount/index’),
meta: { title: ‘添加账户’, icon: ‘’ }
}
]
},
{
path: ‘/addbanner’,
hidden: true,
component: Layout,
children: [
{
path: ‘index/:id’,
name: ‘AddBanner’,
component: () => import(‘@/views/appmanage/addbanner/index’),
meta: { title: ‘添加Banner’, icon: ‘’ }
}
]
},
{
path: ‘/createactivationcode’,
hidden: true,
component: Layout,
children: [
{
path: ‘index’,
name: ‘CreateActivationCode’,
component: () => import(‘@/views/vipmanage/createactivationcode/index’),
meta: { title: ‘生成激活码’, icon: ‘’ }
}
]
},
]
/**
- 放置服务器可配置的动态路由
*/
export const asyncRoutes = [
{
path: ‘/usermanagement’,
component: Layout,
redirect: ‘/usermanagement/rolemanagement’,
meta: { title: ‘用户管理’, icon: ‘user’ },
children: [
{
path: ‘rolemanagement’,
component: () => import(‘@/views/usermanage/rolemanagement/index’),
meta: { title: ‘角色管理’, icon: ‘’ }
},
{
path: ‘accountlist’,
component: () => import(‘@/views/usermanage/accountlist/index’),
meta: { title: ‘账号列表’, icon: ‘’ }
}
]
},
{
path: ‘/voicemanage’,
component: Layout,
redirect: ‘/voicemanage/albumscategories’,
meta: { title: ‘语音管理’, icon: ‘voice’ },
children: [
{
path: ‘albumscategories’,
component: () => import(‘@/views/voicemanage/albumscategories/index’),
meta: { title: ‘专辑分类’, icon: ‘’ }
},
{
path: ‘listenmanage’,
component: () => import(‘@/views/voicemanage/listenmanage/index’),
meta: { title: ‘收听管理’, icon: ‘’ }
}
]
},
{
path: ‘/appmanagement’,
component: Layout,
redirect: ‘/appmanagement/banner’,
meta: { title: ‘App管理’, icon: ‘app’ },
children: [
{
path: ‘banner’,
component: () => import(‘@/views/appmanage/banner/index’),
meta: { title: ‘Banner管理’, icon: ‘’ }
},
{
path: ‘appversions’,
component: () => import(‘@/views/appmanage/appversions/index’),
meta: { title: ‘App版本管理’, icon: ‘’ }
}
]
},
{
path: ‘/vipmanagement’,
component: Layout,
redirect: ‘/vipmanagement/setmeal’,
meta: { title: ‘VIP管理’, icon: ‘vip’ },
children: [
{
path: ‘setmeal’,
component: () => import(‘@/views/vipmanage/setmeal/index’),
meta: { title: ‘套餐管理’, icon: ‘’ }
},
{
path: ‘activationcode’,
component: () => import(‘@/views/vipmanage/activationcode/index’),
meta: { title: ‘激活码管理’, icon: ‘’ }
},
{
path: ‘activationcodelist’,
component: () => import(‘@/views/vipmanage/activationcodelist/index’),
meta: { title: ‘激活码生成列表’, icon: ‘’ }
},
{
path: ‘activationcodeexport’,
component: () => import(‘@/views/vipmanage/activationcodeexport/index’),
meta: { title: ‘激活码导出列表’, icon: ‘’ }
},
{
path: ‘orderlist’,
component: () => import(‘@/views/vipmanage/orderlist/index’),
meta: { title: ‘订单列表’, icon: ‘’ }
},
{
path: ‘vipequity’,
component: () => import(‘@/views/vipmanage/vipequity/index’),
meta: { title: ‘VIP权益说明’, icon: ‘’ }
}
]
},
{
path: ‘/brandownermanage’,
component: Layout,
redirect: ‘/brandownermanage/brandownerlist’,
alwaysShow: true,
meta: { title: ‘品牌商管理’, icon: ‘brand’ },
children: [
{
path: ‘brandownerlist’,
component: () => import(‘@/views/brandownermanage/brandownerlist/index’),
meta: { title: ‘品牌商列表’, icon: ‘’ }
}
]
},
{
path: ‘/machinemanage’,
component: Layout,
redirect: ‘/machinemanage/machinelist’,
alwaysShow: true,
meta: { title: ‘机器管理’, icon: ‘android’ },
children: [
{
path: ‘machinelist’,
component: () => import(‘@/views/machinemanage/machinelist/index’),
meta: { title: ‘机器列表’, icon: ‘’ }
}
]
},
{
path: ‘/softwaremanage’,
component: Layout,
redirect: ‘/softwaremanage/versions’,
meta: { title: ‘软件管理’, icon: ‘software’ },
children: [
{
path: ‘versions’,
component: () => import(‘@/views/softwaremanage/versions/index’),
meta: { title: ‘版本管理’, icon: ‘’ }
},
{
path: ‘usedirection’,
component: () => import(‘@/views/softwaremanage/usedirection/index’),
meta: { title: ‘使用说明’, icon: ‘’ }
}
]
},
{
path: ‘/officialaccounts’,
component: Layout,
redirect: ‘/officialaccounts/accesssettings’,
meta: { title: ‘公众号设置’, icon: ‘weichat’ },
children: [
{
path: ‘accesssettings’,
component: () => import(‘@/views/officialaccounts/accesssettings/index’),
meta: { title: ‘接入设置’, icon: ‘’ }
},
{
path: ‘menu’,
component: () => import(‘@/views/officialaccounts/menu/index’),
meta: { title: ‘菜单设置’, icon: ‘’ }
},
{
path: ‘attentionreply’,
component: () => import(‘@/views/officialaccounts/attentionreply/index’),
meta: { title: ‘关注回复’, icon: ‘’ }
},
{
path: ‘keywordreply’,
component: () => import(‘@/views/officialaccounts/keywordreply/index’),
meta: { title: ‘关键字回复’, icon: ‘’ }
},
{
path: ‘material’,
component: () => import(‘@/views/officialaccounts/material/index’),
meta: { title: ‘素材管理’, icon: ‘’ }
}
]
},
]
const createRouter = () => new Router({
// mode: ‘history’, // require service support
scrollBehavior: () => ({ y: 0 }),
routes: constantRoutes.concat(asyncRoutes).concat(errorRoutes)
})
export const router = createRouter()
// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
const newRouter = createRouter()
router.matcher = newRouter.matcher // reset router
}
export default router
- 获取动态路由数据api/user.js
import request from ‘@/utils/request’
import qs from ‘qs’
/**
*动态路由
*/
export function getAuthMenu() {
return request({
url: ‘/Admin/Index’,
method: ‘get’
})
}
- 修改权限规则(store/module/permission.js)
vue-admin-template模板本身是没有做权限的,自己创建一个即可,规则自己设定,admin中使用的roles配置的,我这里是自动生成的,本质还是生成新的路由list(只是包含新的路由)
注意:store/module/permission.js和项目根目录下的permission别搞混了
import { asyncRoutes, constantRoutes, errorRoutes } from ‘@/router’
import { getAuthMenu } from ‘@/api/user’
import Layout from ‘@/layout’
import { Message } from “element-ui”
/**
-
后台查询的菜单数据拼装成路由格式的数据
-
这里是demo使用的是以前项目的后台数据,这里强制修改了一下
-
@param routes
*/
export function generaMenu(routes, data, parent) {
data.forEach(item => {
let menu
let viewpath
if (parent == “/usermanagement”) {
viewpath = “/usermanage”
} else if (parent == “/appmanagement”) {
viewpath = “/appmanage”
} else if (parent == “/vipmanagement”) {
viewpath = “/vipmanage”
} else {
viewpath = parent
}
if (parent === ‘#’) {
menu = {
path: item.path,
component: Layout,
children: [],
redirect: ${item.path}/${item.children[0].path}
,
meta: { title: item.name, icon: item.icon }
}
} else {
menu = {
path: item.path,
component: loadView(viewpath, item.path),
children: [],
name: item.path,
meta: { title: item.name }
}
}
if (item.children) {
generaMenu(menu.children, item.children, item.path)
}
routes.push(menu)
})
}
export const loadView = (parent, path) => { // 路由懒加载
return (resolve) => require([@/views${parent}/${path}/index
], resolve)
// return () => import(@/views${parent}/${path}/index
)
}
const state = {
routes: [],
addRoutes: []
}
const mutations = {
SET_ROUTES: (state, routes) => {
state.addRoutes = routes
state.routes = constantRoutes.concat(routes).concat(errorRoutes)
}
}
const actions = {
generateRoutes({ commit }, roles) {
return new Promise(resolve => {
const loadMenuData = []
// 先查询后台并返回左侧菜单数据并把数据添加到路由
getAuthMenu().then(response => {
if (response.code !== 200) {
Message({
message: “菜单数据加载异常”,
type: 0,
duration: 2 * 1000
});
} else {
let data = response.data.menu_list
Object.assign(loadMenuData, data)
let routes=[]
generaMenu(routes, loadMenuData, “#”)
let accessedRoutes
if (roles.includes(‘admin’)) {
accessedRoutes = asyncRoutes || []
} else {
accessedRoutes = routes
}
commit(‘SET_ROUTES’, accessedRoutes)
resolve(accessedRoutes)
}
}).catch(error => {
console.log(error)
})
})
},
}
export default {
namespaced: true,
state,
mutations,
actions
}
- 配置项目根目录下的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 } from ‘@/utils/auth’ // get token from cookie
import getPageTitle from ‘@/utils/get-page-title’
NProgress.configure({ showSpinner: false }) // NProgress Configuration
//动态路由添加’/auth-redirect’
const whiteList = [‘/login’] // no redirect whitelist
router.beforeEach(async (to, from, next) => {
// start progress bar
NProgress.start()
// set page title
document.title = getPageTitle(to.meta.title)
// determine whether the user has logged in
const hasToken = getToken()
if (hasToken) {
if (to.path === ‘/login’) {
// if is logged in, redirect to the home page
next({ path: ‘/’ })
NProgress.done()
} else {
// const hasGetUserInfo = store.getters.name
//动态路由
const hasGetUserInfo = store.getters.name&&store.getters.permission_routes.length > 0
if (hasGetUserInfo) {
next()
} else {
try {
// get user info
// await store.dispatch(‘user/getInfo’)
// next()
//配置动态路由
const { contact_name } = await store.dispatch(‘user/getInfo’)
const accessRoutes = await store.dispatch(‘permission/generateRoutes’, contact_name)
router.addRoutes(accessRoutes)
next({ …to, replace: true })
} catch (error) {
// remove token and go to login page to re-login
自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。
深知大多数前端工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但对于培训机构动则几千的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!
因此收集整理了一份《2024年Web前端开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。
既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上前端开发知识点,真正体系化!
由于文件比较大,这里只是将部分目录大纲截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且后续会持续更新
如果你觉得这些内容对你有帮助,可以添加V获取:vip1024c (备注前端)
最后
前端CSS面试题文档,JavaScript面试题文档,Vue面试题文档,大厂面试题文档
一个人可以走的很快,但一群人才能走的更远。不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎扫码加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!
小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!**
因此收集整理了一份《2024年Web前端开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。
[外链图片转存中…(img-r0crBcMz-1712868269261)]
[外链图片转存中…(img-ndgAJh50-1712868269261)]
[外链图片转存中…(img-URgWlT9R-1712868269262)]
[外链图片转存中…(img-YIriWZsj-1712868269262)]
[外链图片转存中…(img-hDVZpUtj-1712868269263)]
[外链图片转存中…(img-Nx07Umii-1712868269263)]
既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上前端开发知识点,真正体系化!
由于文件比较大,这里只是将部分目录大纲截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且后续会持续更新
如果你觉得这些内容对你有帮助,可以添加V获取:vip1024c (备注前端)
[外链图片转存中…(img-c9Qu1qsC-1712868269263)]
最后
前端CSS面试题文档,JavaScript面试题文档,Vue面试题文档,大厂面试题文档
[外链图片转存中…(img-ukATquhQ-1712868269264)]
[外链图片转存中…(img-9Q6eh1m8-1712868269264)]
一个人可以走的很快,但一群人才能走的更远。不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎扫码加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!
[外链图片转存中…(img-EwFWNf8f-1712868269264)]