修改bug
parent
50ee303575
commit
f940314827
|
|
@ -1,7 +1,12 @@
|
|||
|
||||
import axios from 'axios'
|
||||
import { localCache } from '@/io/cache'
|
||||
import { showToast } from 'vant';
|
||||
import { showToast } from 'vant'
|
||||
|
||||
import { useAuthModal } from '@/stores/authModal';
|
||||
|
||||
|
||||
|
||||
const service = axios.create({
|
||||
baseURL: import.meta.env.VITE_API_BASE_URL,
|
||||
timeout: 200000,
|
||||
|
|
@ -32,11 +37,19 @@ service.interceptors.response.use(
|
|||
response => {
|
||||
const { requestBaseUrl } = response.config
|
||||
const res = response.data
|
||||
const authModal = useAuthModal();
|
||||
if (requestBaseUrl == 'chat') {
|
||||
return res
|
||||
} else {
|
||||
if (res.status != 0) {
|
||||
showToast(res.msg || 'Error')
|
||||
if (res.status == 401) {
|
||||
authModal.setAuthModalType('login');
|
||||
authModal.showAuthModal();
|
||||
localCache.remove('auth');
|
||||
localCache.remove('userInfo');
|
||||
} else {
|
||||
showToast(res.msg || 'Error')
|
||||
}
|
||||
return Promise.reject(res.message || 'Error')
|
||||
} else {
|
||||
return res.data
|
||||
|
|
@ -44,14 +57,21 @@ service.interceptors.response.use(
|
|||
}
|
||||
},
|
||||
error => {
|
||||
const res = error.response.data
|
||||
const authModal = useAuthModal();
|
||||
|
||||
if (error.message == 'canceled') return Promise.reject(error)
|
||||
const res = error.response?.data
|
||||
|
||||
const { requestBaseUrl } = error.config
|
||||
if (requestBaseUrl == 'chat') {
|
||||
if (res.errcode == 401) {
|
||||
// localCache.remove('auth');
|
||||
// localCache.remove('userInfo');
|
||||
authModal.setAuthModalType('login');
|
||||
authModal.showAuthModal();
|
||||
localCache.remove('auth');
|
||||
localCache.remove('userInfo');
|
||||
} else {
|
||||
showToast(res.errmsg || 'Error')
|
||||
}
|
||||
showToast(res.errmsg || 'Error')
|
||||
return Promise.reject(res)
|
||||
} else {
|
||||
|
||||
|
|
|
|||
|
|
@ -187,6 +187,9 @@ const autoMessage = async () => {
|
|||
)
|
||||
|
||||
if (loading.value) return
|
||||
|
||||
controller = new AbortController()
|
||||
|
||||
contentLoading.value = true
|
||||
loading.value = true
|
||||
try {
|
||||
|
|
@ -259,6 +262,7 @@ const sendMessage = async () => {
|
|||
inversion: false,
|
||||
loading: true,
|
||||
})
|
||||
controller = new AbortController()
|
||||
prompt.value = ''
|
||||
loading.value = true
|
||||
scrollToBottom()
|
||||
|
|
|
|||
|
|
@ -170,7 +170,7 @@ async function onConversation(action = 'next') {
|
|||
let message = inputValue.value
|
||||
if (loading.value) return
|
||||
if ((!message || message.trim() === '') && action == 'next') return
|
||||
|
||||
controller = new AbortController()
|
||||
const params = {
|
||||
action: action,
|
||||
conversation_id: chatStore.active,
|
||||
|
|
|
|||
Loading…
Reference in New Issue