-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
234 additions
and
275 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import Authority from './src/index.vue'; | ||
export default Authority; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<script lang="ts"> | ||
import { defineComponent, PropType, computed, unref } from 'vue'; | ||
import { PermissionModeEnum } from '/@/enums/appEnum'; | ||
import { RoleEnum } from '/@/enums/roleEnum'; | ||
import { usePermission } from '/@/hooks/web/usePermission'; | ||
import { appStore } from '/@/store/modules/app'; | ||
import { getSlot } from '/@/utils/helper/tsxHelper'; | ||
export default defineComponent({ | ||
name: 'Authority', | ||
props: { | ||
// 指定角色可见 | ||
value: { | ||
type: [Number, Array, String] as PropType<RoleEnum | RoleEnum[]>, | ||
default: '', | ||
}, | ||
}, | ||
setup(props, { slots }) { | ||
const getModeRef = computed(() => { | ||
return appStore.getProjectConfig.permissionMode; | ||
}); | ||
/** | ||
* 渲染角色按钮 | ||
*/ | ||
function renderRoleAuth() { | ||
const { value } = props; | ||
if (!value) { | ||
return getSlot(slots); | ||
} | ||
const { hasPermission } = usePermission(); | ||
return hasPermission(value) ? getSlot(slots) : null; | ||
} | ||
/** | ||
* 渲染编码按钮 | ||
* 这里只判断是否包含,具体实现可以根据项目自行写逻辑 | ||
*/ | ||
function renderCodeAuth() { | ||
const { value } = props; | ||
if (!value) { | ||
return getSlot(slots); | ||
} | ||
const { hasPermission } = usePermission(); | ||
return hasPermission(value) ? getSlot(slots) : null; | ||
} | ||
return () => { | ||
const mode = unref(getModeRef); | ||
// 基于角色渲染 | ||
if (mode === PermissionModeEnum.ROLE) { | ||
return renderRoleAuth(); | ||
} | ||
// 基于后台编码渲染 | ||
if (mode === PermissionModeEnum.BACK) { | ||
return renderCodeAuth(); | ||
} | ||
return getSlot(slots); | ||
}; | ||
}, | ||
}); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export { default as BasicArrow } from './src/BasicArrow.vue'; | ||
export { default as BasicHelp } from './src/BasicHelp'; | ||
export { default as BasicHelp } from './src/BasicHelp.vue'; | ||
export { default as BasicTitle } from './src/BasicTitle.vue'; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.