92 changed files with 318 additions and 546 deletions
@ -1,4 +1,4 @@ |
|||
import type { ExRouteRecordRaw, MenuRecordRaw } from '@vben/types'; |
|||
import type { ExRouteRecordRaw, MenuRecordRaw } from '@vben-core/typings'; |
|||
import type { RouteRecordRaw, Router } from 'vue-router'; |
|||
|
|||
import { mapTree } from '@vben-core/toolkit'; |
|||
@ -1,6 +1,7 @@ |
|||
import type { RouteRecordRaw } from 'vue-router'; |
|||
|
|||
import { filterTree, mapTree } from '@vben-core/toolkit'; |
|||
|
|||
/** |
|||
* 动态生成路由 - 前端方式 |
|||
*/ |
|||
@ -1,2 +1,5 @@ |
|||
export * from './find-menu-by-path'; |
|||
export * from './generate-menus'; |
|||
export * from './generate-routes-backend'; |
|||
export * from './generate-routes-frontend'; |
|||
export * from './merge-route-modules'; |
|||
|
|||
@ -1,7 +0,0 @@ |
|||
import { defineBuildConfig } from 'unbuild'; |
|||
|
|||
export default defineBuildConfig({ |
|||
clean: true, |
|||
declaration: true, |
|||
entries: ['src/index'], |
|||
}); |
|||
@ -1,40 +0,0 @@ |
|||
{ |
|||
"name": "@vben-core/cache", |
|||
"version": "5.0.0", |
|||
"homepage": "https://github.com/vbenjs/vue-vben-admin", |
|||
"bugs": "https://github.com/vbenjs/vue-vben-admin/issues", |
|||
"repository": { |
|||
"type": "git", |
|||
"url": "git+https://github.com/vbenjs/vue-vben-admin.git", |
|||
"directory": "packages/@vben-core/shared/cache" |
|||
}, |
|||
"license": "MIT", |
|||
"type": "module", |
|||
"scripts": { |
|||
"build": "pnpm unbuild", |
|||
"stub": "pnpm unbuild --stub" |
|||
}, |
|||
"files": [ |
|||
"dist" |
|||
], |
|||
"sideEffects": false, |
|||
"main": "./dist/index.mjs", |
|||
"module": "./dist/index.mjs", |
|||
"exports": { |
|||
".": { |
|||
"types": "./src/index.ts", |
|||
"development": "./src/index.ts", |
|||
"default": "./dist/index.mjs" |
|||
} |
|||
}, |
|||
"publishConfig": { |
|||
"exports": { |
|||
".": { |
|||
"types": "./dist/index.d.ts", |
|||
"default": "./dist/index.mjs" |
|||
} |
|||
} |
|||
}, |
|||
"dependencies": {}, |
|||
"devDependencies": {} |
|||
} |
|||
@ -1,6 +0,0 @@ |
|||
{ |
|||
"$schema": "https://json.schemastore.org/tsconfig", |
|||
"extends": "@vben/tsconfig/library.json", |
|||
"include": ["src"], |
|||
"exclude": ["node_modules"] |
|||
} |
|||
@ -1,7 +0,0 @@ |
|||
import { defineBuildConfig } from 'unbuild'; |
|||
|
|||
export default defineBuildConfig({ |
|||
clean: true, |
|||
declaration: true, |
|||
entries: ['src/index'], |
|||
}); |
|||
@ -1,42 +0,0 @@ |
|||
{ |
|||
"name": "@vben-core/colorful", |
|||
"version": "5.0.0", |
|||
"homepage": "https://github.com/vbenjs/vue-vben-admin", |
|||
"bugs": "https://github.com/vbenjs/vue-vben-admin/issues", |
|||
"repository": { |
|||
"type": "git", |
|||
"url": "git+https://github.com/vbenjs/vue-vben-admin.git", |
|||
"directory": "packages/@vben-core/shared/colorful" |
|||
}, |
|||
"license": "MIT", |
|||
"type": "module", |
|||
"scripts": { |
|||
"build": "pnpm unbuild", |
|||
"stub": "pnpm unbuild --stub" |
|||
}, |
|||
"files": [ |
|||
"dist" |
|||
], |
|||
"sideEffects": false, |
|||
"main": "./dist/index.mjs", |
|||
"module": "./dist/index.mjs", |
|||
"exports": { |
|||
".": { |
|||
"types": "./src/index.ts", |
|||
"development": "./src/index.ts", |
|||
"default": "./dist/index.mjs" |
|||
} |
|||
}, |
|||
"publishConfig": { |
|||
"exports": { |
|||
".": { |
|||
"types": "./dist/index.d.ts", |
|||
"default": "./dist/index.mjs" |
|||
} |
|||
} |
|||
}, |
|||
"dependencies": { |
|||
"@ant-design/colors": "^7.1.0", |
|||
"@ctrl/tinycolor": "^4.1.0" |
|||
} |
|||
} |
|||
@ -1,6 +0,0 @@ |
|||
{ |
|||
"$schema": "https://json.schemastore.org/tsconfig", |
|||
"extends": "@vben/tsconfig/library.json", |
|||
"include": ["src"], |
|||
"exclude": ["node_modules"] |
|||
} |
|||
@ -1,3 +0,0 @@ |
|||
# @vben-core/design-tokens |
|||
|
|||
用于维护全局所有的 css 变量,它由 vite 插件在全局注入,不需要手动引入 |
|||
@ -1,39 +0,0 @@ |
|||
{ |
|||
"name": "@vben-core/design-tokens", |
|||
"version": "5.0.0", |
|||
"homepage": "https://github.com/vbenjs/vue-vben-admin", |
|||
"bugs": "https://github.com/vbenjs/vue-vben-admin/issues", |
|||
"repository": { |
|||
"type": "git", |
|||
"url": "git+https://github.com/vbenjs/vue-vben-admin.git", |
|||
"directory": "packages/@vben-core/shared/design-tokens" |
|||
}, |
|||
"license": "MIT", |
|||
"type": "module", |
|||
"scripts": { |
|||
"build": "pnpm vite build", |
|||
"dts": "vue-tsc --declaration --emitDeclarationOnly --declarationDir dist", |
|||
"prepublishOnly": "npm run build" |
|||
}, |
|||
"files": [ |
|||
"dist" |
|||
], |
|||
"sideEffects": [ |
|||
"**/*.css" |
|||
], |
|||
"main": "./dist/index.css", |
|||
"exports": { |
|||
".": { |
|||
"types": "./src/index.ts", |
|||
"development": "./src/index.ts", |
|||
"default": "./dist/index.css" |
|||
} |
|||
}, |
|||
"publishConfig": { |
|||
"exports": { |
|||
".": { |
|||
"default": "./dist/index.mjs" |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -1,6 +0,0 @@ |
|||
{ |
|||
"$schema": "https://json.schemastore.org/tsconfig", |
|||
"extends": "@vben/tsconfig/library.json", |
|||
"include": ["src"], |
|||
"exclude": ["node_modules"] |
|||
} |
|||
@ -1,3 +0,0 @@ |
|||
import { defineConfig } from '@vben/vite-config'; |
|||
|
|||
export default defineConfig(); |
|||
@ -1,5 +1,6 @@ |
|||
import './scss/index.scss'; |
|||
import './css/tailwind.css'; |
|||
import './css/nprogress.css'; |
|||
import './design-tokens'; |
|||
|
|||
export {}; |
|||
|
|||
@ -1,6 +1,6 @@ |
|||
import { describe, expect, it } from 'vitest'; |
|||
|
|||
import { convertToHsl, convertToHslCssVar, isValidColor } from './utils'; |
|||
import { convertToHsl, convertToHslCssVar, isValidColor } from './convert'; |
|||
|
|||
describe('color conversion functions', () => { |
|||
it('should correctly convert color to HSL format', () => { |
|||
@ -1,6 +1,6 @@ |
|||
import { generate } from '@ant-design/colors'; |
|||
|
|||
import { convertToHslCssVar } from './utils'; |
|||
import { convertToHslCssVar } from './convert'; |
|||
|
|||
export * from '@ant-design/colors'; |
|||
|
|||
@ -1,2 +1,2 @@ |
|||
export * from './convert'; |
|||
export * from './generator'; |
|||
export * from './utils'; |
|||
@ -0,0 +1,33 @@ |
|||
interface BasicOption { |
|||
label: string; |
|||
value: string; |
|||
} |
|||
|
|||
interface SelectOption extends BasicOption {} |
|||
|
|||
interface TabsOption extends BasicOption {} |
|||
|
|||
interface BasicUserInfo { |
|||
/** |
|||
* 头像 |
|||
*/ |
|||
avatar: string; |
|||
/** |
|||
* 用户昵称 |
|||
*/ |
|||
realName: string; |
|||
/** |
|||
* 用户角色 |
|||
*/ |
|||
roles?: string[]; |
|||
/** |
|||
* 用户id |
|||
*/ |
|||
userId: string; |
|||
/** |
|||
* 用户名 |
|||
*/ |
|||
username: string; |
|||
} |
|||
|
|||
export type { BasicOption, BasicUserInfo, SelectOption, TabsOption }; |
|||
@ -0,0 +1,43 @@ |
|||
<!-- |
|||
Access control component for fine-grained access control. |
|||
--> |
|||
<script lang="ts" setup> |
|||
import { computed } from 'vue'; |
|||
|
|||
import { useAccess } from './use-access'; |
|||
|
|||
interface Props { |
|||
/** |
|||
* 通过什么方式来控制组件,如果是 role,则传入角色,如果是 code,则传入权限码 |
|||
* @default 'role' |
|||
*/ |
|||
type?: 'code' | 'role'; |
|||
|
|||
/** |
|||
* Specified codes is visible |
|||
* @default [] |
|||
*/ |
|||
value?: string[]; |
|||
} |
|||
|
|||
defineOptions({ |
|||
name: 'AccessControl', |
|||
}); |
|||
|
|||
const props = withDefaults(defineProps<Props>(), { |
|||
type: 'role', |
|||
value: () => [], |
|||
}); |
|||
|
|||
const { hasAuthByCodes, hasAuthByRoles } = useAccess(); |
|||
|
|||
const hasAuth = computed(() => { |
|||
const { type, value } = props; |
|||
return type === 'role' ? hasAuthByRoles(value) : hasAuthByCodes(value); |
|||
}); |
|||
</script> |
|||
|
|||
<template> |
|||
<slot v-if="!value"></slot> |
|||
<slot v-else-if="hasAuth"></slot> |
|||
</template> |
|||
@ -1,29 +0,0 @@ |
|||
<!-- |
|||
Access control component for fine-grained access control. |
|||
--> |
|||
<script lang="ts" setup> |
|||
import { useAccess } from './use-access'; |
|||
|
|||
interface Props { |
|||
/** |
|||
* Specified codes is visible |
|||
* @default [] |
|||
*/ |
|||
value?: string[]; |
|||
} |
|||
|
|||
defineOptions({ |
|||
name: 'CodeAccess', |
|||
}); |
|||
|
|||
withDefaults(defineProps<Props>(), { |
|||
value: () => [], |
|||
}); |
|||
|
|||
const { hasAuthByCodes } = useAccess(); |
|||
</script> |
|||
|
|||
<template> |
|||
<slot v-if="!value"></slot> |
|||
<slot v-else-if="hasAuthByCodes(value)"></slot> |
|||
</template> |
|||
@ -1,5 +1,3 @@ |
|||
export { default as CodeAccess } from './code-access.vue'; |
|||
export * from './generate-menu-and-routes'; |
|||
export { default as RoleAccess } from './role-access.vue'; |
|||
export type * from './types'; |
|||
export { default as AccessControl } from './access-control.vue'; |
|||
export * from './generate-accessible'; |
|||
export * from './use-access'; |
|||
|
|||
@ -1,29 +0,0 @@ |
|||
<!-- |
|||
Access control component for fine-grained access control. |
|||
--> |
|||
<script lang="ts" setup> |
|||
import { useAccess } from './use-access'; |
|||
|
|||
interface Props { |
|||
/** |
|||
* Specified role is visible |
|||
* @default [] |
|||
*/ |
|||
value?: string[]; |
|||
} |
|||
|
|||
defineOptions({ |
|||
name: 'RoleAccess', |
|||
}); |
|||
|
|||
withDefaults(defineProps<Props>(), { |
|||
value: undefined, |
|||
}); |
|||
|
|||
const { hasAuthByRoles } = useAccess(); |
|||
</script> |
|||
|
|||
<template> |
|||
<slot v-if="!value"></slot> |
|||
<slot v-else-if="hasAuthByRoles(value)"></slot> |
|||
</template> |
|||
@ -1,17 +0,0 @@ |
|||
import type { |
|||
ComponentRecordType, |
|||
RouteRecordStringComponent, |
|||
} from '@vben/types'; |
|||
import type { RouteRecordRaw, Router } from 'vue-router'; |
|||
|
|||
interface GeneratorMenuAndRoutesOptions { |
|||
fetchMenuListAsync?: () => Promise<RouteRecordStringComponent[]>; |
|||
forbiddenComponent?: RouteRecordRaw['component']; |
|||
layoutMap?: ComponentRecordType; |
|||
pageMap?: ComponentRecordType; |
|||
roles?: string[]; |
|||
router: Router; |
|||
routes: RouteRecordRaw[]; |
|||
} |
|||
|
|||
export type { GeneratorMenuAndRoutesOptions }; |
|||
@ -1,9 +1,6 @@ |
|||
{ |
|||
"$schema": "https://json.schemastore.org/tsconfig", |
|||
"extends": "@vben/tsconfig/web.json", |
|||
"compilerOptions": { |
|||
"types": ["@vben/types/global"] |
|||
}, |
|||
"include": ["src"], |
|||
"exclude": ["node_modules"] |
|||
} |
|||
|
|||
@ -1,4 +1,2 @@ |
|||
export type * from './router'; |
|||
export type * from './ui'; |
|||
export type * from './user'; |
|||
export type * from '@vben-core/typings'; |
|||
|
|||
@ -1,13 +0,0 @@ |
|||
import type { RouteRecordRaw } from 'vue-router'; |
|||
|
|||
import type { Component } from 'vue'; |
|||
|
|||
// 定义递归类型以将 RouteRecordRaw 的 component 属性更改为 string
|
|||
type RouteRecordStringComponent<T = string> = { |
|||
children?: RouteRecordStringComponent<T>[]; |
|||
component: T; |
|||
} & Omit<RouteRecordRaw, 'children' | 'component'>; |
|||
|
|||
type ComponentRecordType = Record<string, () => Promise<Component>>; |
|||
|
|||
export type { ComponentRecordType, RouteRecordStringComponent }; |
|||
@ -1,11 +0,0 @@ |
|||
interface SelectListItem { |
|||
label: string; |
|||
value: string; |
|||
} |
|||
|
|||
interface TabsItem { |
|||
label: string; |
|||
value: string; |
|||
} |
|||
|
|||
export type { SelectListItem, TabsItem }; |
|||
Loading…
Reference in new issue