@siven-li/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.
- package/.eslintignore +3 -0
- package/.eslintrc +55 -0
- package/README.md +201 -0
- package/app/controller/base.js +37 -0
- package/app/controller/project.js +65 -0
- package/app/controller/view.js +20 -0
- package/app/extend/logger.js +35 -0
- package/app/middleware/api-params-verify.js +97 -0
- package/app/middleware/api-sign-verify.js +30 -0
- package/app/middleware/error-handler.js +34 -0
- package/app/middleware/project-handler.js +22 -0
- package/app/middleware.js +37 -0
- package/app/pages/assets/custom.css +16 -0
- package/app/pages/boot.js +53 -0
- package/app/pages/common/curl.js +74 -0
- package/app/pages/common/utils.js +2 -0
- package/app/pages/dashboard/complex-view/header-view/complex-view/sub-menu/sub-menu.vue +35 -0
- package/app/pages/dashboard/complex-view/header-view/header-view.vue +132 -0
- package/app/pages/dashboard/complex-view/iframe-view/iframe-view.vue +45 -0
- package/app/pages/dashboard/complex-view/schema-view/complex-view/search-panel/search-panel.vue +37 -0
- package/app/pages/dashboard/complex-view/schema-view/complex-view/table-panel/table-panel.vue +130 -0
- package/app/pages/dashboard/complex-view/schema-view/components/component-config.js +23 -0
- package/app/pages/dashboard/complex-view/schema-view/components/create-form/create-form.vue +90 -0
- package/app/pages/dashboard/complex-view/schema-view/components/detail-panel/detail-panel.vue +110 -0
- package/app/pages/dashboard/complex-view/schema-view/components/edit-form/edit-form.vue +133 -0
- package/app/pages/dashboard/complex-view/schema-view/hook/schema.js +125 -0
- package/app/pages/dashboard/complex-view/schema-view/schema-view.vue +97 -0
- package/app/pages/dashboard/complex-view/sider-view/complex-view/sub-menu/sub-menu.vue +35 -0
- package/app/pages/dashboard/complex-view/sider-view/sider-view.vue +127 -0
- package/app/pages/dashboard/dashboard.vue +94 -0
- package/app/pages/dashboard/entry.dashboard.js +43 -0
- package/app/pages/store/index.js +3 -0
- package/app/pages/store/menu.js +59 -0
- package/app/pages/store/project.js +17 -0
- package/app/pages/widgets/header-container/assets/avatar.png +0 -0
- package/app/pages/widgets/header-container/assets/logo.png +0 -0
- package/app/pages/widgets/header-container/header-container.vue +124 -0
- package/app/pages/widgets/schema-form/complex-view/input/input.vue +143 -0
- package/app/pages/widgets/schema-form/complex-view/input-number/input-number.vue +141 -0
- package/app/pages/widgets/schema-form/complex-view/select/select.vue +127 -0
- package/app/pages/widgets/schema-form/form-item-config.js +22 -0
- package/app/pages/widgets/schema-form/schema-form.vue +129 -0
- package/app/pages/widgets/schema-search-bar/complex-view/date-range/date-range.vue +49 -0
- package/app/pages/widgets/schema-search-bar/complex-view/dynamic-select/dynamic-select.vue +65 -0
- package/app/pages/widgets/schema-search-bar/complex-view/input/input.vue +43 -0
- package/app/pages/widgets/schema-search-bar/complex-view/select/select.vue +50 -0
- package/app/pages/widgets/schema-search-bar/schema-search-bar.vue +133 -0
- package/app/pages/widgets/schema-search-bar/search-item-config.js +26 -0
- package/app/pages/widgets/schema-table/schema-table.vue +234 -0
- package/app/pages/widgets/sider-container/sider-container.vue +32 -0
- package/app/public/static/logo.png +0 -0
- package/app/public/static/normalize.css +239 -0
- package/app/router/project.js +6 -0
- package/app/router/view.js +9 -0
- package/app/router-schema/project.js +30 -0
- package/app/service/base.js +12 -0
- package/app/service/project.js +44 -0
- package/app/view/entry.tpl +26 -0
- package/app/webpack/config/webpack.base.js +194 -0
- package/app/webpack/config/webpack.dev.js +58 -0
- package/app/webpack/config/webpack.prod.js +114 -0
- package/app/webpack/dev.js +48 -0
- package/app/webpack/libs/blank.js +1 -0
- package/app/webpack/prod.js +18 -0
- package/config/config.default.js +3 -0
- package/elpis-core/env.js +20 -0
- package/elpis-core/index.js +88 -0
- package/elpis-core/loader/config.js +55 -0
- package/elpis-core/loader/controller.js +56 -0
- package/elpis-core/loader/extend.js +45 -0
- package/elpis-core/loader/middleware.js +58 -0
- package/elpis-core/loader/router-schema.js +38 -0
- package/elpis-core/loader/router.js +40 -0
- package/elpis-core/loader/service.js +56 -0
- package/index.js +39 -0
- package/model/index.js +104 -0
- package/package.json +93 -0
- package/test/controll/project.test.js +203 -0
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="schema-table">
|
|
3
|
+
<el-table
|
|
4
|
+
v-if="schema && schema.properties"
|
|
5
|
+
v-loading="loading"
|
|
6
|
+
:data="tableData"
|
|
7
|
+
class="table"
|
|
8
|
+
>
|
|
9
|
+
<template v-for="(schemaItem, key) in schema.properties">
|
|
10
|
+
<el-table-column
|
|
11
|
+
v-if="schemaItem.option.visible !== false"
|
|
12
|
+
:key="key"
|
|
13
|
+
:prop="key"
|
|
14
|
+
:label="schemaItem.label"
|
|
15
|
+
v-bind="schemaItem.option"
|
|
16
|
+
/>
|
|
17
|
+
</template>
|
|
18
|
+
<el-table-column
|
|
19
|
+
v-if="buttons?.length > 0"
|
|
20
|
+
label="操作"
|
|
21
|
+
fixed="right"
|
|
22
|
+
:width="operationWidth"
|
|
23
|
+
>
|
|
24
|
+
<template #default="scope">
|
|
25
|
+
<el-button
|
|
26
|
+
v-for="item in buttons"
|
|
27
|
+
:key="item.label"
|
|
28
|
+
link
|
|
29
|
+
v-bind="item"
|
|
30
|
+
@click="operationHandler({ btnConfig: item, rowData: scope.row })"
|
|
31
|
+
>
|
|
32
|
+
{{ item.label }}
|
|
33
|
+
</el-button>
|
|
34
|
+
</template>
|
|
35
|
+
</el-table-column>
|
|
36
|
+
</el-table>
|
|
37
|
+
<el-row
|
|
38
|
+
justify="end"
|
|
39
|
+
class="pagination"
|
|
40
|
+
>
|
|
41
|
+
<el-pagination
|
|
42
|
+
:current-page="currentPage"
|
|
43
|
+
:page-size="pageSize"
|
|
44
|
+
:page-sizes="[50, 100, 200, 500]"
|
|
45
|
+
:total="total"
|
|
46
|
+
layout="total, sizes, prev, pager, next, jumper"
|
|
47
|
+
@size-change="onPageSizeChange"
|
|
48
|
+
@current-change="onCurrentPageChange"
|
|
49
|
+
/>
|
|
50
|
+
</el-row>
|
|
51
|
+
</div>
|
|
52
|
+
</template>
|
|
53
|
+
|
|
54
|
+
<script setup>
|
|
55
|
+
import { ref, toRefs, computed, nextTick, watch, onMounted } from 'vue';
|
|
56
|
+
import $curl from '$elpisCommon/curl.js';
|
|
57
|
+
|
|
58
|
+
const props = defineProps({
|
|
59
|
+
/**
|
|
60
|
+
* schema 配置,结构如下:
|
|
61
|
+
* {
|
|
62
|
+
type: 'object',
|
|
63
|
+
properties: {
|
|
64
|
+
key: {
|
|
65
|
+
...schema, // 标准 schema 配置
|
|
66
|
+
type: '', // 字段类型
|
|
67
|
+
label: '', // 字段中文名
|
|
68
|
+
option: {
|
|
69
|
+
...elTableColumnConfig, // 标准 el-table-column 配置
|
|
70
|
+
visible: true, // 是否显示在 table 中
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
...
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
*/
|
|
77
|
+
schema: {
|
|
78
|
+
type: Object,
|
|
79
|
+
default: () => {}
|
|
80
|
+
},
|
|
81
|
+
/**
|
|
82
|
+
* 表格数据源 API
|
|
83
|
+
*/
|
|
84
|
+
api: {
|
|
85
|
+
type: String,
|
|
86
|
+
default: ''
|
|
87
|
+
},
|
|
88
|
+
/**
|
|
89
|
+
* api 请求参数,请求 API 时携带
|
|
90
|
+
*/
|
|
91
|
+
apiParams: {
|
|
92
|
+
type: Object,
|
|
93
|
+
default: () => {}
|
|
94
|
+
},
|
|
95
|
+
/**
|
|
96
|
+
* buttons 操作按钮相关配置,结构如下:
|
|
97
|
+
* [{
|
|
98
|
+
label: '', // 按钮名称
|
|
99
|
+
eventKey: '', // 按钮事件名称
|
|
100
|
+
eventOption: {}, // 按钮事件参数
|
|
101
|
+
...elButtonConfig // 标准 el-button 配置
|
|
102
|
+
}, ...]
|
|
103
|
+
*/
|
|
104
|
+
buttons: {
|
|
105
|
+
type: Array,
|
|
106
|
+
default: () => []
|
|
107
|
+
}
|
|
108
|
+
})
|
|
109
|
+
|
|
110
|
+
const emit = defineEmits(['operate']);
|
|
111
|
+
|
|
112
|
+
const { schema, api, apiParams, buttons } = toRefs(props);
|
|
113
|
+
|
|
114
|
+
const operationWidth = computed(() => {
|
|
115
|
+
return buttons?.value?.length > 0 ? buttons.value.reduce((pre, cur) => {
|
|
116
|
+
return pre + cur.label.length * 18;
|
|
117
|
+
}, 50) : 50;
|
|
118
|
+
})
|
|
119
|
+
|
|
120
|
+
const loading = ref(false);
|
|
121
|
+
const tableData = ref([]);
|
|
122
|
+
const currentPage = ref(1);
|
|
123
|
+
const pageSize = ref(50);
|
|
124
|
+
const total = ref(0);
|
|
125
|
+
|
|
126
|
+
onMounted(() => {
|
|
127
|
+
initData();
|
|
128
|
+
})
|
|
129
|
+
|
|
130
|
+
watch([ schema, api, apiParams ], () => {
|
|
131
|
+
initData ();
|
|
132
|
+
}, { deep: true })
|
|
133
|
+
|
|
134
|
+
const initData = () => {
|
|
135
|
+
currentPage.value = 1;
|
|
136
|
+
pageSize.value = 50;
|
|
137
|
+
nextTick(async () => {
|
|
138
|
+
await loadTableData();
|
|
139
|
+
})
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
let timerId = null;
|
|
143
|
+
const loadTableData = () => {
|
|
144
|
+
clearTimeout(timerId);
|
|
145
|
+
timerId = setTimeout(async () => {
|
|
146
|
+
await featchData();
|
|
147
|
+
timerId = null;
|
|
148
|
+
}, 100)
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const featchData = async () => {
|
|
152
|
+
if (!api.value) return;
|
|
153
|
+
|
|
154
|
+
showLoading();
|
|
155
|
+
// 请求 table 数据
|
|
156
|
+
const res = await $curl({
|
|
157
|
+
method: 'get',
|
|
158
|
+
url: `${api.value}/list`,
|
|
159
|
+
query: {
|
|
160
|
+
...apiParams.value,
|
|
161
|
+
page: currentPage.value,
|
|
162
|
+
size: pageSize.value
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
hideLoading();
|
|
166
|
+
if (!res || !res.success || !Array.isArray(res.data)) {
|
|
167
|
+
tableData.value = [];
|
|
168
|
+
total.value = 0;
|
|
169
|
+
return;
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
tableData.value = buildTableData(res.data);
|
|
173
|
+
total.value = res.metadata.total;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* 对后端返回的数据进行渲染前预处理
|
|
178
|
+
* @param {Object} data 列表数据
|
|
179
|
+
*/
|
|
180
|
+
const buildTableData = (listData) => {
|
|
181
|
+
if (!schema.value?.properties) return listData;
|
|
182
|
+
return listData.map(rowData => {
|
|
183
|
+
for (const key in rowData) {
|
|
184
|
+
const schemaItem = schema.value.properties[key];
|
|
185
|
+
if (schemaItem?.option?.toFixed) {
|
|
186
|
+
rowData[key] = rowData[key].toFixed && rowData[key].toFixed(schemaItem.option.toFixed);
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
return rowData;
|
|
190
|
+
})
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
const showLoading = () => {
|
|
194
|
+
loading.value = true;
|
|
195
|
+
}
|
|
196
|
+
const hideLoading = () => {
|
|
197
|
+
loading.value = false;
|
|
198
|
+
}
|
|
199
|
+
const operationHandler = ({ btnConfig, rowData }) => {
|
|
200
|
+
emit('operate', { btnConfig, rowData })
|
|
201
|
+
}
|
|
202
|
+
const onPageSizeChange = async (value) => {
|
|
203
|
+
pageSize.value = value;
|
|
204
|
+
await loadTableData();
|
|
205
|
+
}
|
|
206
|
+
const onCurrentPageChange = async (value) => {
|
|
207
|
+
currentPage.value = value;
|
|
208
|
+
await loadTableData();
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
defineExpose({
|
|
212
|
+
initData,
|
|
213
|
+
loadTableData,
|
|
214
|
+
showLoading,
|
|
215
|
+
hideLoading
|
|
216
|
+
})
|
|
217
|
+
|
|
218
|
+
</script>
|
|
219
|
+
|
|
220
|
+
<style lang="less" scoped>
|
|
221
|
+
.schema-table {
|
|
222
|
+
flex: 1;
|
|
223
|
+
display: flex;
|
|
224
|
+
flex-direction: column;
|
|
225
|
+
overflow: auto;
|
|
226
|
+
.table {
|
|
227
|
+
flex: 1;
|
|
228
|
+
}
|
|
229
|
+
.pagination {
|
|
230
|
+
margin: 10px 0;
|
|
231
|
+
text-align: right;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
</style>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<el-container class="sider-container">
|
|
3
|
+
<el-aside
|
|
4
|
+
width="200px"
|
|
5
|
+
class="aside"
|
|
6
|
+
>
|
|
7
|
+
<slot name="menu-content" />
|
|
8
|
+
</el-aside>
|
|
9
|
+
<el-main class="main">
|
|
10
|
+
<slot name="main-content" />
|
|
11
|
+
</el-main>
|
|
12
|
+
</el-container>
|
|
13
|
+
</template>
|
|
14
|
+
|
|
15
|
+
<script setup></script>
|
|
16
|
+
|
|
17
|
+
<style lang="less" scoped>
|
|
18
|
+
.sider-container {
|
|
19
|
+
height: 100%;
|
|
20
|
+
|
|
21
|
+
.aside {
|
|
22
|
+
border-right: 1px solid #e8e8e8;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.main {
|
|
26
|
+
overflow: auto;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
:deep(.el-menu) {
|
|
30
|
+
border-right: 0;
|
|
31
|
+
}
|
|
32
|
+
</style>
|
|
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,6 @@
|
|
|
1
|
+
module.exports = (app, router) => {
|
|
2
|
+
const { project: projectController } = app.controller;
|
|
3
|
+
router.get('/api/project', projectController.get.bind(projectController));
|
|
4
|
+
router.get('/api/project/list', projectController.getList.bind(projectController));
|
|
5
|
+
router.get('/api/project/model_list', projectController.getModelList.bind(projectController));
|
|
6
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
module.exports = (app, router) => {
|
|
2
|
+
// 从 app.controller 中取出属性 view 的值,并将其赋值给新变量 viewController
|
|
3
|
+
const { view: viewController } = app.controller;
|
|
4
|
+
|
|
5
|
+
// 用户输入 http://ip:port/view/xxxx 能渲染出对应的页面
|
|
6
|
+
router.get('/view/:page', viewController.renderPage.bind(viewController));
|
|
7
|
+
// 用户输入 http://ip:port/view/xxxx/xxxx/* 能渲染出对应的页面
|
|
8
|
+
router.get('/view/:page/*', viewController.renderPage.bind(viewController));
|
|
9
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
'/api/project': {
|
|
3
|
+
get: {
|
|
4
|
+
query: {
|
|
5
|
+
type: 'object',
|
|
6
|
+
properties: {
|
|
7
|
+
proj_key: {
|
|
8
|
+
type:'string'
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
required: ['proj_key']
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
'/api/project/list': {
|
|
16
|
+
get: {
|
|
17
|
+
query: {
|
|
18
|
+
type: 'object',
|
|
19
|
+
properties: {
|
|
20
|
+
proj_key: {
|
|
21
|
+
type:'string'
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
'/api/project/model_list': {
|
|
28
|
+
get: {}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
module.exports = (app) => {
|
|
2
|
+
const BaseService = require('./base')(app);
|
|
3
|
+
const modelList = require('../../model/index.js')(app);
|
|
4
|
+
return class ProjectService extends BaseService {
|
|
5
|
+
/**
|
|
6
|
+
* 根据 projKey 获取项目配置
|
|
7
|
+
* @param {string} projKey
|
|
8
|
+
*/
|
|
9
|
+
get({ projKey }) {
|
|
10
|
+
let projConfig;
|
|
11
|
+
|
|
12
|
+
modelList.forEach(modelItem => {
|
|
13
|
+
if (modelItem.project[projKey]) {
|
|
14
|
+
projConfig = modelItem.project[projKey]
|
|
15
|
+
}
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
return projConfig;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* 获取统一模型下的项目列表(如果无 projKey,则全量)
|
|
22
|
+
* @param {string} projKey
|
|
23
|
+
*/
|
|
24
|
+
getList({ projKey }) {
|
|
25
|
+
return modelList.reduce((preList, modelItem) => {
|
|
26
|
+
const { project } = modelItem;
|
|
27
|
+
|
|
28
|
+
// 如果传了 projKey,则只取对应模型下的项目,不传则去全量
|
|
29
|
+
if (projKey && !project[projKey]) return preList;
|
|
30
|
+
|
|
31
|
+
for (const pKey in project) {
|
|
32
|
+
preList.push(project[pKey]);
|
|
33
|
+
}
|
|
34
|
+
return preList;
|
|
35
|
+
}, []);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* 获取所有模型与项目的结构化数据
|
|
39
|
+
*/
|
|
40
|
+
async getModelList() {
|
|
41
|
+
return modelList;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html class="dark">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<link href="/static/normalize.css" rel="stylesheet">
|
|
6
|
+
<link href="/static/logo.png" rel="icon" type="image/png">
|
|
7
|
+
<title>{{ name }}</title>
|
|
8
|
+
</head>
|
|
9
|
+
<body style="margin: 0">
|
|
10
|
+
<div id="root"></div>
|
|
11
|
+
<input id="projKey" value="{{ projKey }}" style="display: none">
|
|
12
|
+
<input id="env" value="{{ env }}" style="display: none">
|
|
13
|
+
<input id="options" value="{{ options }}" style="display: none">
|
|
14
|
+
</body>
|
|
15
|
+
|
|
16
|
+
<script type="text/javascript">
|
|
17
|
+
try {
|
|
18
|
+
window.projKey = document.getElementById('projKey').value;
|
|
19
|
+
window.env = document.getElementById('env').value;
|
|
20
|
+
const options = JSON.parse(document.getElementById('options').value);
|
|
21
|
+
window.options = options;
|
|
22
|
+
} catch(e) {
|
|
23
|
+
console.error(e);
|
|
24
|
+
}
|
|
25
|
+
</script>
|
|
26
|
+
</html>
|