diff --git a/README.md b/README.md index 2a7d2f3..02d683d 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ * @Author: zhoux zhouxia@supervision.ltd * @Date: 2023-11-01 13:56:33 * @LastEditors: zhoux zhouxia@supervision.ltd - * @LastEditTime: 2023-11-06 09:43:02 + * @LastEditTime: 2023-11-09 14:10:27 * @FilePath: \general-ai-platform-web\README.md * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE --> @@ -67,3 +67,9 @@ refactor: 既不修复bug也不添加特性的代码更改 perf: 改进性能的代码更改 test: 添加缺少的测试或更正现有测试 chore: 对构建过程或辅助工具和库(如文档)的更改(无法确认内容可使用) + + + +### TODO bug汇总 + +* 新增路由页面,默认该角色拥有查看权限,实际配置并没有(重新配置权限,又能正常访问该新增页面) diff --git a/config/routes.ts b/config/routes.ts index b6d7f92..8d03cbc 100644 --- a/config/routes.ts +++ b/config/routes.ts @@ -131,7 +131,13 @@ export default [ 'path': '/resource/algorithm-model-list', 'component': 'Resource/AlgorithmModelList', - 'access': 'canReadMenu' + 'access': 'canReadMenu', + }, { + 'name': 'algorithm-model-detail', + 'path': '/resource/algorithm-model-detail/:id', + 'component': 'Resource/AlgorithmModelList/detail', + 'access': 'canReadMenu', + "isHideTab": true, }, { 'name': 'business-image-list', diff --git a/mock/modelDetail.ts b/mock/modelDetail.ts new file mode 100644 index 0000000..1a3a9e4 --- /dev/null +++ b/mock/modelDetail.ts @@ -0,0 +1,68 @@ +/* + * @Author: zhoux zhouxia@supervision.ltd + * @Date: 2023-11-09 14:29:49 + * @LastEditors: zhoux zhouxia@supervision.ltd + * @LastEditTime: 2023-11-09 15:34:50 + * @FilePath: \general-ai-platform-web\mock\modelDetail.ts + * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE + */ +import { Request, Response } from 'express'; +import { parse } from 'url'; + +// mock tableListDataSource +const genData = (params: Record): Record => { + const data: Record = { + categoryFkId: 2, + createTime: '2023-10-20T06:23:56.158622Z', + defaultVersionFkId: null, + id: params.id, + name: '离岗', + remark: '', + updateTime: '2023-10-20T06:23:56.158622Z', + }; + + // key: index, + // disabled: i % 6 === 0, + // href: 'https://ant.design', + // avatar: [ + // 'https://gw.alipayobjects.com/zos/rmsportal/eeHMaZBwmTvLdIwMfBpg.png', + // 'https://gw.alipayobjects.com/zos/rmsportal/udxAbMEhpwthVVcjLXik.png', + // ][i % 2], + // name: `TradeCode ${index}`, + // owner: '曲丽丽', + // desc: '这是一段描述', + // callNo: Math.floor(Math.random() * 1000), + // status: Math.floor(Math.random() * 10) % 4, + // updatedAt: moment().format('YYYY-MM-DD'), + // createdAt: moment().format('YYYY-MM-DD'), + // progress: Math.ceil(Math.random() * 100), + + return data; +}; + +function getModelDetail(req: Request, res: Response, u: string, b: Request) { +// let realUrl = u; +// if (!realUrl || Object.prototype.toString.call(realUrl) !== '[object String]') { +// realUrl = req.url; +// } + +// const body = (b && b.body) || req.body; +// const { method, name, desc, key } = body; +// const params = parse(realUrl, true).query as unknown as API.PageParams & +// API.RuleListItem & { +// sorter: any; +// filter: any; +// }; +// console.log(req, 'getModelDetailApi'); + const result = { + data: genData({id: 2}), + success: true, + msg: '获取成功', + }; + + return res.json(result); +} + +export default { + 'GET /api/v1/mock/model/detail': getModelDetail, +}; diff --git a/src/app.tsx b/src/app.tsx index 0262be1..49b84ba 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -1,28 +1,28 @@ -import { Footer, Question, SelectLang, AvatarDropdown, AvatarName } from '@/components'; +import { AvatarDropdown, AvatarName, Footer, Question, SelectLang } from '@/components'; import { LinkOutlined } 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 { history, Link, getLocale } from '@umijs/max'; +import { Link, RunTimeLayoutConfig, getLocale, history, useIntl } from '@umijs/max'; +import { RequestConfig } from 'umi'; import defaultSettings from '../config/defaultSettings'; import { errorConfig } from './requestErrorConfig'; -import React from 'react'; const isDev = process.env.NODE_ENV === 'development'; const loginPath = '/user/login'; -import {RequestConfig} from 'umi'; // @ts-ignore +import { SelectRole } from '@/components/RightContent'; +import zhCN from '@/locales/zh-CN'; +import { postMenuGetMenu } from '@/services/system/Menu'; +import { getUserGetUserInfo } from '@/services/system/User'; +import fixMenuItemIcon from '@/utils/FixMenuItemIcon'; +import { getAllRouteNameTile } from '@/utils/common'; +import { addLocale } from '@@/plugin-locale'; +import { MenuDataItem } from '@ant-design/pro-layout'; import cookie from 'react-cookies'; -import {getUserGetUserInfo} from "@/services/system/User"; -import {MenuDataItem} from "@ant-design/pro-layout"; -import fixMenuItemIcon from "@/utils/FixMenuItemIcon"; -import {postMenuGetMenu} from "@/services/system/Menu"; -import {SelectRole} from "@/components/RightContent"; -import {addLocale} from "@@/plugin-locale"; -import zhCN from "@/locales/zh-CN"; -import {getAllRouteNameTile} from "@/utils/common"; /** * @see https://umijs.org/zh-CN/plugins/plugin-initial-state * */ +// 自定义路由路径集合 +const isCustomPageTitlePaths : string[]= ['/resource/algorithm-model-detail'] export async function getInitialState(): Promise<{ @@ -47,15 +47,16 @@ export async function getInitialState(): Promise<{ const currentUser = await fetchUserInfo(); const menus = await postMenuGetMenu(); if (getLocale() === 'zh-CN') { - let localData = getAllRouteNameTile(menus.data.routes, '') - let localRes:any = {} - localData.forEach((v)=>{ - localRes[`menu${v.name}`] = v.title - }) - console.log(localRes) - addLocale("zh-CN", localRes,{ - momentLocale: "zh-CN", - antd: zhCN + let localData = getAllRouteNameTile(menus.data.routes, ''); + let localRes: any = {}; + localData.forEach((v) => { + // console.log(v.title,'localData_v') + localRes[`menu${v.name}`] = v.title; + }); + console.log(localRes, 'getAllRouteNameTile'); + addLocale('zh-CN', localRes, { + momentLocale: 'zh-CN', + antd: zhCN, }); } @@ -65,7 +66,6 @@ export async function getInitialState(): Promise<{ settings: defaultSettings as Partial, menuData: menus.data.routes, }; - } return { @@ -76,15 +76,37 @@ export async function getInitialState(): Promise<{ // ProLayout 支持的api https://procomponents.ant.design/components/layout export const layout: RunTimeLayoutConfig = ({ initialState, setInitialState }) => { + return { - actionsRender: () => [, , ], + actionsRender: () => [ + , + , + , + ], avatarProps: { src: SERVER_HOST + initialState?.currentUser?.avatarUrl, title: , render: (_, avatarChildren) => { + // console.log(avatarChildren,'') return {avatarChildren}; }, }, + pageTitleRender: () => { + console.log(history, 'pageTitleRender'); + // TODO 目前使用路由path全匹配,后续改成从接口字段读取 + let isCustom: boolean = false + for(let i=0; i { - return initialState?.menuData || [] - } + // console.log(initialState?.menuData,'initialState_menuData') + return initialState?.menuData || []; + }, }, footerRender: () =>