feat: 新增mock环境通道

develop
donghao 1 year ago
parent 0b535104d8
commit 9af58943f3

@ -1,3 +1,11 @@
/*
* @Author: donghao donghao@supervision.ltd
* @Date: 2023-11-01 13:56:33
* @LastEditors: donghao donghao@supervision.ltd
* @LastEditTime: 2024-01-24 14:49:42
* @FilePath: \general-ai-platform-web\config\proxy.ts
* @Description: ,`customMade`, koroFileHeader : https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
/**
* @name
* @see
@ -23,9 +31,10 @@ export default {
// },
dev: {
// localhost:8000/api/** -> https://preview.pro.ant.design/api/**
'/api/v1/': {
// 要代理的地址
target: 'http://192.168.10.96:8888/',
target: 'http://192.168.10.14:8888/',
// target: 'https://www.baidu.com',
// 配置了这个可以从 http 代理到 https
// 依赖 origin 的功能可能需要这个,比如 cookie
@ -55,10 +64,12 @@ export default {
},
},
pre: {
'/api/': {
target: 'your pre url',
'/api/v1/': {
// 要代理的地址
target: 'https://preview.pro.ant.design',
// 配置了这个可以从 http 代理到 https
// 依赖 origin 的功能可能需要这个,比如 cookie
changeOrigin: true,
pathRewrite: { '^': '' },
},
},
};

@ -0,0 +1,24 @@
/*
* @Author: donghao donghao@supervision.ltd
* @Date: 2023-11-01 13:56:33
* @LastEditors: donghao donghao@supervision.ltd
* @LastEditTime: 2024-01-24 17:16:51
* @FilePath: \general-ai-platform-web\mock\route.ts
* @Description: ,`customMade`, koroFileHeader : https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
// 使用中
import { mockGetMenuData } from './pools/menuData';
import { successMockApiProps } from './typing';
import { fetchMockSuccessFullByOther } from './utils/apiMock';
export default {
// 获取菜单
'POST /api/v1/menu/getMenu': async (req: Request, res: Response) => {
const resData: successMockApiProps = {
...fetchMockSuccessFullByOther(mockGetMenuData),
};
res.send(resData);
},
};

@ -0,0 +1 @@
// 模型版本 mock

@ -0,0 +1,60 @@
/*
* @Author: donghao donghao@supervision.ltd
* @Date: 2024-01-24 16:58:15
* @LastEditors: donghao donghao@supervision.ltd
* @LastEditTime: 2024-01-24 16:58:26
* @FilePath: \general-ai-platform-web\mock\pools\algorithmModelData.ts
* @Description: ,`customMade`, koroFileHeader : https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
/**模型版本-选择模型 */
export const mockGetAlgorithmModelFkSelectData = {
data: {
list: [
{
name: '玩手机识别',
id: 1,
defaultVersionFkId: null,
},
{
name: '打瞌睡',
id: 2,
defaultVersionFkId: null,
},
{
name: '离岗',
id: 3,
defaultVersionFkId: null,
},
{
name: '玩手机识别1',
id: 4,
defaultVersionFkId: 6,
},
{
name: '玩手机yolo1',
id: 5,
defaultVersionFkId: 5,
},
{
name: '玩手机yolo2',
id: 6,
defaultVersionFkId: 4,
},
{
name: '打瞌睡yolo1',
id: 7,
defaultVersionFkId: 7,
},
{
name: '离岗yolo1',
id: 8,
defaultVersionFkId: 23,
},
{
name: '测试模型',
id: 9,
defaultVersionFkId: 27,
},
],
},
};

@ -0,0 +1,310 @@
/*
* @Author: donghao donghao@supervision.ltd
* @Date: 2024-01-24 16:05:16
* @LastEditors: donghao donghao@supervision.ltd
* @LastEditTime: 2024-01-24 16:18:18
* @FilePath: \general-ai-platform-web\mock\pools\menuData.ts
* @Description: ,`customMade`, koroFileHeader : https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
/** 菜单目录信息 */
export const mockGetMenuData = {
data: {
routes: [
{
path: '/welcome',
key: '',
name: 'welcome',
icon: 'HomeOutlined',
access: '',
component: 'Welcome',
title: '首页',
routes: [],
},
{
path: '/resource',
key: '',
name: 'resource',
icon: 'BlockOutlined',
access: '',
component: '',
title: '资源管理',
routes: [
{
path: '/resource/model-version-list',
key: '19',
name: 'model-version-list',
icon: '',
access: '',
component: 'Resource/ModelVersionList',
title: '模型版本',
routes: [],
},
{
path: '/resource/model-image-list',
key: '18',
name: 'model-image-list',
icon: '',
access: '',
component: 'Resource/ModelImageList',
title: '模型镜像',
routes: [],
},
{
path: '/resource/model-category-list',
key: '20',
name: 'model-category-list',
icon: '',
access: '',
component: 'Resource/ModelCategoryList',
title: '模型类别',
routes: [],
},
{
path: '/resource/algorithm-model-list',
key: '17',
name: 'algorithm-model-list',
icon: '',
access: '',
component: 'Resource/AlgorithmModelList',
title: '模型列表',
routes: [],
},
{
path: '/resource/business-image-list',
key: '21',
name: 'business-image-list',
icon: '',
access: '',
component: 'Resource/BusinessImageList',
title: '业务镜像',
routes: [],
},
],
},
{
path: '/device',
key: '',
name: 'device',
icon: 'DesktopOutlined',
access: '',
component: '',
title: '设备管理',
routes: [
{
path: '/device/device-category-list',
key: '13',
name: 'device-category-list',
icon: '',
access: '',
component: 'Device/DeviceCategoryList',
title: '设备类别',
routes: [],
},
{
path: '/device/device-group-list',
key: '14',
name: 'device-group-list',
icon: '',
access: '',
component: 'Device/DeviceGroupList',
title: '设备组',
routes: [],
},
{
path: '/device/device-list',
key: '12',
name: 'device-list',
icon: '',
access: '',
component: 'Device/DeviceList',
title: '设备列表',
routes: [],
},
],
},
{
path: '/project',
key: '',
name: 'project',
icon: 'DatabaseOutlined',
access: '',
component: '',
title: '项目管理',
routes: [
{
path: '/project/project-list',
key: '24',
name: 'project-list',
icon: '',
access: '',
component: 'Project/ProjectList',
title: '项目列表',
routes: [],
},
],
},
{
path: '/algorithm_setting',
key: '',
name: 'algorithm_setting',
icon: 'ExperimentOutlined',
access: '',
component: '',
title: '项目部署',
routes: [],
},
{
path: '/analysis',
key: '',
name: 'analysis',
icon: 'DotChartOutlined',
access: '',
component: '',
title: '智能分析',
routes: [
{
path: '/analysis/action-detection-list',
key: '10',
name: 'action-detection-list',
icon: '',
access: '',
component: 'Analysis/ActionDetectionList',
title: '行为异常',
routes: [],
},
],
},
{
path: '/system',
key: '',
name: 'system',
icon: 'SettingOutlined',
access: '',
component: '',
title: '系统管理',
routes: [
{
path: '/system/api-list',
key: '2',
name: 'api-list',
icon: '',
access: '',
component: 'System/ApiList',
title: '接口列表',
routes: [],
},
{
path: '/system/menu-list',
key: '3',
name: 'menu-list',
icon: '',
access: '',
component: 'System/MenuList',
title: '菜单列表',
routes: [],
},
{
path: '/system/role-list',
key: '4',
name: 'role-list',
icon: '',
access: '',
component: 'System/RoleList',
title: '角色列表',
routes: [],
},
{
path: '/system/user-list',
key: '5',
name: 'user-list',
icon: '',
access: '',
component: 'System/UserList',
title: '用户列表',
routes: [],
},
{
path: '/system/post-list',
key: '6',
name: 'post-list',
icon: '',
access: '',
component: 'System/PostList',
title: '岗位列表',
routes: [],
},
{
path: '/system/department-list',
key: '7',
name: 'department-list',
icon: '',
access: '',
component: 'System/DepartmentList',
title: '部门列表',
routes: [],
},
{
path: '/system/operation_record-list',
key: '8',
name: 'operation_record-list',
icon: '',
access: '',
component: 'System/OperationRecordList',
title: '操作日志',
routes: [],
},
],
},
{
path: '/task',
key: '',
name: 'task',
icon: 'CalendarOutlined',
access: '',
component: '',
title: '任务管理',
routes: [],
},
{
path: '/alarm',
key: '',
name: 'alarm',
icon: 'WarningOutlined',
access: '',
component: '',
title: '告警管理',
routes: [],
},
{
path: 'compute_power',
key: '',
name: 'compute_power',
icon: 'ThunderboltOutlined',
access: '',
component: 'Hidden',
title: '算力配置',
routes: [],
},
// {
// path: 'http://192.168.10.96:5601/app/r/s/uDpRg',
// key: '',
// name: 'logging',
// icon: 'BugOutlined',
// access: '',
// component: 'Hidden',
// title: '日志管理',
// routes: [],
// },
// {
// path: 'http://localhost:9003/#/bankScreen',
// key: '',
// name: 'data_screen',
// icon: 'AreaChartOutlined',
// access: '',
// component: 'Hidden',
// title: '数据大屏',
// routes: [],
// },
],
}
};

@ -0,0 +1,173 @@
/*
* @Author: donghao donghao@supervision.ltd
* @Date: 2024-01-24 16:59:35
* @LastEditors: donghao donghao@supervision.ltd
* @LastEditTime: 2024-01-24 17:06:32
* @FilePath: \general-ai-platform-web\mock\pools\modelVersionData.ts
* @Description: ,`customMade`, koroFileHeader : https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
/**模型版本-选择模型 */
export const mockGetModelVersionListData = {
data: {
list: [
{
id: 1,
createTime: '2023-10-21T11:16:46.244747+08:00',
updateTime: '2023-10-23T09:23:38.477132+08:00',
modelFkId: 5,
version: 'V1.0',
path: '/path/a.onnx',
modelConfig: null,
startCode: '',
status: 1,
isEnable: true,
remark: '',
},
{
id: 2,
createTime: '2023-10-21T11:17:11.704304+08:00',
updateTime: '2023-10-23T09:23:55.998654+08:00',
modelFkId: 5,
version: 'V1.2',
path: '/path/b.onnx',
modelConfig: null,
startCode: '',
status: 1,
isEnable: true,
remark: '',
},
{
id: 3,
createTime: '2023-10-21T11:17:49.609481+08:00',
updateTime: '2023-10-23T09:24:14.832605+08:00',
modelFkId: 5,
version: 'V1.1',
path: 'aa',
modelConfig: null,
startCode: '',
status: 1,
isEnable: true,
remark: '',
},
{
id: 4,
createTime: '2023-10-21T11:18:01.331091+08:00',
updateTime: '2023-10-23T09:24:43.671437+08:00',
modelFkId: 6,
version: 'V1.0',
path: 'aaa',
modelConfig: {
params: [
{
name: 'model',
remark: '1',
default: './model_file/yolov5_phone.onnx',
},
{
name: 'model_cache',
remark: '2',
default: './tensort_cache/yolov5_phone.trt',
},
],
},
startCode: '',
status: 1,
isEnable: true,
remark: '',
},
{
id: 5,
createTime: '2023-10-24T15:03:46.104742+08:00',
updateTime: '2023-10-25T17:39:18.952711+08:00',
modelFkId: 5,
version: 'V11',
path: '../config_phone.yaml',
modelConfig: {
params: [],
},
startCode: '',
status: 1,
isEnable: true,
remark: '',
},
{
id: 7,
createTime: '2023-10-25T13:58:04.622319+08:00',
updateTime: '2023-10-25T17:39:37.221289+08:00',
modelFkId: 7,
version: 'V1.0',
path: '../config_sleep.yaml',
modelConfig: {
params: [],
},
startCode: '',
status: 1,
isEnable: true,
remark: '',
},
{
id: 8,
createTime: '2023-10-25T13:59:04.80433+08:00',
updateTime: '2023-10-25T17:39:53.069411+08:00',
modelFkId: 8,
version: 'V1.0',
path: '../config_person.yaml',
modelConfig: {
params: [],
},
startCode: '',
status: 1,
isEnable: true,
remark: '',
},
{
id: 11,
createTime: '2023-11-03T16:44:15.776907+08:00',
updateTime: '2023-11-03T16:44:15.776907+08:00',
modelFkId: 3,
version: '',
path: 'aa',
modelConfig: {
params: [],
},
startCode: '',
status: 1,
isEnable: true,
remark: '',
},
{
id: 12,
createTime: '2023-11-03T16:45:39.870898+08:00',
updateTime: '2023-11-03T16:45:39.870898+08:00',
modelFkId: 3,
version: '',
path: 'aa',
modelConfig: {
params: [],
},
startCode: '',
status: 1,
isEnable: true,
remark: '',
},
{
id: 13,
createTime: '2023-11-03T16:46:36.363785+08:00',
updateTime: '2023-11-03T16:46:36.363785+08:00',
modelFkId: 2,
version: '',
path: 'aa',
modelConfig: {
params: [],
},
startCode: '',
status: 1,
isEnable: true,
remark: '',
},
],
total: 24,
page: 1,
pageSize: 10,
},
};

@ -0,0 +1,78 @@
/*
* @Author: donghao donghao@supervision.ltd
* @Date: 2024-01-24 15:18:28
* @LastEditors: donghao donghao@supervision.ltd
* @LastEditTime: 2024-01-24 16:27:20
* @FilePath: \general-ai-platform-web\mock\pools\userData.ts
* @Description: ,`customMade`, koroFileHeader : https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
/**登录成功信息 */
export const mockBaseLoginData = {
data: {
user: {
id: 1,
createTime: '2023-10-08T16:02:30.775742+08:00',
updateTime: '2024-01-24T14:52:59.630566+08:00',
userName: 'admin',
nickName: '管理员1',
phone: '',
email: '',
avatarId: 1,
roleId: 1,
postId: null,
deptId: null,
roleIds: '1',
postIds: '',
remark: '',
enable: null,
lastLoginTime: '2024-01-24T14:56:32.6205134+08:00',
},
token:
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJJZCI6MSwiVXNlcm5hbWUiOiJhZG1pbiIsIk5pY2tOYW1lIjoi566h55CG5ZGYIiwiUm9sZUlkIjoxLCJCdWZmZXJUaW1lIjo4NjQwMCwiaXNzIjoicW1QbHVzIiwiYXVkIjpbIkdWQSJdLCJleHAiOjE3MDY2ODQxOTIsIm5iZiI6MTcwNjA3OTM5Mn0.Vts4lGMp8X1EpobwqMB6StN7vO8HB4G5jBm_K8DvON4',
expiresAt: 1706684192000,
},
msg: '登录成功',
};
/**获取用户信息 */
export const mockGetUserInfoData = {
data: {
userInfo: {
id: 1,
createTime: '2023-10-08T16:02:30.775742+08:00',
updateTime: '2024-01-24T14:56:32.620573+08:00',
userName: 'admin',
nickName: '管理员1',
phone: '',
email: '',
avatarId: 1,
roleId: 1,
postId: null,
deptId: null,
roleIds: '1',
postIds: '',
remark: '',
enable: null,
lastLoginTime: '2024-01-24T14:56:32.620513+08:00',
roles: [
{
label: '管理员1',
value: 1,
},
],
avatarUrl: 'uploads/image/user/avatar/39c63ddb96a31b9610cd976b896ad4f0_20231016113731.jpg',
},
},
};
/**图形验证码 */
export const mockBaseCaptchaData = {
data: {
captchaId: 'FeAftCoXZXjQ93CRfHuj',
picPath:
'data:image/png;base64,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',
captchaLength: 6,
openCaptcha: true,
},
msg: '验证码获取成功',
};

@ -1,5 +0,0 @@
export default {
'/api/auth_routes': {
'/form/advanced-form': { authority: ['admin', 'user'] },
},
};

@ -0,0 +1,26 @@
/*
* @Author: donghao donghao@supervision.ltd
* @Date: 2024-01-24 15:21:35
* @LastEditors: donghao donghao@supervision.ltd
* @LastEditTime: 2024-01-24 16:36:07
* @FilePath: \general-ai-platform-web\mock\typing.ts
* @Description: ,`customMade`, koroFileHeader : https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
/**成功返回数据结构 */
export interface successMockApiProps {
code: number // 0 成功
success: boolean // true 成功
data: any // mock业务层数据
msg: string | undefined // 成功提示
isMock: boolean // true 标识当前是模拟数据
}
/**失败返回数据结构 */
export interface failMockApiProps {
code?: number // 7 失败
success: boolean // false 失败
data: any // mock业务层数据
msg: string | undefined // 成功提示
isMock: boolean // true 标识当前是模拟数据
}

@ -1,4 +1,9 @@
// 用户 mock
import { Request, Response } from 'express';
import { mockBaseCaptchaData, mockBaseLoginData, mockGetUserInfoData } from './pools/userData';
import { failMockApiProps, successMockApiProps } from './typing';
import { fetchMockSuccessFullByOther } from './utils/apiMock';
const waitTime = (time: number = 100) => {
return new Promise((resolve) => {
@ -117,44 +122,71 @@ export default {
address: 'Sidney No. 1 Lake Park',
},
],
'POST /api/login/account': async (req: Request, res: Response) => {
// 登录
'POST /api/v1/base/login': async (req: Request, res: Response) => {
const { password, username, type } = req.body;
await waitTime(2000);
if (password === 'ant.design' && username === 'admin') {
res.send({
status: 'ok',
type,
currentAuthority: 'admin',
});
await waitTime(1000);
if (password === '123456' && username === 'admin') {
const adminData: successMockApiProps = {
...fetchMockSuccessFullByOther(mockBaseLoginData),
};
res.send(adminData);
access = 'admin';
return;
}
if (password === 'ant.design' && username === 'user') {
res.send({
status: 'ok',
type,
currentAuthority: 'user',
});
access = 'user';
return;
}
if (type === 'mobile') {
res.send({
status: 'ok',
type,
currentAuthority: 'admin',
});
access = 'admin';
return;
}
res.send({
status: 'error',
type,
currentAuthority: 'guest',
});
// TODO 以下未做任何处理
// if (password === 'ant.design' && username === 'user') {
// res.send({
// status: 'ok',
// type,
// currentAuthority: 'user',
// });
// access = 'user';
// return;
// }
// if (type === 'mobile') {
// res.send({
// status: 'ok',
// type,
// currentAuthority: 'admin',
// });
// access = 'admin';
// return;
// }
const failData: failMockApiProps = {
...fetchMockFailFullByOther({
data: {},
msg: '账号或者密码错误',
}),
};
res.send(failData as failMockApiProps);
access = 'guest';
},
// 获取用户信息
'GET /api/v1/user/getUserInfo': async (req: Request, res: Response) => {
await waitTime(1000);
const adminData: successMockApiProps = {
...fetchMockSuccessFullByOther(mockGetUserInfoData),
};
res.send(adminData);
access = 'admin';
},
// 获取图形验证码
'POST /api/v1/base/captcha': (req: Request, res: Response) => {
const resData: successMockApiProps = {
...fetchMockSuccessFullByOther(mockBaseCaptchaData),
};
res.send(resData);
},
// 登出
'POST /api/v1/jwt/jsonInBlacklist': (req: Request, res: Response) => {
const resData: successMockApiProps = {
...fetchMockSuccessFullByOther({ data: {}, msg: 'jwt作废成功' }),
};
res.send(resData);
},
'POST /api/login/outLogin': (req: Request, res: Response) => {
access = '';
res.send({ data: {}, success: true });
@ -198,6 +230,4 @@ export default {
path: '/base/category/list',
});
},
'GET /api/login/captcha': getFakeCaptcha,
};

@ -0,0 +1,29 @@
/*
* @Author: donghao donghao@supervision.ltd
* @Date: 2024-01-24 15:08:23
* @LastEditors: donghao donghao@supervision.ltd
* @LastEditTime: 2024-01-24 17:00:49
* @FilePath: \general-ai-platform-web\mock\utils\apiMock.ts
* @Description: ,`customMade`, koroFileHeader : https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
import { failMockApiProps, successMockApiProps } from '../typing';
export function fetchMockSuccessFullByOther({ data, msg }): successMockApiProps {
return {
code: 0, // 0 成功
success: true, // true 成功
data: data || null, // mock业务层数据
msg: msg | 'ok', // 成功提示
isMock: true, // true 标识当前是模拟数据
} as successMockApiProps;
}
export function fetchMockFailFullByOther({ data, msg }): failMockApiProps {
return {
code: 599, // 0 成功
success: true, // true 成功
data: data || null, // mock业务层数据
msg: msg | 'fail', // 成功提示
isMock: true, // true 标识当前是模拟数据
} as failMockApiProps;
}

@ -311,7 +311,6 @@ const OccupyProportion: React.FC<{
</li>
</ul> */}
</div>
<div className="occupy_des">
<ul
style={{

Loading…
Cancel
Save