Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用SpringCache重写缓存设计 #125

Open
wants to merge 6 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class AdminAdController {

@RequiresPermissions("admin:ad:list")
@RequiresPermissionsDesc(menu={"推广管理" , "广告管理"}, button="查询")
@GetMapping("/list")
@RequestMapping("/list")
public Object list(String name, String content,
@RequestParam(defaultValue = "1") Integer page,
@RequestParam(defaultValue = "10") Integer limit,
Expand Down
1 change: 0 additions & 1 deletion litemall-admin/src/lang/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ export default {
},
permission: {
roles: 'Your roles',
perms: 'Your permissions',
switchRoles: 'Switch roles'
},
guide: {
Expand Down
5 changes: 2 additions & 3 deletions litemall-admin/src/lang/zh.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,8 @@ export default {
github: 'Github 地址'
},
permission: {
roles: '你的角色',
perms: '你的权限',
switchRoles: '切换角色'
roles: '你的权限',
switchRoles: '切换权限'
},
guide: {
description: '引导页对于一些第一次进入项目的人很有用,你可以简单介绍下项目的功能。本 Demo 是基于',
Expand Down
4 changes: 0 additions & 4 deletions litemall-admin/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,11 @@ import './permission' // permission control

import * as filters from './filters' // global filters

import permission from '@/directive/permission/index.js' // 权限判断指令

Vue.use(Element, {
size: Cookies.get('size') || 'medium', // set element-ui default size
i18n: (key, value) => i18n.t(key, value)
})

Vue.directive('permission', permission)

// register global utility filters.
Object.keys(filters).forEach(key => {
Vue.filter(key, filters[key])
Expand Down
16 changes: 8 additions & 8 deletions litemall-admin/src/permission.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import { getToken } from '@/utils/auth' // getToken from cookie
NProgress.configure({ showSpinner: false })// NProgress Configuration

// permission judge function
function hasPermission(perms, permissions) {
if (perms.indexOf('*') >= 0) return true // admin permission passed directly
if (!permissions) return true
return perms.some(perm => permissions.indexOf(perm) >= 0)
function hasPermission(roles, permissionRoles) {
if (roles.indexOf('admin') >= 0) return true // admin permission passed directly
if (!permissionRoles) return true
return roles.some(role => permissionRoles.indexOf(role) >= 0)
}

const whiteList = ['/login', '/auth-redirect']// no redirect whitelist
Expand All @@ -24,10 +24,10 @@ router.beforeEach((to, from, next) => {
next({ path: '/' })
NProgress.done() // if current page is dashboard will not trigger afterEach hook, so manually handle it
} else {
if (store.getters.perms.length === 0) { // 判断当前用户是否已拉取完user_info信息
if (store.getters.roles.length === 0) { // 判断当前用户是否已拉取完user_info信息
store.dispatch('GetUserInfo').then(res => { // 拉取user_info
const perms = res.data.data.perms // note: perms must be a array! such as: ['GET /aaa','POST /bbb']
store.dispatch('GenerateRoutes', { perms }).then(() => { // 根据perms权限生成可访问的路由表
const roles = res.data.data.roles // note: roles must be a array! such as: ['editor','develop']
store.dispatch('GenerateRoutes', { roles }).then(() => { // 根据roles权限生成可访问的路由表
router.addRoutes(store.getters.addRouters) // 动态添加可访问路由表
next({ ...to, replace: true }) // hack方法 确保addRoutes已完成 ,set the replace: true so the navigation will not leave a history record
})
Expand All @@ -39,7 +39,7 @@ router.beforeEach((to, from, next) => {
})
} else {
// 没有动态改变权限的需求可直接next() 删除下方权限判断 ↓
if (hasPermission(store.getters.perms, to.meta.perms)) {
if (hasPermission(store.getters.roles, to.meta.roles)) {
next()
} else {
next({ path: '/401', replace: true, query: { noGoBack: true }})
Expand Down
Loading