map/src/app.ts
2024-05-27 17:24:34 +08:00

43 lines
1012 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 运行时配置
// 全局初始化数据配置,用于 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 };
},
],
};