控制语句代码风格调整

This commit is contained in:
Hooray
2022-10-02 03:29:49 +08:00
parent 340436d757
commit 4ec678f71f
40 changed files with 211 additions and 177 deletions
+4 -3
View File
@@ -5,11 +5,12 @@ export default function useAuth() {
function hasPermission(permission: string) {
const settingsStore = useSettingsStore()
const userStore = useUserStore()
if (settingsStore.app.enablePermission)
if (settingsStore.app.enablePermission) {
return userStore.permissions.includes(permission)
else
}
else {
return true
}
}
function auth(value: string | string[]) {
+4 -3
View File
@@ -10,11 +10,12 @@ export default function useMenu() {
function switchTo(index: number | string) {
menuStore.setActived(index)
if (settingsStore.menu.switchMainMenuAndPageJump) {
if (isExternalLink(menuStore.sidebarMenusFirstDeepestPath))
if (isExternalLink(menuStore.sidebarMenusFirstDeepestPath)) {
window.open(menuStore.sidebarMenusFirstDeepestPath, '_blank')
else
}
else {
router.push(menuStore.sidebarMenusFirstDeepestPath)
}
}
}
+4 -2
View File
@@ -4,14 +4,16 @@ export default function directive(app: App) {
// 注册 v-auth 和 v-auth-all 指令
app.directive('auth', {
mounted: (el, binding) => {
if (!useAuth().auth(binding.value))
if (!useAuth().auth(binding.value)) {
el.remove()
}
},
})
app.directive('auth-all', {
mounted: (el, binding) => {
if (!useAuth().authAll(binding.value))
if (!useAuth().authAll(binding.value)) {
el.remove()
}
},
})
}
+4 -4
View File
@@ -5,11 +5,11 @@ export function isExternalLink(path: string) {
}
export function resolveRoutePath(basePath: string, routePath: string) {
if (isExternalLink(routePath))
if (isExternalLink(routePath)) {
return routePath
if (isExternalLink(basePath))
}
if (isExternalLink(basePath)) {
return basePath
}
return basePath ? path.resolve(basePath, routePath) : routePath
}