feat(projects): 迁移登录完成

This commit is contained in:
Soybean
2022-01-05 01:35:32 +08:00
parent f5a36a05cb
commit b93b80cb4b
54 changed files with 1679 additions and 260 deletions

10
src/typings/api/auth.d.ts vendored Normal file
View File

@ -0,0 +1,10 @@
/** 后端返回的用户权益相关类型 */
declare namespace ApiAuth {
/** 返回的token和刷新token */
interface Token {
token: string;
refreshToken: string;
}
/** 返回的用户信息 */
type UserInfo = Auth.UserInfo;
}

View File

@ -1,7 +1,7 @@
/** 后端返回的路由相关类型 */
declare namespace ApiRoute {
/** 后端返回的路由数据类型 */
interface ResponseRoute {
interface Route {
/** 动态路由 */
routes: AuthRoute.Route[];
/** 路由首页对应的key */

View File

@ -1,15 +1,5 @@
/** 用户相关模块 */
declare namespace Auth {
/** 用户信息 */
interface UserInfo {
/** 用户id */
userId: string;
/** 用户名 */
userName: string;
/** 用户手机号 */
userPhone: string;
}
/**
* 用户角色类型
* - super: 超级管理员
@ -18,4 +8,16 @@ declare namespace Auth {
* - visitor: 游客
*/
type RoleType = 'super' | 'admin' | 'test' | 'visitor';
/** 用户信息 */
interface UserInfo {
/** 用户id */
userId: string;
/** 用户名 */
userName: string;
/** 用户手机号 */
userPhone: string;
/** 用户角色类型 */
userRole: RoleType;
}
}

View File

@ -24,7 +24,7 @@ declare namespace AuthRoute {
: `/${Key}`;
/** 路由路径 */
type RoutePath<Key extends string = string> =
type RoutePath<Key extends string = '' | LoginPath> =
| '/'
| Exclude<KeyToPath<RouteKey>, '/root' | '/redirect'>
| Key
@ -65,8 +65,11 @@ declare namespace AuthRoute {
order?: number;
};
/** 登录路由路径 */
type LoginPath = `/login/:module(${string})?`;
/** 单个路由的类型结构(后端返回此类型结构的路由) */
interface Route<T extends string = ''> {
interface Route<T extends string = '' | LoginPath> {
/** 路由名称(路由唯一标识) */
name: RouteKey;
/** 路由路径 */
@ -85,5 +88,7 @@ declare namespace AuthRoute {
children?: Route[];
/** 路由描述 */
meta: RouteMeta;
/** 属性 */
props?: boolean | Record<string, any> | ((to: any) => Record<string, any>);
}
}

View File

@ -12,6 +12,4 @@ declare namespace Util {
type UnionToTuple<T, U = T> = [T] extends [never]
? []
: [LastInUnion<T>, ...UnionToTuple<Exclude<U, LastInUnion<T>>>];
type Inter = UnionToTuple<'1' | '2'>;
}