Skip to content

Commit

Permalink
chore: 修改打包
Browse files Browse the repository at this point in the history
  • Loading branch information
sdmu-gaoqi committed Jan 21, 2024
1 parent b0ff508 commit 1233701
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 13 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# 访问地址
http://111.229.138.125/admin/index.html

# 目录结构

```
Expand Down
42 changes: 42 additions & 0 deletions mock/prod/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { MockMethod } from 'vite-plugin-mock'

// @ts-ignore
const testMock: MockMethod = [
{
url: '/api/login',
method: 'post',
timeout: 1000,
response: ({ data }: any) => {
return {
code: 0,
data: {
token: 'thisIsToken'
}
}
}
},
{
url: '/api/perm',
method: 'get',
timeout: 1000,
response: ({ data }: any) => {
console.log('登录请求数据 =>', data)
return {
code: 0,
data: ['perm-1']
}
}
},
{
url: '/api/logout',
method: 'get',
timeout: 1000,
response: () => {
return {
code: 0
}
}
}
]

export default testMock
7 changes: 6 additions & 1 deletion src/services/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,10 @@ export const getPerms = () => {
return request.request<CommonResponse<string[]>>({
url: '/api/perm',
method: 'get'
})
}).catch(() => {
return Promise.resolve({
code: 0,
data: ['perm-1']
})
})
}
39 changes: 27 additions & 12 deletions src/services/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,34 @@ import request from './request'
import { CommonResponse } from './type'

export const loginService = () => {
return request.request<
CommonResponse<{
token: string
}>
>({
url: '/api/login',
method: 'post'
})
return request
.request<
CommonResponse<{
token: string
}>
>({
url: '/api/login',
method: 'post'
})
.catch(() => {
return Promise.resolve({
code: 0,
data: {
token: 'thisIsToken'
}
})
})
}

export const logoutService = () => {
return request.request({
url: '/api/logout',
method: 'get'
})
return request
.request({
url: '/api/logout',
method: 'get'
})
.catch(() => {
return Promise.resolve({
code: 0
})
})
}
1 change: 1 addition & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export default defineConfig(
const envData = loadEnv(mode, path.resolve(process.cwd(), 'env'))
console.log('envData环境变量', envData)
return {
base: 'admin',
plugins: [
vue(),
vueJsx(),
Expand Down

0 comments on commit 1233701

Please sign in to comment.