@bit-sun/business-component 3.0.0-alpha.1 → 3.0.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,4 +5,7 @@ export declare const doDetailPageAction: (config: actionItem) => void;
5
5
  export declare const getBreadcrumbNameMap: (menuData: any) => {};
6
6
  export declare const judgeIsEmpty: (value: any) => boolean;
7
7
  export declare const getMainCrumbNameMap: (menuData: any) => {};
8
+ export declare const getModeTypeText: (path: any) => "编辑" | "查看" | "新增" | "--";
9
+ export declare function matchRoute(path: any, routeObj: any, hideRouteObj: any): any;
10
+ export declare const getDetailMatchRoute: (path: any, routeObj: any, hideRouteArray: any) => any;
8
11
  export {};
package/dist/index.esm.js CHANGED
@@ -12240,6 +12240,57 @@ var getMainCrumbNameMap = function getMainCrumbNameMap(menuData) {
12240
12240
  flattenMenuData(menuData, {});
12241
12241
  return routerMap;
12242
12242
  };
12243
+ // mode类型判断
12244
+ var getModeTypeText = function getModeTypeText(path) {
12245
+ if (path.includes('edit')) {
12246
+ return '编辑';
12247
+ }
12248
+ if (path.includes('view')) {
12249
+ return '查看';
12250
+ }
12251
+ if (path.includes('create') || path.includes('add')) {
12252
+ return '新增';
12253
+ }
12254
+ return '--';
12255
+ };
12256
+ function matchRoute(path, routeObj, hideRouteObj) {
12257
+ // 检查是否为特殊路由(add/view/edit)
12258
+ var specialMatch = path.match(/(.*)(\/add|\/create|\/view\/([^\/](.*))+|\/edit\/([^\/](.*))+)$/);
12259
+ if (specialMatch) {
12260
+ // 截取关键部分进行匹配
12261
+ var basePath = specialMatch[1];
12262
+ var matchedRoute = routeObj[basePath];
12263
+ return matchedRoute ? matchedRoute : null; // 如果找到匹配的路由则返回,否则返回null
12264
+ }
12265
+ // 检查是否为action路由
12266
+ var actionMatch = path.match(/.*\/action\/.*/);
12267
+ if (actionMatch) {
12268
+ // 从hideRouteObj中进行全量匹配
12269
+ var _matchedRoute = hideRouteObj[path];
12270
+ return _matchedRoute ? _matchedRoute : null; // 如果找到匹配的路由则返回,否则返回null
12271
+ }
12272
+ // 如果都不匹配,返回null
12273
+ return null;
12274
+ }
12275
+ var getDetailMatchRoute = function getDetailMatchRoute(path, routeObj, hideRouteArray) {
12276
+ var newPath = path.split('?')[0];
12277
+ var hideRouteObj = _defineProperty({}, newPath, hideRouteArray.find(function (itemRoute) {
12278
+ return pathToRegexp(itemRoute.path).test(newPath);
12279
+ }));
12280
+ var matchedRoute = matchRoute(newPath, routeObj, hideRouteObj);
12281
+ if (matchedRoute) {
12282
+ var modeTypeText = path.match(/.*\/action\/.*/) ? '' : getModeTypeText(path);
12283
+ var detailName = matchedRoute.name + modeTypeText;
12284
+ var listNameMap = (matchedRoute === null || matchedRoute === void 0 ? void 0 : matchedRoute.nameMap) || [];
12285
+ listNameMap.pop();
12286
+ return _objectSpread2(_objectSpread2({}, matchedRoute), {}, {
12287
+ path: path,
12288
+ name: detailName,
12289
+ nameMap: listNameMap.concat([detailName])
12290
+ });
12291
+ }
12292
+ return undefined;
12293
+ };
12243
12294
 
12244
12295
  var css_248z$b = ".detail_page_head {\n height: 54px;\n display: flex;\n align-items: center;\n background-color: #FFFFFF;\n border-bottom: 1px solid #f0f0f0;\n}\n.detail_page_head .ant-breadcrumb {\n display: block !important;\n}\n.detail_page_head .ant-breadcrumb .ant-breadcrumb-separator {\n margin: 0 2px;\n}\n.detail_page_head .ant-breadcrumb li .bread_name {\n color: #8A8F8D;\n font-size: 12px;\n cursor: pointer;\n}\n.detail_page_head .ant-breadcrumb li .bread_name:hover {\n color: #000000d9;\n}\n.back_home_img_content {\n display: inline-block;\n height: 28px;\n width: 28px;\n border: 1px solid #BABABA;\n margin: 0 12px 0 20px;\n border-radius: 14px;\n display: flex;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n}\n.back_home_img_content .anticon-arrow-left {\n color: #BABABA;\n}\n.back_home_img_content:hover {\n background-color: #005CFF;\n border: 1px solid #005CFF;\n}\n.back_home_img_content:hover .anticon-arrow-left {\n color: #FFFFFF;\n}\n.detail_page_title_box {\n flex-grow: 1;\n}\n.detail_page_title {\n height: 20px;\n font-family: PingFangSC;\n font-weight: 600;\n font-size: 16px;\n margin-top: 2px;\n color: #000000;\n letter-spacing: 0;\n line-height: 20px;\n}\n.detail_page_btns {\n display: flex;\n gap: 8px;\n margin-right: 20px;\n}\n.detail_page_btns button {\n height: 32px !important;\n display: flex;\n align-items: center;\n gap: 2px;\n border-radius: 3px;\n padding: 0 10px;\n}\n.detail_page_btns .ant-btn-dangerous {\n background-color: #EC5246 !important;\n}\n";
12245
12296
  styleInject(css_248z$b);
@@ -12349,7 +12400,7 @@ var DetailWrapper = /*#__PURE__*/React.memo(function (_ref) {
12349
12400
  return pathKey ? breadcrumbNameMap[pathKey] : undefined;
12350
12401
  };
12351
12402
  var getPageTitle = function getPageTitle(pathname) {
12352
- var currRouterData = matchParamsPath("".concat(basePath).concat(pathname), breadcrumbNameMap);
12403
+ var currRouterData = matchParamsPath("".concat(basePath).concat(pathname), breadcrumbNameMap) || getDetailMatchRoute("".concat(basePath).concat(pathname), breadcrumbNameMap, []);
12353
12404
  if (!currRouterData) {
12354
12405
  return '';
12355
12406
  }
package/dist/index.js CHANGED
@@ -12262,6 +12262,57 @@ var getMainCrumbNameMap = function getMainCrumbNameMap(menuData) {
12262
12262
  flattenMenuData(menuData, {});
12263
12263
  return routerMap;
12264
12264
  };
12265
+ // mode类型判断
12266
+ var getModeTypeText = function getModeTypeText(path) {
12267
+ if (path.includes('edit')) {
12268
+ return '编辑';
12269
+ }
12270
+ if (path.includes('view')) {
12271
+ return '查看';
12272
+ }
12273
+ if (path.includes('create') || path.includes('add')) {
12274
+ return '新增';
12275
+ }
12276
+ return '--';
12277
+ };
12278
+ function matchRoute(path, routeObj, hideRouteObj) {
12279
+ // 检查是否为特殊路由(add/view/edit)
12280
+ var specialMatch = path.match(/(.*)(\/add|\/create|\/view\/([^\/](.*))+|\/edit\/([^\/](.*))+)$/);
12281
+ if (specialMatch) {
12282
+ // 截取关键部分进行匹配
12283
+ var basePath = specialMatch[1];
12284
+ var matchedRoute = routeObj[basePath];
12285
+ return matchedRoute ? matchedRoute : null; // 如果找到匹配的路由则返回,否则返回null
12286
+ }
12287
+ // 检查是否为action路由
12288
+ var actionMatch = path.match(/.*\/action\/.*/);
12289
+ if (actionMatch) {
12290
+ // 从hideRouteObj中进行全量匹配
12291
+ var _matchedRoute = hideRouteObj[path];
12292
+ return _matchedRoute ? _matchedRoute : null; // 如果找到匹配的路由则返回,否则返回null
12293
+ }
12294
+ // 如果都不匹配,返回null
12295
+ return null;
12296
+ }
12297
+ var getDetailMatchRoute = function getDetailMatchRoute(path, routeObj, hideRouteArray) {
12298
+ var newPath = path.split('?')[0];
12299
+ var hideRouteObj = _defineProperty({}, newPath, hideRouteArray.find(function (itemRoute) {
12300
+ return pathToRegexp(itemRoute.path).test(newPath);
12301
+ }));
12302
+ var matchedRoute = matchRoute(newPath, routeObj, hideRouteObj);
12303
+ if (matchedRoute) {
12304
+ var modeTypeText = path.match(/.*\/action\/.*/) ? '' : getModeTypeText(path);
12305
+ var detailName = matchedRoute.name + modeTypeText;
12306
+ var listNameMap = (matchedRoute === null || matchedRoute === void 0 ? void 0 : matchedRoute.nameMap) || [];
12307
+ listNameMap.pop();
12308
+ return _objectSpread2(_objectSpread2({}, matchedRoute), {}, {
12309
+ path: path,
12310
+ name: detailName,
12311
+ nameMap: listNameMap.concat([detailName])
12312
+ });
12313
+ }
12314
+ return undefined;
12315
+ };
12265
12316
 
12266
12317
  var css_248z$b = ".detail_page_head {\n height: 54px;\n display: flex;\n align-items: center;\n background-color: #FFFFFF;\n border-bottom: 1px solid #f0f0f0;\n}\n.detail_page_head .ant-breadcrumb {\n display: block !important;\n}\n.detail_page_head .ant-breadcrumb .ant-breadcrumb-separator {\n margin: 0 2px;\n}\n.detail_page_head .ant-breadcrumb li .bread_name {\n color: #8A8F8D;\n font-size: 12px;\n cursor: pointer;\n}\n.detail_page_head .ant-breadcrumb li .bread_name:hover {\n color: #000000d9;\n}\n.back_home_img_content {\n display: inline-block;\n height: 28px;\n width: 28px;\n border: 1px solid #BABABA;\n margin: 0 12px 0 20px;\n border-radius: 14px;\n display: flex;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n}\n.back_home_img_content .anticon-arrow-left {\n color: #BABABA;\n}\n.back_home_img_content:hover {\n background-color: #005CFF;\n border: 1px solid #005CFF;\n}\n.back_home_img_content:hover .anticon-arrow-left {\n color: #FFFFFF;\n}\n.detail_page_title_box {\n flex-grow: 1;\n}\n.detail_page_title {\n height: 20px;\n font-family: PingFangSC;\n font-weight: 600;\n font-size: 16px;\n margin-top: 2px;\n color: #000000;\n letter-spacing: 0;\n line-height: 20px;\n}\n.detail_page_btns {\n display: flex;\n gap: 8px;\n margin-right: 20px;\n}\n.detail_page_btns button {\n height: 32px !important;\n display: flex;\n align-items: center;\n gap: 2px;\n border-radius: 3px;\n padding: 0 10px;\n}\n.detail_page_btns .ant-btn-dangerous {\n background-color: #EC5246 !important;\n}\n";
12267
12318
  styleInject(css_248z$b);
@@ -12371,7 +12422,7 @@ var DetailWrapper = /*#__PURE__*/React__default['default'].memo(function (_ref)
12371
12422
  return pathKey ? breadcrumbNameMap[pathKey] : undefined;
12372
12423
  };
12373
12424
  var getPageTitle = function getPageTitle(pathname) {
12374
- var currRouterData = matchParamsPath("".concat(basePath).concat(pathname), breadcrumbNameMap);
12425
+ var currRouterData = matchParamsPath("".concat(basePath).concat(pathname), breadcrumbNameMap) || getDetailMatchRoute("".concat(basePath).concat(pathname), breadcrumbNameMap, []);
12375
12426
  if (!currRouterData) {
12376
12427
  return '';
12377
12428
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bit-sun/business-component",
3
- "version": "3.0.0-alpha.1",
3
+ "version": "3.0.0-alpha.2",
4
4
  "scripts": {
5
5
  "start": "dumi dev",
6
6
  "docs:build": "dumi build",
@@ -28,8 +28,8 @@
28
28
  },
29
29
  "peerDependencies": {
30
30
  "antd": "^4.17.2",
31
- "bssula": "3.0.0-alpha.1",
32
- "umi-plugin-bssula": "3.0.0-alpha.1",
31
+ "bssula": "3.0.0-y.0",
32
+ "umi-plugin-bssula": "3.0.0-y.0",
33
33
  "umi": "^3.5.20",
34
34
  "@ant-design/pro-layout": "^6.5.0",
35
35
  "react-dnd": "^16.0.1",
@@ -5,7 +5,7 @@ import {
5
5
  import { Anchor, Tooltip, Button, Menu, Dropdown, Breadcrumb } from 'antd';
6
6
  import React, { useEffect, useState, useMemo } from 'react';
7
7
  import { history } from 'umi';
8
- import { getMainCrumbNameMap, doDetailPageAction, judgeIsEmpty } from './utils';
8
+ import { getMainCrumbNameMap, doDetailPageAction, judgeIsEmpty, getDetailMatchRoute } from './utils';
9
9
  import { memoizeOneFormatter, go2BackAndClose } from '@/utils/utils';
10
10
  import './index.less';
11
11
  import quanping from '../../../assets/icon-quanping.svg';
@@ -89,7 +89,7 @@ const DetailWrapper = React.memo(
89
89
  const currRouterData = matchParamsPath(
90
90
  `${basePath}${pathname}`,
91
91
  breadcrumbNameMap,
92
- );
92
+ ) || getDetailMatchRoute(`${basePath}${pathname}`,breadcrumbNameMap,[]);
93
93
 
94
94
  if (!currRouterData) {
95
95
  return '';
@@ -98,4 +98,63 @@ export const getMainCrumbNameMap = (menuData) => {
98
98
  };
99
99
  flattenMenuData(menuData, {});
100
100
  return routerMap;
101
- }
101
+ }
102
+
103
+
104
+ // mode类型判断
105
+ export const getModeTypeText = (path: any) => {
106
+ if (path.includes('edit')) {
107
+ return '编辑';
108
+ }
109
+ if (path.includes('view')) {
110
+ return '查看';
111
+ }
112
+ if (path.includes('create') || path.includes('add')) {
113
+ return '新增';
114
+ }
115
+ return '--';
116
+ };
117
+
118
+ export function matchRoute(path, routeObj, hideRouteObj) {
119
+ // 检查是否为特殊路由(add/view/edit)
120
+ const specialMatch = path.match(/(.*)(\/add|\/create|\/view\/([^\/](.*))+|\/edit\/([^\/](.*))+)$/);
121
+
122
+ if (specialMatch) {
123
+ // 截取关键部分进行匹配
124
+ const basePath = specialMatch[1];
125
+ const matchedRoute = routeObj[basePath];
126
+ return matchedRoute ? matchedRoute : null; // 如果找到匹配的路由则返回,否则返回null
127
+ }
128
+
129
+ // 检查是否为action路由
130
+ const actionMatch = path.match(/.*\/action\/.*/);
131
+ if (actionMatch) {
132
+ // 从hideRouteObj中进行全量匹配
133
+ const matchedRoute = hideRouteObj[path]
134
+ return matchedRoute ? matchedRoute : null; // 如果找到匹配的路由则返回,否则返回null
135
+ }
136
+
137
+ // 如果都不匹配,返回null
138
+ return null;
139
+ }
140
+
141
+ export const getDetailMatchRoute = (path, routeObj, hideRouteArray) => {
142
+ const newPath = path.split('?')[0]
143
+ const hideRouteObj = {
144
+ [newPath]: hideRouteArray.find((itemRoute) => pathToRegexp(itemRoute.path).test(newPath))
145
+ }
146
+ const matchedRoute = matchRoute(newPath, routeObj, hideRouteObj);
147
+ if (matchedRoute) {
148
+ const modeTypeText = path.match(/.*\/action\/.*/) ? '' : getModeTypeText(path);
149
+ const detailName = matchedRoute.name + modeTypeText;
150
+ const listNameMap = matchedRoute?.nameMap||[];
151
+ listNameMap.pop()
152
+ return {
153
+ ...matchedRoute,
154
+ path,
155
+ name: detailName,
156
+ nameMap: listNameMap.concat([detailName])
157
+ };
158
+ }
159
+ return undefined
160
+ }