diff --git a/config/config.ts b/config/config.ts index acf2afd..752cba6 100644 --- a/config/config.ts +++ b/config/config.ts @@ -2,7 +2,6 @@ import { defineConfig } from '@umijs/max'; import { join } from 'path'; import defaultSettings from './defaultSettings'; -import proxy from './proxy'; import routes from './routes'; const { REACT_APP_ENV = 'dev' } = process.env; @@ -14,7 +13,10 @@ export default defineConfig({ * @doc https://umijs.org/docs/api/config#hash */ hash: true, - + // hash 路由 + // history: { + // type: 'hash', + // }, /** * @name 兼容性设置 * @description 设置 ie11 不一定完美兼容,需要检查自己使用的所有依赖 @@ -54,7 +56,14 @@ export default defineConfig({ * @doc 代理介绍 https://umijs.org/docs/guides/proxy * @doc 代理配置 https://umijs.org/docs/api/config#proxy */ - proxy: proxy[REACT_APP_ENV as keyof typeof proxy], + // proxy: proxy[REACT_APP_ENV as keyof typeof proxy], + proxy: { + '/api/': { + target: 'http://192.168.1.219:8183/', + changeOrigin: true, + pathRewrite: { '^/api': '' }, + }, + }, /** * @name 快速热更新配置 * @description 一个不错的热更新组件,更新时可以保留 state @@ -76,11 +85,12 @@ export default defineConfig({ * @name layout 插件 * @doc https://umijs.org/docs/max/layout-menu */ - title: 'Ant Design Pro', + title: 'SCRM', layout: { - locale: true, + locale: false, ...defaultSettings, }, + /** * @name moment2dayjs 插件 * @description 将项目中的 moment 替换为 dayjs diff --git a/config/defaultSettings.ts b/config/defaultSettings.ts index 9fac66a..3393bdb 100644 --- a/config/defaultSettings.ts +++ b/config/defaultSettings.ts @@ -15,7 +15,7 @@ const Settings: ProLayoutProps & { fixedHeader: false, fixSiderbar: true, colorWeak: false, - title: 'Ant Design Pro', + title: 'SCRM', pwa: true, logo: 'https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg', iconfontUrl: '', @@ -23,7 +23,7 @@ const Settings: ProLayoutProps & { // 参见ts声明,demo 见文档,通过token 修改样式 //https://procomponents.ant.design/components/layout#%E9%80%9A%E8%BF%87-token-%E4%BF%AE%E6%94%B9%E6%A0%B7%E5%BC%8F }, - splitMenus: true + splitMenus: true, }; export default Settings; diff --git a/config/routes.ts b/config/routes.ts index 436b0e3..98eab3b 100644 --- a/config/routes.ts +++ b/config/routes.ts @@ -1,4 +1,4 @@ -/** +/** * @name umi 的路由配置 * @description 只支持 path,component,routes,redirect,wrappers,name,icon 的配置 * @param path path 只支持两种占位符配置,第一种是动态参数 :id 的形式,第二种是 * 通配符,通配符只能出现路由字符串的最后。 @@ -22,49 +22,75 @@ export default [ }, ], }, + // { + // path: '/welcome', + // name: 'welcome', + // icon: 'smile', + // component: './Welcome', + // }, { - path: '/welcome', - name: 'welcome', - icon: 'smile', - component: './Welcome', - }, - { - path: '/admin', - name: 'admin', + path: '/departments', + name: 'scrm', icon: 'crown', - access: 'canAdmin', + // access: 'canAdmin', routes: [ { - path: '/admin', - redirect: '/admin/sub-page', + path: '/departments', + redirect: '/departments/page/list', }, { - path: '/admin/sub-page', - name: 'sub-page', - component: './Admin', + path: '/departments/page', + name: '部门管理', + // hideInBreadcrumb: true, + // component: './Admin', + routes: [ + { + path: '/departments/page', + redirect: '/departments/page/list', + }, + { + name: '部门员工', + icon: 'table', + path: '/departments/page/list', + component: './DepartmentsList', + }, + { + name: '聊天记录', + icon: 'table', + path: '/departments/page/list2', + component: './ChatLogs', + }, + ], }, - { - path: '/admin/sub-page2', - name: 'sub-page2', - component: './Admin', - } + // { + // path: '/departments/sub-page2', + // name: '商品', + // // component: './TableList', + // routes: [ + // { + // name: '列表', + // icon: 'table', + // path: '/departments/sub-page2/list', + // component: './TableList', + // }, + // ], + // }, ], }, - - { - name: 'list.table-list', - icon: 'table', - path: '/list', - component: './TableList', - }, + + // { + // name: 'list.table-list', + // icon: 'table', + // path: '/list', + // component: './TableList', + // }, { path: '/', - redirect: '/welcome', + redirect: '/departments', }, { path: '*', layout: false, component: './404', }, - ]; diff --git a/package.json b/package.json index 96084e3..e91c1df 100644 --- a/package.json +++ b/package.json @@ -92,4 +92,4 @@ "engines": { "node": ">=12.0.0" } -} +} \ No newline at end of file diff --git a/src/app.tsx b/src/app.tsx index 024f261..51b63b1 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -1,15 +1,14 @@ import Footer from '@/components/Footer'; -import { Question, SelectLang } from '@/components/RightContent'; -import { LinkOutlined } from '@ant-design/icons'; +import { LinkOutlined, VerticalAlignTopOutlined } from '@ant-design/icons'; import type { Settings as LayoutSettings } from '@ant-design/pro-components'; -import { SettingDrawer } from '@ant-design/pro-components'; -import type { RunTimeLayoutConfig } from '@umijs/max'; +import type { RequestConfig, RunTimeLayoutConfig } from '@umijs/max'; import { history, Link } from '@umijs/max'; -import defaultSettings from '../config/defaultSettings'; -import { errorConfig } from './requestErrorConfig'; -import { currentUser as queryCurrentUser } from './services/ant-design-pro/api'; +import { App, FloatButton } from 'antd'; import React from 'react'; +import defaultSettings from '../config/defaultSettings'; import { AvatarDropdown, AvatarName } from './components/RightContent/AvatarDropdown'; +import { errorConfig } from './requestErrorConfig'; +import { post } from './services/ajax'; const isDev = process.env.NODE_ENV === 'development'; const loginPath = '/user/login'; @@ -24,9 +23,7 @@ export async function getInitialState(): Promise<{ }> { const fetchUserInfo = async () => { try { - const msg = await queryCurrentUser({ - skipErrorHandler: true, - }); + const msg = await post({ url: '/User/LoginStatus' }); return msg.data; } catch (error) { history.push(loginPath); @@ -51,18 +48,27 @@ export async function getInitialState(): Promise<{ // ProLayout 支持的api https://procomponents.ant.design/components/layout export const layout: RunTimeLayoutConfig = ({ initialState, setInitialState }) => { + // console.log(initialState?.settings); + + const { notification } = App.useApp(); + window.NotificationCF = notification; + return { - actionsRender: () => [, ], + // actionsRender: () => [, ], + actionsRender: () => [], avatarProps: { - src: initialState?.currentUser?.avatar, + src: initialState?.currentUser?.avatar + ? '/api/' + initialState?.currentUser?.avatar + : 'https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg', title: , render: (_, avatarChildren) => { return {avatarChildren}; }, }, - waterMarkProps: { - content: initialState?.currentUser?.name, - }, + // waterMarkProps: { + // content: initialState?.currentUser?.login_name, + // }, + siderWidth: 200, footerRender: () =>