fix(v-auth): ensure the background mode is correct close #330
| | |
| | | tinycolor, |
| | | }: GenerateColorsParams) { |
| | | const arr = new Array(19).fill(0); |
| | | const lightens = arr.map((t, i) => { |
| | | const lightens = arr.map((_t, i) => { |
| | | return mixLighten(color, i / 5); |
| | | }); |
| | | |
| | | const darkens = arr.map((t, i) => { |
| | | const darkens = arr.map((_t, i) => { |
| | | return mixDarken(color, i / 5); |
| | | }); |
| | | |
| | | const alphaColors = arr.map((t, i) => { |
| | | const alphaColors = arr.map((_t, i) => { |
| | | return tinycolor(color) |
| | | .setAlpha(i / 20) |
| | | .toRgbString(); |
| | | }); |
| | | |
| | | const tinycolorLightens = arr |
| | | .map((t, i) => { |
| | | .map((_t, i) => { |
| | | return tinycolor(color) |
| | | .lighten(i * 5) |
| | | .toHexString(); |
| | |
| | | .filter((item) => item !== '#ffffff'); |
| | | |
| | | const tinycolorDarkens = arr |
| | | .map((t, i) => { |
| | | .map((_t, i) => { |
| | | return tinycolor(color) |
| | | .darken(i * 5) |
| | | .toHexString(); |
| | |
| | | |
| | | .@{menu-prefix-cls}-submenu-active { |
| | | color: @primary-color !important; |
| | | // background: fade(@primary-color, 8); |
| | | |
| | | &-border { |
| | | .light-border(); |
| | |
| | | } |
| | | |
| | | &-dark { |
| | | // background: @menu-dark; |
| | | |
| | | .@{menu-prefix-cls}-submenu-active { |
| | | color: #fff !important; |
| | | } |
| | |
| | | cursor: pointer; |
| | | outline: none; |
| | | align-items: center; |
| | | // transition: all @transition-time @ease-in-out; |
| | | |
| | | &:hover, |
| | | &:active { |
| | |
| | | |
| | | &:hover { |
| | | color: #fff; |
| | | // background: @menu-dark; |
| | | } |
| | | |
| | | // &-active:not(.@{menu-prefix-cls}-submenu) { |
| | | // color: @primary-color; |
| | | // } |
| | | } |
| | | |
| | | &-dark&-vertical&-collapse { |
| | |
| | | } |
| | | |
| | | &-dark&-vertical &-submenu &-item { |
| | | // &:hover { |
| | | // color: #fff; |
| | | // background: transparent; |
| | | // } |
| | | |
| | | &-active, |
| | | &-active:hover { |
| | | color: #fff; |
| | |
| | | } |
| | | |
| | | &-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-title { |
| | | background: transparent; |
| | |
| | | |
| | | @page-footer-z-index: 99; |
| | | |
| | | // left-menu |
| | | @app-menu-item-height: 42px; |
| | | |
| | | .bem(@n; @content) { |
| | | @{namespace}-@{n} { |
| | | @content(); |
| | |
| | | */ |
| | | import type { App, Directive, DirectiveBinding } from 'vue'; |
| | | |
| | | import projectSetting from '/@/settings/projectSetting'; |
| | | import { usePermission } from '/@/hooks/web/usePermission'; |
| | | import { PermissionModeEnum } from '/@/enums/appEnum'; |
| | | |
| | | function isAuth(el: Element, binding: any) { |
| | | const { hasPermission } = usePermission(); |
| | |
| | | } |
| | | } |
| | | |
| | | function isBackMode() { |
| | | return projectSetting.permissionMode === PermissionModeEnum.BACK; |
| | | } |
| | | |
| | | 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); |
| | | }; |
| | | |
| | | const authDirective: Directive = { |
| | | mounted, |
| | | updated, |
| | | }; |
| | | |
| | | export function setupPermissionDirective(app: App) { |
| | |
| | | |
| | | .@{header-prefix-cls}-action { |
| | | &__item { |
| | | .app-iconify { |
| | | padding: 0 10px; |
| | | font-size: 16px !important; |
| | | } |
| | | |
| | | &:hover { |
| | | background: @header-dark-bg-hover-color; |
| | | } |
| | |
| | | import { filter } from '/@/utils/helper/treeHelper'; |
| | | import { toRaw } from 'vue'; |
| | | import { getMenuListById } from '/@/api/sys/menu'; |
| | | import { getPermCodeByUserId } from '/@/api/sys/user'; |
| | | |
| | | import { transformObjToRoute, flatRoutes } from '/@/router/helper/routeHelper'; |
| | | import { transformRouteToMenu } from '/@/router/helper/menuHelper'; |
| | |
| | | } |
| | | |
| | | @Action |
| | | async changePermissionCode(userId: string) { |
| | | const codeList = await getPermCodeByUserId({ userId }); |
| | | this.commitPermCodeListState(codeList); |
| | | } |
| | | |
| | | @Action |
| | | async buildRoutesAction(id?: number | string): Promise<AppRouteRecordRaw[]> { |
| | | const { t } = useI18n(); |
| | | let routes: AppRouteRecordRaw[] = []; |
| | |
| | | }); |
| | | // Here to get the background routing menu logic to modify by yourself |
| | | 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) { |
| | | throw new Error('paramId is undefined!'); |
| | | } |
| | |
| | | import CurrentPermissionMode from '../CurrentPermissionMode.vue'; |
| | | import { usePermission } from '/@/hooks/web/usePermission'; |
| | | import { Authority } from '/@/components/Authority'; |
| | | import { getPermCodeByUserId } from '/@/api/sys/user'; |
| | | import { permissionStore } from '/@/store/modules/permission'; |
| | | import { PermissionModeEnum } from '/@/enums/appEnum'; |
| | | import { PageWrapper } from '/@/components/Page'; |
| | |
| | | setup() { |
| | | const { hasPermission } = usePermission(); |
| | | |
| | | // !模拟从后台获取权限编码, 该函数可能只需要执行一次,实际项目可以自行放到合适的时机 |
| | | async function changePermissionCode(userId: string) { |
| | | const codeList = await getPermCodeByUserId({ userId }); |
| | | permissionStore.commitPermCodeListState(codeList); |
| | | function changePermissionCode(userId: string) { |
| | | permissionStore.changePermissionCode(userId); |
| | | } |
| | | // 默认初始化为1 |
| | | changePermissionCode('1'); |
| | | |
| | | return { |
| | | hasPermission, |
| | | permissionStore, |