mirror of
https://gitee.com/hhyykk/ipms-sjy-ui.git
synced 2025-06-18 22:32:00 +08:00
Merge branch 'gitee-master' into feature-project
# Conflicts: # README.md
This commit is contained in:
commit
fa8f650aa1
@ -143,6 +143,7 @@
|
|||||||
"url": "https://gitee.com/yudaocode/yudao-ui-admin-vue3/issues"
|
"url": "https://gitee.com/yudaocode/yudao-ui-admin-vue3/issues"
|
||||||
},
|
},
|
||||||
"homepage": "https://gitee.com/yudaocode/yudao-ui-admin-vue3",
|
"homepage": "https://gitee.com/yudaocode/yudao-ui-admin-vue3",
|
||||||
|
"web-types": "./web-types.json",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">= 16.0.0",
|
"node": ">= 16.0.0",
|
||||||
"pnpm": ">=8.6.0"
|
"pnpm": ">=8.6.0"
|
||||||
|
@ -8,7 +8,8 @@ export function hasPermi(app: App<Element>) {
|
|||||||
const { wsCache } = useCache()
|
const { wsCache } = useCache()
|
||||||
const { value } = binding
|
const { value } = binding
|
||||||
const all_permission = '*:*:*'
|
const all_permission = '*:*:*'
|
||||||
const permissions = wsCache.get(CACHE_KEY.USER).permissions
|
const userInfo = wsCache.get(CACHE_KEY.USER)
|
||||||
|
const permissions = userInfo?.permissions || []
|
||||||
|
|
||||||
if (value && value instanceof Array && value.length > 0) {
|
if (value && value instanceof Array && value.length > 0) {
|
||||||
const permissionFlag = value
|
const permissionFlag = value
|
||||||
|
@ -8,7 +8,8 @@ export function hasRole(app: App<Element>) {
|
|||||||
const { wsCache } = useCache()
|
const { wsCache } = useCache()
|
||||||
const { value } = binding
|
const { value } = binding
|
||||||
const super_admin = 'super_admin'
|
const super_admin = 'super_admin'
|
||||||
const roles = wsCache.get(CACHE_KEY.USER).roles
|
const userInfo = wsCache.get(CACHE_KEY.USER)
|
||||||
|
const roles = userInfo?.roles || []
|
||||||
|
|
||||||
if (value && value instanceof Array && value.length > 0) {
|
if (value && value instanceof Array && value.length > 0) {
|
||||||
const roleFlag = value
|
const roleFlag = value
|
||||||
|
@ -35,8 +35,9 @@ export const usePermissionStore = defineStore('permission', {
|
|||||||
return new Promise<void>(async (resolve) => {
|
return new Promise<void>(async (resolve) => {
|
||||||
// 获得菜单列表,它在登录的时候,setUserInfoAction 方法中已经进行获取
|
// 获得菜单列表,它在登录的时候,setUserInfoAction 方法中已经进行获取
|
||||||
let res: AppCustomRouteRecordRaw[] = []
|
let res: AppCustomRouteRecordRaw[] = []
|
||||||
if (wsCache.get(CACHE_KEY.ROLE_ROUTERS)) {
|
const roleRouters = wsCache.get(CACHE_KEY.ROLE_ROUTERS)
|
||||||
res = wsCache.get(CACHE_KEY.ROLE_ROUTERS) as AppCustomRouteRecordRaw[]
|
if (roleRouters) {
|
||||||
|
res = roleRouters as AppCustomRouteRecordRaw[]
|
||||||
}
|
}
|
||||||
const routerMap: AppRouteRecordRaw[] = generateRoute(res)
|
const routerMap: AppRouteRecordRaw[] = generateRoute(res)
|
||||||
// 动态路由,404一定要放到最后面
|
// 动态路由,404一定要放到最后面
|
||||||
|
@ -10,7 +10,8 @@ const RefreshTokenKey = 'REFRESH_TOKEN'
|
|||||||
// 获取token
|
// 获取token
|
||||||
export const getAccessToken = () => {
|
export const getAccessToken = () => {
|
||||||
// 此处与TokenKey相同,此写法解决初始化时Cookies中不存在TokenKey报错
|
// 此处与TokenKey相同,此写法解决初始化时Cookies中不存在TokenKey报错
|
||||||
return wsCache.get(AccessTokenKey) ? wsCache.get(AccessTokenKey) : wsCache.get('ACCESS_TOKEN')
|
const accessToken = wsCache.get(AccessTokenKey)
|
||||||
|
return accessToken ? accessToken : wsCache.get('ACCESS_TOKEN')
|
||||||
}
|
}
|
||||||
|
|
||||||
// 刷新token
|
// 刷新token
|
||||||
|
@ -12,8 +12,9 @@ export function checkPermi(value: string[]) {
|
|||||||
const { wsCache } = useCache()
|
const { wsCache } = useCache()
|
||||||
const permissionDatas = value
|
const permissionDatas = value
|
||||||
const all_permission = '*:*:*'
|
const all_permission = '*:*:*'
|
||||||
const permissions = wsCache.get(CACHE_KEY.USER).permissions
|
const userInfo = wsCache.get(CACHE_KEY.USER)
|
||||||
const hasPermission = permissions.some((permission) => {
|
const permissions = userInfo?.permissions || []
|
||||||
|
const hasPermission = permissions.some((permission: string) => {
|
||||||
return all_permission === permission || permissionDatas.includes(permission)
|
return all_permission === permission || permissionDatas.includes(permission)
|
||||||
})
|
})
|
||||||
return !!hasPermission
|
return !!hasPermission
|
||||||
@ -33,8 +34,9 @@ export function checkRole(value: string[]) {
|
|||||||
const { wsCache } = useCache()
|
const { wsCache } = useCache()
|
||||||
const permissionRoles = value
|
const permissionRoles = value
|
||||||
const super_admin = 'super_admin'
|
const super_admin = 'super_admin'
|
||||||
const roles = wsCache.get(CACHE_KEY.USER).roles
|
const userInfo = wsCache.get(CACHE_KEY.USER)
|
||||||
const hasRole = roles.some((role) => {
|
const roles = userInfo?.roles || []
|
||||||
|
const hasRole = roles.some((role: string) => {
|
||||||
return super_admin === role || permissionRoles.includes(role)
|
return super_admin === role || permissionRoles.includes(role)
|
||||||
})
|
})
|
||||||
return !!hasRole
|
return !!hasRole
|
||||||
|
19
web-types.json
Normal file
19
web-types.json
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://json.schemastore.org/web-types",
|
||||||
|
"framework": "vue",
|
||||||
|
"name": "name written in package.json",
|
||||||
|
"version": "version written in package.json",
|
||||||
|
"contributions": {
|
||||||
|
"html": {
|
||||||
|
"types-syntax": "typescript",
|
||||||
|
"attributes": [
|
||||||
|
{
|
||||||
|
"name": "v-hasPermi"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "v-hasRole"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user