@wanglindoc/elpis 1.0.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 (88) hide show
  1. package/.eslintignore +2 -0
  2. package/.eslintrc +52 -0
  3. package/.idea/codeStyles/Project.xml +14 -0
  4. package/.idea/codeStyles/codeStyleConfig.xml +5 -0
  5. package/.idea/elpis.iml +12 -0
  6. package/.idea/inspectionProfiles/Project_Default.xml +6 -0
  7. package/.idea/modules.xml +8 -0
  8. package/.idea/prettier.xml +7 -0
  9. package/.idea/vcs.xml +6 -0
  10. package/README.md +232 -0
  11. package/app/controller/base.js +42 -0
  12. package/app/controller/project.js +76 -0
  13. package/app/controller/view.js +19 -0
  14. package/app/extend/logger.js +42 -0
  15. package/app/middleware/api-params-verify.js +81 -0
  16. package/app/middleware/api-sign-verify.js +45 -0
  17. package/app/middleware/error-handler.js +41 -0
  18. package/app/middleware/project-handler.js +30 -0
  19. package/app/middleware.js +42 -0
  20. package/app/pages/assets/custom.css +14 -0
  21. package/app/pages/boot.js +51 -0
  22. package/app/pages/common/curl.js +91 -0
  23. package/app/pages/common/utils.js +7 -0
  24. package/app/pages/dashboard/complex-view/header-view/complex-view/sub-menu/sub-menu.vue +18 -0
  25. package/app/pages/dashboard/complex-view/header-view/header-view.vue +154 -0
  26. package/app/pages/dashboard/complex-view/iframe-view/iframe-view.vue +46 -0
  27. package/app/pages/dashboard/complex-view/schema-view/complex-view/search-panel/search-panel.vue +40 -0
  28. package/app/pages/dashboard/complex-view/schema-view/complex-view/table-panel/table-panel.vue +127 -0
  29. package/app/pages/dashboard/complex-view/schema-view/components/component-config.js +22 -0
  30. package/app/pages/dashboard/complex-view/schema-view/components/create-form/create-form.vue +95 -0
  31. package/app/pages/dashboard/complex-view/schema-view/components/detail-panel/detail-panel.vue +104 -0
  32. package/app/pages/dashboard/complex-view/schema-view/components/edit-form/edit-form.vue +129 -0
  33. package/app/pages/dashboard/complex-view/schema-view/hook/schema.js +137 -0
  34. package/app/pages/dashboard/complex-view/schema-view/schema-view.vue +102 -0
  35. package/app/pages/dashboard/complex-view/sider-view/complex-view/sub-menu.vue +21 -0
  36. package/app/pages/dashboard/complex-view/sider-view/sider-view.vue +141 -0
  37. package/app/pages/dashboard/dashboard.vue +96 -0
  38. package/app/pages/dashboard/entry.dashboard.js +53 -0
  39. package/app/pages/dashboard/todo/todo.vue +6 -0
  40. package/app/pages/store/index.js +5 -0
  41. package/app/pages/store/menu.js +73 -0
  42. package/app/pages/store/project.js +15 -0
  43. package/app/pages/widgets/header-container/asserts/avatar.png +0 -0
  44. package/app/pages/widgets/header-container/asserts/logo.png +0 -0
  45. package/app/pages/widgets/header-container/header-container.vue +106 -0
  46. package/app/pages/widgets/schema-form/complex-view/input/input.vue +137 -0
  47. package/app/pages/widgets/schema-form/complex-view/input-number/input-number.vue +135 -0
  48. package/app/pages/widgets/schema-form/complex-view/select/select.vue +119 -0
  49. package/app/pages/widgets/schema-form/form-item-config.js +20 -0
  50. package/app/pages/widgets/schema-form/schema-form.vue +145 -0
  51. package/app/pages/widgets/schema-search-bar/complex-view/date-range/date-range.vue +52 -0
  52. package/app/pages/widgets/schema-search-bar/complex-view/dynamic-select/dynamic-select.vue +65 -0
  53. package/app/pages/widgets/schema-search-bar/complex-view/input/input.vue +42 -0
  54. package/app/pages/widgets/schema-search-bar/complex-view/select/select.vue +49 -0
  55. package/app/pages/widgets/schema-search-bar/schema-search-bar.vue +129 -0
  56. package/app/pages/widgets/schema-search-bar/search-item-config.js +24 -0
  57. package/app/pages/widgets/schema-table/schema-table.vue +212 -0
  58. package/app/pages/widgets/sider-container/sider-container.vue +26 -0
  59. package/app/public/output/entry.page1.tpl +55 -0
  60. package/app/public/output/entry.page2.tpl +11 -0
  61. package/app/public/static/favicon.ico +0 -0
  62. package/app/public/static/normalize.css +267 -0
  63. package/app/router/project.js +14 -0
  64. package/app/router/view.js +9 -0
  65. package/app/router-schema/project.js +32 -0
  66. package/app/service/base.js +15 -0
  67. package/app/service/project.js +48 -0
  68. package/app/view/entry.tpl +22 -0
  69. package/app/webpack/build-dev.js +64 -0
  70. package/app/webpack/build-prod.js +29 -0
  71. package/app/webpack/config/webpack.base.js +352 -0
  72. package/app/webpack/config/webpack.dev.js +59 -0
  73. package/app/webpack/config/webpack.prod.js +145 -0
  74. package/app/webpack/libs/blank.js +1 -0
  75. package/config/config.default.js +4 -0
  76. package/elpis-core/env.js +20 -0
  77. package/elpis-core/index.js +106 -0
  78. package/elpis-core/loader/config.js +62 -0
  79. package/elpis-core/loader/controller.js +79 -0
  80. package/elpis-core/loader/extend.js +67 -0
  81. package/elpis-core/loader/middleware.js +77 -0
  82. package/elpis-core/loader/router-schema.js +57 -0
  83. package/elpis-core/loader/router.js +57 -0
  84. package/elpis-core/loader/service.js +76 -0
  85. package/index.js +39 -0
  86. package/model/index.js +128 -0
  87. package/package.json +90 -0
  88. package/test/controller/project.test.js +243 -0
@@ -0,0 +1,267 @@
1
+ /*! normalize.css v3.0.2 | MIT License | git.io/normalize */
2
+
3
+ /**
4
+ * 1. Set default font family to sans-serif.
5
+ * 2. Prevent iOS text size adjust after orientation change, without disabling
6
+ * user zoom.
7
+ */
8
+ html,
9
+ body,
10
+ span,
11
+ div,
12
+ p,
13
+ a,
14
+ table,
15
+ tbody,
16
+ td,
17
+ h1,
18
+ h2,
19
+ h3,
20
+ img,
21
+ form,
22
+ font,
23
+ strong,
24
+ b,
25
+ i,
26
+ dl,
27
+ dt,
28
+ dd,
29
+ ol,
30
+ ul,
31
+ li,
32
+ dl,
33
+ dd,
34
+ dt,
35
+ iframe,
36
+ label,
37
+ blockquote,
38
+ input,
39
+ button {
40
+ padding: 0;
41
+ margin: 0;
42
+ list-style: none;
43
+ }
44
+
45
+ html {
46
+ font-family: "Open Sans", "Helvetica Neue", "Microsoft Yahei", sans-serif; /* 1 */
47
+ -ms-text-size-adjust: 100%; /* 2 */
48
+ -webkit-text-size-adjust: 100%; /* 2 */
49
+ }
50
+
51
+ /**
52
+ * Remove default margin.
53
+ */
54
+
55
+ body {
56
+ margin: 0;
57
+ }
58
+
59
+ /* Links
60
+ ========================================================================== */
61
+
62
+ /**
63
+ * Remove the gray background color from active links in IE 10.
64
+ */
65
+
66
+ a {
67
+ background-color: transparent;
68
+ text-decoration: none;
69
+ }
70
+
71
+ /**
72
+ * Improve readability when focused and also mouse hovered in all browsers.
73
+ */
74
+
75
+ a:active,
76
+ a:hover {
77
+ outline: 0;
78
+ }
79
+
80
+ /* Text-level semantics
81
+ ========================================================================== */
82
+
83
+ /**
84
+ * Address style set to `bolder` in Firefox 4+, Safari, and Chrome.
85
+ */
86
+
87
+ b,
88
+ strong {
89
+ font-weight: bold;
90
+ }
91
+
92
+ /* Embedded content
93
+ ========================================================================== */
94
+
95
+ /**
96
+ * Remove border when inside `a` element in IE 8/9/10.
97
+ */
98
+
99
+ img {
100
+ border: 0;
101
+ }
102
+
103
+ /* Grouping content
104
+ ========================================================================== */
105
+
106
+ /**
107
+ * Address margin not present in IE 8/9 and Safari.
108
+ */
109
+
110
+ figure {
111
+ margin: 1em 40px;
112
+ }
113
+
114
+ /* Forms
115
+ ========================================================================== */
116
+
117
+ /**
118
+ * Known limitation: by default, Chrome and Safari on OS X allow very limited
119
+ * styling of `select`, unless a `border` property is set.
120
+ */
121
+
122
+ /**
123
+ * 1. Correct color not being inherited.
124
+ * Known issue: affects color of disabled elements.
125
+ * 2. Correct font properties not being inherited.
126
+ * 3. Address margins set differently in Firefox 4+, Safari, and Chrome.
127
+ */
128
+
129
+ button,
130
+ input,
131
+ optgroup,
132
+ select,
133
+ textarea {
134
+ color: inherit; /* 1 */
135
+ font: inherit; /* 2 */
136
+ margin: 0; /* 3 */
137
+ }
138
+
139
+ /**
140
+ * Address `overflow` set to `hidden` in IE 8/9/10/11.
141
+ */
142
+
143
+ button {
144
+ overflow: visible;
145
+ }
146
+
147
+ /**
148
+ * Address inconsistent `text-transform` inheritance for `button` and `select`.
149
+ * All other form control elements do not inherit `text-transform` values.
150
+ * Correct `button` style inheritance in Firefox, IE 8/9/10/11, and Opera.
151
+ * Correct `select` style inheritance in Firefox.
152
+ */
153
+
154
+ button,
155
+ select {
156
+ text-transform: none;
157
+ }
158
+
159
+ /**
160
+ * 1. Avoid the WebKit bug in Android 4.0.* where (2) destroys native `audio`
161
+ * and `video` controls.
162
+ * 2. Correct inability to style clickable `input` types in iOS.
163
+ * 3. Improve usability and consistency of cursor style between image-type
164
+ * `input` and others.
165
+ */
166
+
167
+ button,
168
+ html input[type="button"], /* 1 */
169
+ input[type="reset"],
170
+ input[type="submit"] {
171
+ -webkit-appearance: button; /* 2 */
172
+ cursor: pointer; /* 3 */
173
+ }
174
+
175
+ /**
176
+ * Re-set default cursor for disabled elements.
177
+ */
178
+
179
+ button[disabled],
180
+ html input[disabled] {
181
+ cursor: default;
182
+ }
183
+
184
+ /**
185
+ * Remove inner padding and border in Firefox 4+.
186
+ */
187
+
188
+ button::-moz-focus-inner,
189
+ input::-moz-focus-inner {
190
+ border: 0;
191
+ padding: 0;
192
+ }
193
+
194
+ /**
195
+ * Address Firefox 4+ setting `line-height` on `input` using `!important` in
196
+ * the UA stylesheet.
197
+ */
198
+
199
+ input {
200
+ line-height: normal;
201
+ }
202
+
203
+ /**
204
+ * It's recommended that you don't attempt to style these elements.
205
+ * Firefox's implementation doesn't respect box-sizing, padding, or width.
206
+ *
207
+ * 1. Address box sizing set to `content-box` in IE 8/9/10.
208
+ * 2. Remove excess padding in IE 8/9/10.
209
+ */
210
+
211
+ input[type="checkbox"],
212
+ input[type="radio"] {
213
+ box-sizing: border-box; /* 1 */
214
+ padding: 0; /* 2 */
215
+ }
216
+
217
+ /**
218
+ * Fix the cursor style for Chrome's increment/decrement buttons. For certain
219
+ * `font-size` values of the `input`, it causes the cursor style of the
220
+ * decrement button to change from `default` to `text`.
221
+ */
222
+
223
+ input[type="number"]::-webkit-inner-spin-button,
224
+ input[type="number"]::-webkit-outer-spin-button {
225
+ height: auto;
226
+ }
227
+
228
+ /**
229
+ * 1. Address `appearance` set to `searchfield` in Safari and Chrome.
230
+ * 2. Address `box-sizing` set to `border-box` in Safari and Chrome
231
+ * (include `-moz` to future-proof).
232
+ */
233
+
234
+ input[type="search"] {
235
+ -webkit-appearance: textfield; /* 1 */
236
+ -moz-box-sizing: content-box;
237
+ -webkit-box-sizing: content-box; /* 2 */
238
+ box-sizing: content-box;
239
+ }
240
+
241
+ /**
242
+ * Remove inner padding and search cancel button in Safari and Chrome on OS X.
243
+ * Safari (but not Chrome) clips the cancel button when the search input has
244
+ * padding (and `textfield` appearance).
245
+ */
246
+
247
+ input[type="search"]::-webkit-search-cancel-button,
248
+ input[type="search"]::-webkit-search-decoration {
249
+ -webkit-appearance: none;
250
+ }
251
+
252
+ /* Tables
253
+ ========================================================================== */
254
+
255
+ /**
256
+ * Remove most spacing between table cells.
257
+ */
258
+
259
+ table {
260
+ border-collapse: collapse;
261
+ border-spacing: 0;
262
+ }
263
+
264
+ td,
265
+ th {
266
+ padding: 0;
267
+ }
@@ -0,0 +1,14 @@
1
+ module.exports = (app, router) => {
2
+ const { project: projectController } = app.controllers;
3
+ router.get(
4
+ "/api/project/model_list",
5
+ projectController.getModelList.bind(projectController),
6
+ );
7
+
8
+ router.get(
9
+ "/api/project/list",
10
+ projectController.getList.bind(projectController),
11
+ );
12
+
13
+ router.get("/api/project", projectController.get.bind(projectController));
14
+ };
@@ -0,0 +1,9 @@
1
+ module.exports = (app, router) => {
2
+ const { view: viewController } = app.controllers;
3
+
4
+ // 用户输入 http://ip:port/view/xxx 能渲染出对应的页面
5
+ router.get("/view/:page", viewController.renderPage.bind(viewController));
6
+
7
+ // 用户输入 http://ip:port/view/xxx/xxx/xxx 能渲染出对应的页面
8
+ router.get("/view/:page/*", viewController.renderPage.bind(viewController));
9
+ };
@@ -0,0 +1,32 @@
1
+ module.exports = {
2
+ "/api/project/model_list": {
3
+ get: {},
4
+ },
5
+
6
+ "/api/project/list": {
7
+ get: {
8
+ query: {
9
+ type: "object",
10
+ properties: {
11
+ proj_key: {
12
+ type: "string",
13
+ },
14
+ },
15
+ },
16
+ },
17
+ },
18
+
19
+ "/api/project": {
20
+ get: {
21
+ query: {
22
+ type: "object",
23
+ properties: {
24
+ proj_key: {
25
+ type: "string",
26
+ },
27
+ },
28
+ required: ["proj_key"],
29
+ },
30
+ },
31
+ },
32
+ };
@@ -0,0 +1,15 @@
1
+ const superagent = require("superagent");
2
+
3
+ module.exports = (app) => {
4
+ return class BaseService {
5
+ /**
6
+ * service 基类
7
+ * 统一收拢 service 的公共方法
8
+ */
9
+ constructor() {
10
+ this.app = app;
11
+ this.config = app.config;
12
+ this.curl = superagent;
13
+ }
14
+ };
15
+ };
@@ -0,0 +1,48 @@
1
+ module.exports = (app) => {
2
+ const BaseService = require("./base")(app);
3
+ const modelList = require("../../model/index.js")(app);
4
+ // console.log("modelList", JSON.stringify(modelList));
5
+ return class ProjectService extends BaseService {
6
+ /**
7
+ * 获取所有模型与项目的结构化数据
8
+ */
9
+ async getModelList() {
10
+ return modelList;
11
+ }
12
+
13
+ /**
14
+ * 获取统一模型下的项目列表(如果无 projKey,取全量)
15
+ */
16
+ getList({ projKey }) {
17
+ return modelList.reduce((preList, modelitem) => {
18
+ const { project } = modelitem;
19
+
20
+ if (projKey && !project[projKey]) {
21
+ return preList;
22
+ }
23
+
24
+ for (const pKey in project) {
25
+ preList.push(project[pKey]);
26
+ }
27
+
28
+ return preList;
29
+ }, []);
30
+ }
31
+
32
+ /**
33
+ * 根据 projKey 获取项目配置
34
+ * @param {*} param0
35
+ */
36
+ get({ projKey }) {
37
+ let projConfig;
38
+
39
+ modelList.forEach((modelItem) => {
40
+ if (modelItem.project[projKey]) {
41
+ projConfig = modelItem.project[projKey];
42
+ }
43
+ });
44
+
45
+ return projConfig;
46
+ }
47
+ };
48
+ };
@@ -0,0 +1,22 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <title>{{ name }}</title>
6
+ <link href="/static/normalize.css" rel="stylesheet" />
7
+ <link rel="shortcut icon" href="/static/favicon.ico" type="image/x-icon" />
8
+ </head>
9
+ <body>
10
+ <div id="root"></div>
11
+
12
+ <input id="projKey" value="{{projKey}}" style="display: none;" />
13
+ </body>
14
+
15
+ <script>
16
+ try {
17
+ window.projKey = document.getElementById("projKey").value
18
+ } catch (error) {
19
+ console.log(error,'tpl 注入信息');
20
+ }
21
+ </script>
22
+ </html>
@@ -0,0 +1,64 @@
1
+ // 本地开发启动devServer
2
+ const express = require("express");
3
+ const path = require("path");
4
+ const webpack = require("webpack");
5
+ const consoler = require("consoler");
6
+ const webpackDevMiddleware = require("webpack-dev-middleware");
7
+ const webpackHotMiddleware = require("webpack-hot-middleware");
8
+
9
+ module.exports = () => {
10
+ // 从 webpack.dev.js 中获取webpack配置和devServer配置
11
+ const {
12
+ webpackDevConfig,
13
+ DEV_SERVER_CONFIG,
14
+ } = require("./config/webpack.dev");
15
+
16
+ const app = express();
17
+
18
+ // 把通过webpack解析的东西取出来
19
+ const compiler = webpack(webpackDevConfig);
20
+
21
+ // 指定静态文件目录
22
+ app.use(express.static(path.join(__dirname, "../public/dist")));
23
+
24
+ // 引用 webpackDevMiddleware 中间件(监控文件改动)
25
+ app.use(
26
+ webpackDevMiddleware(compiler, {
27
+ // 落地文件,告诉服务哪些文件需要落地到磁盘
28
+ writeToDisk: (filePath) => filePath.endsWith(".tpl"),
29
+
30
+ // 资源路径,js、css代码片段存放进内存中的虚拟目录
31
+ publicPath: webpackDevConfig.output.publicPath,
32
+
33
+ // headers 配置
34
+ headers: {
35
+ "Access-Control-Allow-Origin": "*",
36
+ "Access-Control-Allow-Methods": "GET,POST,PUT,DELETE,PATCH,OPTIONS",
37
+ "Access-Control-Allow-Headers":
38
+ "X-Requested-With, content-type, Authorization",
39
+ },
40
+
41
+ stats: {
42
+ // 打印内容时有颜色
43
+ colors: true,
44
+ },
45
+ }),
46
+ );
47
+
48
+ // 引用 webpackHotMiddleware 中间件 (实现热更新通讯)
49
+ app.use(
50
+ webpackHotMiddleware(compiler, {
51
+ // 热更新地址
52
+ path: `/${DEV_SERVER_CONFIG.HMR_PATH}`,
53
+ log: () => {},
54
+ }),
55
+ );
56
+
57
+ consoler.info("请等待webpack初次构建完成……");
58
+
59
+ const port = DEV_SERVER_CONFIG.PORT;
60
+
61
+ app.listen(port, () => {
62
+ console.log(`app listening on port ${port}`);
63
+ });
64
+ };
@@ -0,0 +1,29 @@
1
+ const webpack = require("webpack");
2
+ const webpackProdConfig = require("./config/webpack.prod.js");
3
+ // const { webpackDevConfig } = require("./config/webpack.dev");
4
+ console.log("\nproduction 构建开始...\n");
5
+
6
+ module.exports = () => {
7
+ webpack(webpackProdConfig, (err, stats) => {
8
+ // webpack(webpackDevConfig, (err, stats) => {
9
+ // if (err) {
10
+ // throw err;
11
+ // }
12
+ if (err) return console.log(err);
13
+
14
+ process.stdout.write(
15
+ `${stats.toString({
16
+ // 在控制台输出色彩信息
17
+ colors: true,
18
+ // 不显示每个模块的打包信息
19
+ modules: false,
20
+ // 不显示子编译任务的信息
21
+ children: false,
22
+ // 不显示每个代码快的信息
23
+ chunks: false,
24
+ // 显示代码块中模块的信息
25
+ chunkModules: true,
26
+ })}`,
27
+ );
28
+ });
29
+ };