This commit is contained in:
2026-08-28 17:31:02 +02:00
commit 2b30e8bd39
694 changed files with 49243 additions and 0 deletions
+39
View File
@@ -0,0 +1,39 @@
import axios, { type AxiosError, HttpStatusCode } from 'axios';
import { ElMessage } from 'element-plus';
import router from '@/router';
import { ROUTE_NAMES } from '@/consts/routeNames';
import { useAuthStore } from '@/stores/auth';
import { config } from '@/config';
export const api = axios.create({
baseURL: config.api.baseUrl,
withCredentials: true
});
api.interceptors.response.use(
response => response,
(error: AxiosError) => {
const status = error.response?.status;
const url = error.config?.url ?? '';
if (status === HttpStatusCode.Unauthorized && !url.includes('/auth/login')) {
ElMessage.error('Your session ended. Please sign in again.');
const { clearSession } = useAuthStore();
clearSession();
router.push({ name: ROUTE_NAMES.Login });
}
if (status === HttpStatusCode.Forbidden) {
ElMessage.error('You do not have access to this resource.');
}
if (status === HttpStatusCode.TooManyRequests) {
ElMessage.error('Too many requests. Please slow down and try again.');
}
return Promise.reject(error);
}
);
+6
View File
@@ -0,0 +1,6 @@
import dayjs from 'dayjs';
import relativeTime from 'dayjs/plugin/relativeTime';
dayjs.extend(relativeTime);
export default dayjs;