@slice_cy/mint 1.2.0

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 (98) hide show
  1. package/README.md +697 -0
  2. package/app/common/base-response.js +10 -0
  3. package/app/common/business-error.js +10 -0
  4. package/app/common/error-code.js +22 -0
  5. package/app/common/return-utils.js +40 -0
  6. package/app/common/router-schema-validator.js +25 -0
  7. package/app/controller/base.js +24 -0
  8. package/app/controller/project.js +90 -0
  9. package/app/controller/view.js +13 -0
  10. package/app/docs/dsl-doc.js +148 -0
  11. package/app/extend/logger.js +30 -0
  12. package/app/extend/params-valid.js +6 -0
  13. package/app/extend/return-utils.js +9 -0
  14. package/app/middleware/api-sign-verify.js +25 -0
  15. package/app/middleware/err-handler.js +18 -0
  16. package/app/middleware/project-handler.js +25 -0
  17. package/app/pages/boot.js +34 -0
  18. package/app/pages/dashboard/complex-view/header-view/index.vue +108 -0
  19. package/app/pages/dashboard/complex-view/iframe-view/index.vue +37 -0
  20. package/app/pages/dashboard/complex-view/schema-view/complex-view/search-panel/index.vue +36 -0
  21. package/app/pages/dashboard/complex-view/schema-view/complex-view/table-panel/index.vue +123 -0
  22. package/app/pages/dashboard/complex-view/schema-view/components/component-config.js +14 -0
  23. package/app/pages/dashboard/complex-view/schema-view/components/createForm/index.vue +72 -0
  24. package/app/pages/dashboard/complex-view/schema-view/components/detailPanel/index.vue +52 -0
  25. package/app/pages/dashboard/complex-view/schema-view/components/editForm/index.vue +87 -0
  26. package/app/pages/dashboard/complex-view/schema-view/hook/use-schema.js +113 -0
  27. package/app/pages/dashboard/complex-view/schema-view/index.vue +114 -0
  28. package/app/pages/dashboard/complex-view/sider-view/index.vue +116 -0
  29. package/app/pages/dashboard/entry.dashboard.js +44 -0
  30. package/app/pages/dashboard/index.vue +60 -0
  31. package/app/pages/service/index.js +70 -0
  32. package/app/pages/store/index.js +4 -0
  33. package/app/pages/store/menu.js +86 -0
  34. package/app/pages/store/project.js +9 -0
  35. package/app/pages/utils/index.js +26 -0
  36. package/app/pages/widgets/header-container/assets/avatar.png +0 -0
  37. package/app/pages/widgets/header-container/assets/icon.png +0 -0
  38. package/app/pages/widgets/header-container/index.vue +108 -0
  39. package/app/pages/widgets/schema-form/components/input/index.vue +155 -0
  40. package/app/pages/widgets/schema-form/components/input-number/index.vue +148 -0
  41. package/app/pages/widgets/schema-form/components/select/index.vue +132 -0
  42. package/app/pages/widgets/schema-form/form-item-cofnig.js +18 -0
  43. package/app/pages/widgets/schema-form/index.vue +137 -0
  44. package/app/pages/widgets/schema-search-bar/component/date-range-picker/index.vue +55 -0
  45. package/app/pages/widgets/schema-search-bar/component/dynamic-select/index.vue +70 -0
  46. package/app/pages/widgets/schema-search-bar/component/input/index.vue +54 -0
  47. package/app/pages/widgets/schema-search-bar/component/select/index.vue +65 -0
  48. package/app/pages/widgets/schema-search-bar/index.vue +143 -0
  49. package/app/pages/widgets/schema-search-bar/search-item-config.js +20 -0
  50. package/app/pages/widgets/schema-table/index.vue +198 -0
  51. package/app/pages/widgets/sider-container/index.vue +30 -0
  52. package/app/post-router.js +9 -0
  53. package/app/pre-middleware.js +37 -0
  54. package/app/public/dist/entry.dashboard.tpl +2 -0
  55. package/app/public/dist/entry.project-list.tpl +2 -0
  56. package/app/public/dist/prod/css/async.609.bcbe5779.css +1 -0
  57. package/app/public/dist/prod/css/async.952.9bc7c180.css +1 -0
  58. package/app/public/dist/prod/css/common.1a98227b.css +1 -0
  59. package/app/public/dist/prod/css/entry.project-list.14f64dd9.css +1 -0
  60. package/app/public/dist/prod/js/142.56646c73.bundle.js +1 -0
  61. package/app/public/dist/prod/js/609.8270b20d.bundle.js +1 -0
  62. package/app/public/dist/prod/js/68.2813fafe.bundle.js +1 -0
  63. package/app/public/dist/prod/js/952.c76c04fb.bundle.js +1 -0
  64. package/app/public/dist/prod/js/common.9985f827.bundle.js +1 -0
  65. package/app/public/dist/prod/js/entry.dashboard.cd7591e4.bundle.js +1 -0
  66. package/app/public/dist/prod/js/entry.project-list.beb0fa9d.bundle.js +1 -0
  67. package/app/public/dist/prod/js/runtime.5602b906.bundle.js +1 -0
  68. package/app/public/dist/prod/js/vendor.709fbf32.bundle.js +53 -0
  69. package/app/public/dist/prod/static/images/avatar.78e68eaa.png +0 -0
  70. package/app/public/dist/static/logo.png +0 -0
  71. package/app/public/dist/static/normalize.css +1 -0
  72. package/app/public/static/logo.png +0 -0
  73. package/app/public/static/normalize.css +267 -0
  74. package/app/router/project.js +6 -0
  75. package/app/router/view.js +5 -0
  76. package/app/router-schema/project.js +14 -0
  77. package/app/service/base.js +22 -0
  78. package/app/service/project.js +49 -0
  79. package/app/view/entry.tpl +18 -0
  80. package/app/webpack/config/webpack.base.js +288 -0
  81. package/app/webpack/config/webpack.dev.js +53 -0
  82. package/app/webpack/config/webpack.prod.js +106 -0
  83. package/app/webpack/dev.js +34 -0
  84. package/app/webpack/libs/block.js +1 -0
  85. package/app/webpack/prod.js +21 -0
  86. package/config/config.default.js +5 -0
  87. package/index.js +37 -0
  88. package/mint-core/env.js +23 -0
  89. package/mint-core/index.js +101 -0
  90. package/mint-core/loader/config.js +59 -0
  91. package/mint-core/loader/controller.js +59 -0
  92. package/mint-core/loader/extend.js +42 -0
  93. package/mint-core/loader/middleware.js +54 -0
  94. package/mint-core/loader/router-schema.js +39 -0
  95. package/mint-core/loader/router.js +36 -0
  96. package/mint-core/loader/service.js +57 -0
  97. package/model/index.js +94 -0
  98. package/package.json +93 -0
@@ -0,0 +1,57 @@
1
+ const path = require("path");
2
+ const glob = require("glob");
3
+ const { sep } = path;
4
+ /**
5
+ * 把多个中间件函数注册到app.service
6
+ * @param {object} app koa 实例
7
+ *
8
+ * 文件系统:app/service
9
+ * | custom-model
10
+ * | xxx.js
11
+ * | custom-service.js
12
+ * 结果: app.service.customModel.customService
13
+ */
14
+
15
+ module.exports = (app) => {
16
+ // 读取app/service目录路径
17
+ const businessServicePath = path.join(app.businessPath, `service`);
18
+ // 读取eplis内部app/service目录路径
19
+ const mintServicePath = path.join(__dirname, `..${sep}..${sep}app${sep}service`);
20
+
21
+ // 获取所有文件
22
+ const businessFileList = glob.sync(path.join(businessServicePath, "**", "*.js"));
23
+ const mintFileList = glob.sync(path.join(mintServicePath, "**", "*.js"));
24
+
25
+ const service = {};
26
+
27
+ const handleFile = (filePath, servicePath) => {
28
+ let tempService = service;
29
+ // 从路径中截取合法的子路径(subtring截取在不同的操作系统上分隔符不一样可能会错位,使用path的api进行兼容替代)
30
+ let relPath = path.relative(servicePath, filePath);
31
+ // 将 - 或者 _ 转换成驼峰
32
+ relPath = relPath.replace(/[-_](\w)/gi, (_, letter) => letter.toUpperCase());
33
+ const parts = relPath.split(sep);
34
+ let filename = parts.pop();
35
+ filename = path.parse(filename).name;
36
+ const names = [...parts, filename];
37
+
38
+ // 创建嵌套对象指向
39
+ for (let i = 0, len = names.length; i < len; ++i) {
40
+ if (i == len - 1) {
41
+ const Service = require(filePath)(app);
42
+ tempService[names[i]] = new Service();
43
+ } else {
44
+ if (!tempService[names[i]]) {
45
+ tempService[names[i]] = {};
46
+ }
47
+ tempService = tempService[names[i]];
48
+ }
49
+ }
50
+ };
51
+ // 遍历所有文件
52
+ mintFileList.forEach((filePath) => handleFile(filePath, mintServicePath));
53
+ businessFileList.forEach((filePath) => handleFile(filePath, businessServicePath));
54
+
55
+ // 挂载到app.service中
56
+ app.service = service;
57
+ };
package/model/index.js ADDED
@@ -0,0 +1,94 @@
1
+ const glob = require("glob");
2
+ const path = require("path");
3
+ const { mergeWith, cloneDeep } = require("lodash");
4
+ const { sep } = path;
5
+
6
+ const projectExtendModel = (model, project) => {
7
+ return mergeWith(model, project, (modelValue, projectValue) => {
8
+ if (Array.isArray(modelValue) && Array.isArray(projectValue)) {
9
+ const resultList = [];
10
+ /**
11
+ * model有,project没有 -> 新增
12
+ * model有,project有 -> 合并
13
+ * project有,model没有 -> 新增
14
+ * project有,model也有 -> 合并
15
+ */
16
+ for (let i = 0; i < modelValue.length; i++) {
17
+ const modelItem = modelValue[i];
18
+ const projectItem = projectValue.find((i) => i.key === modelItem.key);
19
+ resultList.push(projectItem ? projectExtendModel(modelItem, projectItem) : modelItem);
20
+ }
21
+
22
+ for (let i = 0; i < projectValue.length; i++) {
23
+ const projectItem = projectValue[i];
24
+ const modelItem = modelValue.find((i) => i.key === projectItem.key);
25
+ if (!modelItem) {
26
+ resultList.push(projectItem);
27
+ }
28
+ }
29
+ return resultList;
30
+ }
31
+ });
32
+ };
33
+ /**
34
+ * loader结果:
35
+ * modelList: [
36
+ * {
37
+ * model: {},
38
+ * project: {
39
+ * proj1: {},
40
+ * proj2: {}
41
+ * }
42
+ * }
43
+ * ]
44
+ * @param {*} app
45
+ * @returns
46
+ */
47
+ module.exports = (app) => {
48
+ const modelList = [];
49
+ const modelPath = path.join(app.baseDir, "model");
50
+ const fileList = glob.sync(path.join(modelPath, `**${sep}*.js`));
51
+
52
+ fileList.forEach((file) => {
53
+ if (file.indexOf("index.js") > -1) return;
54
+
55
+ const type = file.match(/model\/.*?\/project\/.*?\.js$/)?.length ? "project" : "model";
56
+ if (type === "model") {
57
+ // 处理model
58
+ const modelKey = file.match(/\/model\/(.*?)\/model.js/)?.[1];
59
+ let modelItem = modelList.find((item) => item.model?.key === modelKey);
60
+ if (!modelItem) {
61
+ modelItem = {};
62
+ modelList.push(modelItem);
63
+ }
64
+
65
+ modelItem.model = require(file);
66
+ modelItem.model.key = modelKey;
67
+ }
68
+
69
+ if (type === "project") {
70
+ // 处理project
71
+ const modelKey = file.match(/\/model\/(.*?)\/project/)?.[1];
72
+ const projectKey = file.match(/\/model\/.*?\/project\/(.*?).js/)?.[1];
73
+ let modelItem = modelList.find((item) => item.model?.key === modelKey);
74
+ if (!modelItem) {
75
+ modelItem = {};
76
+ modelList.push(modelItem);
77
+ }
78
+ if (!modelItem?.project) {
79
+ modelItem.project = {};
80
+ }
81
+ modelItem.project[projectKey] = require(file);
82
+ modelItem.project[projectKey].key = projectKey;
83
+ modelItem.project[projectKey].modelKey = modelKey;
84
+ }
85
+ });
86
+
87
+ modelList.forEach((item) => {
88
+ const { model, project } = item;
89
+ for (let key in project) {
90
+ project[key] = projectExtendModel(cloneDeep(model), cloneDeep(project[key]));
91
+ }
92
+ });
93
+ return modelList;
94
+ };
package/package.json ADDED
@@ -0,0 +1,93 @@
1
+ {
2
+ "name": "@slice_cy/mint",
3
+ "version": "1.2.0",
4
+ "description": "",
5
+ "main": "index.js",
6
+ "files": [
7
+ "index.js",
8
+ "mint-core",
9
+ "app",
10
+ "!app/test",
11
+ "config",
12
+ "model",
13
+ "README.md"
14
+ ],
15
+ "scripts": {
16
+ "test": "cross-env NODE_ENV=test nodemon index.js",
17
+ "lint": "eslint . --quiet",
18
+ "lint:fix": "eslint . --fix",
19
+ "format": "prettier . --write",
20
+ "format:check": "prettier . --check",
21
+ "prepare": "husky",
22
+ "commitlint": "commitlint --edit",
23
+ "release": "standard-version",
24
+ "publish": "npm run release && npm publish --access public --registry=https://registry.npmjs.org",
25
+ "docs:dev": "vitepress dev docs --host 0.0.0.0",
26
+ "docs:build": "vitepress build docs",
27
+ "docs:preview": "vitepress preview docs --host 0.0.0.0"
28
+ },
29
+ "keywords": [],
30
+ "author": "zhangchuyuan",
31
+ "license": "ISC",
32
+ "packageManager": "pnpm@10.17.1",
33
+ "dependencies": {
34
+ "@ant-design/icons-vue": "^7.0.1",
35
+ "@babel/core": "^7.24.0",
36
+ "ajv": "^6.15.0",
37
+ "ant-design-vue": "^4.2.6",
38
+ "axios": "^0.19.2",
39
+ "babel-loader": "^8.0.4",
40
+ "copy-webpack-plugin": "^14.0.0",
41
+ "cors": "^2.8.6",
42
+ "css-loader": "^6.11.0",
43
+ "css-minimizer-webpack-plugin": "^5.0.1",
44
+ "express": "^4.18.2",
45
+ "glob": "^7.1.4",
46
+ "html-webpack-inject-attributes-plugin": "^1.0.1",
47
+ "html-webpack-plugin": "^5.5.3",
48
+ "koa": "2.7.0",
49
+ "koa-bodyparser": "^4.2.1",
50
+ "koa-nunjucks-2": "^3.0.2",
51
+ "koa-router": "^7.4.0",
52
+ "koa-static": "^5.0.0",
53
+ "less": "^3.8.1",
54
+ "less-loader": "^13.0.0",
55
+ "lodash": "^4.17.21",
56
+ "log4js": "^6.9.1",
57
+ "md5": "^2.2.1",
58
+ "mini-css-extract-plugin": "^2.10.2",
59
+ "pinia": "^2.1.6",
60
+ "style-loader": "^4.0.0",
61
+ "superagent": "^8.1.2",
62
+ "terser-webpack-plugin": "^5.6.1",
63
+ "thread-loader": "^4.0.4",
64
+ "unplugin-vue-components": "^32.1.0",
65
+ "vue": "^3.5.39",
66
+ "vue-loader": "^17.4.2",
67
+ "vue-router": "^5.1.0",
68
+ "webpack": "^5.107.2",
69
+ "webpack-dev-middleware": "^6.1.1",
70
+ "webpack-hot-middleware": "^2.25.4",
71
+ "webpack-merge": "^6.0.1",
72
+ "zod": "^4.4.3"
73
+ },
74
+ "devDependencies": {
75
+ "@commitlint/cli": "^21.0.1",
76
+ "@commitlint/config-conventional": "^21.0.1",
77
+ "@eslint/js": "^10.0.1",
78
+ "cross-env": "^10.1.0",
79
+ "eslint": "^10.4.0",
80
+ "eslint-config-prettier": "^10.1.8",
81
+ "eslint-plugin-vue": "^10.9.1",
82
+ "globals": "^17.6.0",
83
+ "husky": "^9.1.7",
84
+ "jest": "^30.4.2",
85
+ "nodemon": "^1.19.2",
86
+ "prettier": "^3.8.4",
87
+ "standard-version": "^9.5.0",
88
+ "supertest": "^7.2.2",
89
+ "vue-eslint-parser": "^10.4.0",
90
+ "webpack-bundle-analyzer": "^5.3.0",
91
+ "vitepress": "^1.6.4"
92
+ }
93
+ }