diff --git a/mock/user.ts b/mock/user.ts
index 98e96bb..aafff0d 100644
--- a/mock/user.ts
+++ b/mock/user.ts
@@ -1,70 +1,70 @@
-//用户信息数据
+//虚假的mock用户信息数据,用于测试
//createuserList:次函数执行会返回一个数组,数组里面包含两个用户信息
function createUserList() {
- return [
- {
- userId: 1,
- avatar:
- 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif',
- username: 'admin',
- password: '111111',
- desc: '平台管理员',
- roles: ['平台管理员'],
- buttons: ['cuser.detail'],
- routes: ['home'],
- token: 'Admin Token',
- },
- {
- userId: 2,
- avatar:
- 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif',
- username: 'system',
- password: '111111',
- desc: '系统管理员',
- roles: ['系统管理员'],
- buttons: ['cuser.detail', 'cuser.user'],
- routes: ['home'],
- token: 'System Token',
- },
- ]
+ return [
+ {
+ userId: 1,
+ avatar:
+ 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif',
+ username: 'admin',
+ password: '111111',
+ desc: '平台管理员',
+ roles: ['平台管理员'],
+ buttons: ['cuser.detail'],
+ routes: ['home'],
+ token: 'Admin Token',
+ },
+ {
+ userId: 2,
+ avatar:
+ 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif',
+ username: 'system',
+ password: '111111',
+ desc: '系统管理员',
+ roles: ['系统管理员'],
+ buttons: ['cuser.detail', 'cuser.user'],
+ routes: ['home'],
+ token: 'System Token',
+ },
+ ]
}
export default [
- // 用户登录接口
- {
- url: '/api/user/login',//请求地址
- method: 'post',//请求方式
- response: ({ body }) => {
- //获取请求体携带过来的用户名与密码
- const { username, password } = body;
- //调用获取用户信息函数,用于判断是否有此用户
- const checkUser = createUserList().find(
- (item) => item.username === username && item.password === password,
- )
- //没有用户返回失败信息
- if (!checkUser) {
- return { code: 201, data: { message: '账号或者密码不正确' } }
- }
- //如果有返回成功信息
- const { token } = checkUser
- return { code: 200, data: { token } }
- },
+ // 用户登录接口
+ {
+ url: '/api/user/login', //请求地址
+ method: 'post', //请求方式
+ response: ({ body }) => {
+ //获取请求体携带过来的用户名与密码
+ const { username, password } = body
+ //调用获取用户信息函数,用于判断是否有此用户
+ const checkUser = createUserList().find(
+ (item) => item.username === username && item.password === password,
+ )
+ //没有用户返回失败信息
+ if (!checkUser) {
+ return { code: 201, data: { message: '账号或者密码不正确' } }
+ }
+ //如果有返回成功信息
+ const { token } = checkUser
+ return { code: 200, data: { token } }
},
- // 获取用户信息
- {
- url: '/api/user/info',
- method: 'get',
- response: (request) => {
- //获取请求头携带token
- const token = request.headers.token;
- //查看用户信息是否包含有次token用户
- const checkUser = createUserList().find((item) => item.token === token)
- //没有返回失败的信息
- if (!checkUser) {
- return { code: 201, data: { message: '获取用户信息失败' } }
- }
- //如果有返回成功信息
- return { code: 200, data: {checkUser} }
- },
+ },
+ // 获取用户信息
+ {
+ url: '/api/user/info',
+ method: 'get',
+ response: (request) => {
+ //获取请求头携带token
+ const token = request.headers.token
+ //查看用户信息是否包含有次token用户
+ const checkUser = createUserList().find((item) => item.token === token)
+ //没有返回失败的信息
+ if (!checkUser) {
+ return { code: 201, data: { message: '获取用户信息失败' } }
+ }
+ //如果有返回成功信息
+ return { code: 200, data: { checkUser } }
},
-]
\ No newline at end of file
+ },
+]
diff --git a/src/App.vue b/src/App.vue
index 399ffed..4461d41 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -4,14 +4,12 @@
-
+
diff --git a/src/api/user/index.ts b/src/api/user/index.ts
index f674565..0f1ff57 100644
--- a/src/api/user/index.ts
+++ b/src/api/user/index.ts
@@ -1,19 +1,17 @@
//统一管理项目相关信息
-import request from "@/utils/request";
-import type {
- loginForm,
- loginResponseDate,
- userReponseData,
-} from './type'
+import request from '@/utils/request'
+import type { loginForm, loginResponseDate, userReponseData } from './type'
//统一管理接口
enum API {
- LOGIN_URL = '/user/login',
- USERINFO_URL = '/user/info',
- // LOGOUT_URL = '/admin/acl/index/logout',
+ LOGIN_URL = '/user/login',
+ USERINFO_URL = '/user/info',
+ // LOGOUT_URL = '/admin/acl/index/logout',
}
//登录接口
-export const reqLogin = (data: loginForm) => request.post(API.LOGIN_URL, data)
+export const reqLogin = (data: loginForm) =>
+ request.post(API.LOGIN_URL, data)
//获取用户信息
-export const reqUserInfo = () =>request.get(API.USERINFO_URL)
+export const reqUserInfo = () =>
+ request.get(API.USERINFO_URL)
//退出登录
-// export const reqLogout = () => request.post(API.LOGOUT_URL)
\ No newline at end of file
+// export const reqLogout = () => request.post(API.LOGOUT_URL)
diff --git a/src/api/user/type.ts b/src/api/user/type.ts
index 1c030b4..1c4ef30 100644
--- a/src/api/user/type.ts
+++ b/src/api/user/type.ts
@@ -1,33 +1,33 @@
//登录接口需要携带参数ts类型
-export interface loginForm{
- username:string,
- password:string
+export interface loginForm {
+ username: string
+ password: string
}
-interface dataType{
- token:string
+interface dataType {
+ token: string
}
//登录接口返回数据类型
-export interface loginResponseDate{
- code:number,
- date:dataType
+export interface loginResponseDate {
+ code: number
+ date: dataType
}
//定义服务器返回用户信息相关数据类型
-interface userInfo{
- userId:number,
- avatar:string,
- username:string,
- password:string,
- desc:string,
- roles:string[],
- buttons:string[],
- routes:string[],
- token:string
+interface userInfo {
+ userId: number
+ avatar: string
+ username: string
+ password: string
+ desc: string
+ roles: string[]
+ buttons: string[]
+ routes: string[]
+ token: string
}
-interface user{
- checkUser:userInfo
+interface user {
+ checkUser: userInfo
+}
+export interface userReponseData {
+ code: number
+ date: user
}
-export interface userReponseData{
- code:number,
- date:user
-}
\ No newline at end of file
diff --git a/src/components/Pagination/index.vue b/src/components/Pagination/index.vue
index 2dd905f..858159c 100644
--- a/src/components/Pagination/index.vue
+++ b/src/components/Pagination/index.vue
@@ -1,11 +1,5 @@
-
+
-
+
-
-
-
+
diff --git a/src/components/SvgIcon/index.vue b/src/components/SvgIcon/index.vue
index f873ba4..f1a08bb 100644
--- a/src/components/SvgIcon/index.vue
+++ b/src/components/SvgIcon/index.vue
@@ -9,7 +9,7 @@
-