@codertqy/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 (83) hide show
  1. package/.eslintignore +2 -0
  2. package/.eslintrc +55 -0
  3. package/README.md +218 -0
  4. package/app/controller/base.js +40 -0
  5. package/app/controller/project.js +81 -0
  6. package/app/controller/view.js +22 -0
  7. package/app/extend/logger.js +43 -0
  8. package/app/middleware/api-params-verify.js +73 -0
  9. package/app/middleware/api-sign-verify.js +49 -0
  10. package/app/middleware/error-handler.js +31 -0
  11. package/app/middleware/project-handler.js +26 -0
  12. package/app/middleware.js +44 -0
  13. package/app/pages/assets/custom.css +14 -0
  14. package/app/pages/boot.js +56 -0
  15. package/app/pages/common/curl.js +84 -0
  16. package/app/pages/common/index.css +3 -0
  17. package/app/pages/common/utils.js +1 -0
  18. package/app/pages/dashboard/complex-view/header-view/complex-view/sub-menu/sub-menu.vue +19 -0
  19. package/app/pages/dashboard/complex-view/header-view/header-view.vue +126 -0
  20. package/app/pages/dashboard/complex-view/iframe-view/iframe-view.vue +45 -0
  21. package/app/pages/dashboard/complex-view/schema-view/complex-view/search-panel/search-panel.vue +35 -0
  22. package/app/pages/dashboard/complex-view/schema-view/complex-view/table-panel/table-panel.vue +120 -0
  23. package/app/pages/dashboard/complex-view/schema-view/components/component-config.js +23 -0
  24. package/app/pages/dashboard/complex-view/schema-view/components/create-form/create-form.vue +87 -0
  25. package/app/pages/dashboard/complex-view/schema-view/components/detail-panel/detail-panel.vue +100 -0
  26. package/app/pages/dashboard/complex-view/schema-view/components/edit-form/edit-form.vue +122 -0
  27. package/app/pages/dashboard/complex-view/schema-view/hook/schema.js +161 -0
  28. package/app/pages/dashboard/complex-view/schema-view/schema-view.vue +95 -0
  29. package/app/pages/dashboard/complex-view/sider-view/complex-view/sub-menu/sub-menu.vue +19 -0
  30. package/app/pages/dashboard/complex-view/sider-view/sider-view.vue +135 -0
  31. package/app/pages/dashboard/dashboard.vue +86 -0
  32. package/app/pages/dashboard/entry.dashboard.js +48 -0
  33. package/app/pages/store/index.js +3 -0
  34. package/app/pages/store/menu.js +68 -0
  35. package/app/pages/store/project.js +12 -0
  36. package/app/pages/widgets/header-container/asserts/avatar.png +0 -0
  37. package/app/pages/widgets/header-container/asserts/logo.png +0 -0
  38. package/app/pages/widgets/header-container/header-container.vue +107 -0
  39. package/app/pages/widgets/schema-form/complex-view/input/input.vue +138 -0
  40. package/app/pages/widgets/schema-form/complex-view/input-number/input-number.vue +140 -0
  41. package/app/pages/widgets/schema-form/complex-view/select/select.vue +122 -0
  42. package/app/pages/widgets/schema-form/form-item-config.js +20 -0
  43. package/app/pages/widgets/schema-form/schema-form.vue +135 -0
  44. package/app/pages/widgets/schema-search-bar/complex-view/date-range/date-range.vue +51 -0
  45. package/app/pages/widgets/schema-search-bar/complex-view/dynamic-select/dynamic-select.vue +63 -0
  46. package/app/pages/widgets/schema-search-bar/complex-view/input/input.vue +41 -0
  47. package/app/pages/widgets/schema-search-bar/complex-view/select/select.vue +49 -0
  48. package/app/pages/widgets/schema-search-bar/schema-search-bar.vue +126 -0
  49. package/app/pages/widgets/schema-search-bar/search-item-config.js +22 -0
  50. package/app/pages/widgets/schema-table/schema-table.vue +259 -0
  51. package/app/pages/widgets/sider-container/sider-container.vue +27 -0
  52. package/app/public/output/entry.page1.tpl +40 -0
  53. package/app/public/output/entry.page2.tpl +11 -0
  54. package/app/public/static/logo.png +0 -0
  55. package/app/public/static/normalize.css +239 -0
  56. package/app/router/project.js +22 -0
  57. package/app/router/view.js +17 -0
  58. package/app/router-schema/project.js +34 -0
  59. package/app/service/base.js +15 -0
  60. package/app/service/project.js +59 -0
  61. package/app/view/entry.tpl +25 -0
  62. package/app/webpack/config/webpack.base.js +280 -0
  63. package/app/webpack/config/webpack.dev.js +57 -0
  64. package/app/webpack/config/webpack.prod.js +127 -0
  65. package/app/webpack/dev.js +63 -0
  66. package/app/webpack/libs/blank.js +1 -0
  67. package/app/webpack/prod.js +22 -0
  68. package/config/config.beta.js +1 -0
  69. package/config/config.default.js +3 -0
  70. package/config/config.prod.js +1 -0
  71. package/elpis-core/env.js +27 -0
  72. package/elpis-core/index.js +98 -0
  73. package/elpis-core/loader/config.js +58 -0
  74. package/elpis-core/loader/controller.js +93 -0
  75. package/elpis-core/loader/extend.js +63 -0
  76. package/elpis-core/loader/middleware.js +84 -0
  77. package/elpis-core/loader/router-schema.js +56 -0
  78. package/elpis-core/loader/router.js +50 -0
  79. package/elpis-core/loader/service.js +85 -0
  80. package/index.js +38 -0
  81. package/model/index.js +129 -0
  82. package/package.json +92 -0
  83. package/test/controller/project.test.js +214 -0
@@ -0,0 +1,259 @@
1
+ <template>
2
+ <div class="schema-table">
3
+ <!-- 表格 -->
4
+ <el-table
5
+ v-if="schema && schema.properties"
6
+ v-loading="loading"
7
+ :data="tableData"
8
+ class="table"
9
+ >
10
+ <template v-for="(schemaItem, key) in schema.properties">
11
+ <!-- visible:false 表示不可见,true表示可见 -->
12
+ <!-- v-bind是将一个对象数据,传递给el-table-column,:name这种形式是单个数据 -->
13
+ <el-table-column
14
+ v-if="schemaItem.option.visible !== false"
15
+ :key="key"
16
+ :prop="key"
17
+ :label="schemaItem.label"
18
+ v-bind="schemaItem.option"
19
+ >
20
+ </el-table-column>
21
+ </template>
22
+ <el-table-column
23
+ v-if="buttons?.length > 0"
24
+ label="操作"
25
+ fixed="right"
26
+ :width="operationWidth"
27
+ >
28
+ <template #default="scoped">
29
+ <el-button
30
+ v-for="item in buttons"
31
+ link
32
+ v-bind="item"
33
+ @click="operationHandler({ btnConfig: item, rowData: scoped.row })"
34
+ >
35
+ {{ item.label }}
36
+ </el-button>
37
+ </template>
38
+ </el-table-column>
39
+ </el-table>
40
+ <!-- 分页器 -->
41
+ <el-row class="pagination">
42
+ <el-pagination
43
+ :current-page="currentPage"
44
+ :page-size="pageSize"
45
+ :page-sizes="[10, 20, 30, 40]"
46
+ :total="total"
47
+ @current-change="onCurrentChange"
48
+ @size-change="onSizeChange"
49
+ layout="total, sizes, prev, pager, next, jumper"
50
+ >
51
+ </el-pagination>
52
+ </el-row>
53
+ </div>
54
+ </template>
55
+
56
+ <script setup>
57
+ import { toRefs, ref, watch, onMounted, computed, nextTick } from "vue";
58
+ import $curl from "$elpisCommon/curl";
59
+ const emit = defineEmits(["operate"]);
60
+
61
+ const props = defineProps({
62
+ /**
63
+ * schema 配置,结构如下:
64
+ {
65
+ type: "object",
66
+ properties: {
67
+ key: {
68
+ ...schema, // 标准 schema 配置
69
+ type: "", // 字段类型
70
+ tabel: "", // 字段的中文名
71
+ option: {
72
+ ...elTableColumnConfig, // 标准 el-table-column 配置
73
+ visible: true, // 默认为 true (false 或 不配置时,表示不在表单中显示)
74
+ },
75
+ },
76
+ },
77
+ },
78
+ */
79
+ schema: {
80
+ type: Object,
81
+ },
82
+ /**
83
+ * 表格数据源 api
84
+ */
85
+ api: {
86
+ type: String,
87
+ },
88
+
89
+ /**
90
+ * 方案二:请求参数,请求 API 时携带
91
+ */
92
+ apiParams: {
93
+ type: Object,
94
+ },
95
+ /**
96
+ * buttons 操作按钮相关配置,结构如下:
97
+ *[{
98
+ label: "", //按钮中文名
99
+ eventKey: "", // 按钮事件名
100
+ eventOption: {}, // 按钮事件具体操作配置
101
+ ...elButtonConfig, // 标准 el-button 配置 样式外观
102
+ }]
103
+ *
104
+ */
105
+ buttons: {
106
+ type: Array,
107
+ },
108
+ });
109
+ const { schema, api, apiParams, buttons } = toRefs(props);
110
+
111
+ const loading = ref(false);
112
+ const tableData = ref([]);
113
+ const currentPage = ref(1);
114
+ const pageSize = ref(10);
115
+ const total = ref(0);
116
+
117
+ onMounted(() => {
118
+ initData();
119
+ });
120
+
121
+ /**
122
+ * 动态计算操作按钮列表的宽度
123
+ */
124
+ const operationWidth = computed(() => {
125
+ return buttons?.value?.length > 0
126
+ ? buttons.value.reduce((pre, cur) => {
127
+ // 获取按钮中文名长度,乘以 18,得到按钮宽度
128
+ return pre + cur.label.length * 18;
129
+ }, 50)
130
+ : 50;
131
+ });
132
+
133
+ const operationHandler = async ({ btnConfig, rowData }) => {
134
+ emit("operate", {
135
+ btnConfig,
136
+ rowData,
137
+ });
138
+ };
139
+
140
+ // 监听对应数据变化,发送请求
141
+ watch(
142
+ [schema, api,apiParams],
143
+ () => {
144
+ initData();
145
+ },
146
+ { deep: true },
147
+ );
148
+ const initData = () => {
149
+ currentPage.value = 1;
150
+ pageSize.value = 10;
151
+ nextTick(async () => {
152
+ await loadTableData();
153
+ });
154
+ };
155
+
156
+ // 采用防抖,等最后一个会导致发送请求的数据不变后才发送请求。。。来防止页面的重复请求
157
+ let timerId = null;
158
+ const loadTableData = async () => {
159
+ clearTimeout(timerId);
160
+ timerId = setTimeout(() => {
161
+ fetchTableData().finally(() => {
162
+ timerId = null;
163
+ });
164
+ }, 100);
165
+ };
166
+ const fetchTableData = async () => {
167
+ if (!api.value) {
168
+ return;
169
+ }
170
+
171
+ showLoading();
172
+ // TODO: 请求 table 数据
173
+ const res = await $curl({
174
+ method: "get",
175
+ // 请求的是表格数据列表
176
+ url: `${api.value}/list`,
177
+ query: {
178
+ // 添加上请求参数
179
+ ...apiParams.value,
180
+ page: currentPage.value,
181
+ pageSize: pageSize.value,
182
+ },
183
+ });
184
+ hideLoading();
185
+ // 不存在数据,就置空
186
+ if (!res || !res.success || !Array.isArray(res.data)) {
187
+ tableData.value = [];
188
+ total.value = 0;
189
+ return;
190
+ }
191
+ // 进一步转换数据格式
192
+ tableData.value = buildTableData(res.data);
193
+ total.value = res.metadata.total;
194
+ };
195
+
196
+ /**
197
+ * 对后端返回的数据,进行预处理
198
+ * @param data
199
+ */
200
+ const buildTableData = (listData) => {
201
+ if (!schema.value?.properties) {
202
+ return listData;
203
+ }
204
+ return listData.map((rowData) => {
205
+ for (const dKey in rowData) {
206
+ // 拿到 schema 中 properties对象的每一个 key
207
+ const schemaItem = schema.value.properties[dKey];
208
+
209
+ // 处理 toFixed
210
+ if (schemaItem?.option?.toFixed) {
211
+ rowData[dKey] = Number(rowData[dKey]).toFixed(
212
+ schemaItem.option.toFixed,
213
+ );
214
+ }
215
+ }
216
+ return rowData;
217
+ });
218
+ };
219
+
220
+ const showLoading = () => {
221
+ loading.value = true;
222
+ };
223
+
224
+ const hideLoading = () => {
225
+ loading.value = false;
226
+ };
227
+
228
+ const onCurrentChange = async (value) => {
229
+ currentPage.value = value;
230
+ await loadTableData();
231
+ };
232
+ const onSizeChange = async (value) => {
233
+ pageSize.value = value;
234
+ await loadTableData();
235
+ };
236
+
237
+ // 暴露一些方法,让外部调用内部的一些方法更新数据
238
+ defineExpose({
239
+ initData,
240
+ loadTableData,
241
+ showLoading,
242
+ hideLoading,
243
+ });
244
+ </script>
245
+
246
+ <style scoped lang="less">
247
+ .schema-table {
248
+ display: flex;
249
+ flex-direction: column;
250
+ height: 550px;
251
+ .table {
252
+ flex: 1;
253
+ }
254
+
255
+ .pagination {
256
+ margin: 10px 0;
257
+ }
258
+ }
259
+ </style>
@@ -0,0 +1,27 @@
1
+ <template>
2
+ <el-container class="sider-container">
3
+ <el-aside width="200px" class="aside">
4
+ <slot name="menu-content"></slot>
5
+ </el-aside>
6
+ <el-main class="main">
7
+ <slot name="main-content"></slot>
8
+ </el-main>
9
+ </el-container>
10
+ </template>
11
+ <script setup></script>
12
+
13
+ <style scoped lang="less">
14
+ .sider-container {
15
+ height: 100%;
16
+ .aside {
17
+ border-right: 1px solid #e8e8e8;
18
+ }
19
+ .main {
20
+ overflow: scroll;
21
+ }
22
+ }
23
+
24
+ :deep(el-menu) {
25
+ border-right: 0;
26
+ }
27
+ </style>
@@ -0,0 +1,40 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>{{ name }}</title>
7
+ <link rel="stylesheet" href="/static/normalize.css" />
8
+ <link href="/static/logo.png" rel="icon" type="image/x-icon" />
9
+ </head>
10
+ <body>
11
+ <h1 style="color: red">Page1</h1>
12
+ <input id="env" value="{{ env }}" style="display: none" />
13
+ <input id="options" value="{{ options }}" style="display: none" />
14
+ <button onclick="handleClick()">发送请求</button>
15
+ </body>
16
+ <script src="https://cdn.bootcss.com/axios/0.18.0/axios.min.js"></script>
17
+ <script src="https://cdn.jsdelivr.net/npm/js-md5@0.8.3/src/md5.min.js"></script>
18
+ <script type="text/javascript">
19
+ try {
20
+ window.env = document.getElementById("env").value;
21
+ window.options = JSON.parse(document.getElementById("options").value);
22
+ } catch (error) {
23
+ console.log(error);
24
+ }
25
+
26
+ const handleClick = async () => {
27
+ const signKey = "bgkjibal2kbhkc4vbakjl3sdvhja";
28
+ const st = Date.now();
29
+ // 根据秘钥和时间戳生成签名,并且以headers形式传递给后端
30
+ axios.request({
31
+ method: "get",
32
+ url: `/api/project/list/123`,
33
+ // params: { proj_key: 1},
34
+ headers: { s_t: st, s_sign: md5(`${signKey}_${st}`) },
35
+ });
36
+ // const { data } = await axios.get("/api/project/list");
37
+ // console.log(data);
38
+ };
39
+ </script>
40
+ </html>
@@ -0,0 +1,11 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Document</title>
7
+ </head>
8
+ <body>
9
+ <h1 style="color:blue">Page2</h1>
10
+ </body>
11
+ </html>
Binary file
@@ -0,0 +1,239 @@
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,body,span,div,p,a,table,tbody,td,h1,h2,h3,img,form,font,strong,b,i,dl,dt,dd,ol,ul,li,dl,dd,dt,iframe,label,blockquote,input,button
9
+ {
10
+ padding: 0;
11
+ margin: 0;
12
+ list-style: none;
13
+ }
14
+
15
+ html {
16
+ font-family: "Open Sans","Helvetica Neue","Microsoft Yahei",sans-serif;/* 1 */
17
+ -ms-text-size-adjust: 100%; /* 2 */
18
+ -webkit-text-size-adjust: 100%; /* 2 */
19
+ }
20
+
21
+ /**
22
+ * Remove default margin.
23
+ */
24
+
25
+ body {
26
+ margin: 0;
27
+ }
28
+
29
+ /* Links
30
+ ========================================================================== */
31
+
32
+ /**
33
+ * Remove the gray background color from active links in IE 10.
34
+ */
35
+
36
+ a {
37
+ background-color: transparent;
38
+ text-decoration: none;
39
+ }
40
+
41
+ /**
42
+ * Improve readability when focused and also mouse hovered in all browsers.
43
+ */
44
+
45
+ a:active,
46
+ a:hover {
47
+ outline: 0;
48
+ }
49
+
50
+ /* Text-level semantics
51
+ ========================================================================== */
52
+
53
+ /**
54
+ * Address style set to `bolder` in Firefox 4+, Safari, and Chrome.
55
+ */
56
+
57
+ b,
58
+ strong {
59
+ font-weight: bold;
60
+ }
61
+
62
+ /* Embedded content
63
+ ========================================================================== */
64
+
65
+ /**
66
+ * Remove border when inside `a` element in IE 8/9/10.
67
+ */
68
+
69
+ img {
70
+ border: 0;
71
+ }
72
+
73
+
74
+ /* Grouping content
75
+ ========================================================================== */
76
+
77
+ /**
78
+ * Address margin not present in IE 8/9 and Safari.
79
+ */
80
+
81
+ figure {
82
+ margin: 1em 40px;
83
+ }
84
+
85
+
86
+ /* Forms
87
+ ========================================================================== */
88
+
89
+ /**
90
+ * Known limitation: by default, Chrome and Safari on OS X allow very limited
91
+ * styling of `select`, unless a `border` property is set.
92
+ */
93
+
94
+ /**
95
+ * 1. Correct color not being inherited.
96
+ a * Known issue: affects color of disabled elements.
97
+ * 2. Correct font properties not being inherited.
98
+ * 3. Address margins set differently in Firefox 4+, Safari, and Chrome.
99
+ */
100
+
101
+ button,
102
+ input,
103
+ optgroup,
104
+ select,
105
+ textarea {
106
+ color: inherit; /* 1 */
107
+ font: inherit; /* 2 */
108
+ margin: 0; /* 3 */
109
+ }
110
+
111
+ /**
112
+ * Address `overflow` set to `hidden` in IE 8/9/10/11.
113
+ */
114
+
115
+ button {
116
+ overflow: visible;
117
+ }
118
+
119
+ /**
120
+ * Address inconsistent `text-transform` inheritance for `button` and `select`.
121
+ * All other form control elements do not inherit `text-transform` values.
122
+ * Correct `button` style inheritance in Firefox, IE 8/9/10/11, and Opera.
123
+ * Correct `select` style inheritance in Firefox.
124
+ */
125
+
126
+ button,
127
+ select {
128
+ text-transform: none;
129
+ }
130
+
131
+ /**
132
+ * 1. Avoid the WebKit bug in Android 4.0.* where (2) destroys native `audio`
133
+ * and `video` controls.
134
+ * 2. Correct inability to style clickable `input` types in iOS.
135
+ * 3. Improve usability and consistency of cursor style between image-type
136
+ * `input` and others.
137
+ */
138
+
139
+ button,
140
+ html input[type="button"], /* 1 */
141
+ input[type="reset"],
142
+ input[type="submit"] {
143
+ -webkit-appearance: button; /* 2 */
144
+ cursor: pointer; /* 3 */
145
+ }
146
+
147
+ /**
148
+ * Re-set default cursor for disabled elements.
149
+ */
150
+
151
+ button[disabled],
152
+ html input[disabled] {
153
+ cursor: default;
154
+ }
155
+
156
+ /**
157
+ * Remove inner padding and border in Firefox 4+.
158
+ */
159
+
160
+ button::-moz-focus-inner,
161
+ input::-moz-focus-inner {
162
+ border: 0;
163
+ padding: 0;
164
+ }
165
+
166
+ /**
167
+ * Address Firefox 4+ setting `line-height` on `input` using `!important` in
168
+ * the UA stylesheet.
169
+ */
170
+
171
+ input {
172
+ line-height: normal;
173
+ }
174
+
175
+ /**
176
+ * It's recommended that you don't attempt to style these elements.
177
+ * Firefox's implementation doesn't respect box-sizing, padding, or width.
178
+ *
179
+ * 1. Address box sizing set to `content-box` in IE 8/9/10.
180
+ * 2. Remove excess padding in IE 8/9/10.
181
+ */
182
+
183
+ input[type="checkbox"],
184
+ input[type="radio"] {
185
+ box-sizing: border-box; /* 1 */
186
+ padding: 0; /* 2 */
187
+ }
188
+
189
+ /**
190
+ * Fix the cursor style for Chrome's increment/decrement buttons. For certain
191
+ * `font-size` values of the `input`, it causes the cursor style of the
192
+ * decrement button to change from `default` to `text`.
193
+ */
194
+
195
+ input[type="number"]::-webkit-inner-spin-button,
196
+ input[type="number"]::-webkit-outer-spin-button {
197
+ height: auto;
198
+ }
199
+
200
+ /**
201
+ * 1. Address `appearance` set to `searchfield` in Safari and Chrome.
202
+ * 2. Address `box-sizing` set to `border-box` in Safari and Chrome
203
+ * (include `-moz` to future-proof).
204
+ */
205
+
206
+ input[type="search"] {
207
+ -webkit-appearance: textfield; /* 1 */
208
+ -moz-box-sizing: content-box;
209
+ -webkit-box-sizing: content-box; /* 2 */
210
+ box-sizing: content-box;
211
+ }
212
+
213
+ /**
214
+ * Remove inner padding and search cancel button in Safari and Chrome on OS X.
215
+ * Safari (but not Chrome) clips the cancel button when the search input has
216
+ * padding (and `textfield` appearance).
217
+ */
218
+
219
+ input[type="search"]::-webkit-search-cancel-button,
220
+ input[type="search"]::-webkit-search-decoration {
221
+ -webkit-appearance: none;
222
+ }
223
+
224
+ /* Tables
225
+ ========================================================================== */
226
+
227
+ /**
228
+ * Remove most spacing between table cells.
229
+ */
230
+
231
+ table {
232
+ border-collapse: collapse;
233
+ border-spacing: 0;
234
+ }
235
+
236
+ td,
237
+ th {
238
+ padding: 0;
239
+ }
@@ -0,0 +1,22 @@
1
+ /**
2
+ * 路由
3
+ *
4
+ * 第一步 先编写路由 调用 controller 方法
5
+ */
6
+ module.exports = (app, router) => {
7
+ const { project: ProjectController } = app.controller;
8
+ // 采用bind保持this指向,作用域
9
+ // Koa 自动把 ctx 传给后面的函数。Koa -> 路由 -> controller 一路传下来的
10
+ router.get(
11
+ "/api/project/model_list",
12
+ ProjectController.getModelList.bind(ProjectController),
13
+ );
14
+ router.get(
15
+ "/api/project/list",
16
+ ProjectController.getList.bind(ProjectController),
17
+ );
18
+ router.get(
19
+ "/api/project",
20
+ ProjectController.get.bind(ProjectController),
21
+ );
22
+ };
@@ -0,0 +1,17 @@
1
+ module.exports = (app, router) => {
2
+ const { view: ViewController } = app.controller;
3
+
4
+ /**
5
+ * 用户请求该路由,就会调用view的renderPage方法,然后就会去寻找controller层中的对应类中方法,创建找public目录下的页面,渲染并返回给用户
6
+ */
7
+ // 用户输入 http://ip:port/view/xxx 就能渲染出对应的页面
8
+ router.get("/view/:page", ViewController.renderPage.bind(ViewController));
9
+
10
+ // 添加一个路由去匹配
11
+ // 目的是:使用History模式后,没有了对应的#,在 controller 层中跳转是
12
+ // /view/dashboard${projItem.homePage}
13
+ // 如果projItem.homePage是/schema?id=1 只是上面一个路由会匹配不到
14
+
15
+ // 用户输入 http://ip:port/view/xxx/xxx/* 就能渲染出对应的页面
16
+ router.get("/view/:page/*", ViewController.renderPage.bind(ViewController));
17
+ };
@@ -0,0 +1,34 @@
1
+ /**
2
+ * 指定 接口 参数限制
3
+ */
4
+ module.exports = {
5
+ "/api/project": {
6
+ get: {
7
+ query: {
8
+ type: "object",
9
+ properties: {
10
+ proj_key: {
11
+ type: "string",
12
+ },
13
+ },
14
+ // 必传
15
+ required: ["proj_key"],
16
+ },
17
+ },
18
+ },
19
+ "/api/project/list": {
20
+ get: {
21
+ query: {
22
+ type: "object",
23
+ properties: {
24
+ proj_key: {
25
+ type: "string",
26
+ },
27
+ },
28
+ },
29
+ },
30
+ "/api/project/model_list": {
31
+ get: {},
32
+ },
33
+ },
34
+ };
@@ -0,0 +1,15 @@
1
+ // 方便在service层也可以请求一些资源
2
+ const superagent = require("superagent");
3
+ module.exports = (app) => {
4
+ return class BaseService {
5
+ /**
6
+ * 基类
7
+ * 统一收拢 service 相关的
8
+ */
9
+ constructor() {
10
+ this.app = app;
11
+ this.config = app.config;
12
+ this.curl = superagent;
13
+ }
14
+ };
15
+ };