2023-08-30 13:55:59 +08:00
|
|
|
|
// 运行时配置
|
|
|
|
|
|
|
|
|
|
// 全局初始化数据配置,用于 Layout 用户信息和权限初始化
|
|
|
|
|
// 更多信息见文档:https://next.umijs.org/docs/api/runtime-config#getinitialstate
|
|
|
|
|
export async function getInitialState(): Promise<{ name: string }> {
|
|
|
|
|
return {
|
|
|
|
|
name: 'logout',
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
import logo from './assets/images/logo.png'
|
|
|
|
|
export const layout = () => {
|
|
|
|
|
return {
|
|
|
|
|
logo: logo,
|
|
|
|
|
title: '班布地图',
|
|
|
|
|
menu: {
|
|
|
|
|
locale: false,
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
};
|
2024-05-27 16:17:02 +08:00
|
|
|
|
|
|
|
|
|
// 配置请求header
|
|
|
|
|
import { RequestConfig } from '@umijs/max';
|
|
|
|
|
|
|
|
|
|
export const request: RequestConfig = {
|
|
|
|
|
requestInterceptors: [
|
|
|
|
|
(url, options) => {
|
|
|
|
|
const token = localStorage.getItem('authToken'); // 从某处获取你的认证token,例如localStorage
|
|
|
|
|
if (token) {
|
|
|
|
|
const headers = {
|
2024-05-27 17:24:34 +08:00
|
|
|
|
Authorization: `${token}`,
|
2024-05-27 16:17:02 +08:00
|
|
|
|
...options.headers,
|
|
|
|
|
};
|
|
|
|
|
return {
|
|
|
|
|
url: url,
|
|
|
|
|
options: { ...options, headers },
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
return { url, options };
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
};
|