diff --git a/config/proxy.ts b/config/proxy.ts index ab24392..8d6782d 100644 --- a/config/proxy.ts +++ b/config/proxy.ts @@ -1,49 +1,49 @@ -/** - * @name 代理的配置 - * @see 在生产环境 代理是无法生效的,所以这里没有生产环境的配置 - * ------------------------------- - * The agent cannot take effect in the production environment - * so there is no configuration of the production environment - * For details, please see - * https://pro.ant.design/docs/deploy - * - * @doc https://umijs.org/docs/guides/proxy - */ -export default { - // 如果需要自定义本地开发服务器 请取消注释按需调整 - dev: { - // localhost:8000/api/** -> https://preview.pro.ant.design/api/** - '/api/': { - // 要代理的地址 - target: 'http://39.98.44.136:8080', - // 配置了这个可以从 http 代理到 https - // 依赖 origin 的功能可能需要这个,比如 cookie - changeOrigin: true, - pathRewrite: { '^/api': '' }, - }, - '/profile/avatar/': { - target: 'http://39.98.44.136:8080', - changeOrigin: true, - } - }, - - /** - * @name 详细的代理配置 - * @doc https://github.com/chimurai/http-proxy-middleware - */ - test: { - // localhost:8000/api/** -> https://preview.pro.ant.design/api/** - '/api/': { - target: 'https://proapi.azurewebsites.net', - changeOrigin: true, - pathRewrite: { '^': '' }, - }, - }, - pre: { - '/api/': { - target: 'your pre url', - changeOrigin: true, - pathRewrite: { '^': '' }, - }, - }, -}; +/** + * @name 代理的配置 + * @see 在生产环境 代理是无法生效的,所以这里没有生产环境的配置 + * ------------------------------- + * The agent cannot take effect in the production environment + * so there is no configuration of the production environment + * For details, please see + * https://pro.ant.design/docs/deploy + * + * @doc https://umijs.org/docs/guides/proxy + */ +export default { + // 如果需要自定义本地开发服务器 请取消注释按需调整 + dev: { + // localhost:8000/api/** -> https://preview.pro.ant.design/api/** + '/api/': { + // 要代理的地址 + target: 'https://qd.zhaopinzao8dian.com/api', + // 配置了这个可以从 http 代理到 https + // 依赖 origin 的功能可能需要这个,比如 cookie + changeOrigin: true, + pathRewrite: { '^/api': '' }, + }, + '/profile/avatar/': { + target: 'https://qd.zhaopinzao8dian.com/api', + changeOrigin: true, + } + }, + + /** + * @name 详细的代理配置 + * @doc https://github.com/chimurai/http-proxy-middleware + */ + test: { + // localhost:8000/api/** -> https://preview.pro.ant.design/api/** + '/api/': { + target: 'https://proapi.azurewebsites.net', + changeOrigin: true, + pathRewrite: { '^': '' }, + }, + }, + pre: { + '/api/': { + target: 'your pre url', + changeOrigin: true, + pathRewrite: { '^': '' }, + }, + }, +}; diff --git a/package.json b/package.json index e0b9123..b7a876a 100644 --- a/package.json +++ b/package.json @@ -56,6 +56,7 @@ "@amap/amap-jsapi-loader": "^1.0.1", "@ant-design/charts": "^2.3.0", "@ant-design/icons": "^5.5.0", + "@ant-design/maps": "^1.0.0", "@ant-design/plots": "^2.3.2", "@ant-design/pro-components": "^2.8.7", "@ant-design/use-emotion-css": "1.0.4", diff --git a/src/app.tsx b/src/app.tsx index 900d7e9..ab7c2f4 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -1,271 +1,271 @@ -import { AvatarDropdown, AvatarName, Footer, SelectLang } from '@/components'; -import type { Settings as LayoutSettings } from '@ant-design/pro-components'; -import { SettingDrawer } from '@ant-design/pro-components'; -import type { RunTimeLayoutConfig } from '@umijs/max'; -import { history } from '@umijs/max'; -import defaultSettings from '../config/defaultSettings'; -import { errorConfig } from './requestErrorConfig'; -import { clearSessionToken, getAccessToken, getRefreshToken, getTokenExpireTime } from './access'; -import { - getRemoteMenu, - getRoutersInfo, - getUserInfo, - patchRouteWithRemoteMenus, - setRemoteMenu, -} from './services/session'; -import { PageEnum } from './enums/pagesEnums'; -import { stringify } from 'querystring'; -import { message } from 'antd'; - -const isDev = process.env.NODE_ENV === 'development'; -const loginOut = async () => { - clearSessionToken(); - setRemoteMenu(null); - const { search, pathname } = window.location; - const urlParams = new URL(window.location.href).searchParams; - /** 此方法会跳转到 redirect 参数所在的位置 */ - const redirect = urlParams.get('redirect'); - // Note: There may be security issues, please note - console.log('redirect', window.location.pathname, redirect); - if (window.location.pathname !== '/qingdao/user/login' && !redirect) { - history.replace({ - pathname: '/user/login', - search: stringify({ - redirect: pathname.replace('/qingdao', '') + search, - }), - }); - } -}; - -/** - * @see https://umijs.org/zh-CN/plugins/plugin-initial-state - * */ -export async function getInitialState(): Promise<{ - settings?: Partial; - currentUser?: API.CurrentUser; - loading?: boolean; - fetchUserInfo?: () => Promise; -}> { - const fetchUserInfo = async () => { - try { - const response = await getUserInfo({ - skipErrorHandler: true, - }); - if (response.user.avatar === '') { - response.user.avatar = - 'https://gw.alipayobjects.com/zos/rmsportal/BiazfanxmamNRoxxVxka.png'; - } - return { - ...response.user, - permissions: response.permissions, - roles: response.roles, - } as API.CurrentUser; - } catch (error) { - console.log(error); - history.push(PageEnum.LOGIN); - } - return undefined; - }; - // 如果不是登录页面,执行 - const { location } = history; - if (location.pathname !== PageEnum.LOGIN) { - const currentUser = await fetchUserInfo(); - return { - fetchUserInfo, - currentUser, - settings: defaultSettings as Partial, - }; - } - return { - fetchUserInfo, - settings: defaultSettings as Partial, - }; -} - -// ProLayout 支持的api https://procomponents.ant.design/components/layout -export const layout: RunTimeLayoutConfig = ({ initialState, setInitialState }) => { - return { - // actionsRender: () => [, ], - actionsRender: () => [], - avatarProps: { - src: initialState?.currentUser?.avatar, - title: , - render: (_, avatarChildren) => { - return {avatarChildren}; - }, - }, - waterMarkProps: { - // content: initialState?.currentUser?.nickName, - }, - // actionRef: layoutActionRef, - menu: { - locale: false, - // // 每当 initialState?.currentUser?.userid 发生修改时重新执行 request - params: { - userId: initialState?.currentUser?.userId, - }, - request: async () => { - if (!initialState?.currentUser?.userId) { - return []; - } - return getRemoteMenu(); - }, - }, - footerRender: () =>