@zgfe/business-lib 1.1.46 → 1.1.48

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.
package/config.js CHANGED
@@ -8,12 +8,32 @@ const path = require('path');
8
8
  */
9
9
  function getConfig(defaultConfig, basePath) {
10
10
  const configPath = path.resolve(basePath, '.config.json');
11
- if (fs.existsSync(configPath)) {
12
- const config = fs.readFileSync(configPath, 'utf-8');
13
- return JSON.parse(config);
11
+ let resConfig = defaultConfig;
12
+ try {
13
+ if (fs.existsSync(configPath)) {
14
+ const config = fs.readFileSync(configPath, 'utf-8');
15
+ if (!config || config === '{}') {
16
+ throw new Error('配置文件为空');
17
+ }
18
+ const configObj = JSON.parse(config);
19
+ // 如果读取的配置文件,数据结构与默认配置不一致,则更新配置文件,更新规则:以默认配置为准,保留用户自定义配置
20
+ const isSame = Object.keys(defaultConfig).every((key) => {
21
+ return configObj.hasOwnProperty(key);
22
+ });
23
+ if (!isSame) {
24
+ resConfig = Object.assign({}, defaultConfig, configObj);
25
+ throw new Error('配置文件数据结构不一致');
26
+ }
27
+ resConfig = configObj;
28
+ } else {
29
+ throw new Error('配置文件不存在');
30
+ }
31
+ } catch (e) {
32
+ console.log(e.message);
33
+ fs.writeFileSync(configPath, JSON.stringify(resConfig, null, 2));
14
34
  }
15
- fs.writeFileSync(configPath, JSON.stringify(defaultConfig, null, 2));
16
- return defaultConfig;
35
+ console.log('配置详情', resConfig);
36
+ return resConfig;
17
37
  }
18
38
 
19
39
  module.exports = {
@@ -1,8 +1,9 @@
1
1
  import React, { ReactNode } from 'react';
2
- import { AppInfoProps } from '../context';
2
+ import { AppInfoProps, GlobalContextProps } from '../context';
3
3
  declare const DemoContent: React.FC<{
4
4
  children?: ReactNode;
5
5
  needMeta?: boolean;
6
6
  currentApp?: AppInfoProps;
7
+ contextProps?: GlobalContextProps;
7
8
  }>;
8
9
  export default DemoContent;
@@ -49,7 +49,8 @@ function ajax(url, options) {
49
49
  var DemoContent = function DemoContent(_ref3) {
50
50
  var children = _ref3.children,
51
51
  currentApp = _ref3.currentApp,
52
- needMeta = _ref3.needMeta;
52
+ needMeta = _ref3.needMeta,
53
+ contextProps = _ref3.contextProps;
53
54
  var _useState = useState([]),
54
55
  _useState2 = _slicedToArray(_useState, 2),
55
56
  eventGroups = _useState2[0],
@@ -168,7 +169,7 @@ var DemoContent = function DemoContent(_ref3) {
168
169
  });
169
170
  }
170
171
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(BizGlobalDataContext.Provider, {
171
- value: {
172
+ value: _objectSpread({
172
173
  currentApp: _objectSpread(_objectSpread({}, currentApp), {}, {
173
174
  appId: currentApp === null || currentApp === void 0 ? void 0 : currentApp.id
174
175
  }),
@@ -178,7 +179,7 @@ var DemoContent = function DemoContent(_ref3) {
178
179
  eventIdMap: store === null || store === void 0 ? void 0 : store.eventIdMap,
179
180
  eventNameMap: store === null || store === void 0 ? void 0 : store.eventNameMap,
180
181
  userGroupList: userGroups
181
- }
182
+ }, contextProps)
182
183
  }, children));
183
184
  };
184
185
  export default DemoContent;
@@ -15,7 +15,8 @@ var DemoWrapper = function DemoWrapper(_ref) {
15
15
  var children = _ref.children,
16
16
  className = _ref.className,
17
17
  defaultApp = _ref.defaultApp,
18
- needMeta = _ref.needMeta;
18
+ needMeta = _ref.needMeta,
19
+ contextProps = _ref.contextProps;
19
20
  var _useState = useState(true),
20
21
  _useState2 = _slicedToArray(_useState, 2),
21
22
  loading = _useState2[0],
@@ -69,7 +70,8 @@ var DemoWrapper = function DemoWrapper(_ref) {
69
70
  }) : /*#__PURE__*/React.createElement(DemoContent, {
70
71
  currentApp: app,
71
72
  needMeta: needMeta,
72
- key: app === null || app === void 0 ? void 0 : app.appId
73
+ key: app === null || app === void 0 ? void 0 : app.appId,
74
+ contextProps: contextProps
73
75
  }, children));
74
76
  };
75
77
  export default DemoWrapper;
@@ -1,10 +1,12 @@
1
1
  import React, { ReactNode } from 'react';
2
+ import { GlobalContextProps } from '../context';
2
3
  declare namespace DemoWrapperTypes {
3
4
  interface Props {
4
5
  className?: string;
5
6
  defaultApp?: number;
6
7
  needMeta?: boolean;
7
8
  children?: ReactNode;
9
+ contextProps?: GlobalContextProps;
8
10
  }
9
11
  }
10
12
  export declare const Props: React.FC<DemoWrapperTypes.Props>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zgfe/business-lib",
3
- "version": "1.1.46",
3
+ "version": "1.1.48",
4
4
  "scripts": {
5
5
  "start": "dumi dev",
6
6
  "docs:build": "dumi build",
@@ -60,5 +60,5 @@
60
60
  "react": "^16.12.0 || ^17.0.0",
61
61
  "yorkie": "^2.0.0"
62
62
  },
63
- "gitHead": "e2f88bda1687860eabfc88b95bc95cd853b7134c"
63
+ "gitHead": "7e4a250cd2198b2f1bf9228858c4ffc818efdb54"
64
64
  }