mirror of
https://github.com/chansee97/nova-admin.git
synced 2025-04-05 04:22:49 +08:00
chore: modfify 2 alova
This commit is contained in:
parent
87a70d9a1a
commit
76f15c8d5a
24
README.md
24
README.md
@ -11,14 +11,14 @@
|
|||||||
|
|
||||||
<div align='center'>
|
<div align='center'>
|
||||||
|
|
||||||
**English** | [中文](./README.zh-CN.md)
|
English | [中文](./README.zh-CN.md)
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
## 🌈introduction
|
## introduction
|
||||||
|
|
||||||
[Nova-admin](https://github.com/chansee97/nova-admin) A free and open-source template for middle platform/back-end based on Vue3, Vite4, Typescript, pinia, Naive UI, and Vue-Router to help improve the development efficiency of middle platform/back-end
|
[Nova-admin](https://github.com/chansee97/nova-admin) A free and open-source template for middle platform/back-end based on Vue3, Vite4, Typescript, pinia, Naive UI, and Vue-Router to help improve the development efficiency of middle platform/back-end
|
||||||
|
|
||||||
## ⚡features
|
## features
|
||||||
|
|
||||||
- **Latest popular technology stack** - Developed based on the latest technology stack such as Vue3, Vite, TypeScript, NaiveUI, Pinia, etc
|
- **Latest popular technology stack** - Developed based on the latest technology stack such as Vue3, Vite, TypeScript, NaiveUI, Pinia, etc
|
||||||
- **Network request function encapsulation** - Perfect axios encapsulation and configuration, unified response processing and multi-scenario capability
|
- **Network request function encapsulation** - Perfect axios encapsulation and configuration, unified response processing and multi-scenario capability
|
||||||
@ -28,7 +28,7 @@
|
|||||||
- **Theme Configuration** - Dark Theme Adaptation
|
- **Theme Configuration** - Dark Theme Adaptation
|
||||||
- **Code Specification** - Only perform eslint verification at commit time, no too many restrictions, easier development
|
- **Code Specification** - Only perform eslint verification at commit time, no too many restrictions, easier development
|
||||||
|
|
||||||
## 😎project preview & display
|
## project preview & display
|
||||||
|
|
||||||
- [Nova-Admin preview](https://admin-nova.vercel.app/)
|
- [Nova-Admin preview](https://admin-nova.vercel.app/)
|
||||||
|
|
||||||
@ -38,11 +38,11 @@
|
|||||||

|

|
||||||

|

|
||||||
|
|
||||||
## 💎related projects
|
## related projects
|
||||||
|
|
||||||
- [Nova-admin-nest](https://github.com/chansee97/nove-admin-nest) (under development) Nova-Admin supporting background project based on TS, NestJs, typeorm
|
- [Nova-admin-nest](https://github.com/chansee97/nove-admin-nest) (under development) Nova-Admin supporting background project based on TS, NestJs, typeorm
|
||||||
|
|
||||||
## 🚧install and use
|
## install and use
|
||||||
|
|
||||||
The local development environment is recommended to use pnpm 8.x, Node.js 16.x
|
The local development environment is recommended to use pnpm 8.x, Node.js 16.x
|
||||||
|
|
||||||
@ -58,22 +58,26 @@ pnpm build
|
|||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## 🙌 learn to communicate
|
## learn to communicate
|
||||||
|
|
||||||
Nova-Admin is a completely open-source and free project. It is still being optimized and iterated. It is designed to help developers more conveniently develop medium and large management systems. If you have any questions, please ask questions in the QQ exchange group.
|
Nova-Admin is a completely open-source and free project. It is still being optimized and iterated. It is designed to help developers more conveniently develop medium and large management systems. If you have any questions, please ask questions in the QQ exchange group.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
## 🧩contribution
|
## contribution
|
||||||
|
|
||||||
If you find any issues or have suggestions for improvement, please create an issue or submit a PR. We welcome your contributions!
|
If you find any issues or have suggestions for improvement, please create an issue or submit a PR. We welcome your contributions!
|
||||||
|
|
||||||
## 🤗support
|
## support
|
||||||
|
|
||||||
If you feel that this project is helpful for your work or study, please help me order a ✨ Star, which will be a great encouragement and support for me, or you can buy me a cup of coffee below
|
If you feel that this project is helpful for your work or study, please help me order a ✨ Star, which will be a great encouragement and support for me, or you can buy me a cup of coffee below
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
## 🧾License
|
## [Contributors](https://github.com/chansee97/nova-admin/graphs/contributors)
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
[MIT](LICENSE)
|
[MIT](LICENSE)
|
||||||
|
@ -11,14 +11,14 @@
|
|||||||
|
|
||||||
<div align='center'>
|
<div align='center'>
|
||||||
|
|
||||||
[English](./README.md) | **中文**
|
[English](./README.md) | 中文
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
## 🌈 介绍
|
## 介绍
|
||||||
|
|
||||||
[Nova-admin](https://github.com/chansee97/nova-admin)一个基于Vue3、Vite4、Typescript、pinia、Naive UI、Vue-Router的后台管理免费开源模板,助力提高中后台开发效率
|
[Nova-admin](https://github.com/chansee97/nova-admin)一个基于Vue3、Vite4、Typescript、pinia、Naive UI、Vue-Router的后台管理免费开源模板,助力提高中后台开发效率
|
||||||
|
|
||||||
## ⚡特性
|
## 特性
|
||||||
|
|
||||||
- **最新流行技术栈** - 基于Vue3、Vite、TypeScript、NaiveUI、Pinia等最新技术栈开发
|
- **最新流行技术栈** - 基于Vue3、Vite、TypeScript、NaiveUI、Pinia等最新技术栈开发
|
||||||
- **网络请求功能封装** - 完善的axios封装和配置,统一的响应处理和多场景能力
|
- **网络请求功能封装** - 完善的axios封装和配置,统一的响应处理和多场景能力
|
||||||
@ -28,7 +28,7 @@
|
|||||||
- **主题配置** - 黑暗主题适配
|
- **主题配置** - 黑暗主题适配
|
||||||
- **代码规范** - 仅在提交时进行eslint校验,没有过多限制,开发更简便
|
- **代码规范** - 仅在提交时进行eslint校验,没有过多限制,开发更简便
|
||||||
|
|
||||||
## 😎 项目预览&展示
|
## 项目预览&展示
|
||||||
|
|
||||||
- [Nova-Admin 预览](https://admin-nova.vercel.app/)
|
- [Nova-Admin 预览](https://admin-nova.vercel.app/)
|
||||||
|
|
||||||
@ -38,11 +38,11 @@
|
|||||||

|

|
||||||

|

|
||||||
|
|
||||||
## 💎 相关项目
|
## 相关项目
|
||||||
|
|
||||||
- [Nova-admin-nest](https://github.com/chansee97/nove-admin-nest) (开发中)基于TS, NestJs, typeorm的Nova-Admin配套后台项目
|
- [Nova-admin-nest](https://github.com/chansee97/nove-admin-nest) (开发中)基于TS, NestJs, typeorm的Nova-Admin配套后台项目
|
||||||
|
|
||||||
## 🚧 安装使用
|
## 安装使用
|
||||||
|
|
||||||
本地开发环境建议使用 pnpm 8.x 、Node.js 16.x
|
本地开发环境建议使用 pnpm 8.x 、Node.js 16.x
|
||||||
|
|
||||||
@ -58,22 +58,26 @@ pnpm build
|
|||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## 🙌 学习交流
|
## 学习交流
|
||||||
|
|
||||||
Nova-Admin 是完全开源免费的项目,目前仍然在优化迭代中,旨在帮助开发者更方便地进行中大型管理系统开发,有使用问题欢迎在QQ交流群内提问。
|
Nova-Admin 是完全开源免费的项目,目前仍然在优化迭代中,旨在帮助开发者更方便地进行中大型管理系统开发,有使用问题欢迎在QQ交流群内提问。
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
## 🧩贡献
|
## 贡献
|
||||||
|
|
||||||
如果您发现了任何问题或有改进建议,请创建一个issue或提交一个PR。我们欢迎您的贡献!
|
如果您发现了任何问题或有改进建议,请创建一个issue或提交一个PR。我们欢迎您的贡献!
|
||||||
|
|
||||||
## 🤗 支持
|
## 支持
|
||||||
|
|
||||||
如果感觉本项目对你工作或学习有帮助,请帮我点一个✨Star,这将是对我极大的鼓励与支持, 也可以在下方请我喝一杯咖啡
|
如果感觉本项目对你工作或学习有帮助,请帮我点一个✨Star,这将是对我极大的鼓励与支持, 也可以在下方请我喝一杯咖啡
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
## 🧾License
|
## [贡献者](https://github.com/chansee97/nova-admin/graphs/contributors)
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## 协议
|
||||||
|
|
||||||
[MIT](LICENSE)
|
[MIT](LICENSE)
|
||||||
|
31
index.html
31
index.html
@ -1,20 +1,17 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8" />
|
<head>
|
||||||
<link
|
<meta charset="UTF-8" />
|
||||||
rel="icon"
|
<link rel="icon" href="/favicon.svg" />
|
||||||
href="/favicon.svg" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<meta
|
<title>%VITE_APP_NAME%</title>
|
||||||
name="viewport"
|
</head>
|
||||||
content="width=device-width, initial-scale=1.0" />
|
|
||||||
<title>%VITE_APP_NAME%</title>
|
<body>
|
||||||
</head>
|
<div id="appLoading"></div>
|
||||||
<body>
|
<div id="app"></div>
|
||||||
<div id="appLoading"></div>
|
<script type="module" src="/src/main.ts"></script>
|
||||||
<div id="app"></div>
|
</body>
|
||||||
<script
|
|
||||||
type="module"
|
|
||||||
src="/src/main.ts"></script>
|
|
||||||
</body>
|
|
||||||
</html>
|
</html>
|
||||||
|
16
package.json
16
package.json
@ -24,7 +24,7 @@
|
|||||||
"admin-template",
|
"admin-template",
|
||||||
"vue-admin",
|
"vue-admin",
|
||||||
"vue-admin-template",
|
"vue-admin-template",
|
||||||
"Vite4",
|
"Vite5",
|
||||||
"Vite",
|
"Vite",
|
||||||
"vite-admin",
|
"vite-admin",
|
||||||
"TypeScript",
|
"TypeScript",
|
||||||
@ -44,17 +44,14 @@
|
|||||||
"build:dev": "vue-tsc --noEmit && vite build --mode dev",
|
"build:dev": "vue-tsc --noEmit && vite build --mode dev",
|
||||||
"build:test": "vue-tsc --noEmit && vite build --mode test",
|
"build:test": "vue-tsc --noEmit && vite build --mode test",
|
||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
"lint": "eslint . --fix",
|
"lint": "eslint .",
|
||||||
|
"lint:fix": "eslint . --fix",
|
||||||
"sizecheck": "npx vite-bundle-visualizer"
|
"sizecheck": "npx vite-bundle-visualizer"
|
||||||
},
|
},
|
||||||
"config": {
|
|
||||||
"commitizen": {
|
|
||||||
"path": "./node_modules/cz-customizable"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@tinymce/tinymce-vue": "^5.1.1",
|
"@tinymce/tinymce-vue": "^5.1.1",
|
||||||
"@vueuse/core": "^10.9.0",
|
"@vueuse/core": "^10.9.0",
|
||||||
|
"alova": "^2.17.1",
|
||||||
"axios": "^1.6.7",
|
"axios": "^1.6.7",
|
||||||
"crypto-js": "^4.2.0",
|
"crypto-js": "^4.2.0",
|
||||||
"echarts": "^5.5.0",
|
"echarts": "^5.5.0",
|
||||||
@ -91,6 +88,11 @@
|
|||||||
"vite-plugin-svg-icons": "^2.0.1",
|
"vite-plugin-svg-icons": "^2.0.1",
|
||||||
"vue-tsc": "^1.8.27"
|
"vue-tsc": "^1.8.27"
|
||||||
},
|
},
|
||||||
|
"workspaces": {
|
||||||
|
"packages": [
|
||||||
|
"packages/*"
|
||||||
|
]
|
||||||
|
},
|
||||||
"simple-git-hooks": {
|
"simple-git-hooks": {
|
||||||
"pre-commit": "pnpm lint-staged"
|
"pre-commit": "pnpm lint-staged"
|
||||||
},
|
},
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { mockRequest } from '../http'
|
import { alovaInstance } from '../http'
|
||||||
|
|
||||||
interface Ilogin {
|
interface Ilogin {
|
||||||
username: string
|
username: string
|
||||||
@ -6,14 +6,14 @@ interface Ilogin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function fetchLogin(params: Ilogin) {
|
export function fetchLogin(params: Ilogin) {
|
||||||
return mockRequest.post<any>('/login', params)
|
return alovaInstance.Post<any>('/login', params)
|
||||||
}
|
}
|
||||||
export function fetchUpdateToken(params: any) {
|
export function fetchUpdateToken(params: any) {
|
||||||
return mockRequest.post<ApiAuth.loginToken>('/updateToken', params)
|
return alovaInstance.Post<ApiAuth.loginToken>('/updateToken', params)
|
||||||
}
|
}
|
||||||
export function fetchUserInfo(params: any) {
|
export function fetchUserInfo(params: any) {
|
||||||
return mockRequest.get<Auth.UserInfo>('/getUserInfo', { params })
|
return alovaInstance.Get<Auth.UserInfo>('/getUserInfo', { params })
|
||||||
}
|
}
|
||||||
export function fetchUserRoutes(params: { id: number }) {
|
export function fetchUserRoutes(params: { id: number }) {
|
||||||
return mockRequest.get<AppRoute.Route[]>('/getUserRoutes', { params })
|
return alovaInstance.Get<AppRoute.Route[]>('/getUserRoutes', { params })
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { mockRequest } from '../http'
|
import { alovaInstance } from '../http'
|
||||||
|
|
||||||
export function fetchUserList() {
|
export function fetchUserList() {
|
||||||
return mockRequest.get('/userList')
|
return alovaInstance.Get('/userList')
|
||||||
}
|
}
|
||||||
|
@ -1,45 +1,45 @@
|
|||||||
import { mockRequest, request } from '../http'
|
import qs from 'qs'
|
||||||
|
import { alovaInstance } from '../http'
|
||||||
|
|
||||||
/* get方法测试 */
|
/* get方法测试 */
|
||||||
export function fetachGet(params?: any) {
|
export function fetachGet(params?: any) {
|
||||||
return request.get('/getAPI', { params })
|
return alovaInstance.Get('/getAPI', { params })
|
||||||
}
|
}
|
||||||
/* post方法测试 */
|
/* post方法测试 */
|
||||||
export function fetachPost(data: any) {
|
export function fetachPost(data: any) {
|
||||||
return request.post('/postAPI', data)
|
return alovaInstance.Post('/postAPI', data)
|
||||||
}
|
}
|
||||||
/* formPost方法测试 */
|
/* formPost方法测试 */
|
||||||
export function fetachFormPost(data: any) {
|
export function fetachFormPost(data: any) {
|
||||||
return request.formPost('/postAPI', data)
|
return alovaInstance.Post('/postAPI', qs.stringify(data), {
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/x-www-form-urlencoded',
|
||||||
|
},
|
||||||
|
})
|
||||||
}
|
}
|
||||||
/* delete方法测试 */
|
/* delete方法测试 */
|
||||||
export function fetachDelete() {
|
export function fetachDelete() {
|
||||||
return request.delete('/deleteAPI')
|
return alovaInstance.Delete('/deleteAPI')
|
||||||
}
|
}
|
||||||
/* put方法测试 */
|
/* put方法测试 */
|
||||||
export function fetachPut(data: any) {
|
export function fetachPut(data: any) {
|
||||||
return request.put('/putAPI', data)
|
return alovaInstance.Put('/putAPI', data)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 测试状态码500失败 */
|
/* 测试状态码500失败 */
|
||||||
export function testFailedRequest() {
|
export function testFailedRequest() {
|
||||||
return request.get('/filedRequest')
|
return alovaInstance.Get('/serverError')
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 测试业务码500失败 */
|
/* 测试业务码500失败 */
|
||||||
export function testFailedResponse() {
|
export function testFailedResponse() {
|
||||||
return request.get('/filedResponse')
|
return alovaInstance.Post('/businessError')
|
||||||
|
}
|
||||||
|
/* token失效的接口 */
|
||||||
|
export function expiredTokenRequest() {
|
||||||
|
return alovaInstance.Get('/expiredToken')
|
||||||
}
|
}
|
||||||
/* 测试token刷新接口 */
|
/* 测试token刷新接口 */
|
||||||
export function testUpdataToken() {
|
export function refreshToken() {
|
||||||
return request.get('/updataToken')
|
return alovaInstance.Get('/updataToken')
|
||||||
}
|
|
||||||
/* 测试token刷新接口 */
|
|
||||||
export function testFailedResponse_NT() {
|
|
||||||
return request.get('/failedResponse_NT')
|
|
||||||
}
|
|
||||||
|
|
||||||
/* mock方法测试 */
|
|
||||||
export function fetchMock() {
|
|
||||||
return mockRequest.post('/login')
|
|
||||||
}
|
}
|
||||||
|
83
src/service/http/alova.ts
Normal file
83
src/service/http/alova.ts
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
import type { Method } from 'alova'
|
||||||
|
import { createAlova } from 'alova'
|
||||||
|
import VueHook from 'alova/vue'
|
||||||
|
import GlobalFetch from 'alova/GlobalFetch'
|
||||||
|
import {
|
||||||
|
handleBusinessError,
|
||||||
|
handleRefreshToken,
|
||||||
|
handleResponseError,
|
||||||
|
handleServiceResult,
|
||||||
|
} from './handle'
|
||||||
|
import {
|
||||||
|
DEFAULT_ALOVA_OPTIONS,
|
||||||
|
DEFAULT_BACKEND_OPTIONS,
|
||||||
|
REFRESH_TOKEN_CODE,
|
||||||
|
} from './config'
|
||||||
|
import { local } from '@/utils'
|
||||||
|
|
||||||
|
// docs path of alova.js https://alova.js.org/
|
||||||
|
/**
|
||||||
|
* 前端alova的配置
|
||||||
|
*/
|
||||||
|
interface AlovaConfig {
|
||||||
|
baseURL: string
|
||||||
|
timeout?: number
|
||||||
|
beforeRequest?: (method: Method<globalThis.Ref<unknown>>) => void
|
||||||
|
}
|
||||||
|
|
||||||
|
export function createAlovaInstance(
|
||||||
|
alovaConfig: AlovaConfig,
|
||||||
|
backendConfig?: Service.BackendConfig,
|
||||||
|
) {
|
||||||
|
const _backendConfig = { ...DEFAULT_BACKEND_OPTIONS, ...backendConfig }
|
||||||
|
const _alovaConfig = { ...DEFAULT_ALOVA_OPTIONS, ...alovaConfig }
|
||||||
|
|
||||||
|
return createAlova({
|
||||||
|
statesHook: VueHook,
|
||||||
|
requestAdapter: GlobalFetch(),
|
||||||
|
localCache: null,
|
||||||
|
baseURL: _alovaConfig.baseURL,
|
||||||
|
timeout: _alovaConfig.timeout,
|
||||||
|
|
||||||
|
beforeRequest(method) {
|
||||||
|
// 添加token到请求头
|
||||||
|
method.config.headers.token = `Bearer ${local.get('token')}`
|
||||||
|
alovaConfig.beforeRequest?.(method)
|
||||||
|
},
|
||||||
|
|
||||||
|
responded: {
|
||||||
|
// 请求成功的拦截器
|
||||||
|
onSuccess: async (response, method) => {
|
||||||
|
const { status } = response
|
||||||
|
|
||||||
|
if (status === 200) {
|
||||||
|
// 获取返回的数据
|
||||||
|
const apiData = await response.json()
|
||||||
|
// 请求成功
|
||||||
|
if (apiData[_backendConfig.codeKey] === _backendConfig.successCode)
|
||||||
|
return handleServiceResult(apiData.data, null)
|
||||||
|
|
||||||
|
// token失效, 刷新token
|
||||||
|
if (REFRESH_TOKEN_CODE.includes(apiData[_backendConfig.codeKey])) {
|
||||||
|
await handleRefreshToken()
|
||||||
|
method.send()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 业务请求失败
|
||||||
|
const errorResult = handleBusinessError(apiData, _backendConfig)
|
||||||
|
return handleServiceResult(null, errorResult)
|
||||||
|
}
|
||||||
|
// 接口请求失败
|
||||||
|
const errorResult = handleResponseError(response)
|
||||||
|
return handleServiceResult(null, errorResult)
|
||||||
|
},
|
||||||
|
onError: (error, _method) => {
|
||||||
|
console.warn('🚀 ~ error:', error)
|
||||||
|
},
|
||||||
|
|
||||||
|
onComplete: async (_method) => {
|
||||||
|
// 处理请求完成逻辑
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
63
src/service/http/config.ts
Normal file
63
src/service/http/config.ts
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
/** 默认实例的Aixos配置 */
|
||||||
|
import type { AxiosRequestConfig } from 'axios'
|
||||||
|
|
||||||
|
export const DEFAULT_AXIOS_OPTIONS: AxiosRequestConfig = {
|
||||||
|
// 请求超时时间,默认15秒
|
||||||
|
timeout: 15 * 1000,
|
||||||
|
}
|
||||||
|
export const DEFAULT_ALOVA_OPTIONS: AxiosRequestConfig = {
|
||||||
|
// 请求超时时间,默认15秒
|
||||||
|
timeout: 15 * 1000,
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 默认实例的后端字段配置 */
|
||||||
|
export const DEFAULT_BACKEND_OPTIONS = {
|
||||||
|
codeKey: 'code',
|
||||||
|
dataKey: 'data',
|
||||||
|
msgKey: 'msg',
|
||||||
|
successCode: 200,
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 错误信息的显示时间 */
|
||||||
|
export const ERROR_MSG_DURATION = 3 * 1000
|
||||||
|
|
||||||
|
/** 默认的请求错误code */
|
||||||
|
export const DEFAULT_REQUEST_ERROR_CODE = 'DEFAULT'
|
||||||
|
|
||||||
|
/** 默认的请求错误文本 */
|
||||||
|
export const DEFAULT_REQUEST_ERROR_MSG = '请求错误~'
|
||||||
|
|
||||||
|
/** 请求超时的错误code */
|
||||||
|
export const REQUEST_TIMEOUT_CODE = 'TIME_OUT'
|
||||||
|
|
||||||
|
/** 请求超时的错误文本 */
|
||||||
|
export const REQUEST_TIMEOUT_MSG = '请求超时~'
|
||||||
|
|
||||||
|
/** 默认的请求错误code */
|
||||||
|
export const NETWORK_ERROR_CODE = 'NETWORK_ERROR'
|
||||||
|
|
||||||
|
/** 默认的请求错误文本 */
|
||||||
|
export const NETWORK_ERROR_MSG = '网络错误'
|
||||||
|
|
||||||
|
/** 请求不成功各种状态的错误 */
|
||||||
|
export const ERROR_STATUS = {
|
||||||
|
400: '400: 请求出现语法错误~',
|
||||||
|
401: '401: 用户未授权~',
|
||||||
|
403: '403: 服务器拒绝访问~',
|
||||||
|
404: '404: 请求的资源不存在~',
|
||||||
|
405: '405: 请求方法未允许~',
|
||||||
|
408: '408: 网络请求超时~',
|
||||||
|
500: '500: 服务器内部错误~',
|
||||||
|
501: '501: 服务器未实现请求功能~',
|
||||||
|
502: '502: 错误网关~',
|
||||||
|
503: '503: 服务不可用~',
|
||||||
|
504: '504: 网关超时~',
|
||||||
|
505: '505: http版本不支持该请求~',
|
||||||
|
[DEFAULT_REQUEST_ERROR_CODE]: DEFAULT_REQUEST_ERROR_MSG,
|
||||||
|
}
|
||||||
|
|
||||||
|
/** token刷新的code */
|
||||||
|
export const REFRESH_TOKEN_CODE = [888, 999]
|
||||||
|
|
||||||
|
/** 没有错误提示的code */
|
||||||
|
export const ERROR_NO_TIP_STATUS = [10000]
|
@ -1,4 +1,4 @@
|
|||||||
import type { AxiosError, AxiosRequestConfig, AxiosResponse } from 'axios'
|
import type { AxiosError } from 'axios'
|
||||||
import { showError } from './utils'
|
import { showError } from './utils'
|
||||||
import {
|
import {
|
||||||
DEFAULT_REQUEST_ERROR_CODE,
|
DEFAULT_REQUEST_ERROR_CODE,
|
||||||
@ -8,7 +8,7 @@ import {
|
|||||||
NETWORK_ERROR_MSG,
|
NETWORK_ERROR_MSG,
|
||||||
REQUEST_TIMEOUT_CODE,
|
REQUEST_TIMEOUT_CODE,
|
||||||
REQUEST_TIMEOUT_MSG,
|
REQUEST_TIMEOUT_MSG,
|
||||||
} from '@/config'
|
} from './config'
|
||||||
import { useAuthStore } from '@/store'
|
import { useAuthStore } from '@/store'
|
||||||
import { fetchUpdateToken } from '@/service'
|
import { fetchUpdateToken } from '@/service'
|
||||||
import { local } from '@/utils'
|
import { local } from '@/utils'
|
||||||
@ -20,9 +20,9 @@ type ErrorStatus = keyof typeof ERROR_STATUS
|
|||||||
* @param {AxiosError} err
|
* @param {AxiosError} err
|
||||||
* @return {*}
|
* @return {*}
|
||||||
*/
|
*/
|
||||||
export function handleAxiosError(err: AxiosError) {
|
export function handleFontEndError(err: AxiosError) {
|
||||||
const error: Service.RequestError = {
|
const error: Service.RequestError = {
|
||||||
type: 'Axios',
|
type: 'Alova',
|
||||||
code: DEFAULT_REQUEST_ERROR_CODE,
|
code: DEFAULT_REQUEST_ERROR_CODE,
|
||||||
msg: DEFAULT_REQUEST_ERROR_MSG,
|
msg: DEFAULT_REQUEST_ERROR_MSG,
|
||||||
}
|
}
|
||||||
@ -54,7 +54,7 @@ export function handleAxiosError(err: AxiosError) {
|
|||||||
* @param {AxiosResponse} response
|
* @param {AxiosResponse} response
|
||||||
* @return {*}
|
* @return {*}
|
||||||
*/
|
*/
|
||||||
export function handleResponseError(response: AxiosResponse) {
|
export function handleResponseError(response: Response) {
|
||||||
const error: Service.RequestError = {
|
const error: Service.RequestError = {
|
||||||
type: 'Axios',
|
type: 'Axios',
|
||||||
code: DEFAULT_REQUEST_ERROR_CODE,
|
code: DEFAULT_REQUEST_ERROR_CODE,
|
||||||
@ -83,7 +83,7 @@ export function handleResponseError(response: AxiosResponse) {
|
|||||||
* @param {Service} config axios字段配置
|
* @param {Service} config axios字段配置
|
||||||
* @return {*}
|
* @return {*}
|
||||||
*/
|
*/
|
||||||
export function handleBusinessError(data: Record<string, any>, config: Service.BackendResultConfig) {
|
export function handleBusinessError(data: Record<string, any>, config: Service.BackendConfig) {
|
||||||
const { codeKey, msgKey } = config
|
const { codeKey, msgKey } = config
|
||||||
const error: Service.RequestError = {
|
const error: Service.RequestError = {
|
||||||
type: 'Business',
|
type: 'Business',
|
||||||
@ -119,23 +119,18 @@ export function handleServiceResult<T = any>(data: any, error: Service.RequestEr
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @description: 处理接口token刷新
|
* @description: 处理接口token刷新
|
||||||
* @param {AxiosRequestConfig} config axios字段配置
|
|
||||||
* @return {*}
|
* @return {*}
|
||||||
*/
|
*/
|
||||||
export async function handleRefreshToken(config: AxiosRequestConfig) {
|
export async function handleRefreshToken() {
|
||||||
const authStore = useAuthStore()
|
const authStore = useAuthStore()
|
||||||
const refreshToken = local.get('refreshToken')
|
const refreshToken = local.get('refreshToken')
|
||||||
const { data } = await fetchUpdateToken(refreshToken)
|
const { data } = await fetchUpdateToken(refreshToken)
|
||||||
if (data) {
|
if (data) {
|
||||||
local.set('refreshToken', data.accessToken)
|
local.set('token', data.accessToken)
|
||||||
local.set('token', data.refreshToken)
|
local.set('refreshToken', data.refreshToken)
|
||||||
|
}
|
||||||
// 设置token
|
else {
|
||||||
if (config.headers)
|
// 刷新失败,推出
|
||||||
typeof config.headers.set === 'function' && config.headers.set('Authorization', `Bearer ${data.accessToken || ''}`)
|
await authStore.resetAuthStore()
|
||||||
|
|
||||||
return config
|
|
||||||
}
|
}
|
||||||
await authStore.resetAuthStore()
|
|
||||||
return null
|
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { createRequest } from './request'
|
import { createRequest } from './request'
|
||||||
|
import { createAlovaInstance } from './alova'
|
||||||
import { proxyConfig } from '@/config'
|
import { proxyConfig } from '@/config'
|
||||||
|
|
||||||
const { url, urlPattern } = proxyConfig[import.meta.env.MODE]
|
const { url, urlPattern } = proxyConfig[import.meta.env.MODE]
|
||||||
@ -15,3 +16,7 @@ export const request = createRequest({
|
|||||||
export const mockRequest = createRequest({ baseURL: 'https://mock.apifox.com/m1/4071143-0-default' }, {
|
export const mockRequest = createRequest({ baseURL: 'https://mock.apifox.com/m1/4071143-0-default' }, {
|
||||||
msgKey: 'message',
|
msgKey: 'message',
|
||||||
})
|
})
|
||||||
|
|
||||||
|
export const alovaInstance = createAlovaInstance({
|
||||||
|
baseURL: 'https://mock.apifox.com/m1/4071143-0-default',
|
||||||
|
})
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
import type { AxiosError, AxiosInstance, AxiosRequestConfig } from 'axios'
|
import type { AxiosError, AxiosInstance, AxiosRequestConfig } from 'axios'
|
||||||
import {
|
import {
|
||||||
handleAxiosError,
|
|
||||||
handleBusinessError,
|
handleBusinessError,
|
||||||
|
handleFontEndError,
|
||||||
handleRefreshToken,
|
handleRefreshToken,
|
||||||
handleResponseError,
|
handleResponseError,
|
||||||
handleServiceResult,
|
handleServiceResult,
|
||||||
} from './handle'
|
} from './handle'
|
||||||
import { clearInvalidParameters, transformRequestData } from './utils'
|
import { clearInvalidParameters, transformRequestData } from './utils'
|
||||||
|
import { DEFAULT_AXIOS_OPTIONS, DEFAULT_BACKEND_OPTIONS, REFRESH_TOKEN_CODE } from './config'
|
||||||
import { local } from '@/utils'
|
import { local } from '@/utils'
|
||||||
import { DEFAULT_AXIOS_OPTIONS, DEFAULT_BACKEND_OPTIONS, REFRESH_TOKEN_CODE } from '@/config'
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description: 封装axios请求类
|
* @description: 封装axios请求类
|
||||||
@ -18,11 +18,11 @@ export default class CreateAxiosInstance {
|
|||||||
// axios 实例
|
// axios 实例
|
||||||
instance: AxiosInstance
|
instance: AxiosInstance
|
||||||
// 后台字段配置
|
// 后台字段配置
|
||||||
backendConfig: Service.BackendResultConfig
|
backendConfig: Service.BackendConfig
|
||||||
// 基础配置
|
// 基础配置
|
||||||
axiosConfig: AxiosRequestConfig = {}
|
axiosConfig: AxiosRequestConfig = {}
|
||||||
|
|
||||||
constructor(axiosConfig: AxiosRequestConfig, backendConfig: Partial<Service.BackendResultConfig> = DEFAULT_BACKEND_OPTIONS) {
|
constructor(axiosConfig: AxiosRequestConfig, backendConfig: Partial<Service.BackendConfig> = DEFAULT_BACKEND_OPTIONS) {
|
||||||
// 设置了axios实例上的一些默认配置,新配置会覆盖默认配置
|
// 设置了axios实例上的一些默认配置,新配置会覆盖默认配置
|
||||||
this.backendConfig = { ...DEFAULT_BACKEND_OPTIONS, ...backendConfig }
|
this.backendConfig = { ...DEFAULT_BACKEND_OPTIONS, ...backendConfig }
|
||||||
this.instance = axios.create({ ...DEFAULT_AXIOS_OPTIONS, ...axiosConfig })
|
this.instance = axios.create({ ...DEFAULT_AXIOS_OPTIONS, ...axiosConfig })
|
||||||
@ -48,7 +48,7 @@ export default class CreateAxiosInstance {
|
|||||||
return handleConfig
|
return handleConfig
|
||||||
},
|
},
|
||||||
(error: AxiosError) => {
|
(error: AxiosError) => {
|
||||||
const errorResult = handleAxiosError(error)
|
const errorResult = handleFontEndError(error)
|
||||||
return handleServiceResult(null, errorResult)
|
return handleServiceResult(null, errorResult)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@ -79,7 +79,7 @@ export default class CreateAxiosInstance {
|
|||||||
},
|
},
|
||||||
(error: AxiosError) => {
|
(error: AxiosError) => {
|
||||||
// 处理http常见错误,进行全局提示等
|
// 处理http常见错误,进行全局提示等
|
||||||
const errorResult = handleAxiosError(error)
|
const errorResult = handleFontEndError(error)
|
||||||
return handleServiceResult(null, errorResult)
|
return handleServiceResult(null, errorResult)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
@ -34,7 +34,7 @@ async function getRequestResponse(options: {
|
|||||||
*/
|
*/
|
||||||
export function createRequest(
|
export function createRequest(
|
||||||
axiosConfig: AxiosRequestConfig,
|
axiosConfig: AxiosRequestConfig,
|
||||||
backendConfig?: Partial<Service.BackendResultConfig>,
|
backendConfig?: Partial<Service.BackendConfig>,
|
||||||
) {
|
) {
|
||||||
const axiosInstance = new CreateAxiosInstance(axiosConfig, backendConfig)
|
const axiosInstance = new CreateAxiosInstance(axiosConfig, backendConfig)
|
||||||
/**
|
/**
|
||||||
|
@ -54,7 +54,7 @@ function handleFormData(data: Record<string, any>) {
|
|||||||
* 接口提交的参数去除无效字段
|
* 接口提交的参数去除无效字段
|
||||||
* @param requestData -接口提交的参数
|
* @param requestData -接口提交的参数
|
||||||
*/
|
*/
|
||||||
export function clearInvalidParameters(requestData: Record<string, any>) {
|
export function clearInvalidParameters(requestData?: Record<string, any>) {
|
||||||
const result: Record<string, any> = {}
|
const result: Record<string, any> = {}
|
||||||
for (const key in requestData) {
|
for (const key in requestData) {
|
||||||
if (isEmpty(requestData[key]) || isNullOrUnDef(requestData[key]))
|
if (isEmpty(requestData[key]) || isNullOrUnDef(requestData[key]))
|
||||||
|
5
src/typings/service.d.ts
vendored
5
src/typings/service.d.ts
vendored
@ -1,7 +1,8 @@
|
|||||||
/** 请求的相关类型 */
|
/** 请求的相关类型 */
|
||||||
declare namespace Service {
|
declare namespace Service {
|
||||||
|
|
||||||
/** 后端接口返回的数据结构配置 */
|
/** 后端接口返回的数据结构配置 */
|
||||||
interface BackendResultConfig {
|
interface BackendConfig {
|
||||||
/** 表示后端请求状态码的属性字段 */
|
/** 表示后端请求状态码的属性字段 */
|
||||||
codeKey: string
|
codeKey: string
|
||||||
/** 表示后端请求数据的属性字段 */
|
/** 表示后端请求数据的属性字段 */
|
||||||
@ -12,7 +13,7 @@ declare namespace Service {
|
|||||||
successCode: number | string
|
successCode: number | string
|
||||||
}
|
}
|
||||||
|
|
||||||
type RequestErrorType = 'Axios' | 'Response' | 'Business'
|
type RequestErrorType = 'Axios' | 'Alova' | 'Response' | 'Business'
|
||||||
type RequestCode = string | number
|
type RequestCode = string | number
|
||||||
|
|
||||||
interface RequestError {
|
interface RequestError {
|
||||||
|
@ -19,7 +19,7 @@ const model = ref({ ...initialModel })
|
|||||||
|
|
||||||
const formRef = ref<FormInst | null>()
|
const formRef = ref<FormInst | null>()
|
||||||
function sendMail(id: number) {
|
function sendMail(id: number) {
|
||||||
window.$message?.success(`用户id:${id}`)
|
window.$message?.success(`删除用户id:${id}`)
|
||||||
}
|
}
|
||||||
const columns: DataTableColumns = [
|
const columns: DataTableColumns = [
|
||||||
{
|
{
|
||||||
@ -166,63 +166,24 @@ function handleAddTable() {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<NSpace
|
<NSpace vertical size="large">
|
||||||
vertical
|
|
||||||
size="large"
|
|
||||||
>
|
|
||||||
<n-card>
|
<n-card>
|
||||||
<n-form
|
<n-form ref="formRef" :model="model" label-placement="left" :show-feedback="false">
|
||||||
ref="formRef"
|
<n-grid :x-gap="30" :cols="18">
|
||||||
:model="model"
|
<n-form-item-gi :span="4" label="姓名" path="condition_1">
|
||||||
label-placement="left"
|
<n-input v-model:value="model.condition_1" placeholder="请输入" />
|
||||||
:show-feedback="false"
|
|
||||||
>
|
|
||||||
<n-grid
|
|
||||||
:x-gap="30"
|
|
||||||
:cols="18"
|
|
||||||
>
|
|
||||||
<n-form-item-gi
|
|
||||||
:span="4"
|
|
||||||
label="姓名"
|
|
||||||
path="condition_1"
|
|
||||||
>
|
|
||||||
<n-input
|
|
||||||
v-model:value="model.condition_1"
|
|
||||||
placeholder="请输入"
|
|
||||||
/>
|
|
||||||
</n-form-item-gi>
|
</n-form-item-gi>
|
||||||
<n-form-item-gi
|
<n-form-item-gi :span="4" label="年龄" path="condition_2">
|
||||||
:span="4"
|
<n-input v-model:value="model.condition_2" placeholder="请输入" />
|
||||||
label="年龄"
|
|
||||||
path="condition_2"
|
|
||||||
>
|
|
||||||
<n-input
|
|
||||||
v-model:value="model.condition_2"
|
|
||||||
placeholder="请输入"
|
|
||||||
/>
|
|
||||||
</n-form-item-gi>
|
</n-form-item-gi>
|
||||||
<n-form-item-gi
|
<n-form-item-gi :span="4" label="性别" path="condition_3">
|
||||||
:span="4"
|
<n-input v-model:value="model.condition_3" placeholder="请输入" />
|
||||||
label="性别"
|
|
||||||
path="condition_3"
|
|
||||||
>
|
|
||||||
<n-input
|
|
||||||
v-model:value="model.condition_3"
|
|
||||||
placeholder="请输入"
|
|
||||||
/>
|
|
||||||
</n-form-item-gi>
|
</n-form-item-gi>
|
||||||
<n-form-item-gi
|
<n-form-item-gi :span="4" label="地址" path="condition_4">
|
||||||
:span="4"
|
<n-input v-model:value="model.condition_4" placeholder="请输入" />
|
||||||
label="地址"
|
|
||||||
path="condition_4"
|
|
||||||
>
|
|
||||||
<n-input
|
|
||||||
v-model:value="model.condition_4"
|
|
||||||
placeholder="请输入"
|
|
||||||
/>
|
|
||||||
</n-form-item-gi>
|
</n-form-item-gi>
|
||||||
<n-gi :span="1">
|
<n-gi :span="1">
|
||||||
<NButton type="primary">
|
<NButton type="primary" @click="getUserList">
|
||||||
<template #icon>
|
<template #icon>
|
||||||
<i-icon-park-outline-search />
|
<i-icon-park-outline-search />
|
||||||
</template>
|
</template>
|
||||||
@ -230,11 +191,7 @@ function handleAddTable() {
|
|||||||
</NButton>
|
</NButton>
|
||||||
</n-gi>
|
</n-gi>
|
||||||
<n-gi :span="1">
|
<n-gi :span="1">
|
||||||
<NButton
|
<NButton strong secondary @click="handleResetSearch">
|
||||||
strong
|
|
||||||
secondary
|
|
||||||
@click="handleResetSearch"
|
|
||||||
>
|
|
||||||
<template #icon>
|
<template #icon>
|
||||||
<i-icon-park-outline-redo />
|
<i-icon-park-outline-redo />
|
||||||
</template>
|
</template>
|
||||||
@ -245,54 +202,30 @@ function handleAddTable() {
|
|||||||
</n-form>
|
</n-form>
|
||||||
</n-card>
|
</n-card>
|
||||||
<n-card>
|
<n-card>
|
||||||
<NSpace
|
<NSpace vertical size="large">
|
||||||
vertical
|
|
||||||
size="large"
|
|
||||||
>
|
|
||||||
<div class="flex gap-4">
|
<div class="flex gap-4">
|
||||||
<NButton
|
<NButton type="primary" @click="handleAddTable">
|
||||||
type="primary"
|
|
||||||
@click="handleAddTable"
|
|
||||||
>
|
|
||||||
<template #icon>
|
<template #icon>
|
||||||
<i-icon-park-outline-add-one />
|
<i-icon-park-outline-add-one />
|
||||||
</template>
|
</template>
|
||||||
新建
|
新建
|
||||||
</NButton>
|
</NButton>
|
||||||
<NButton
|
<NButton strong secondary>
|
||||||
strong
|
|
||||||
secondary
|
|
||||||
>
|
|
||||||
<template #icon>
|
<template #icon>
|
||||||
<i-icon-park-outline-afferent />
|
<i-icon-park-outline-afferent />
|
||||||
</template>
|
</template>
|
||||||
批量导入
|
批量导入
|
||||||
</NButton>
|
</NButton>
|
||||||
<NButton
|
<NButton strong secondary class="ml-a">
|
||||||
strong
|
|
||||||
secondary
|
|
||||||
class="ml-a"
|
|
||||||
>
|
|
||||||
<template #icon>
|
<template #icon>
|
||||||
<i-icon-park-outline-download />
|
<i-icon-park-outline-download />
|
||||||
</template>
|
</template>
|
||||||
下载
|
下载
|
||||||
</NButton>
|
</NButton>
|
||||||
</div>
|
</div>
|
||||||
<n-data-table
|
<n-data-table :columns="columns" :data="listData" :loading="loading" />
|
||||||
:columns="columns"
|
<Pagination :count="100" @change="changePage" />
|
||||||
:data="listData"
|
<TableModal v-model:visible="visible" :type="modalType" :modal-data="editData" />
|
||||||
:loading="loading"
|
|
||||||
/>
|
|
||||||
<Pagination
|
|
||||||
:count="100"
|
|
||||||
@change="changePage"
|
|
||||||
/>
|
|
||||||
<TableModal
|
|
||||||
v-model:visible="visible"
|
|
||||||
:type="modalType"
|
|
||||||
:modal-data="editData"
|
|
||||||
/>
|
|
||||||
</NSpace>
|
</NSpace>
|
||||||
</n-card>
|
</n-card>
|
||||||
</NSpace>
|
</NSpace>
|
||||||
|
@ -1,18 +1,19 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import {
|
import {
|
||||||
|
expiredTokenRequest,
|
||||||
fetachDelete,
|
fetachDelete,
|
||||||
fetachFormPost,
|
fetachFormPost,
|
||||||
fetachGet,
|
fetachGet,
|
||||||
fetachPost,
|
fetachPost,
|
||||||
fetachPut,
|
fetachPut,
|
||||||
fetchMock,
|
fetchUpdateToken,
|
||||||
testFailedRequest,
|
testFailedRequest,
|
||||||
testFailedResponse,
|
testFailedResponse,
|
||||||
testFailedResponse_NT,
|
testFailedResponse_NT,
|
||||||
testUpdataToken,
|
|
||||||
} from '@/service'
|
} from '@/service'
|
||||||
|
|
||||||
const msg = ref()
|
const msg = ref()
|
||||||
|
|
||||||
function pinter() {
|
function pinter() {
|
||||||
msg.value = import.meta.env
|
msg.value = import.meta.env
|
||||||
}
|
}
|
||||||
@ -75,14 +76,15 @@ function failedResponse_NT() {
|
|||||||
msg.value = res
|
msg.value = res
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
// 测试刷新token
|
// token过期
|
||||||
function updataToken() {
|
function expiredToken() {
|
||||||
testUpdataToken().then((res) => {
|
expiredTokenRequest().then((res) => {
|
||||||
msg.value = res
|
msg.value = res
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
function mock() {
|
// 刷新token
|
||||||
fetchMock().then((res) => {
|
function updataToken() {
|
||||||
|
fetchUpdateToken('test token').then((res) => {
|
||||||
msg.value = res
|
msg.value = res
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -92,96 +94,44 @@ function mock() {
|
|||||||
<div>
|
<div>
|
||||||
<n-h1>接口功能测试</n-h1>
|
<n-h1>接口功能测试</n-h1>
|
||||||
<n-space>
|
<n-space>
|
||||||
<n-button
|
<n-button strong secondary type="success" @click="pinter">
|
||||||
strong
|
|
||||||
secondary
|
|
||||||
type="success"
|
|
||||||
@click="pinter"
|
|
||||||
>
|
|
||||||
check env
|
check env
|
||||||
</n-button>
|
</n-button>
|
||||||
<n-button
|
<n-button strong secondary type="success" @click="get">
|
||||||
strong
|
|
||||||
secondary
|
|
||||||
type="success"
|
|
||||||
@click="get"
|
|
||||||
>
|
|
||||||
use online get
|
use online get
|
||||||
</n-button>
|
</n-button>
|
||||||
<n-button
|
<n-button strong secondary type="success" @click="post">
|
||||||
strong
|
|
||||||
secondary
|
|
||||||
type="success"
|
|
||||||
@click="post"
|
|
||||||
>
|
|
||||||
use online post
|
use online post
|
||||||
</n-button>
|
</n-button>
|
||||||
<n-button
|
<n-button strong secondary type="success" @click="formPost">
|
||||||
strong
|
|
||||||
secondary
|
|
||||||
type="success"
|
|
||||||
@click="formPost"
|
|
||||||
>
|
|
||||||
use online formPost
|
use online formPost
|
||||||
</n-button>
|
</n-button>
|
||||||
<n-button
|
<n-button strong secondary type="success" @click="delete2">
|
||||||
strong
|
|
||||||
secondary
|
|
||||||
type="success"
|
|
||||||
@click="delete2"
|
|
||||||
>
|
|
||||||
use online delete
|
use online delete
|
||||||
</n-button>
|
</n-button>
|
||||||
<n-button
|
<n-button strong secondary type="success" @click="put">
|
||||||
strong
|
|
||||||
secondary
|
|
||||||
type="success"
|
|
||||||
@click="put"
|
|
||||||
>
|
|
||||||
use online put
|
use online put
|
||||||
</n-button>
|
</n-button>
|
||||||
<n-button
|
<n-button strong secondary type="error" @click="failedRequest">
|
||||||
strong
|
失败-错误状态码
|
||||||
secondary
|
|
||||||
type="success"
|
|
||||||
@click="mock"
|
|
||||||
>
|
|
||||||
to use mock
|
|
||||||
</n-button>
|
</n-button>
|
||||||
<n-button
|
<n-button strong secondary type="error" @click="failedResponse">
|
||||||
strong
|
失败-错误业务码
|
||||||
secondary
|
|
||||||
type="error"
|
|
||||||
@click="failedRequest"
|
|
||||||
>
|
|
||||||
请求失败
|
|
||||||
</n-button>
|
</n-button>
|
||||||
<n-button
|
<n-button strong secondary type="error" @click="failedResponse_NT">
|
||||||
strong
|
|
||||||
secondary
|
|
||||||
type="error"
|
|
||||||
@click="failedResponse"
|
|
||||||
>
|
|
||||||
响应失败
|
|
||||||
</n-button>
|
|
||||||
<n-button
|
|
||||||
strong
|
|
||||||
secondary
|
|
||||||
type="error"
|
|
||||||
@click="failedResponse_NT"
|
|
||||||
>
|
|
||||||
响应失败(无提示)
|
响应失败(无提示)
|
||||||
</n-button>
|
</n-button>
|
||||||
<n-button
|
<n-button strong secondary @click="expiredToken">
|
||||||
strong
|
token 过期
|
||||||
secondary
|
</n-button>
|
||||||
@click="updataToken"
|
<n-button strong secondary @click="updataToken">
|
||||||
>
|
refresh token
|
||||||
测试刷新token接口
|
|
||||||
</n-button>
|
</n-button>
|
||||||
</n-space>
|
</n-space>
|
||||||
|
|
||||||
{{ msg }}
|
<pre>
|
||||||
|
{{ msg }}
|
||||||
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user