tianheng-ui 0.0.6 → 0.0.10
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 +6 -13
- package/{src → lib}/index.js +1 -1
- package/lib/theme-chalk/cell.css +40 -0
- package/lib/theme-chalk/index.css +2 -1940
- package/lib/tianheng-ui.js +2 -0
- package/lib/tianheng-ui.js.map +1 -0
- package/package.json +8 -6
- package/packages/cell/index.vue +44 -132
- package/packages/codeEditor/index.js +8 -0
- package/packages/codeEditor/index.vue +212 -0
- package/packages/table/index.vue +24 -18
- package/src/App.vue +0 -31
- package/src/assets/logo.png +0 -0
- package/src/main.js +0 -11
package/packages/cell/index.vue
CHANGED
@@ -1,144 +1,56 @@
|
|
1
1
|
<template>
|
2
|
-
<div
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
<div class="th-cell-content">
|
19
|
-
<div v-if="title" class="th-cell-title">{{ title }}</div>
|
20
|
-
<slot v-else name="title" />
|
21
|
-
<div v-if="label" class="th-cell-label">{{ label }}</div>
|
22
|
-
<slot v-else name="label" />
|
2
|
+
<div
|
3
|
+
class="th-cell"
|
4
|
+
:class="[customClass, center ? 'is-center' : '']"
|
5
|
+
:style="customStyle"
|
6
|
+
@click="handleClick"
|
7
|
+
>
|
8
|
+
<i v-if="icon" class="th-cell-icon" :class="icon"></i>
|
9
|
+
<slot v-else name="icon" />
|
10
|
+
<div class="th-cell-content">
|
11
|
+
<div
|
12
|
+
v-if="title"
|
13
|
+
class="th-cell-title"
|
14
|
+
:class="titleClass"
|
15
|
+
:style="titleStyle"
|
16
|
+
>
|
17
|
+
{{ title }}
|
23
18
|
</div>
|
24
|
-
<
|
25
|
-
<
|
19
|
+
<slot v-else name="title" />
|
20
|
+
<div v-if="label" class="th-cell-label" :class="labelClass">
|
21
|
+
{{ label }}
|
22
|
+
</div>
|
23
|
+
<slot v-else name="label" />
|
24
|
+
</div>
|
25
|
+
<div v-if="value" class="th-cell-value" :class="valueClass">
|
26
|
+
{{ value }}
|
26
27
|
</div>
|
28
|
+
<slot v-else />
|
27
29
|
</div>
|
28
30
|
</template>
|
29
31
|
|
30
32
|
<script>
|
31
33
|
export default {
|
32
|
-
name:
|
34
|
+
name: "ThCell",
|
33
35
|
props: {
|
34
|
-
title:
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
},
|
40
|
-
value: {
|
41
|
-
type: String,
|
42
|
-
default: () => {
|
43
|
-
return "";
|
44
|
-
},
|
45
|
-
},
|
46
|
-
label: {
|
47
|
-
type: String,
|
48
|
-
default: () => {
|
49
|
-
return "";
|
50
|
-
},
|
51
|
-
},
|
52
|
-
icon: {
|
53
|
-
type: String,
|
54
|
-
default: () => {
|
55
|
-
return "";
|
56
|
-
},
|
57
|
-
},
|
58
|
-
customStyle: {
|
59
|
-
type: String,
|
60
|
-
default: () => {
|
61
|
-
return "";
|
62
|
-
},
|
63
|
-
},
|
64
|
-
loading: {
|
65
|
-
type: Boolean,
|
66
|
-
default: () => {
|
67
|
-
return false;
|
68
|
-
},
|
69
|
-
},
|
70
|
-
},
|
71
|
-
};
|
72
|
-
</script>
|
36
|
+
title: Number | String,
|
37
|
+
value: Number | String,
|
38
|
+
label: String,
|
39
|
+
icon: String,
|
40
|
+
center: Boolean,
|
73
41
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
align-items: center;
|
79
|
-
padding: 10px 15px;
|
80
|
-
border-radius: 4px;
|
81
|
-
border: 1px solid #ebeef5;
|
82
|
-
background-color: white;
|
83
|
-
overflow: hidden;
|
84
|
-
transition: 0.3s;
|
85
|
-
.th-cell-icon {
|
86
|
-
margin-right: 10px;
|
87
|
-
font-size: 18px;
|
88
|
-
}
|
89
|
-
.th-cell-content {
|
90
|
-
flex: 1;
|
91
|
-
}
|
92
|
-
&-title {
|
93
|
-
font-size: 16px;
|
94
|
-
color: #333333;
|
95
|
-
}
|
96
|
-
&-label {
|
97
|
-
margin-top: 5px;
|
98
|
-
font-size: 14px;
|
99
|
-
color: #666666;
|
100
|
-
word-wrap: break-word;
|
101
|
-
word-break: break-all;
|
102
|
-
}
|
103
|
-
&-value {
|
104
|
-
margin-left: 10px;
|
105
|
-
max-width: 50%;
|
106
|
-
font-size: 14px;
|
107
|
-
color: #999999;
|
108
|
-
word-wrap: break-word;
|
109
|
-
word-break: break-all;
|
110
|
-
}
|
111
|
-
}
|
112
|
-
.th-cell:hover {
|
113
|
-
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
|
114
|
-
}
|
42
|
+
customClass: String | Object,
|
43
|
+
titleClass: String | Object,
|
44
|
+
labelClass: String | Object,
|
45
|
+
valueClass: String | Object,
|
115
46
|
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
border: 1px solid #ebeef5;
|
124
|
-
&-icon {
|
125
|
-
width: 30px;
|
126
|
-
height: 30px;
|
127
|
-
margin-right: 10px;
|
128
|
-
font-size: 18px;
|
129
|
-
}
|
130
|
-
&-content {
|
131
|
-
flex: 1;
|
132
|
-
}
|
133
|
-
&-title {
|
134
|
-
width: 100px;
|
135
|
-
}
|
136
|
-
&-label {
|
137
|
-
margin-top: 5px;
|
138
|
-
}
|
139
|
-
&-value {
|
140
|
-
margin-left: 10px;
|
141
|
-
width: 100px;
|
47
|
+
customStyle: String | Object,
|
48
|
+
titleStyle: String | Object
|
49
|
+
},
|
50
|
+
methods: {
|
51
|
+
handleClick(evt) {
|
52
|
+
this.$emit("click", evt);
|
53
|
+
}
|
142
54
|
}
|
143
|
-
}
|
144
|
-
</
|
55
|
+
};
|
56
|
+
</script>
|
@@ -0,0 +1,212 @@
|
|
1
|
+
<template>
|
2
|
+
<div class="wrap">
|
3
|
+
<div class="code-editor" :ref="generateId"></div>
|
4
|
+
<span v-if="withFullscreenBtn" title="全屏显示">
|
5
|
+
<svg-icon
|
6
|
+
class="icon-fullscreen"
|
7
|
+
icon-class="fullscreen"
|
8
|
+
:style="{ bottom: (withFooterBtns ? 47 : 10) + 'px' }"
|
9
|
+
@click.native="fullscreen"
|
10
|
+
></svg-icon>
|
11
|
+
</span>
|
12
|
+
|
13
|
+
<el-dialog
|
14
|
+
ref="dialog"
|
15
|
+
custom-class="code-dialog"
|
16
|
+
:visible.sync="isVisible"
|
17
|
+
title="脚本编辑"
|
18
|
+
fullscreen
|
19
|
+
append-to-body
|
20
|
+
:show-footer="false"
|
21
|
+
@close="closeEditCode"
|
22
|
+
>
|
23
|
+
<code-editor v-model="dialogValue"></code-editor>
|
24
|
+
</el-dialog>
|
25
|
+
</div>
|
26
|
+
</template>
|
27
|
+
<script>
|
28
|
+
// 引入全局实例
|
29
|
+
import ace from "ace-builds";
|
30
|
+
// 主题风格,引入主题后还需要在 options 中指定主题才会生效
|
31
|
+
import "ace-builds/src-min-noconflict/theme-monokai";
|
32
|
+
import "ace-builds/src-min-noconflict/theme-dracula";
|
33
|
+
// 支持代码格式, 需要引入具体的语法高亮库才会有对应的语法高亮效果
|
34
|
+
import "ace-builds/src-min-noconflict/mode-javascript";
|
35
|
+
import "ace-builds/src-min-noconflict/mode-json";
|
36
|
+
import "ace-builds/src-min-noconflict/mode-css";
|
37
|
+
import "ace-builds/src-min-noconflict/ext-language_tools";
|
38
|
+
import jsWorkerUrl from "file-loader!ace-builds/src-noconflict/worker-javascript";
|
39
|
+
import jsonWorkerUrl from "file-loader!ace-builds/src-noconflict/worker-json";
|
40
|
+
import cssWorkerUrl from "file-loader!ace-builds/src-noconflict/worker-css";
|
41
|
+
ace.config.setModuleUrl("ace/mode/javascript_worker", jsWorkerUrl);
|
42
|
+
ace.config.setModuleUrl("ace/mode/json_worker", jsonWorkerUrl);
|
43
|
+
ace.config.setModuleUrl("ace/mode/css_worker", cssWorkerUrl);
|
44
|
+
ace.config.setModuleUrl(
|
45
|
+
"ace/snippets/javascript",
|
46
|
+
require("file-loader!ace-builds/src-noconflict/snippets/javascript.js")
|
47
|
+
);
|
48
|
+
ace.config.setModuleUrl(
|
49
|
+
"ace/snippets/css",
|
50
|
+
require("file-loader!ace-builds/src-noconflict/snippets/css.js")
|
51
|
+
);
|
52
|
+
|
53
|
+
export default {
|
54
|
+
name: "CodeEditor",
|
55
|
+
model: {
|
56
|
+
event: "change",
|
57
|
+
},
|
58
|
+
props: {
|
59
|
+
// 编辑器内容
|
60
|
+
value: String,
|
61
|
+
// 默认语言
|
62
|
+
language: {
|
63
|
+
type: String,
|
64
|
+
default: "javascript",
|
65
|
+
},
|
66
|
+
// 主题,对应主题库 JS 需要提前引入
|
67
|
+
theme: {
|
68
|
+
type: String,
|
69
|
+
default: "monokai",
|
70
|
+
},
|
71
|
+
// 是否只读
|
72
|
+
readonly: {
|
73
|
+
type: Boolean,
|
74
|
+
default: false,
|
75
|
+
},
|
76
|
+
// 最大行数
|
77
|
+
maxLines: Number,
|
78
|
+
// 是否显示全屏按钮
|
79
|
+
withFullscreenBtn: {
|
80
|
+
type: Boolean,
|
81
|
+
default: false,
|
82
|
+
},
|
83
|
+
withFooterBtns: {
|
84
|
+
type: Boolean,
|
85
|
+
default: false,
|
86
|
+
},
|
87
|
+
},
|
88
|
+
data() {
|
89
|
+
return {
|
90
|
+
editor: null,
|
91
|
+
generateId:
|
92
|
+
"id_" +
|
93
|
+
Math.random()
|
94
|
+
.toString(36)
|
95
|
+
.substr(2, 4),
|
96
|
+
isVisible: false,
|
97
|
+
dialogValue: "",
|
98
|
+
};
|
99
|
+
},
|
100
|
+
mounted() {
|
101
|
+
// 初始化
|
102
|
+
this.initEditor();
|
103
|
+
},
|
104
|
+
watch: {
|
105
|
+
value(val) {
|
106
|
+
if (this.editor.getValue() !== val) {
|
107
|
+
this.editor.setValue(val);
|
108
|
+
this.editor.clearSelection();
|
109
|
+
}
|
110
|
+
},
|
111
|
+
},
|
112
|
+
methods: {
|
113
|
+
// 初始化
|
114
|
+
initEditor() {
|
115
|
+
// 创建实例
|
116
|
+
this.editor = ace.edit(this.$refs[this.generateId], {
|
117
|
+
mode: `ace/mode/${this.language}`,
|
118
|
+
theme: `ace/theme/${this.theme}`,
|
119
|
+
fontSize: 12,
|
120
|
+
tabSize: 2,
|
121
|
+
value: this.value,
|
122
|
+
selectionStyle: "text",
|
123
|
+
maxLines: this.maxLines,
|
124
|
+
readOnly: this.readonly,
|
125
|
+
});
|
126
|
+
// 设置属性等,具体需要可根据官方参数自行设置
|
127
|
+
this.editor.setOptions({
|
128
|
+
enableBasicAutocompletion: true,
|
129
|
+
enableSnippets: true,
|
130
|
+
enableLiveAutocompletion: true,
|
131
|
+
wrap: true,
|
132
|
+
setShowPrintMargin: false,
|
133
|
+
});
|
134
|
+
// 设置值改变监听
|
135
|
+
this.editor.on("change", () => {
|
136
|
+
this.$emit("change", this.editor.getValue());
|
137
|
+
});
|
138
|
+
},
|
139
|
+
// 实例方法,高亮某一行
|
140
|
+
gotoLine(lineNumber) {
|
141
|
+
this.editor.gotoLine(lineNumber);
|
142
|
+
},
|
143
|
+
// 全屏编辑
|
144
|
+
fullscreen() {
|
145
|
+
this.dialogValue = JSON.parse(JSON.stringify(this.editor.getValue()));
|
146
|
+
this.isVisible = true;
|
147
|
+
},
|
148
|
+
closeEditCode() {
|
149
|
+
this.editor.setValue(this.dialogValue);
|
150
|
+
this.editor.clearSelection();
|
151
|
+
},
|
152
|
+
// resize编辑器
|
153
|
+
resize() {
|
154
|
+
this.editor.resize(true);
|
155
|
+
},
|
156
|
+
destroy() {
|
157
|
+
if (this.editor) {
|
158
|
+
this.editor.destroy();
|
159
|
+
this.editor = null;
|
160
|
+
}
|
161
|
+
},
|
162
|
+
},
|
163
|
+
beforeDestroy() {
|
164
|
+
this.destroy();
|
165
|
+
},
|
166
|
+
};
|
167
|
+
</script>
|
168
|
+
<style lang="scss" scoped>
|
169
|
+
.wrap {
|
170
|
+
position: relative;
|
171
|
+
.code-editor {
|
172
|
+
min-height: 150px;
|
173
|
+
height: 100%;
|
174
|
+
border: 1px solid #282f3a;
|
175
|
+
background-color: #0e1013;
|
176
|
+
}
|
177
|
+
.icon-fullscreen {
|
178
|
+
position: absolute;
|
179
|
+
// color: #fff;
|
180
|
+
right: 10px;
|
181
|
+
font-size: 16px;
|
182
|
+
z-index: 9999;
|
183
|
+
cursor: pointer;
|
184
|
+
}
|
185
|
+
}
|
186
|
+
.code-dialog {
|
187
|
+
&::before {
|
188
|
+
content: "";
|
189
|
+
position: absolute;
|
190
|
+
display: block;
|
191
|
+
top: 0;
|
192
|
+
left: 0;
|
193
|
+
right: 0;
|
194
|
+
width: 100%;
|
195
|
+
height: 2px;
|
196
|
+
background-image: linear-gradient(270deg, #00deff, #2483ff 74%);
|
197
|
+
}
|
198
|
+
display: flex;
|
199
|
+
flex-direction: column;
|
200
|
+
background-color: #303640;
|
201
|
+
.el-dialog__header {
|
202
|
+
border: none;
|
203
|
+
.el-dialog__title {
|
204
|
+
color: #ccc;
|
205
|
+
}
|
206
|
+
}
|
207
|
+
.el-dialog__body {
|
208
|
+
flex: 1 1 0;
|
209
|
+
padding-top: 10px;
|
210
|
+
}
|
211
|
+
}
|
212
|
+
</style>
|
package/packages/table/index.vue
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
v-loading="loading"
|
6
6
|
:data="data"
|
7
7
|
:row-key="rowKey"
|
8
|
-
stripe
|
8
|
+
:stripe="stripe"
|
9
9
|
:highlight-current-row="selectType === 'single'"
|
10
10
|
:tree-props="treeProps"
|
11
11
|
@current-change="handleSingleSelect"
|
@@ -93,86 +93,92 @@
|
|
93
93
|
import TableColumn from "./column.vue";
|
94
94
|
|
95
95
|
export default {
|
96
|
-
name:
|
96
|
+
name: "ThTable",
|
97
97
|
components: {
|
98
|
-
TableColumn
|
98
|
+
TableColumn
|
99
99
|
},
|
100
100
|
props: {
|
101
101
|
data: {
|
102
102
|
type: Array,
|
103
103
|
default: () => {
|
104
104
|
return [];
|
105
|
-
}
|
105
|
+
}
|
106
106
|
},
|
107
107
|
options: {
|
108
108
|
type: Array,
|
109
109
|
default: () => {
|
110
110
|
return [];
|
111
|
-
}
|
111
|
+
}
|
112
112
|
},
|
113
113
|
// single:单行选中 multiple:多行选中
|
114
114
|
selectType: {
|
115
115
|
type: String,
|
116
116
|
default: () => {
|
117
117
|
return "";
|
118
|
-
}
|
118
|
+
}
|
119
119
|
},
|
120
120
|
// 行双击事件
|
121
121
|
dblclick: {
|
122
122
|
type: Function,
|
123
123
|
default: () => {
|
124
124
|
return null;
|
125
|
-
}
|
125
|
+
}
|
126
|
+
},
|
127
|
+
stripe: {
|
128
|
+
type: Boolean,
|
129
|
+
default: () => {
|
130
|
+
return false;
|
131
|
+
}
|
126
132
|
},
|
127
133
|
treeProps: {
|
128
134
|
type: Object,
|
129
135
|
default: function() {
|
130
136
|
return {};
|
131
|
-
}
|
137
|
+
}
|
132
138
|
},
|
133
139
|
// 对象,不传表示没有分页,包含三个参数,均必填pageSize:每页展示的条数。currentPage:当前页码。pageCount:总页数
|
134
140
|
pageInfo: {
|
135
141
|
type: Object,
|
136
142
|
default: function() {
|
137
143
|
return {};
|
138
|
-
}
|
144
|
+
}
|
139
145
|
},
|
140
146
|
loading: {
|
141
147
|
type: Boolean,
|
142
148
|
default: () => {
|
143
149
|
return false;
|
144
|
-
}
|
150
|
+
}
|
145
151
|
},
|
146
152
|
height: {
|
147
153
|
type: String,
|
148
154
|
default: () => {
|
149
155
|
return "";
|
150
|
-
}
|
156
|
+
}
|
151
157
|
},
|
152
158
|
rowKey: {
|
153
159
|
type: String,
|
154
160
|
default: () => {
|
155
161
|
return "";
|
156
|
-
}
|
162
|
+
}
|
157
163
|
},
|
158
164
|
showPage: {
|
159
165
|
type: Boolean,
|
160
166
|
default: () => {
|
161
167
|
return true;
|
162
|
-
}
|
168
|
+
}
|
163
169
|
},
|
164
170
|
emptyText: {
|
165
171
|
type: String,
|
166
172
|
default: () => {
|
167
173
|
return "暂无数据";
|
168
|
-
}
|
174
|
+
}
|
169
175
|
},
|
170
176
|
loadingText: {
|
171
177
|
type: String,
|
172
178
|
default: () => {
|
173
179
|
return "加载中";
|
174
|
-
}
|
175
|
-
}
|
180
|
+
}
|
181
|
+
}
|
176
182
|
},
|
177
183
|
data() {
|
178
184
|
return {};
|
@@ -229,8 +235,8 @@ export default {
|
|
229
235
|
},
|
230
236
|
getTable() {
|
231
237
|
return this.$refs["th_table"];
|
232
|
-
}
|
233
|
-
}
|
238
|
+
}
|
239
|
+
}
|
234
240
|
};
|
235
241
|
</script>
|
236
242
|
|
package/src/App.vue
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
<template>
|
2
|
-
<div id="app">
|
3
|
-
<th-cell
|
4
|
-
v-for="(item, index) in list"
|
5
|
-
:key="index"
|
6
|
-
:title="item.title" :label="item.label"
|
7
|
-
></th-cell>
|
8
|
-
</div>
|
9
|
-
</template>
|
10
|
-
|
11
|
-
<script>
|
12
|
-
import ThCell from "../packages/cell/index.vue";
|
13
|
-
export default {
|
14
|
-
name: "app",
|
15
|
-
components: { ThCell },
|
16
|
-
data() {
|
17
|
-
return {
|
18
|
-
list: [{ title: "张三", label: "18岁" }]
|
19
|
-
};
|
20
|
-
}
|
21
|
-
};
|
22
|
-
</script>
|
23
|
-
|
24
|
-
<style lang="scss">
|
25
|
-
#app {
|
26
|
-
font-family: "Avenir", Helvetica, Arial, sans-serif;
|
27
|
-
-webkit-font-smoothing: antialiased;
|
28
|
-
-moz-osx-font-smoothing: grayscale;
|
29
|
-
color: #2c3e50;
|
30
|
-
}
|
31
|
-
</style>
|
package/src/assets/logo.png
DELETED
Binary file
|