提交 8a80f12b 编写于 作者: View Design's avatar View Design

Update useRequest.js

上级 9363212f
const BASE_URL = 'https://gpu-pod656e861afe3d944d6b3ce77e-7862.node.inscode.run'
const request = async (url, options = {}) => {
const token = useCookie('token')
const fullUrl = BASE_URL + url
......@@ -20,6 +19,21 @@ const request = async (url, options = {}) => {
},
onResponseError({ request, response, options }) {
const status = response.status
if (process.client && (status === 401 || status === 403)) {
let title
if (status === 401) title = '抱歉,您没有权限操作'
else if (status === 403) title = '抱歉,您没有权限访问当前内容'
nextTick(() => {
const toast = useToast()
toast.add({
icon: 'i-heroicons-exclamation-triangle-20-solid',
timeout: 3000,
title: title,
color: 'red'
})
})
}
// 处理响应错误
console.log('[ResponseError]', request)
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册