chore: init project
This commit is contained in:
7
packages/@vben-core/shared/typings/build.config.ts
Normal file
7
packages/@vben-core/shared/typings/build.config.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import { defineBuildConfig } from 'unbuild';
|
||||
|
||||
export default defineBuildConfig({
|
||||
clean: true,
|
||||
declaration: true,
|
||||
entries: ['src/index'],
|
||||
});
|
88
packages/@vben-core/shared/typings/global.d.ts
vendored
Normal file
88
packages/@vben-core/shared/typings/global.d.ts
vendored
Normal file
@@ -0,0 +1,88 @@
|
||||
import 'vue-router';
|
||||
|
||||
declare module 'vue-router' {
|
||||
interface RouteMeta {
|
||||
/**
|
||||
* 是否固定标签页
|
||||
* @default false
|
||||
*/
|
||||
affixTab?: boolean;
|
||||
/**
|
||||
* 需要特定的角色标识才可以访问
|
||||
* @default []
|
||||
*/
|
||||
authority?: string[];
|
||||
/**
|
||||
* 徽标
|
||||
*/
|
||||
badge?: string;
|
||||
/**
|
||||
* 徽标类型
|
||||
*/
|
||||
badgeType?: 'dot' | 'normal';
|
||||
/**
|
||||
* 徽标颜色
|
||||
*/
|
||||
badgeVariants?:
|
||||
| 'default'
|
||||
| 'destructive'
|
||||
| 'primary'
|
||||
| 'success'
|
||||
| 'warning'
|
||||
| string;
|
||||
/**
|
||||
* 当前路由的子级在菜单中不展现
|
||||
* @default false
|
||||
*/
|
||||
hideChildrenInMenu?: boolean;
|
||||
/**
|
||||
* 当前路由在面包屑中不展现
|
||||
* @default false
|
||||
*/
|
||||
hideInBreadcrumb?: boolean;
|
||||
/**
|
||||
* 当前路由在菜单中不展现
|
||||
* @default false
|
||||
*/
|
||||
hideInMenu?: boolean;
|
||||
|
||||
/**
|
||||
* 当前路由在标签页不展现
|
||||
* @default false
|
||||
*/
|
||||
hideInTab?: boolean;
|
||||
/**
|
||||
* 路由跳转地址
|
||||
*/
|
||||
href?: string;
|
||||
/**
|
||||
* 图标(菜单/tab)
|
||||
*/
|
||||
icon?: string;
|
||||
/**
|
||||
* iframe 地址
|
||||
*/
|
||||
iframeSrc?: string;
|
||||
/**
|
||||
* 忽略权限,直接可以访问
|
||||
* @default false
|
||||
*/
|
||||
ignoreAccess?: boolean;
|
||||
/**
|
||||
* 开启KeepAlive缓存
|
||||
*/
|
||||
keepAlive?: boolean;
|
||||
/**
|
||||
* 路由是否已经加载过
|
||||
*/
|
||||
loaded?: boolean;
|
||||
/**
|
||||
* 用于路由->菜单排序
|
||||
*/
|
||||
orderNo?: number;
|
||||
/**
|
||||
* 标题名称
|
||||
*/
|
||||
title: string;
|
||||
}
|
||||
}
|
50
packages/@vben-core/shared/typings/package.json
Normal file
50
packages/@vben-core/shared/typings/package.json
Normal file
@@ -0,0 +1,50 @@
|
||||
{
|
||||
"name": "@vben-core/typings",
|
||||
"version": "1.0.0",
|
||||
"type": "module",
|
||||
"license": "MIT",
|
||||
"homepage": "https://github.com/vbenjs/vue-vben-admin",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/vbenjs/vue-vben-admin.git",
|
||||
"directory": "packages/@vben-core/shared/typings"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/vbenjs/vue-vben-admin/issues"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "pnpm unbuild",
|
||||
"stub": "pnpm build --stub"
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"main": "./dist/index.mjs",
|
||||
"module": "./dist/index.mjs",
|
||||
"types": "./dist/index.d.ts",
|
||||
"imports": {
|
||||
"#*": "./src/*"
|
||||
},
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./src/index.ts",
|
||||
"development": "./src/index.ts",
|
||||
"default": "./dist/index.mjs"
|
||||
},
|
||||
"./global": {
|
||||
"types": "./global.d.ts"
|
||||
}
|
||||
},
|
||||
"publishConfig": {
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./dist/index.d.ts",
|
||||
"default": "./dist/index.mjs"
|
||||
}
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"vue": "^3.4.27",
|
||||
"vue-router": "^4.3.2"
|
||||
}
|
||||
}
|
44
packages/@vben-core/shared/typings/src/access.ts
Normal file
44
packages/@vben-core/shared/typings/src/access.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
interface RoleInfo {
|
||||
/** 角色名 */
|
||||
roleName: string;
|
||||
/** 角色值 */
|
||||
value: string;
|
||||
}
|
||||
|
||||
/** 用户信息 */
|
||||
interface UserInfo {
|
||||
/**
|
||||
* 头像
|
||||
*/
|
||||
avatar: string;
|
||||
/**
|
||||
* 用户描述
|
||||
*/
|
||||
desc: string;
|
||||
/**
|
||||
* 首页地址
|
||||
*/
|
||||
homePath: string;
|
||||
/**
|
||||
* 用户昵称
|
||||
*/
|
||||
realName: string;
|
||||
/**
|
||||
* 用户角色信息
|
||||
*/
|
||||
roles: RoleInfo[];
|
||||
/**
|
||||
* accessToken
|
||||
*/
|
||||
token: string;
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
userId: string;
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
username: string;
|
||||
}
|
||||
|
||||
export type { RoleInfo, UserInfo };
|
6
packages/@vben-core/shared/typings/src/index.ts
Normal file
6
packages/@vben-core/shared/typings/src/index.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
export * from './access';
|
||||
export * from './menu-record';
|
||||
export * from './preference';
|
||||
export * from './tabs';
|
||||
export * from './tools';
|
||||
export * from './ui';
|
71
packages/@vben-core/shared/typings/src/menu-record.ts
Normal file
71
packages/@vben-core/shared/typings/src/menu-record.ts
Normal file
@@ -0,0 +1,71 @@
|
||||
import type { RouteRecordRaw } from 'vue-router';
|
||||
|
||||
/**
|
||||
* 扩展路由原始对象
|
||||
*/
|
||||
type ExRouteRecordRaw = {
|
||||
parent?: string;
|
||||
parents?: string[];
|
||||
path?: any;
|
||||
} & RouteRecordRaw;
|
||||
|
||||
interface MenuRecordBadgeRaw {
|
||||
/**
|
||||
* 徽标
|
||||
*/
|
||||
badge?: string;
|
||||
/**
|
||||
* 徽标类型
|
||||
*/
|
||||
badgeType?: 'dot' | 'normal';
|
||||
/**
|
||||
* 徽标颜色
|
||||
*/
|
||||
badgeVariants?: 'destructive' | 'primary' | string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 菜单原始对象
|
||||
*/
|
||||
interface MenuRecordRaw extends MenuRecordBadgeRaw {
|
||||
/**
|
||||
* 子菜单
|
||||
*/
|
||||
children?: MenuRecordRaw[];
|
||||
/**
|
||||
* 是否禁用菜单
|
||||
* @default false
|
||||
*/
|
||||
disabled?: boolean;
|
||||
/**
|
||||
* 图标名
|
||||
*/
|
||||
icon?: string;
|
||||
/**
|
||||
* 菜单名
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* 排序号
|
||||
*/
|
||||
orderNo?: number;
|
||||
/**
|
||||
* 父级路径
|
||||
*/
|
||||
parent?: string;
|
||||
/**
|
||||
* 所有父级路径
|
||||
*/
|
||||
parents?: string[];
|
||||
/**
|
||||
* 菜单路径,唯一,可当作key
|
||||
*/
|
||||
path: string;
|
||||
/**
|
||||
* 是否显示菜单
|
||||
* @default true
|
||||
*/
|
||||
show?: boolean;
|
||||
}
|
||||
|
||||
export type { ExRouteRecordRaw, MenuRecordBadgeRaw, MenuRecordRaw };
|
130
packages/@vben-core/shared/typings/src/preference.ts
Normal file
130
packages/@vben-core/shared/typings/src/preference.ts
Normal file
@@ -0,0 +1,130 @@
|
||||
type LayoutType =
|
||||
| 'full-content'
|
||||
| 'header-nav'
|
||||
| 'mixed-nav'
|
||||
| 'side-mixed-nav'
|
||||
| 'side-nav';
|
||||
|
||||
type BreadcrumbStyle = 'background' | 'normal';
|
||||
|
||||
type NavigationStyle = 'normal' | 'rounded';
|
||||
|
||||
type ThemeType = 'auto' | 'dark' | 'light';
|
||||
|
||||
type ContentCompactType = 'compact' | 'wide';
|
||||
|
||||
type LayoutHeaderMode = 'auto' | 'auto-scroll' | 'fixed' | 'static';
|
||||
|
||||
type PageTransitionType = 'fade-slide';
|
||||
|
||||
type AuthPageLayout = 'panel-center' | 'panel-left' | 'panel-right';
|
||||
|
||||
type SupportLocale = 'en-US' | 'zh-CN';
|
||||
|
||||
interface Language {
|
||||
key: SupportLocale;
|
||||
text: string;
|
||||
}
|
||||
|
||||
interface Preference {
|
||||
/** 应用名 */
|
||||
appName: string;
|
||||
/** 登录注册页面布局 */
|
||||
authPageLayout: AuthPageLayout;
|
||||
/** 面包屑是否只有一个时隐藏 */
|
||||
breadcrumbHideOnlyOne: boolean;
|
||||
/** 面包屑首页图标是否可见 */
|
||||
breadcrumbHome: boolean;
|
||||
/** 面包屑图标是否可见 */
|
||||
breadcrumbIcon: boolean;
|
||||
/** 面包屑类型 */
|
||||
breadcrumbStyle: BreadcrumbStyle;
|
||||
/** 面包屑是否可见 */
|
||||
breadcrumbVisible: boolean;
|
||||
/** 是否开启灰色模式 */
|
||||
colorGrayMode: boolean;
|
||||
/** 主题色 */
|
||||
colorPrimary: string;
|
||||
/** 是否开启色弱模式 */
|
||||
colorWeakMode: boolean;
|
||||
/** 是否开启紧凑模式 */
|
||||
compact: boolean;
|
||||
/** 是否开启内容紧凑模式 */
|
||||
contentCompact: ContentCompactType;
|
||||
/** 页脚Copyright */
|
||||
copyright: string;
|
||||
/** 应用默认头像 */
|
||||
defaultAvatar: string;
|
||||
/** 页脚是否固定 */
|
||||
footerFixed: boolean;
|
||||
/** 页脚是否可见 */
|
||||
footerVisible: boolean;
|
||||
/** header显示模式 */
|
||||
headerMode: LayoutHeaderMode;
|
||||
/** 顶栏是否可见 */
|
||||
headerVisible: boolean;
|
||||
/** 是否移动端 */
|
||||
isMobile: boolean;
|
||||
/** 开启标签页缓存功能 */
|
||||
keepAlive: boolean;
|
||||
/** 布局方式 */
|
||||
layout: LayoutType;
|
||||
/** 支持的语言 */
|
||||
locale: SupportLocale;
|
||||
/** 应用Logo */
|
||||
logo: string;
|
||||
/** logo是否可见 */
|
||||
logoVisible: boolean;
|
||||
/** 导航菜单风格 */
|
||||
navigationStyle: NavigationStyle;
|
||||
/** 是否开启页面加载进度条 */
|
||||
pageProgress: boolean;
|
||||
/** 页面切换动画 */
|
||||
pageTransition: PageTransitionType;
|
||||
/** 页面切换动画是否启用 */
|
||||
pageTransitionEnable: boolean;
|
||||
/** 是否开启半深色菜单(只在theme='light'时生效) */
|
||||
semiDarkMenu: boolean;
|
||||
/** 侧边栏是否折叠 */
|
||||
sideCollapse: boolean;
|
||||
/** 侧边栏折叠时,是否显示title */
|
||||
sideCollapseShowTitle: boolean;
|
||||
/** 菜单自动展开状态 */
|
||||
sideExpandOnHover: boolean;
|
||||
/** 侧边栏扩展区域是否折叠 */
|
||||
sideExtraCollapse: boolean;
|
||||
/** 侧边栏是否可见 */
|
||||
sideVisible: boolean;
|
||||
/** 侧边栏宽度 */
|
||||
sideWidth: number;
|
||||
/** 是否开启多标签页图标 */
|
||||
tabsIcon: boolean;
|
||||
/** 是否开启多标签页 */
|
||||
tabsVisible: boolean;
|
||||
/** 当前主题 */
|
||||
theme: ThemeType;
|
||||
}
|
||||
|
||||
// 这些属性是静态的,不会随着用户的操作而改变
|
||||
interface StaticPreference {
|
||||
/** 主题色预设 */
|
||||
colorPrimaryPresets: string[];
|
||||
/** 支持的语言 */
|
||||
supportLanguages: Language[];
|
||||
}
|
||||
|
||||
type PreferenceKeys = keyof Preference;
|
||||
|
||||
export type {
|
||||
AuthPageLayout,
|
||||
BreadcrumbStyle,
|
||||
ContentCompactType,
|
||||
LayoutHeaderMode,
|
||||
LayoutType,
|
||||
PageTransitionType,
|
||||
Preference,
|
||||
PreferenceKeys,
|
||||
StaticPreference,
|
||||
SupportLocale,
|
||||
ThemeType,
|
||||
};
|
3
packages/@vben-core/shared/typings/src/tabs.ts
Normal file
3
packages/@vben-core/shared/typings/src/tabs.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
import type { RouteLocationNormalized } from 'vue-router';
|
||||
|
||||
export type TabItem = RouteLocationNormalized;
|
89
packages/@vben-core/shared/typings/src/tools.ts
Normal file
89
packages/@vben-core/shared/typings/src/tools.ts
Normal file
@@ -0,0 +1,89 @@
|
||||
import { type ComputedRef, type MaybeRef } from 'vue';
|
||||
|
||||
/**
|
||||
* 深度部分类型
|
||||
*/
|
||||
type DeepPartial<T> = T extends object
|
||||
? {
|
||||
[P in keyof T]?: DeepPartial<T[P]>;
|
||||
}
|
||||
: T;
|
||||
|
||||
/**
|
||||
* 任意类型的异步函数
|
||||
*/
|
||||
|
||||
type AnyPromiseFunction<T extends any[] = any[], R = void> = (
|
||||
...arg: T
|
||||
) => PromiseLike<R>;
|
||||
|
||||
/**
|
||||
* 任意类型的普通函数
|
||||
*/
|
||||
type AnyNormalFunction<T extends any[] = any[], R = void> = (...arg: T) => R;
|
||||
|
||||
/**
|
||||
* 任意类型的函数
|
||||
*/
|
||||
type AnyFunction<T extends any[] = any[], R = void> =
|
||||
| AnyNormalFunction<T, R>
|
||||
| AnyPromiseFunction<T, R>;
|
||||
|
||||
/**
|
||||
* T | null 包装
|
||||
*/
|
||||
type Nullable<T> = T | null;
|
||||
|
||||
/**
|
||||
* T | Not null 包装
|
||||
*/
|
||||
type NonNullable<T> = T extends null | undefined ? never : T;
|
||||
|
||||
/**
|
||||
* 字符串类型对象
|
||||
*/
|
||||
type Recordable<T> = Record<string, T>;
|
||||
|
||||
/**
|
||||
* 字符串类型对象(只读)
|
||||
*/
|
||||
interface ReadonlyRecordable<T = any> {
|
||||
readonly [key: string]: T;
|
||||
}
|
||||
|
||||
/**
|
||||
* setTimeout 返回值类型
|
||||
*/
|
||||
type TimeoutHandle = ReturnType<typeof setTimeout>;
|
||||
|
||||
/**
|
||||
* setInterval 返回值类型
|
||||
*/
|
||||
type IntervalHandle = ReturnType<typeof setInterval>;
|
||||
|
||||
/**
|
||||
* 也许它是一个计算的 ref,或者一个 getter 函数
|
||||
*
|
||||
*/
|
||||
type MaybeReadonlyRef<T> = (() => T) | ComputedRef<T>;
|
||||
|
||||
/**
|
||||
* 也许它是一个 ref,或者一个普通值,或者一个 getter 函数
|
||||
*
|
||||
*/
|
||||
type MaybeComputedRef<T> = MaybeReadonlyRef<T> | MaybeRef<T>;
|
||||
|
||||
export {
|
||||
type AnyFunction,
|
||||
type AnyNormalFunction,
|
||||
type AnyPromiseFunction,
|
||||
type DeepPartial,
|
||||
type IntervalHandle,
|
||||
type MaybeComputedRef,
|
||||
type MaybeReadonlyRef,
|
||||
type NonNullable,
|
||||
type Nullable,
|
||||
type ReadonlyRecordable,
|
||||
type Recordable,
|
||||
type TimeoutHandle,
|
||||
};
|
6
packages/@vben-core/shared/typings/src/ui.ts
Normal file
6
packages/@vben-core/shared/typings/src/ui.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
interface SelectListItem {
|
||||
label: string;
|
||||
value: string;
|
||||
}
|
||||
|
||||
export type { SelectListItem };
|
5
packages/@vben-core/shared/typings/tsconfig.json
Normal file
5
packages/@vben-core/shared/typings/tsconfig.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/tsconfig",
|
||||
"extends": "@vben/tsconfig/library.json",
|
||||
"include": ["src"]
|
||||
}
|
Reference in New Issue
Block a user