@zgfe/business-lib 1.1.44 → 1.1.46

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.
Files changed (3) hide show
  1. package/config.js +21 -0
  2. package/package.json +3 -3
  3. package/.umirc.ts +0 -57
package/config.js ADDED
@@ -0,0 +1,21 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+
4
+ /**
5
+ * 对关键配置信息进行本地化存储,避免多人项目配置代码冲突
6
+ * @param defaultConfig
7
+ * @returns
8
+ */
9
+ function getConfig(defaultConfig, basePath) {
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);
14
+ }
15
+ fs.writeFileSync(configPath, JSON.stringify(defaultConfig, null, 2));
16
+ return defaultConfig;
17
+ }
18
+
19
+ module.exports = {
20
+ getConfig,
21
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zgfe/business-lib",
3
- "version": "1.1.44",
3
+ "version": "1.1.46",
4
4
  "scripts": {
5
5
  "start": "dumi dev",
6
6
  "docs:build": "dumi build",
@@ -20,7 +20,7 @@
20
20
  },
21
21
  "files": [
22
22
  "es",
23
- ".umirc.ts"
23
+ "config.js"
24
24
  ],
25
25
  "lint-staged": {
26
26
  "*.{js,jsx,less,md,json}": [
@@ -60,5 +60,5 @@
60
60
  "react": "^16.12.0 || ^17.0.0",
61
61
  "yorkie": "^2.0.0"
62
62
  },
63
- "gitHead": "5c1fda9e1cbe6a0dd4619b3eca1a0c36c6bcb22b"
63
+ "gitHead": "e2f88bda1687860eabfc88b95bc95cd853b7134c"
64
64
  }
package/.umirc.ts DELETED
@@ -1,57 +0,0 @@
1
- import { defineConfig } from 'dumi';
2
- import { theme } from './src/assets/theme';
3
- import * as fs from 'fs';
4
- import * as path from 'path';
5
-
6
- /**
7
- * 对关键配置信息进行本地化存储,避免多人项目配置代码冲突
8
- * @param defaultConfig
9
- * @returns
10
- */
11
- export function getConfig<T>(defaultConfig: T): T {
12
- // 判断配置文件是否存在
13
- const configPath = path.resolve(__dirname, '.config.json');
14
- if (fs.existsSync(configPath)) {
15
- const config = fs.readFileSync(configPath, 'utf-8');
16
- return JSON.parse(config);
17
- }
18
- // 不存在则创建配置文件, 并写入默认配置
19
- fs.writeFileSync(configPath, JSON.stringify(defaultConfig, null, 2));
20
- return defaultConfig;
21
- }
22
-
23
- const config = getConfig<{
24
- target: string;
25
- mockKey: string;
26
- }>({
27
- target: 'https://mock.clevertools.cn',
28
- mockKey: 'e8e9f051-e314-11ed-9935-f78eebd92bb4',
29
- });
30
-
31
- export default defineConfig({
32
- title: 'business-lib',
33
- favicon:
34
- 'https://user-images.githubusercontent.com/9554297/83762004-a0761b00-a6a9-11ea-83b4-9c8ff721d4b8.png',
35
- logo: 'https://user-images.githubusercontent.com/9554297/83762004-a0761b00-a6a9-11ea-83b4-9c8ff721d4b8.png',
36
- outputPath: 'docs-dist',
37
- hash: true,
38
- // more config: https://d.umijs.org/config
39
- theme,
40
- devServer: {},
41
- proxy: (() => {
42
- const result = {};
43
- const rules = ['/scene', '/zg/web', '/apppanel', '/analysis/api/'];
44
- rules.forEach((rule) => {
45
- result[rule] = {
46
- target: config.target,
47
- logLevel: 'info',
48
- secure: false,
49
- changeOrigin: true,
50
- headers: {
51
- 'clever-mock': config.mockKey,
52
- },
53
- };
54
- });
55
- return result;
56
- })(),
57
- });