Commit 67962f1deea31d695d20ae0ea7fc39b39c1eea47

Authored by Vben
1 parent 8360b1d6

fix(v-auth): ensure the background mode is correct close #330

build/config/themeConfig.ts
... ... @@ -38,22 +38,22 @@ export function generateColors({
38 38 tinycolor,
39 39 }: GenerateColorsParams) {
40 40 const arr = new Array(19).fill(0);
41   - const lightens = arr.map((t, i) => {
  41 + const lightens = arr.map((_t, i) => {
42 42 return mixLighten(color, i / 5);
43 43 });
44 44  
45   - const darkens = arr.map((t, i) => {
  45 + const darkens = arr.map((_t, i) => {
46 46 return mixDarken(color, i / 5);
47 47 });
48 48  
49   - const alphaColors = arr.map((t, i) => {
  49 + const alphaColors = arr.map((_t, i) => {
50 50 return tinycolor(color)
51 51 .setAlpha(i / 20)
52 52 .toRgbString();
53 53 });
54 54  
55 55 const tinycolorLightens = arr
56   - .map((t, i) => {
  56 + .map((_t, i) => {
57 57 return tinycolor(color)
58 58 .lighten(i * 5)
59 59 .toHexString();
... ... @@ -61,7 +61,7 @@ export function generateColors({
61 61 .filter((item) => item !== '#ffffff');
62 62  
63 63 const tinycolorDarkens = arr
64   - .map((t, i) => {
  64 + .map((_t, i) => {
65 65 return tinycolor(color)
66 66 .darken(i * 5)
67 67 .toHexString();
... ...
src/components/SimpleMenu/src/components/menu.less
... ... @@ -111,7 +111,6 @@
111 111  
112 112 .@{menu-prefix-cls}-submenu-active {
113 113 color: @primary-color !important;
114   - // background: fade(@primary-color, 8);
115 114  
116 115 &-border {
117 116 .light-border();
... ... @@ -120,8 +119,6 @@
120 119 }
121 120  
122 121 &-dark {
123   - // background: @menu-dark;
124   -
125 122 .@{menu-prefix-cls}-submenu-active {
126 123 color: #fff !important;
127 124 }
... ... @@ -137,7 +134,6 @@
137 134 cursor: pointer;
138 135 outline: none;
139 136 align-items: center;
140   - // transition: all @transition-time @ease-in-out;
141 137  
142 138 &:hover,
143 139 &:active {
... ... @@ -264,12 +260,7 @@
264 260  
265 261 &:hover {
266 262 color: #fff;
267   - // background: @menu-dark;
268 263 }
269   -
270   - // &-active:not(.@{menu-prefix-cls}-submenu) {
271   - // color: @primary-color;
272   - // }
273 264 }
274 265  
275 266 &-dark&-vertical&-collapse {
... ... @@ -296,11 +287,6 @@
296 287 }
297 288  
298 289 &-dark&-vertical &-submenu &-item {
299   - // &:hover {
300   - // color: #fff;
301   - // background: transparent;
302   - // }
303   -
304 290 &-active,
305 291 &-active:hover {
306 292 color: #fff;
... ... @@ -313,11 +299,6 @@
313 299 }
314 300  
315 301 &-dark&-vertical &-opened {
316   - // background: @menu-dark-active-bg;
317   - // .@{menu-prefix-cls}-submenu-title {
318   - // background: @menu-dark;
319   - // }
320   -
321 302 .@{menu-prefix-cls}-submenu-has-parent-submenu {
322 303 .@{menu-prefix-cls}-submenu-title {
323 304 background: transparent;
... ...
src/design/var/index.less
... ... @@ -32,9 +32,6 @@
32 32  
33 33 @page-footer-z-index: 99;
34 34  
35   -// left-menu
36   -@app-menu-item-height: 42px;
37   -
38 35 .bem(@n; @content) {
39 36 @{namespace}-@{n} {
40 37 @content();
... ...
src/directives/permission.ts
... ... @@ -5,9 +5,7 @@
5 5 */
6 6 import type { App, Directive, DirectiveBinding } from 'vue';
7 7  
8   -import projectSetting from '/@/settings/projectSetting';
9 8 import { usePermission } from '/@/hooks/web/usePermission';
10   -import { PermissionModeEnum } from '/@/enums/appEnum';
11 9  
12 10 function isAuth(el: Element, binding: any) {
13 11 const { hasPermission } = usePermission();
... ... @@ -19,23 +17,12 @@ function isAuth(el: Element, binding: any) {
19 17 }
20 18 }
21 19  
22   -function isBackMode() {
23   - return projectSetting.permissionMode === PermissionModeEnum.BACK;
24   -}
25   -
26 20 const mounted = (el: Element, binding: DirectiveBinding<any>) => {
27   - if (isBackMode()) return;
28   - isAuth(el, binding);
29   -};
30   -
31   -const updated = (el: Element, binding: DirectiveBinding<any>) => {
32   - if (!isBackMode()) return;
33 21 isAuth(el, binding);
34 22 };
35 23  
36 24 const authDirective: Directive = {
37 25 mounted,
38   - updated,
39 26 };
40 27  
41 28 export function setupPermissionDirective(app: App) {
... ...
src/layouts/default/header/index.less
... ... @@ -175,6 +175,11 @@
175 175  
176 176 .@{header-prefix-cls}-action {
177 177 &__item {
  178 + .app-iconify {
  179 + padding: 0 10px;
  180 + font-size: 16px !important;
  181 + }
  182 +
178 183 &:hover {
179 184 background: @header-dark-bg-hover-color;
180 185 }
... ...
src/store/modules/permission.ts
... ... @@ -13,6 +13,7 @@ import { asyncRoutes } from &#39;/@/router/routes&#39;;
13 13 import { filter } from '/@/utils/helper/treeHelper';
14 14 import { toRaw } from 'vue';
15 15 import { getMenuListById } from '/@/api/sys/menu';
  16 +import { getPermCodeByUserId } from '/@/api/sys/user';
16 17  
17 18 import { transformObjToRoute, flatRoutes } from '/@/router/helper/routeHelper';
18 19 import { transformRouteToMenu } from '/@/router/helper/menuHelper';
... ... @@ -83,6 +84,12 @@ class Permission extends VuexModule {
83 84 }
84 85  
85 86 @Action
  87 + async changePermissionCode(userId: string) {
  88 + const codeList = await getPermCodeByUserId({ userId });
  89 + this.commitPermCodeListState(codeList);
  90 + }
  91 +
  92 + @Action
86 93 async buildRoutesAction(id?: number | string): Promise<AppRouteRecordRaw[]> {
87 94 const { t } = useI18n();
88 95 let routes: AppRouteRecordRaw[] = [];
... ... @@ -106,6 +113,10 @@ class Permission extends VuexModule {
106 113 });
107 114 // Here to get the background routing menu logic to modify by yourself
108 115 const paramId = id || userStore.getUserInfoState.userId;
  116 +
  117 + // !Simulate to obtain permission codes from the background,
  118 + // this function may only need to be executed once, and the actual project can be put at the right time by itself
  119 + this.changePermissionCode('1');
109 120 if (!paramId) {
110 121 throw new Error('paramId is undefined!');
111 122 }
... ...
src/views/demo/permission/back/Btn.vue
... ... @@ -59,7 +59,6 @@
59 59 import CurrentPermissionMode from '../CurrentPermissionMode.vue';
60 60 import { usePermission } from '/@/hooks/web/usePermission';
61 61 import { Authority } from '/@/components/Authority';
62   - import { getPermCodeByUserId } from '/@/api/sys/user';
63 62 import { permissionStore } from '/@/store/modules/permission';
64 63 import { PermissionModeEnum } from '/@/enums/appEnum';
65 64 import { PageWrapper } from '/@/components/Page';
... ... @@ -69,13 +68,10 @@
69 68 setup() {
70 69 const { hasPermission } = usePermission();
71 70  
72   - // !模拟从后台获取权限编码, 该函数可能只需要执行一次,实际项目可以自行放到合适的时机
73   - async function changePermissionCode(userId: string) {
74   - const codeList = await getPermCodeByUserId({ userId });
75   - permissionStore.commitPermCodeListState(codeList);
  71 + function changePermissionCode(userId: string) {
  72 + permissionStore.changePermissionCode(userId);
76 73 }
77   - // 默认初始化为1
78   - changePermissionCode('1');
  74 +
79 75 return {
80 76 hasPermission,
81 77 permissionStore,
... ...