chore: 脚手架
This commit is contained in:
@@ -1,20 +1,25 @@
|
||||
import { useAppConfig } from '@vben/hooks';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
const { clientId } = useAppConfig(import.meta.env, import.meta.env.PROD);
|
||||
|
||||
export namespace AuthApi {
|
||||
/** 登录接口参数 */
|
||||
export interface LoginParams {
|
||||
code?: string;
|
||||
grantType: string;
|
||||
password: string;
|
||||
tenantId: string;
|
||||
username: string;
|
||||
uuid?: string;
|
||||
}
|
||||
|
||||
/** 登录接口返回值 */
|
||||
export interface LoginResult {
|
||||
accessToken: string;
|
||||
desc: string;
|
||||
realName: string;
|
||||
refreshToken: string;
|
||||
userId: string;
|
||||
username: string;
|
||||
access_token: string;
|
||||
client_id: string;
|
||||
expire_in: number;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,12 +27,46 @@ export namespace AuthApi {
|
||||
* 登录
|
||||
*/
|
||||
export async function login(data: AuthApi.LoginParams) {
|
||||
return requestClient.post<AuthApi.LoginResult>('/auth/login', data);
|
||||
return requestClient.post<AuthApi.LoginResult>(
|
||||
'/auth/login',
|
||||
{ ...data, clientId },
|
||||
{
|
||||
encrypt: true,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户权限码
|
||||
* 用户登出
|
||||
* @returns void
|
||||
*/
|
||||
export async function getAccessCodes() {
|
||||
return requestClient.get<string[]>('/auth/codes');
|
||||
export function doLogout() {
|
||||
return requestClient.post<void>('/auth/logout');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param companyName 租户/公司名称
|
||||
* @param domain 绑定域名(不带http(s)://) 可选
|
||||
* @param tenantId 租户id
|
||||
*/
|
||||
export interface TenantOption {
|
||||
companyName: string;
|
||||
domain?: string;
|
||||
tenantId: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param tenantEnabled 是否启用租户
|
||||
* @param voList 租户列表
|
||||
*/
|
||||
export interface TenantResp {
|
||||
tenantEnabled: boolean;
|
||||
voList: TenantOption[];
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取租户列表 下拉框使用
|
||||
*/
|
||||
export function tenantList() {
|
||||
return requestClient.get<TenantResp>('/auth/tenant/list');
|
||||
}
|
||||
|
42
apps/web-antd/src/api/core/captcha.ts
Normal file
42
apps/web-antd/src/api/core/captcha.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
/**
|
||||
* 发送短信验证码
|
||||
* @param phonenumber 手机号
|
||||
* @returns void
|
||||
*/
|
||||
export function sendSmsCode(phonenumber: string) {
|
||||
return requestClient.get<void>('/resource/sms/code', {
|
||||
params: { phonenumber },
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送邮件验证码
|
||||
* @param email 邮箱
|
||||
* @returns void
|
||||
*/
|
||||
export function sendEmailCode(email: string) {
|
||||
return requestClient.get<void>('/resource/email/code', {
|
||||
params: { email },
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param img 图片验证码 需要和base64拼接
|
||||
* @param captchaEnabled 是否开启
|
||||
* @param uuid 验证码ID
|
||||
*/
|
||||
export interface CaptchaResponse {
|
||||
captchaEnabled: boolean;
|
||||
img: string;
|
||||
uuid: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 图片验证码
|
||||
* @returns resp
|
||||
*/
|
||||
export function captchaImage() {
|
||||
return requestClient.get<CaptchaResponse>('/auth/code');
|
||||
}
|
@@ -1,10 +1,45 @@
|
||||
import type { RouteRecordStringComponent } from '@vben/types';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
/**
|
||||
* @description: 菜单meta
|
||||
* @param title 菜单名
|
||||
* @param icon 菜单图标
|
||||
* @param noCache 是否不缓存
|
||||
* @param link 外链链接
|
||||
*/
|
||||
export interface MenuMeta {
|
||||
icon: string;
|
||||
link?: string;
|
||||
noCache: boolean;
|
||||
title: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 菜单
|
||||
* @param name 菜单名
|
||||
* @param path 菜单路径
|
||||
* @param hidden 是否隐藏
|
||||
* @param component 组件名称 Laout
|
||||
* @param alwaysShow 总是显示
|
||||
* @param query 路由参数(json形式)
|
||||
* @param meta 路由信息
|
||||
* @param children 子路由信息
|
||||
*/
|
||||
export interface Menu {
|
||||
alwaysShow?: boolean;
|
||||
children: Menu[];
|
||||
component: string;
|
||||
hidden: boolean;
|
||||
meta: MenuMeta;
|
||||
name: string;
|
||||
path: string;
|
||||
query?: string;
|
||||
redirect?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户所有菜单
|
||||
*/
|
||||
export async function getAllMenus() {
|
||||
return requestClient.get<RouteRecordStringComponent[]>('/menu/all');
|
||||
return requestClient.get<Menu[]>('/system/menu/getRouters');
|
||||
}
|
||||
|
@@ -1,10 +1,45 @@
|
||||
import type { UserInfo } from '@vben/types';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export interface Role {
|
||||
dataScope: string;
|
||||
flag: boolean;
|
||||
roleId: number;
|
||||
roleKey: string;
|
||||
roleName: string;
|
||||
roleSort: number;
|
||||
status: string;
|
||||
superAdmin: boolean;
|
||||
}
|
||||
|
||||
export interface User {
|
||||
avatar: string;
|
||||
createTime: string;
|
||||
deptId: number;
|
||||
deptName: string;
|
||||
email: string;
|
||||
loginDate: string;
|
||||
loginIp: string;
|
||||
nickName: string;
|
||||
phonenumber: string;
|
||||
remark: string;
|
||||
roles: Role[];
|
||||
sex: string;
|
||||
status: string;
|
||||
tenantId: string;
|
||||
userId: number;
|
||||
userName: string;
|
||||
userType: string;
|
||||
}
|
||||
|
||||
export interface UserInfoResp {
|
||||
permissions: string[];
|
||||
roles: string[];
|
||||
user: User;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户信息
|
||||
*/
|
||||
export async function getUserInfo() {
|
||||
return requestClient.get<UserInfo>('/user/info');
|
||||
return requestClient.get<UserInfoResp>('/system/user/getInfo');
|
||||
}
|
||||
|
Reference in New Issue
Block a user