Полная зачистка legacy + закрытие fix24.1/fix24.2 + обновление логотипа
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
import axios, { InternalAxiosRequestConfig, AxiosResponse } from "axios";
|
||||
import { useAccountStoreHook } from "@/store/modules/account";
|
||||
import { useAdminStoreHook } from "@/store/modules/admin";
|
||||
import i18n from "@/lang/index";
|
||||
|
||||
const dynamicBase = (window as any).__dynamic_base__ || "";
|
||||
const API_BASE = "/hui";
|
||||
const t = i18n.global.t;
|
||||
// Создание axios instance
|
||||
const service = axios.create({
|
||||
baseURL: `${dynamicBase}${API_BASE}`,
|
||||
@@ -13,9 +15,9 @@ const service = axios.create({
|
||||
// Request interceptor
|
||||
service.interceptors.request.use(
|
||||
(config: InternalAxiosRequestConfig) => {
|
||||
const accountStore = useAccountStoreHook();
|
||||
if (accountStore.token) {
|
||||
config.headers.Authorization = accountStore.token;
|
||||
const adminStore = useAdminStoreHook();
|
||||
if (adminStore.token) {
|
||||
config.headers.Authorization = adminStore.token;
|
||||
}
|
||||
return config;
|
||||
},
|
||||
@@ -44,8 +46,8 @@ service.interceptors.response.use(
|
||||
const { code, msg } = error.response.data;
|
||||
// Token истёк, нужен повторный вход
|
||||
if (code === "A0230") {
|
||||
ElMessageBox.confirm("Текущая сессия истекла, войдите снова", "Подтверждение", {
|
||||
confirmButtonText: "ОК",
|
||||
ElMessageBox.confirm(t("common.sessionExpired"), t("common.warning"), {
|
||||
confirmButtonText: t("common.confirm"),
|
||||
type: "warning",
|
||||
}).then(() => {
|
||||
localStorage.clear();
|
||||
@@ -61,5 +63,3 @@ service.interceptors.response.use(
|
||||
|
||||
// Export axios instance
|
||||
export default service;
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user