mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-12-15 04:25:57 +08:00
feat: add new theme berry (#860)
* feat: add theme berry * docs: add development notes * fix: fix blank page * chore: update implementation * fix: fix package.json * chore: update ui copy --------- Co-authored-by: JustSong <songquanpeng@foxmail.com>
This commit is contained in:
26
web/berry/src/utils/api.js
Normal file
26
web/berry/src/utils/api.js
Normal file
@@ -0,0 +1,26 @@
|
||||
import { showError } from './common';
|
||||
import axios from 'axios';
|
||||
import { store } from 'store/index';
|
||||
import { LOGIN } from 'store/actions';
|
||||
import config from 'config';
|
||||
|
||||
export const API = axios.create({
|
||||
baseURL: process.env.REACT_APP_SERVER ? process.env.REACT_APP_SERVER : '/'
|
||||
});
|
||||
|
||||
API.interceptors.response.use(
|
||||
(response) => response,
|
||||
(error) => {
|
||||
if (error.response?.status === 401) {
|
||||
localStorage.removeItem('user');
|
||||
store.dispatch({ type: LOGIN, payload: null });
|
||||
window.location.href = config.basename + '/login';
|
||||
}
|
||||
|
||||
if (error.response?.data?.message) {
|
||||
error.message = error.response.data.message;
|
||||
}
|
||||
|
||||
showError(error);
|
||||
}
|
||||
);
|
||||
Reference in New Issue
Block a user