Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
najiu-admin-template
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
najiu-frontend
najiu-admin-template
Commits
67962f1d
Commit
67962f1d
authored
Mar 18, 2021
by
Vben
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(v-auth): ensure the background mode is correct close #330
parent
8360b1d6
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
24 additions
and
47 deletions
+24
-47
themeConfig.ts
build/config/themeConfig.ts
+5
-5
menu.less
src/components/SimpleMenu/src/components/menu.less
+0
-19
index.less
src/design/var/index.less
+0
-3
permission.ts
src/directives/permission.ts
+0
-13
index.less
src/layouts/default/header/index.less
+5
-0
permission.ts
src/store/modules/permission.ts
+11
-0
Btn.vue
src/views/demo/permission/back/Btn.vue
+3
-7
No files found.
build/config/themeConfig.ts
View file @
67962f1d
...
@@ -38,22 +38,22 @@ export function generateColors({
...
@@ -38,22 +38,22 @@ export function generateColors({
tinycolor
,
tinycolor
,
}:
GenerateColorsParams
)
{
}:
GenerateColorsParams
)
{
const
arr
=
new
Array
(
19
).
fill
(
0
);
const
arr
=
new
Array
(
19
).
fill
(
0
);
const
lightens
=
arr
.
map
((
t
,
i
)
=>
{
const
lightens
=
arr
.
map
((
_
t
,
i
)
=>
{
return
mixLighten
(
color
,
i
/
5
);
return
mixLighten
(
color
,
i
/
5
);
});
});
const
darkens
=
arr
.
map
((
t
,
i
)
=>
{
const
darkens
=
arr
.
map
((
_
t
,
i
)
=>
{
return
mixDarken
(
color
,
i
/
5
);
return
mixDarken
(
color
,
i
/
5
);
});
});
const
alphaColors
=
arr
.
map
((
t
,
i
)
=>
{
const
alphaColors
=
arr
.
map
((
_
t
,
i
)
=>
{
return
tinycolor
(
color
)
return
tinycolor
(
color
)
.
setAlpha
(
i
/
20
)
.
setAlpha
(
i
/
20
)
.
toRgbString
();
.
toRgbString
();
});
});
const
tinycolorLightens
=
arr
const
tinycolorLightens
=
arr
.
map
((
t
,
i
)
=>
{
.
map
((
_
t
,
i
)
=>
{
return
tinycolor
(
color
)
return
tinycolor
(
color
)
.
lighten
(
i
*
5
)
.
lighten
(
i
*
5
)
.
toHexString
();
.
toHexString
();
...
@@ -61,7 +61,7 @@ export function generateColors({
...
@@ -61,7 +61,7 @@ export function generateColors({
.
filter
((
item
)
=>
item
!==
'
#ffffff
'
);
.
filter
((
item
)
=>
item
!==
'
#ffffff
'
);
const
tinycolorDarkens
=
arr
const
tinycolorDarkens
=
arr
.
map
((
t
,
i
)
=>
{
.
map
((
_
t
,
i
)
=>
{
return
tinycolor
(
color
)
return
tinycolor
(
color
)
.
darken
(
i
*
5
)
.
darken
(
i
*
5
)
.
toHexString
();
.
toHexString
();
...
...
src/components/SimpleMenu/src/components/menu.less
View file @
67962f1d
...
@@ -111,7 +111,6 @@
...
@@ -111,7 +111,6 @@
.@{menu-prefix-cls}-submenu-active {
.@{menu-prefix-cls}-submenu-active {
color: @primary-color !important;
color: @primary-color !important;
// background: fade(@primary-color, 8);
&-border {
&-border {
.light-border();
.light-border();
...
@@ -120,8 +119,6 @@
...
@@ -120,8 +119,6 @@
}
}
&-dark {
&-dark {
// background: @menu-dark;
.@{menu-prefix-cls}-submenu-active {
.@{menu-prefix-cls}-submenu-active {
color: #fff !important;
color: #fff !important;
}
}
...
@@ -137,7 +134,6 @@
...
@@ -137,7 +134,6 @@
cursor: pointer;
cursor: pointer;
outline: none;
outline: none;
align-items: center;
align-items: center;
// transition: all @transition-time @ease-in-out;
&:hover,
&:hover,
&:active {
&:active {
...
@@ -264,12 +260,7 @@
...
@@ -264,12 +260,7 @@
&:hover {
&:hover {
color: #fff;
color: #fff;
// background: @menu-dark;
}
}
// &-active:not(.@{menu-prefix-cls}-submenu) {
// color: @primary-color;
// }
}
}
&-dark&-vertical&-collapse {
&-dark&-vertical&-collapse {
...
@@ -296,11 +287,6 @@
...
@@ -296,11 +287,6 @@
}
}
&-dark&-vertical &-submenu &-item {
&-dark&-vertical &-submenu &-item {
// &:hover {
// color: #fff;
// background: transparent;
// }
&-active,
&-active,
&-active:hover {
&-active:hover {
color: #fff;
color: #fff;
...
@@ -313,11 +299,6 @@
...
@@ -313,11 +299,6 @@
}
}
&-dark&-vertical &-opened {
&-dark&-vertical &-opened {
// background: @menu-dark-active-bg;
// .@{menu-prefix-cls}-submenu-title {
// background: @menu-dark;
// }
.@{menu-prefix-cls}-submenu-has-parent-submenu {
.@{menu-prefix-cls}-submenu-has-parent-submenu {
.@{menu-prefix-cls}-submenu-title {
.@{menu-prefix-cls}-submenu-title {
background: transparent;
background: transparent;
...
...
src/design/var/index.less
View file @
67962f1d
...
@@ -32,9 +32,6 @@
...
@@ -32,9 +32,6 @@
@page-footer-z-index: 99;
@page-footer-z-index: 99;
// left-menu
@app-menu-item-height: 42px;
.bem(@n; @content) {
.bem(@n; @content) {
@{namespace}-@{n} {
@{namespace}-@{n} {
@content();
@content();
...
...
src/directives/permission.ts
View file @
67962f1d
...
@@ -5,9 +5,7 @@
...
@@ -5,9 +5,7 @@
*/
*/
import
type
{
App
,
Directive
,
DirectiveBinding
}
from
'
vue
'
;
import
type
{
App
,
Directive
,
DirectiveBinding
}
from
'
vue
'
;
import
projectSetting
from
'
/@/settings/projectSetting
'
;
import
{
usePermission
}
from
'
/@/hooks/web/usePermission
'
;
import
{
usePermission
}
from
'
/@/hooks/web/usePermission
'
;
import
{
PermissionModeEnum
}
from
'
/@/enums/appEnum
'
;
function
isAuth
(
el
:
Element
,
binding
:
any
)
{
function
isAuth
(
el
:
Element
,
binding
:
any
)
{
const
{
hasPermission
}
=
usePermission
();
const
{
hasPermission
}
=
usePermission
();
...
@@ -19,23 +17,12 @@ function isAuth(el: Element, binding: any) {
...
@@ -19,23 +17,12 @@ function isAuth(el: Element, binding: any) {
}
}
}
}
function
isBackMode
()
{
return
projectSetting
.
permissionMode
===
PermissionModeEnum
.
BACK
;
}
const
mounted
=
(
el
:
Element
,
binding
:
DirectiveBinding
<
any
>
)
=>
{
const
mounted
=
(
el
:
Element
,
binding
:
DirectiveBinding
<
any
>
)
=>
{
if
(
isBackMode
())
return
;
isAuth
(
el
,
binding
);
};
const
updated
=
(
el
:
Element
,
binding
:
DirectiveBinding
<
any
>
)
=>
{
if
(
!
isBackMode
())
return
;
isAuth
(
el
,
binding
);
isAuth
(
el
,
binding
);
};
};
const
authDirective
:
Directive
=
{
const
authDirective
:
Directive
=
{
mounted
,
mounted
,
updated
,
};
};
export
function
setupPermissionDirective
(
app
:
App
)
{
export
function
setupPermissionDirective
(
app
:
App
)
{
...
...
src/layouts/default/header/index.less
View file @
67962f1d
...
@@ -175,6 +175,11 @@
...
@@ -175,6 +175,11 @@
.@{header-prefix-cls}-action {
.@{header-prefix-cls}-action {
&__item {
&__item {
.app-iconify {
padding: 0 10px;
font-size: 16px !important;
}
&:hover {
&:hover {
background: @header-dark-bg-hover-color;
background: @header-dark-bg-hover-color;
}
}
...
...
src/store/modules/permission.ts
View file @
67962f1d
...
@@ -13,6 +13,7 @@ import { asyncRoutes } from '/@/router/routes';
...
@@ -13,6 +13,7 @@ import { asyncRoutes } from '/@/router/routes';
import
{
filter
}
from
'
/@/utils/helper/treeHelper
'
;
import
{
filter
}
from
'
/@/utils/helper/treeHelper
'
;
import
{
toRaw
}
from
'
vue
'
;
import
{
toRaw
}
from
'
vue
'
;
import
{
getMenuListById
}
from
'
/@/api/sys/menu
'
;
import
{
getMenuListById
}
from
'
/@/api/sys/menu
'
;
import
{
getPermCodeByUserId
}
from
'
/@/api/sys/user
'
;
import
{
transformObjToRoute
,
flatRoutes
}
from
'
/@/router/helper/routeHelper
'
;
import
{
transformObjToRoute
,
flatRoutes
}
from
'
/@/router/helper/routeHelper
'
;
import
{
transformRouteToMenu
}
from
'
/@/router/helper/menuHelper
'
;
import
{
transformRouteToMenu
}
from
'
/@/router/helper/menuHelper
'
;
...
@@ -82,6 +83,12 @@ class Permission extends VuexModule {
...
@@ -82,6 +83,12 @@ class Permission extends VuexModule {
this
.
lastBuildMenuTimeState
=
0
;
this
.
lastBuildMenuTimeState
=
0
;
}
}
@
Action
async
changePermissionCode
(
userId
:
string
)
{
const
codeList
=
await
getPermCodeByUserId
({
userId
});
this
.
commitPermCodeListState
(
codeList
);
}
@
Action
@
Action
async
buildRoutesAction
(
id
?:
number
|
string
):
Promise
<
AppRouteRecordRaw
[]
>
{
async
buildRoutesAction
(
id
?:
number
|
string
):
Promise
<
AppRouteRecordRaw
[]
>
{
const
{
t
}
=
useI18n
();
const
{
t
}
=
useI18n
();
...
@@ -106,6 +113,10 @@ class Permission extends VuexModule {
...
@@ -106,6 +113,10 @@ class Permission extends VuexModule {
});
});
// Here to get the background routing menu logic to modify by yourself
// Here to get the background routing menu logic to modify by yourself
const
paramId
=
id
||
userStore
.
getUserInfoState
.
userId
;
const
paramId
=
id
||
userStore
.
getUserInfoState
.
userId
;
// !Simulate to obtain permission codes from the background,
// this function may only need to be executed once, and the actual project can be put at the right time by itself
this
.
changePermissionCode
(
'
1
'
);
if
(
!
paramId
)
{
if
(
!
paramId
)
{
throw
new
Error
(
'
paramId is undefined!
'
);
throw
new
Error
(
'
paramId is undefined!
'
);
}
}
...
...
src/views/demo/permission/back/Btn.vue
View file @
67962f1d
...
@@ -59,7 +59,6 @@
...
@@ -59,7 +59,6 @@
import
CurrentPermissionMode
from
'
../CurrentPermissionMode.vue
'
;
import
CurrentPermissionMode
from
'
../CurrentPermissionMode.vue
'
;
import
{
usePermission
}
from
'
/@/hooks/web/usePermission
'
;
import
{
usePermission
}
from
'
/@/hooks/web/usePermission
'
;
import
{
Authority
}
from
'
/@/components/Authority
'
;
import
{
Authority
}
from
'
/@/components/Authority
'
;
import
{
getPermCodeByUserId
}
from
'
/@/api/sys/user
'
;
import
{
permissionStore
}
from
'
/@/store/modules/permission
'
;
import
{
permissionStore
}
from
'
/@/store/modules/permission
'
;
import
{
PermissionModeEnum
}
from
'
/@/enums/appEnum
'
;
import
{
PermissionModeEnum
}
from
'
/@/enums/appEnum
'
;
import
{
PageWrapper
}
from
'
/@/components/Page
'
;
import
{
PageWrapper
}
from
'
/@/components/Page
'
;
...
@@ -69,13 +68,10 @@
...
@@ -69,13 +68,10 @@
setup
()
{
setup
()
{
const
{
hasPermission
}
=
usePermission
();
const
{
hasPermission
}
=
usePermission
();
// !模拟从后台获取权限编码, 该函数可能只需要执行一次,实际项目可以自行放到合适的时机
function
changePermissionCode
(
userId
:
string
)
{
async
function
changePermissionCode
(
userId
:
string
)
{
permissionStore
.
changePermissionCode
(
userId
);
const
codeList
=
await
getPermCodeByUserId
({
userId
});
permissionStore
.
commitPermCodeListState
(
codeList
);
}
}
// 默认初始化为1
changePermissionCode
(
'
1
'
);
return
{
return
{
hasPermission
,
hasPermission
,
permissionStore
,
permissionStore
,
...
...
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