mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-11-19 22:53:41 +08:00
🐛 fix: exception handling
This commit is contained in:
@@ -13,7 +13,7 @@ API.interceptors.response.use(
|
||||
if (error.response?.status === 401) {
|
||||
localStorage.removeItem('user');
|
||||
store.dispatch({ type: LOGIN, payload: null });
|
||||
window.location.href = '/login';
|
||||
// window.location.href = '/login';
|
||||
}
|
||||
|
||||
if (error.response?.data?.message) {
|
||||
|
||||
@@ -70,12 +70,16 @@ export function showInfo(message) {
|
||||
}
|
||||
|
||||
export async function getOAuthState() {
|
||||
const res = await API.get('/api/oauth/state');
|
||||
const { success, message, data } = res.data;
|
||||
if (success) {
|
||||
return data;
|
||||
} else {
|
||||
showError(message);
|
||||
try {
|
||||
const res = await API.get('/api/oauth/state');
|
||||
const { success, message, data } = res.data;
|
||||
if (success) {
|
||||
return data;
|
||||
} else {
|
||||
showError(message);
|
||||
return '';
|
||||
}
|
||||
} catch (error) {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user