@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.
- package/README.md +697 -0
- package/app/common/base-response.js +10 -0
- package/app/common/business-error.js +10 -0
- package/app/common/error-code.js +22 -0
- package/app/common/return-utils.js +40 -0
- package/app/common/router-schema-validator.js +25 -0
- package/app/controller/base.js +24 -0
- package/app/controller/project.js +90 -0
- package/app/controller/view.js +13 -0
- package/app/docs/dsl-doc.js +148 -0
- package/app/extend/logger.js +30 -0
- package/app/extend/params-valid.js +6 -0
- package/app/extend/return-utils.js +9 -0
- package/app/middleware/api-sign-verify.js +25 -0
- package/app/middleware/err-handler.js +18 -0
- package/app/middleware/project-handler.js +25 -0
- package/app/pages/boot.js +34 -0
- package/app/pages/dashboard/complex-view/header-view/index.vue +108 -0
- package/app/pages/dashboard/complex-view/iframe-view/index.vue +37 -0
- package/app/pages/dashboard/complex-view/schema-view/complex-view/search-panel/index.vue +36 -0
- package/app/pages/dashboard/complex-view/schema-view/complex-view/table-panel/index.vue +123 -0
- package/app/pages/dashboard/complex-view/schema-view/components/component-config.js +14 -0
- package/app/pages/dashboard/complex-view/schema-view/components/createForm/index.vue +72 -0
- package/app/pages/dashboard/complex-view/schema-view/components/detailPanel/index.vue +52 -0
- package/app/pages/dashboard/complex-view/schema-view/components/editForm/index.vue +87 -0
- package/app/pages/dashboard/complex-view/schema-view/hook/use-schema.js +113 -0
- package/app/pages/dashboard/complex-view/schema-view/index.vue +114 -0
- package/app/pages/dashboard/complex-view/sider-view/index.vue +116 -0
- package/app/pages/dashboard/entry.dashboard.js +44 -0
- package/app/pages/dashboard/index.vue +60 -0
- package/app/pages/service/index.js +70 -0
- package/app/pages/store/index.js +4 -0
- package/app/pages/store/menu.js +86 -0
- package/app/pages/store/project.js +9 -0
- package/app/pages/utils/index.js +26 -0
- package/app/pages/widgets/header-container/assets/avatar.png +0 -0
- package/app/pages/widgets/header-container/assets/icon.png +0 -0
- package/app/pages/widgets/header-container/index.vue +108 -0
- package/app/pages/widgets/schema-form/components/input/index.vue +155 -0
- package/app/pages/widgets/schema-form/components/input-number/index.vue +148 -0
- package/app/pages/widgets/schema-form/components/select/index.vue +132 -0
- package/app/pages/widgets/schema-form/form-item-cofnig.js +18 -0
- package/app/pages/widgets/schema-form/index.vue +137 -0
- package/app/pages/widgets/schema-search-bar/component/date-range-picker/index.vue +55 -0
- package/app/pages/widgets/schema-search-bar/component/dynamic-select/index.vue +70 -0
- package/app/pages/widgets/schema-search-bar/component/input/index.vue +54 -0
- package/app/pages/widgets/schema-search-bar/component/select/index.vue +65 -0
- package/app/pages/widgets/schema-search-bar/index.vue +143 -0
- package/app/pages/widgets/schema-search-bar/search-item-config.js +20 -0
- package/app/pages/widgets/schema-table/index.vue +198 -0
- package/app/pages/widgets/sider-container/index.vue +30 -0
- package/app/post-router.js +9 -0
- package/app/pre-middleware.js +37 -0
- package/app/public/dist/entry.dashboard.tpl +2 -0
- package/app/public/dist/entry.project-list.tpl +2 -0
- package/app/public/dist/prod/css/async.609.bcbe5779.css +1 -0
- package/app/public/dist/prod/css/async.952.9bc7c180.css +1 -0
- package/app/public/dist/prod/css/common.1a98227b.css +1 -0
- package/app/public/dist/prod/css/entry.project-list.14f64dd9.css +1 -0
- package/app/public/dist/prod/js/142.56646c73.bundle.js +1 -0
- package/app/public/dist/prod/js/609.8270b20d.bundle.js +1 -0
- package/app/public/dist/prod/js/68.2813fafe.bundle.js +1 -0
- package/app/public/dist/prod/js/952.c76c04fb.bundle.js +1 -0
- package/app/public/dist/prod/js/common.9985f827.bundle.js +1 -0
- package/app/public/dist/prod/js/entry.dashboard.cd7591e4.bundle.js +1 -0
- package/app/public/dist/prod/js/entry.project-list.beb0fa9d.bundle.js +1 -0
- package/app/public/dist/prod/js/runtime.5602b906.bundle.js +1 -0
- package/app/public/dist/prod/js/vendor.709fbf32.bundle.js +53 -0
- package/app/public/dist/prod/static/images/avatar.78e68eaa.png +0 -0
- package/app/public/dist/static/logo.png +0 -0
- package/app/public/dist/static/normalize.css +1 -0
- package/app/public/static/logo.png +0 -0
- package/app/public/static/normalize.css +267 -0
- package/app/router/project.js +6 -0
- package/app/router/view.js +5 -0
- package/app/router-schema/project.js +14 -0
- package/app/service/base.js +22 -0
- package/app/service/project.js +49 -0
- package/app/view/entry.tpl +18 -0
- package/app/webpack/config/webpack.base.js +288 -0
- package/app/webpack/config/webpack.dev.js +53 -0
- package/app/webpack/config/webpack.prod.js +106 -0
- package/app/webpack/dev.js +34 -0
- package/app/webpack/libs/block.js +1 -0
- package/app/webpack/prod.js +21 -0
- package/config/config.default.js +5 -0
- package/index.js +37 -0
- package/mint-core/env.js +23 -0
- package/mint-core/index.js +101 -0
- package/mint-core/loader/config.js +59 -0
- package/mint-core/loader/controller.js +59 -0
- package/mint-core/loader/extend.js +42 -0
- package/mint-core/loader/middleware.js +54 -0
- package/mint-core/loader/router-schema.js +39 -0
- package/mint-core/loader/router.js +36 -0
- package/mint-core/loader/service.js +57 -0
- package/model/index.js +94 -0
- 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
|
+
}
|