Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
baas3-fe
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guxukai
baas3-fe
Commits
0ce9fd66
Commit
0ce9fd66
authored
Jan 04, 2022
by
guxukai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: 按钮权限
parent
b695e195
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
125 additions
and
48 deletions
+125
-48
index.vue
src/shared/layouts/components/console-menu/index.vue
+62
-45
default-layout.vue
src/shared/layouts/default-layout.vue
+4
-1
main.ts
src/shared/main.ts
+2
-0
AuthOperationUser.ts
src/shared/models/auth-service/AuthOperationUser.ts
+3
-2
Operation.ts
src/shared/models/auth-service/Operation.ts
+9
-0
auth.ts
src/shared/store/modules/auth.ts
+1
-0
auth.ts
src/shared/types/auth.ts
+2
-0
permission-utils.ts
src/shared/utils/permission-utils.ts
+35
-0
shims-vue.d.ts
src/shims-vue.d.ts
+7
-0
No files found.
src/shared/layouts/components/console-menu/index.vue
View file @
0ce9fd66
<
template
>
<
template
>
<!-- 超管控制台和只有个人控制台时没有下拉框 -->
<g-query-wrapper
:data=
"consoleData"
:loading=
"consoleLoading"
:error=
"consoleError"
:run=
"consoleRun"
>
<div
v-if=
"isSuperAdmin || onlyPersonal"
class=
"toggle-menu"
>
<g-query-wrapper
:data=
"operationData"
:loading=
"operationLoading"
:error=
"operationError"
:run=
"operationRun"
>
{{
consoleName
}}
<!-- 超管控制台和只有个人控制台时没有下拉框 -->
</div>
<div
v-if=
"isSuperAdmin || onlyPersonal"
class=
"toggle-menu"
>
<el-dropdown
v-else
class=
"toggle-menu"
placement=
"bottom-start"
trigger=
"click"
@
command=
"handleToggleConsole"
>
{{
consoleName
}}
<span
class=
"el-dropdown-link"
>
</div>
<span>
{{
consoleName
}}
</span>
<el-dropdown
v-else
class=
"toggle-menu"
placement=
"bottom-start"
trigger=
"click"
@
command=
"handleToggleConsole"
>
<el-icon
class=
"el-icon--right"
>
<span
class=
"el-dropdown-link"
>
<g-icon
name=
"ArrowDown"
/>
<span>
{{
consoleName
}}
</span>
</el-icon>
<el-icon
class=
"el-icon--right"
>
</span>
<g-icon
name=
"ArrowDown"
/>
<template
#
dropdown
>
</el-icon>
<el-dropdown-menu>
</span>
<div
v-for=
"item in consoleList"
v-show=
"item.child.length !== 0"
:key=
"item.id"
>
<template
#
dropdown
>
<!-- 控制台系统类型 -->
<el-dropdown-menu>
<p
class=
"auth-class"
>
<div
v-for=
"item in consoleList"
v-show=
"item.child.length !== 0"
:key=
"item.id"
>
<span>
{{
item
.
name
}}
</span>
<!-- 控制台系统类型 -->
</p>
<p
class=
"auth-class"
>
<!-- 控制台对象 -->
<span>
{{
item
.
name
}}
</span>
<el-dropdown-item
</p>
v-for=
"child in item.child"
<!-- 控制台对象 -->
:key=
"child.id"
<el-dropdown-item
class=
"text-overflow"
v-for=
"child in item.child"
:class=
"
{ 'is-active': consoleObjectId === child.id }"
:key=
"child.id"
:command="{ parent: item, child }"
class=
"text-overflow"
>
:class=
"
{ 'is-active': consoleObjectId === child.id }"
<span
class=
"auth-name"
>
{{
child
.
name
}}
</span>
:command="{ parent: item, child }"
</el-dropdown-item>
>
</div>
<span
class=
"auth-name"
>
{{
child
.
name
}}
</span>
</el-dropdown-menu>
</el-dropdown-item>
</
template
>
</div>
</el-dropdown>
</el-dropdown-menu>
</
template
>
</el-dropdown>
</g-query-wrapper>
</g-query-wrapper>
</template>
</template>
<
script
lang=
"ts"
>
<
script
lang=
"ts"
>
export
default
{
export
default
{
...
@@ -45,6 +49,7 @@ import { computed } from 'vue'
...
@@ -45,6 +49,7 @@ import { computed } from 'vue'
import
{
useUser
}
from
'@shared/store/modules/user'
import
{
useUser
}
from
'@shared/store/modules/user'
import
{
useAuth
}
from
'@shared/store/modules/auth'
import
{
useAuth
}
from
'@shared/store/modules/auth'
import
{
useRoute
,
useRouter
}
from
'vue-router'
import
{
useRoute
,
useRouter
}
from
'vue-router'
import
{
AuthOperationUser
}
from
'@shared/models/auth-service/AuthOperationUser'
const
$router
=
useRouter
()
const
$router
=
useRouter
()
const
$route
=
useRoute
()
const
$route
=
useRoute
()
const
userStore
=
useUser
()
const
userStore
=
useUser
()
...
@@ -64,19 +69,31 @@ const {
...
@@ -64,19 +69,31 @@ const {
loading
:
consoleLoading
,
loading
:
consoleLoading
,
error
:
consoleError
,
error
:
consoleError
,
run
:
consoleRun
,
run
:
consoleRun
,
}
=
useRequest
(
}
=
useRequest
(()
=>
()
=>
AuthConsole
.
get
({
AuthConsole
.
get
({
userId
:
userStore
.
userInfo
.
id
,
userId
:
userStore
.
userInfo
.
id
,
}).
then
(
res
=>
{
}).
then
(
res
=>
{
if
(
res
.
code
===
GATEWAY_CODE
.
success
)
{
if
(
res
.
code
===
GATEWAY_CODE
.
success
)
{
authStore
.
$patch
({
consoleList
:
res
.
data
})
authStore
.
$patch
({
consoleList
:
res
.
data
})
}
}
return
res
return
res
}),
}),
)
{
const
{
ready
:
computed
(()
=>
Boolean
(
userStore
.
userInfo
.
id
)),
data
:
operationData
,
},
loading
:
operationLoading
,
error
:
operationError
,
run
:
operationRun
,
}
=
useRequest
(()
=>
AuthOperationUser
.
get
({
userId
:
userStore
.
userInfo
.
id
,
objectId
:
authStore
.
consoleInfo
.
consoleObjectId
,
}).
then
(
res
=>
{
if
(
res
.
code
===
GATEWAY_CODE
.
success
)
{
authStore
.
$patch
({
operationList
:
res
.
data
})
}
return
res
}),
)
)
// 切换控制台
// 切换控制台
const
handleToggleConsole
=
({
parent
,
child
})
=>
{
const
handleToggleConsole
=
({
parent
,
child
})
=>
{
...
...
src/shared/layouts/default-layout.vue
View file @
0ce9fd66
...
@@ -83,7 +83,7 @@
...
@@ -83,7 +83,7 @@
<g-icon
name=
"Bell"
class=
"w-[1em] h-[1em] text-xl cursor-pointer"
/>
<g-icon
name=
"Bell"
class=
"w-[1em] h-[1em] text-xl cursor-pointer"
/>
</el-badge>
</el-badge>
<el-dropdown>
<el-dropdown>
<el-avatar
size=
"medium"
src=
"https://agile.huijiewei.com/files/202111/a102_xlenirqXfd.png
"
></el-avatar>
<el-avatar
size=
"medium"
:src=
"userInfo.image
"
></el-avatar>
<
template
#
dropdown
>
<
template
#
dropdown
>
<el-dropdown-menu>
<el-dropdown-menu>
<el-dropdown-item
@
click=
"handleLogout"
>
退出
</el-dropdown-item>
<el-dropdown-item
@
click=
"handleLogout"
>
退出
</el-dropdown-item>
...
@@ -123,6 +123,7 @@ import { useLayout } from '@shared/store/modules/layout'
...
@@ -123,6 +123,7 @@ import { useLayout } from '@shared/store/modules/layout'
import
ConsoleMenu
from
'./components/console-menu/index.vue'
import
ConsoleMenu
from
'./components/console-menu/index.vue'
import
{
LocaleType
}
from
'@shared/types/layout'
import
{
LocaleType
}
from
'@shared/types/layout'
import
{
useI18n
}
from
'vue-i18n'
import
{
useI18n
}
from
'vue-i18n'
import
{
useUser
}
from
'@shared/store/modules/user'
const
props
=
defineProps
({
const
props
=
defineProps
({
enableRouteFilter
:
{
enableRouteFilter
:
{
type
:
Boolean
,
type
:
Boolean
,
...
@@ -131,10 +132,12 @@ const props = defineProps({
...
@@ -131,10 +132,12 @@ const props = defineProps({
})
})
const
{
locale
}
=
useI18n
()
const
{
locale
}
=
useI18n
()
const
layoutStore
=
useLayout
()
const
layoutStore
=
useLayout
()
const
userStore
=
useUser
()
const
PROJECT_NAME
=
process
.
env
.
APP_NAME
const
PROJECT_NAME
=
process
.
env
.
APP_NAME
const
$route
=
useRoute
()
const
$route
=
useRoute
()
const
$router
=
useRouter
()
const
$router
=
useRouter
()
const
breadcrumbList
=
computed
(()
=>
layoutStore
.
breadcrumbList
)
const
breadcrumbList
=
computed
(()
=>
layoutStore
.
breadcrumbList
)
const
userInfo
=
computed
(()
=>
userStore
.
userInfo
)
const
localeList
:
{
key
:
LocaleType
;
value
:
string
}[]
=
[
const
localeList
:
{
key
:
LocaleType
;
value
:
string
}[]
=
[
{
{
key
:
'zh'
,
key
:
'zh'
,
...
...
src/shared/main.ts
View file @
0ce9fd66
...
@@ -9,6 +9,8 @@ import '@assets/icons'
...
@@ -9,6 +9,8 @@ import '@assets/icons'
import
'@assets/font/font.css'
import
'@assets/font/font.css'
import
'@assets/css/tailwind.css'
import
'@assets/css/tailwind.css'
import
{
i18n
}
from
'@shared/plugins/i18n'
import
{
i18n
}
from
'@shared/plugins/i18n'
import
{
hasBtnPermission
}
from
'@shared/utils/permission-utils'
createMockServer
()
createMockServer
()
export
const
app
=
createApp
(
App
)
export
const
app
=
createApp
(
App
)
app
.
config
.
globalProperties
.
hasPerm
=
hasBtnPermission
app
.
use
(
store
).
use
(
ElementPlus
).
use
(
i18n
)
app
.
use
(
store
).
use
(
ElementPlus
).
use
(
i18n
)
src/shared/models/auth-service/AuthOperationUser.ts
View file @
0ce9fd66
...
@@ -2,6 +2,7 @@ import { JsonProperty, Serializable } from 'typescript-json-serializer'
...
@@ -2,6 +2,7 @@ import { JsonProperty, Serializable } from 'typescript-json-serializer'
import
{
api
}
from
'@shared/http/axios'
import
{
api
}
from
'@shared/http/axios'
import
{
HttpResponse
}
from
'@shared/http/HttpResponse'
import
{
HttpResponse
}
from
'@shared/http/HttpResponse'
import
{
Model
}
from
'@shared/models/Model'
import
{
Model
}
from
'@shared/models/Model'
import
{
Operation
}
from
'@shared/models/auth-service/Operation'
@
Serializable
()
@
Serializable
()
export
class
AuthOperationUser
extends
Model
<
AuthOperationUser
>
{
export
class
AuthOperationUser
extends
Model
<
AuthOperationUser
>
{
...
@@ -10,8 +11,8 @@ export class AuthOperationUser extends Model<AuthOperationUser> {
...
@@ -10,8 +11,8 @@ export class AuthOperationUser extends Model<AuthOperationUser> {
* @param payload
* @param payload
*/
*/
static
async
get
(
payload
:
AuthOperationUserGetReq
)
{
static
async
get
(
payload
:
AuthOperationUserGetReq
)
{
return
await
api
.
get
<
HttpResponse
>
(
'/services/auth-service/operation/user'
,
{
return
await
api
.
get
<
HttpResponse
<
Operation
[]
>
>
(
'/services/auth-service/operation/user'
,
{
data
:
payload
,
params
:
payload
,
})
})
}
}
}
}
...
...
src/shared/models/auth-service/Operation.ts
0 → 100644
View file @
0ce9fd66
import
{
Model
}
from
'@shared/models/Model'
import
{
JsonProperty
,
Serializable
}
from
'typescript-json-serializer'
@
Serializable
()
export
class
Operation
extends
Model
<
Operation
>
{
@
JsonProperty
()
description
:
string
@
JsonProperty
()
id
:
string
@
JsonProperty
()
name
:
string
@
JsonProperty
()
type
:
number
}
src/shared/store/modules/auth.ts
View file @
0ce9fd66
...
@@ -11,6 +11,7 @@ export const useAuth = defineStore('auth', {
...
@@ -11,6 +11,7 @@ export const useAuth = defineStore('auth', {
consoleName
:
'我的控制台'
,
consoleName
:
'我的控制台'
,
consoleTypeId
:
'0'
,
consoleTypeId
:
'0'
,
},
},
operationList
:
[],
}),
}),
actions
:
{},
actions
:
{},
persist
:
{
persist
:
{
...
...
src/shared/types/auth.ts
View file @
0ce9fd66
import
{
AuthLogin
}
from
'@shared/models/gateway/AuthLogin'
import
{
AuthLogin
}
from
'@shared/models/gateway/AuthLogin'
import
{
OperationObject
}
from
'@shared/models/auth-service/OperationObject'
import
{
OperationObject
}
from
'@shared/models/auth-service/OperationObject'
import
{
Operation
}
from
'@shared/models/auth-service/Operation'
export
type
AuthType
=
{
export
type
AuthType
=
{
loginInfo
:
AuthLogin
loginInfo
:
AuthLogin
consoleList
:
OperationObject
[]
consoleList
:
OperationObject
[]
consoleInfo
:
ConsoleInfo
consoleInfo
:
ConsoleInfo
operationList
:
Operation
[]
}
}
export
type
ConsoleInfo
=
{
export
type
ConsoleInfo
=
{
consoleObjectId
:
string
consoleObjectId
:
string
...
...
src/shared/utils/permission-utils.ts
0 → 100644
View file @
0ce9fd66
import
{
useAuth
}
from
'@shared/store/modules/auth'
import
{
useUser
}
from
'@shared/store/modules/user'
export
function
hasBtnPermission
(
permission
:
string
)
{
const
authStore
=
useAuth
()
const
userStore
=
useUser
()
let
str
=
''
if
(
!
permission
)
{
return
false
}
else
{
const
consoleTypeId
=
authStore
.
consoleInfo
.
consoleTypeId
switch
(
consoleTypeId
)
{
case
'1'
:
str
=
'auth.baas.'
+
permission
break
case
'2'
:
// 联盟
str
=
'auth.federation.'
+
permission
break
case
'3'
:
// 企业
str
=
'auth.organization.'
+
permission
break
}
const
btnList
=
authStore
.
operationList
.
map
(
_
=>
_
.
id
)
const
userId
=
Number
(
userStore
.
userInfo
.
id
)
if
(
userId
===
10000000
)
{
return
true
}
else
{
return
btnList
.
indexOf
(
str
)
>
-
1
}
}
}
src/shims-vue.d.ts
View file @
0ce9fd66
/* eslint-disable */
/* eslint-disable */
declare
module
'*.vue'
{
declare
module
'*.vue'
{
import
type
{
DefineComponent
}
from
'vue'
import
type
{
DefineComponent
}
from
'vue'
const
component
:
DefineComponent
<
{},
{},
any
>
const
component
:
DefineComponent
<
{},
{},
any
>
...
@@ -9,3 +10,9 @@ declare module '*.svg' {
...
@@ -9,3 +10,9 @@ declare module '*.svg' {
const
component
:
DefineComponent
;
const
component
:
DefineComponent
;
export
default
component
;
export
default
component
;
}
}
declare
module
'@vue/runtime-core'
{
import
{
hasBtnPermission
}
from
"@shared/utils/permission-utils"
;
interface
ComponentCustomProperties
{
hasPerm
:
typeof
hasBtnPermission
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment