43 lines
1012 B
TypeScript
43 lines
1012 B
TypeScript
// 运行时配置
|
||
|
||
// 全局初始化数据配置,用于 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,
|
||
},
|
||
};
|
||
};
|
||
|
||
// 配置请求header
|
||
import { RequestConfig } from '@umijs/max';
|
||
|
||
export const request: RequestConfig = {
|
||
requestInterceptors: [
|
||
(url, options) => {
|
||
const token = localStorage.getItem('authToken'); // 从某处获取你的认证token,例如localStorage
|
||
if (token) {
|
||
const headers = {
|
||
Authorization: `${token}`,
|
||
...options.headers,
|
||
};
|
||
return {
|
||
url: url,
|
||
options: { ...options, headers },
|
||
};
|
||
}
|
||
return { url, options };
|
||
},
|
||
],
|
||
};
|