chore: prettier & lint
Former-commit-id: 486f65e137348f400d7b95067bd3cd5a2f23ff44
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
// translate router.meta.title, be used in breadcrumb sidebar tagsview
|
||||
import i18n from '@/lang/index';
|
||||
import i18n from "@/lang/index";
|
||||
|
||||
export function translateRouteTitleI18n(title: any) {
|
||||
// 判断是否存在国际化配置,如果没有原生返回
|
||||
const hasKey = i18n.global.te('route.' + title);
|
||||
const hasKey = i18n.global.te("route." + title);
|
||||
if (hasKey) {
|
||||
const translatedTitle = i18n.global.t('route.' + title);
|
||||
const translatedTitle = i18n.global.t("route." + title);
|
||||
return translatedTitle;
|
||||
}
|
||||
return title;
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import axios, { InternalAxiosRequestConfig, AxiosResponse } from 'axios';
|
||||
import { useUserStoreHook } from '@/store/modules/user';
|
||||
import axios, { InternalAxiosRequestConfig, AxiosResponse } from "axios";
|
||||
import { useUserStoreHook } from "@/store/modules/user";
|
||||
|
||||
// 创建 axios 实例
|
||||
const service = axios.create({
|
||||
baseURL: import.meta.env.VITE_APP_BASE_API,
|
||||
timeout: 50000,
|
||||
headers: { 'Content-Type': 'application/json;charset=utf-8' }
|
||||
headers: { "Content-Type": "application/json;charset=utf-8" },
|
||||
});
|
||||
|
||||
// 请求拦截器
|
||||
@@ -26,7 +26,7 @@ service.interceptors.request.use(
|
||||
service.interceptors.response.use(
|
||||
(response: AxiosResponse) => {
|
||||
const { code, msg } = response.data;
|
||||
if (code === '00000') {
|
||||
if (code === "00000") {
|
||||
return response.data;
|
||||
}
|
||||
// 响应数据为二进制流处理(Excel导出)
|
||||
@@ -34,23 +34,23 @@ service.interceptors.response.use(
|
||||
return response;
|
||||
}
|
||||
|
||||
ElMessage.error(msg || '系统出错');
|
||||
return Promise.reject(new Error(msg || 'Error'));
|
||||
ElMessage.error(msg || "系统出错");
|
||||
return Promise.reject(new Error(msg || "Error"));
|
||||
},
|
||||
(error: any) => {
|
||||
if (error.response.data) {
|
||||
const { code, msg } = error.response.data;
|
||||
// token 过期,重新登录
|
||||
if (code === 'A0230') {
|
||||
ElMessageBox.confirm('当前页面已失效,请重新登录', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
type: 'warning'
|
||||
if (code === "A0230") {
|
||||
ElMessageBox.confirm("当前页面已失效,请重新登录", "提示", {
|
||||
confirmButtonText: "确定",
|
||||
type: "warning",
|
||||
}).then(() => {
|
||||
localStorage.clear();
|
||||
window.location.href = '/';
|
||||
window.location.href = "/";
|
||||
});
|
||||
} else {
|
||||
ElMessage.error(msg || '系统出错');
|
||||
ElMessage.error(msg || "系统出错");
|
||||
}
|
||||
}
|
||||
return Promise.reject(error.message);
|
||||
|
||||
@@ -47,7 +47,7 @@ export const scrollTo = (to: number, duration: number, callback?: any) => {
|
||||
const change = to - start;
|
||||
const increment = 20;
|
||||
let currentTime = 0;
|
||||
duration = typeof duration === 'undefined' ? 500 : duration;
|
||||
duration = typeof duration === "undefined" ? 500 : duration;
|
||||
const animateScroll = function () {
|
||||
// increment the time
|
||||
currentTime += increment;
|
||||
@@ -59,7 +59,7 @@ export const scrollTo = (to: number, duration: number, callback?: any) => {
|
||||
if (currentTime < duration) {
|
||||
requestAnimFrame(animateScroll);
|
||||
} else {
|
||||
if (callback && typeof callback === 'function') {
|
||||
if (callback && typeof callback === "function") {
|
||||
// the animation is done so lets callback
|
||||
callback();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user