tianheng-ui 0.0.8 → 0.0.12

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "tianheng-ui",
3
3
  "description": "A Vue.js project",
4
- "version": "0.0.8",
4
+ "version": "0.0.12",
5
5
  "author": "shu lang <403732931@qq.com>",
6
6
  "license": "MIT",
7
7
  "private": false,
@@ -11,8 +11,11 @@
11
11
  "build": "cross-env NODE_ENV=production webpack --progress --hide-modules"
12
12
  },
13
13
  "dependencies": {
14
+ "ace-builds": "^1.4.13",
14
15
  "element-ui": "^2.15.6",
15
- "vue": "^2.5.11"
16
+ "nprogress": "^0.2.0",
17
+ "vue": "^2.5.11",
18
+ "vue-router": "^3.5.3"
16
19
  },
17
20
  "browserslist": [
18
21
  "> 1%",
@@ -43,7 +46,7 @@
43
46
  "homepage": "http://element.eleme.io",
44
47
  "keywords": [
45
48
  "tianheng",
46
- "prompt"
49
+ "tianheng-ui"
47
50
  ],
48
51
  "style": "lib/theme-chalk/index.css"
49
52
  }
@@ -1,144 +1,116 @@
1
1
  <template>
2
- <div>
3
- <el-skeleton :loading="loading" animated>
4
- <template slot="template">
5
- <div class="skeleton">
6
- <el-skeleton-item class="skeleton-icon" variant="image" />
7
- <div class="skeleton-content">
8
- <el-skeleton-item class="skeleton-title" variant="h4" />
9
- <el-skeleton-item class="skeleton-label" variant="text" />
10
- </div>
11
- <el-skeleton-item class="skeleton-value" variant="text" />
12
- </div>
13
- </template>
14
- </el-skeleton>
15
- <div v-if="!loading" class="th-cell" :style="customStyle">
16
- <i v-if="icon" class="th-cell-icon" :class="icon"></i>
17
- <slot v-else name="icon" />
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="[
5
+ customClass,
6
+ center ? 'is-center' : '',
7
+ active ? cellActive : '',
8
+ hover ? cellHover : ''
9
+ ]"
10
+ :style="customStyle"
11
+ @click="handleClick"
12
+ >
13
+ <i v-if="icon" class="th-cell-icon" :class="icon"></i>
14
+ <slot v-else name="icon" />
15
+ <div class="th-cell-content">
16
+ <div
17
+ v-if="title"
18
+ class="th-cell-title"
19
+ :class="[titleClass, active ? titleActive : '', hover ? titleHover : 'title-color']"
20
+ :style="titleStyle"
21
+ >
22
+ {{ title }}
23
23
  </div>
24
- <div v-if="value" class="th-cell-value">{{ value }}</div>
25
- <slot v-else />
24
+ <slot v-else name="title" />
25
+ <div
26
+ v-if="label"
27
+ class="th-cell-label"
28
+ :class="[labelClass, active ? labelActive : '', hover ? labelHover : '']"
29
+ >
30
+ {{ label }}
31
+ </div>
32
+ <slot v-else name="label" />
33
+ </div>
34
+ <div
35
+ v-if="value"
36
+ class="th-cell-value"
37
+ :class="[valueClass, active ? valueActive : '', hover ? valueHover : '']"
38
+ >
39
+ {{ value }}
26
40
  </div>
41
+ <slot v-else />
27
42
  </div>
28
43
  </template>
29
44
 
30
45
  <script>
31
46
  export default {
32
- name:'ThCell',
47
+ name: "ThCell",
33
48
  props: {
34
- title: {
35
- type: String,
36
- default: () => {
37
- return "";
38
- },
49
+ title: Number | String,
50
+ value: Number | String,
51
+ label: String,
52
+ icon: String,
53
+
54
+ customStyle: String | Object,
55
+ titleStyle: String | Object,
56
+
57
+ customClass: String | Object,
58
+ titleClass: String | Object,
59
+ labelClass: String | Object,
60
+ valueClass: String | Object,
61
+
62
+ cellActiveClass: String | Object,
63
+ titleActiveClass: String | Object,
64
+ labelActiveClass: String | Object,
65
+ valueActiveClass: String | Object,
66
+
67
+ cellHoverClass: String | Object,
68
+ titleHoverClass: String | Object,
69
+ labelHoverClass: String | Object,
70
+ valueHoverClass: String | Object,
71
+
72
+ center: Boolean,
73
+ hover: Boolean,
74
+ active: Boolean
75
+ },
76
+ computed: {
77
+ cellActive() {
78
+ if (this.cellActiveClass) return this.cellActiveClass;
79
+ else return "is-active";
80
+ },
81
+ titleActive() {
82
+ if (this.titleActiveClass) return this.titleActiveClass;
83
+ else return "is-active";
39
84
  },
40
- value: {
41
- type: String,
42
- default: () => {
43
- return "";
44
- },
85
+ labelActive() {
86
+ if (this.labelActiveClass) return this.labelActiveClass;
87
+ else return "is-active";
45
88
  },
46
- label: {
47
- type: String,
48
- default: () => {
49
- return "";
50
- },
89
+ valueActive() {
90
+ if (this.valueActiveClass) return this.valueActiveClass;
91
+ else return "is-active";
51
92
  },
52
- icon: {
53
- type: String,
54
- default: () => {
55
- return "";
56
- },
93
+ cellHover() {
94
+ if (this.cellHoverClass) return this.cellHoverClass;
95
+ else return "is-hover";
57
96
  },
58
- customStyle: {
59
- type: String,
60
- default: () => {
61
- return "";
62
- },
97
+ titleHover() {
98
+ if (this.titleHoverClass) return this.titleHoverClass;
99
+ else return "is-hover";
63
100
  },
64
- loading: {
65
- type: Boolean,
66
- default: () => {
67
- return false;
68
- },
101
+ labelHover() {
102
+ if (this.labelHoverClass) return this.labelHoverClass;
103
+ else return "is-hover";
69
104
  },
105
+ valueHover() {
106
+ if (this.valueHoverClass) return this.valueHoverClass;
107
+ else return "is-hover";
108
+ }
70
109
  },
110
+ methods: {
111
+ handleClick(evt) {
112
+ this.$emit("click", evt);
113
+ }
114
+ }
71
115
  };
72
116
  </script>
73
-
74
- <style lang="less" scoped>
75
- .th-cell {
76
- position: relative;
77
- display: flex;
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
- }
115
-
116
- .skeleton {
117
- display: flex;
118
- align-items: center;
119
- // height: 64px;
120
- margin-bottom: 20px;
121
- padding: 10px 15px;
122
- border-radius: 4px;
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;
142
- }
143
- }
144
- </style>
@@ -0,0 +1,8 @@
1
+ import CodeEditor from "./index.vue";
2
+
3
+ /* istanbul ignore next */
4
+ CodeEditor.install = function(Vue) {
5
+ Vue.component(CodeEditor.name, CodeEditor);
6
+ };
7
+
8
+ export default CodeEditor;
@@ -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>
@@ -5,7 +5,8 @@
5
5
  v-loading="loading"
6
6
  :data="data"
7
7
  :row-key="rowKey"
8
- stripe
8
+ :stripe="stripe"
9
+ :border="border"
9
10
  :highlight-current-row="selectType === 'single'"
10
11
  :tree-props="treeProps"
11
12
  @current-change="handleSingleSelect"
@@ -93,86 +94,98 @@
93
94
  import TableColumn from "./column.vue";
94
95
 
95
96
  export default {
96
- name:'ThTable',
97
+ name: "ThTable",
97
98
  components: {
98
- TableColumn,
99
+ TableColumn
99
100
  },
100
101
  props: {
101
102
  data: {
102
103
  type: Array,
103
104
  default: () => {
104
105
  return [];
105
- },
106
+ }
106
107
  },
107
108
  options: {
108
109
  type: Array,
109
110
  default: () => {
110
111
  return [];
111
- },
112
+ }
112
113
  },
113
114
  // single:单行选中 multiple:多行选中
114
115
  selectType: {
115
116
  type: String,
116
117
  default: () => {
117
118
  return "";
118
- },
119
+ }
119
120
  },
120
121
  // 行双击事件
121
122
  dblclick: {
122
123
  type: Function,
123
124
  default: () => {
124
125
  return null;
125
- },
126
+ }
127
+ },
128
+ stripe: {
129
+ type: Boolean,
130
+ default: () => {
131
+ return false;
132
+ }
126
133
  },
127
134
  treeProps: {
128
135
  type: Object,
129
136
  default: function() {
130
137
  return {};
131
- },
138
+ }
132
139
  },
133
140
  // 对象,不传表示没有分页,包含三个参数,均必填pageSize:每页展示的条数。currentPage:当前页码。pageCount:总页数
134
141
  pageInfo: {
135
142
  type: Object,
136
143
  default: function() {
137
144
  return {};
138
- },
145
+ }
139
146
  },
140
147
  loading: {
141
148
  type: Boolean,
142
149
  default: () => {
143
150
  return false;
144
- },
151
+ }
145
152
  },
146
153
  height: {
147
154
  type: String,
148
155
  default: () => {
149
156
  return "";
150
- },
157
+ }
151
158
  },
152
159
  rowKey: {
153
160
  type: String,
154
161
  default: () => {
155
162
  return "";
156
- },
163
+ }
157
164
  },
158
165
  showPage: {
159
166
  type: Boolean,
160
167
  default: () => {
161
168
  return true;
162
- },
169
+ }
163
170
  },
164
171
  emptyText: {
165
172
  type: String,
166
173
  default: () => {
167
174
  return "暂无数据";
168
- },
175
+ }
169
176
  },
170
177
  loadingText: {
171
178
  type: String,
172
179
  default: () => {
173
180
  return "加载中";
174
- },
181
+ }
175
182
  },
183
+ border: {
184
+ type: Boolean,
185
+ default: () => {
186
+ return false;
187
+ }
188
+ }
176
189
  },
177
190
  data() {
178
191
  return {};
@@ -229,8 +242,8 @@ export default {
229
242
  },
230
243
  getTable() {
231
244
  return this.$refs["th_table"];
232
- },
233
- },
245
+ }
246
+ }
234
247
  };
235
248
  </script>
236
249