From 599624e94429223d3893f0a3929668c54590018b Mon Sep 17 00:00:00 2001 From: haoxr <1490493387@qq.com> Date: Wed, 1 Mar 2023 00:47:39 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E4=BB=A3=E7=A0=81=E9=87=8D?= =?UTF-8?q?=E6=9E=84=E4=BC=98=E5=8C=96(VueUse=E4=BD=BF=E7=94=A8)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Former-commit-id: f33b8d352dd9e9b2a706c94cdd7afa150ac12931 --- src/api/auth/index.ts | 16 +-- src/api/auth/types.ts | 16 +-- src/api/user/index.ts | 4 +- src/api/user/types.ts | 120 +++++++++++++----- src/lang/index.ts | 3 +- src/layout/components/Sidebar/Link.vue | 2 +- src/layout/components/Sidebar/SidebarItem.vue | 2 +- src/permission.ts | 6 +- src/router/index.ts | 1 - src/settings.ts | 39 +++++- src/store/modules/app.ts | 41 ++---- src/store/modules/settings.ts | 24 +--- src/store/modules/user.ts | 15 +-- src/utils/localStorage.ts | 53 -------- src/utils/request.ts | 4 +- src/views/system/user/index.vue | 12 +- 16 files changed, 164 insertions(+), 194 deletions(-) delete mode 100644 src/utils/localStorage.ts diff --git a/src/api/auth/index.ts b/src/api/auth/index.ts index d25fb90a..8c85cef9 100644 --- a/src/api/auth/index.ts +++ b/src/api/auth/index.ts @@ -1,13 +1,13 @@ import request from '@/utils/request'; import { AxiosPromise } from 'axios'; -import { ILoginData, TokenResult, VerifyCode } from './types'; +import { LoginData, LoginResult } from './types'; /** * - * @param data {LoginForm} + * @param data {LoginData} * @returns */ -export function loginApi(data: ILoginData): AxiosPromise { +export function loginApi(data: LoginData): AxiosPromise { return request({ url: '/api/v1/auth/login', method: 'post', @@ -24,13 +24,3 @@ export function logoutApi() { method: 'delete' }); } - -/** - * 获取图片验证码 - */ -export function getCaptcha(): AxiosPromise { - return request({ - url: '/captcha?t=' + new Date().getTime().toString(), - method: 'get' - }); -} diff --git a/src/api/auth/types.ts b/src/api/auth/types.ts index 53675540..0814d674 100644 --- a/src/api/auth/types.ts +++ b/src/api/auth/types.ts @@ -1,23 +1,15 @@ /** - * 登录数据类型 + * 登录请求 */ -export interface ILoginData { +export interface LoginData { username: string; password: string; - /** - * 验证码Code - */ - //verifyCode: string; - /** - * 验证码Code服务端缓存key(UUID) - */ - // verifyCodeKey: string; } /** - * Token响应类型 + * 登录详情 */ -export interface TokenResult { +export interface LoginResult { accessToken: string; refreshToken: string; expires: number; diff --git a/src/api/user/index.ts b/src/api/user/index.ts index a3e18b4c..3d43d42a 100644 --- a/src/api/user/index.ts +++ b/src/api/user/index.ts @@ -1,6 +1,6 @@ import request from '@/utils/request'; import { AxiosPromise } from 'axios'; -import { UserForm, UserInfo, UserPageResult, UserQuery } from './types'; +import { UserForm, UserInfo, UserPageVO, UserQuery } from './types'; /** * 登录成功后获取用户信息(昵称、头像、权限集合和角色集合) @@ -19,7 +19,7 @@ export function getUserInfo(): AxiosPromise { */ export function listUserPages( queryParams: UserQuery -): AxiosPromise { +): AxiosPromise> { return request({ url: '/api/v1/users/pages', method: 'get', diff --git a/src/api/user/types.ts b/src/api/user/types.ts index 486244c2..81a6bc48 100644 --- a/src/api/user/types.ts +++ b/src/api/user/types.ts @@ -9,7 +9,7 @@ export interface UserInfo { } /** - * 用户查询参数 + * 用户查询对象类型 */ export interface UserQuery extends PageQuery { keywords: string; @@ -18,48 +18,102 @@ export interface UserQuery extends PageQuery { } /** - * 用户分页列表项声明 + * 用户分页对象 */ -export interface UserType { - id: string; - username: string; - nickname: string; - mobile: string; - gender: number; - avatar: string; - email: string; - status: number; - deptName: string; - roleNames: string; - createTime: string; +export interface UserPageVO { + /** + * 用户头像地址 + */ + avatar?: string; + /** + * 创建时间 + */ + createTime?: Date; + /** + * 部门名称 + */ + deptName?: string; + /** + * 用户邮箱 + */ + email?: string; + /** + * 性别 + */ + genderLabel?: string; + /** + * 用户ID + */ + id?: number; + /** + * 手机号 + */ + mobile?: string; + /** + * 用户昵称 + */ + nickname?: string; + /** + * 角色名称,多个使用英文逗号(,)分割 + */ + roleNames?: string; + /** + * 用户状态(1:启用;0:禁用) + */ + status?: number; + /** + * 用户名 + */ + username?: string; } /** - * 用户分页项类型声明 - */ -export type UserPageResult = PageResult; - -/** - * 用户表单类型声明 + * 用户表单类型 */ export interface UserForm { - id: number | undefined; - deptId: number; - username: string; - nickname: string; - password: string; - mobile: string; - email: string; - gender: number; - status: number; - remark: string; - roleIds: number[]; + /** + * 用户头像 + */ + avatar?: string; + /** + * 部门ID + */ + deptId?: number; + /** + * 邮箱 + */ + email?: string; + /** + * 性别 + */ + gender?: number; + /** + * 用户ID + */ + id?: number; + mobile?: string; + /** + * 昵称 + */ + nickname?: string; + /** + * 角色ID集合 + */ + roleIds?: number[]; + /** + * 用户状态(1:正常;0:禁用) + */ + status?: number; + /** + * 用户名 + */ + username?: string; } /** - * 用户导入表单类型声明 + * 用户导入视图对象类型 */ -export interface UserImportData { +export interface UserImportVO { deptId: number; roleIds: number[]; } diff --git a/src/lang/index.ts b/src/lang/index.ts index 5ca3f653..8ed51e90 100644 --- a/src/lang/index.ts +++ b/src/lang/index.ts @@ -1,6 +1,5 @@ // 自定义国际化配置 import { createI18n } from 'vue-i18n'; -import { localStorage } from '@/utils/localStorage'; // 本地语言包 import enLocale from './en'; @@ -22,7 +21,7 @@ const messages = { */ export const getLanguage = () => { // 本地缓存获取 - let language = localStorage.get('language'); + let language = localStorage.getItem('language'); if (language) { return language; } diff --git a/src/layout/components/Sidebar/Link.vue b/src/layout/components/Sidebar/Link.vue index c592bbd0..8e9337c1 100644 --- a/src/layout/components/Sidebar/Link.vue +++ b/src/layout/components/Sidebar/Link.vue @@ -1,6 +1,6 @@