| | |
| | | import { getRemoteMenu, getRoutersInfo, getUserInfo, setRemoteMenu, patchRouteWithRemoteMenus } from './services/route'; |
| | | import { getToken } from '@/utils/token-util' |
| | | import { TOKEN_HEADER_NAME, TOKEN_STORE_NAME } from '@/config/setting'; |
| | | import { API_BASE_URL } from '@/config/setting' |
| | | |
| | | const isDev = process.env.NODE_ENV === 'development'; |
| | | const loginPath = '/user/login'; |
| | |
| | | * @doc https://umijs.org/docs/max/request#配置 |
| | | */ |
| | | export const request = { |
| | | // baseURL: 'http://localhost:9999', |
| | | baseURL: API_BASE_URL, |
| | | ...errorConfig, |
| | | timeout: 60000, |
| | | // 前置守卫 |
| | |
| | | import React, { useCallback } from 'react'; |
| | | import { flushSync } from 'react-dom'; |
| | | import HeaderDropdown from '../HeaderDropdown'; |
| | | import { setRemoteMenu } from '@/services/route' |
| | | import { removeToken } from '@/utils/token-util' |
| | | |
| | | export type GlobalHeaderRightProps = { |
| | | menu?: boolean; |
| | |
| | | * 退出登录,并且将当前的 url 保存 |
| | | */ |
| | | const loginOut = async () => { |
| | | await outLogin(); |
| | | // await outLogin(); |
| | | removeToken(); |
| | | setRemoteMenu(null); |
| | | const { search, pathname } = window.location; |
| | | const urlParams = new URL(window.location.href).searchParams; |
| | | /** 此方法会跳转到 redirect 参数所在的位置 */ |
| | |
| | | const menuItems = [ |
| | | ...(menu |
| | | ? [ |
| | | { |
| | | key: 'center', |
| | | icon: <UserOutlined />, |
| | | label: '个人中心', |
| | | }, |
| | | { |
| | | key: 'settings', |
| | | icon: <SettingOutlined />, |
| | | label: '个人设置', |
| | | }, |
| | | { |
| | | type: 'divider' as const, |
| | | }, |
| | | ] |
| | | { |
| | | key: 'center', |
| | | icon: <UserOutlined />, |
| | | label: '个人中心', |
| | | }, |
| | | { |
| | | key: 'settings', |
| | | icon: <SettingOutlined />, |
| | | label: '个人设置', |
| | | }, |
| | | { |
| | | type: 'divider' as const, |
| | | }, |
| | | ] |
| | | : []), |
| | | { |
| | | key: 'logout', |
| | |
| | | // 接口地址 |
| | | export const API_BASE_URL: string = ''; |
| | | export const API_BASE_URL: string = 'http://localhost:9090/wcs'; |
| | | |
| | | // 项目名称 |
| | | export const PROJECT_NAME: string = ''; |
| | |
| | | const handleSubmit = async (values) => { |
| | | try { |
| | | const r = await request('/api/login', { |
| | | baseURL: 'http://localhost:9090/wcs', |
| | | method: 'POST', |
| | | headers: { |
| | | 'Content-Type': 'application/json' |
| | |
| | | |
| | | export async function getUserInfo(options) { |
| | | return request('/api/auth/user', { |
| | | baseURL: 'http://localhost:9090/wcs', |
| | | method: 'GET', |
| | | ...(options || {}), |
| | | }); |
| | |
| | | |
| | | export async function getRouters() { |
| | | return request('/api/auth/menu', { |
| | | baseURL: 'http://localhost:9090/wcs' |
| | | }); |
| | | } |
| | | |
| | |
| | | "@@test/*": ["./src/.umi-test/*"] |
| | | } |
| | | }, |
| | | "include": ["./**/*.d.ts", "./**/*.ts", "./**/*.tsx", "src/app.tsx", "src/utils/icon-util.js", "src/pages/User/Login/index.jsx", "src/components/Footer/index.jsx"] |
| | | "include": ["./**/*.d.ts", "./**/*.ts", "./**/*.tsx", "src/app.tsx", "src/utils/icon-util.js", "src/pages/User/Login/index.jsx", "src/components/Footer/index.jsx", "src/components/HeaderDropdown/index.jsx"] |
| | | } |