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