zhang_li
6 months ago
6 changed files with 60 additions and 74 deletions
@ -1,4 +1,5 @@ |
|||||
|
|
||||
VITE_BASE_URL=http://192.168.0.106:12080/admin-api |
VITE_BASE_URL=http://192.168.0.106:12080/admin-api |
||||
#VITE_BASE_URL=http://dev.ccwin-in.com:25202/api/admin-api |
#VITE_BASE_URL=http://dev.ccwin-in.com:25202/api/admin-api |
||||
VITE_BASE_URL_IMAGE=http://localhost:12080/admin-api |
VITE_BASE_URL_IMAGE=http://192.168.0.106:12080/admin-api |
||||
|
|
||||
|
@ -1,62 +1,64 @@ |
|||||
// import store from '@/store'
|
// import store from '@/store'
|
||||
import { useCountStore } from '@/store' |
import { |
||||
const store = useCountStore() |
useCountStore |
||||
console.log(store) |
} from '@/store' |
||||
|
const store = useCountStore() |
||||
|
|
||||
function authPermission(permission) { |
function authPermission(permission) { |
||||
const all_permission = "*:*:*" |
const all_permission = "*:*:*" |
||||
const permissions = store && store.permissions |
const permissions = store && store.permissions |
||||
if (permission && permission.length > 0) { |
if (permission && permission.length > 0) { |
||||
return permissions.some(v => { |
return permissions.some(v => { |
||||
return all_permission === v || v === permission |
return all_permission === v || v === permission |
||||
}) |
}) |
||||
} else { |
} else { |
||||
return false |
return false |
||||
} |
} |
||||
} |
} |
||||
|
|
||||
function authRole(role) { |
function authRole(role) { |
||||
const super_admin = "admin" |
const super_admin = "admin" |
||||
const roles = store && store.roles |
const roles = store && store.roles |
||||
if (role && role.length > 0) { |
if (role && role.length > 0) { |
||||
return roles.some(v => { |
return roles.some(v => { |
||||
return super_admin === v || v === role |
return super_admin === v || v === role |
||||
}) |
}) |
||||
} else { |
} else { |
||||
return false |
return false |
||||
} |
} |
||||
} |
} |
||||
|
|
||||
export default { |
export default { |
||||
// 验证用户是否具备某权限
|
// 验证用户是否具备某权限
|
||||
hasPermi(permission) { |
hasPermi(permission) { |
||||
return authPermission(permission) |
return authPermission(permission) |
||||
}, |
}, |
||||
// 验证用户是否含有指定权限,只需包含其中一个
|
// 验证用户是否含有指定权限,只需包含其中一个
|
||||
hasPermiOr(permissions) { |
hasPermiOr(permissions) { |
||||
return permissions.some(item => { |
return permissions.some(item => { |
||||
return authPermission(item) |
return authPermission(item) |
||||
}) |
}) |
||||
}, |
}, |
||||
// 验证用户是否含有指定权限,必须全部拥有
|
// 验证用户是否含有指定权限,必须全部拥有
|
||||
hasPermiAnd(permissions) { |
hasPermiAnd(permissions) { |
||||
return permissions.every(item => { |
return permissions.every(item => { |
||||
return authPermission(item) |
return authPermission(item) |
||||
}) |
}) |
||||
}, |
}, |
||||
// 验证用户是否具备某角色
|
// 验证用户是否具备某角色
|
||||
hasRole(role) { |
hasRole(role) { |
||||
return authRole(role) |
return authRole(role) |
||||
}, |
}, |
||||
// 验证用户是否含有指定角色,只需包含其中一个
|
// 验证用户是否含有指定角色,只需包含其中一个
|
||||
hasRoleOr(roles) { |
hasRoleOr(roles) { |
||||
return roles.some(item => { |
return roles.some(item => { |
||||
return authRole(item) |
return authRole(item) |
||||
}) |
}) |
||||
}, |
}, |
||||
// 验证用户是否含有指定角色,必须全部拥有
|
// 验证用户是否含有指定角色,必须全部拥有
|
||||
hasRoleAnd(roles) { |
hasRoleAnd(roles) { |
||||
return roles.every(item => { |
return roles.every(item => { |
||||
return authRole(item) |
return authRole(item) |
||||
}) |
}) |
||||
} |
} |
||||
} |
} |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 22 KiB |
Loading…
Reference in new issue