tianheng-ui 0.0.8 → 0.0.9

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.9",
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%",
@@ -1,144 +1,38 @@
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" />
23
- </div>
24
- <div v-if="value" class="th-cell-value">{{ value }}</div>
25
- <slot v-else />
2
+ <div
3
+ class="th-cell"
4
+ :class="[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 v-if="title" class="th-cell-title">{{ title }}</div>
12
+ <slot v-else name="title" />
13
+ <div v-if="label" class="th-cell-label">{{ label }}</div>
14
+ <slot v-else name="label" />
26
15
  </div>
16
+ <div v-if="value" class="th-cell-value">{{ value }}</div>
17
+ <slot v-else />
27
18
  </div>
28
19
  </template>
29
20
 
30
21
  <script>
31
22
  export default {
32
- name:'ThCell',
23
+ name: "ThCell",
33
24
  props: {
34
- title: {
35
- type: String,
36
- default: () => {
37
- return "";
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
- },
25
+ title: Number | String,
26
+ value: Number | String,
27
+ label: String,
28
+ icon: String,
29
+ customStyle: String | Object,
30
+ center: Boolean
70
31
  },
32
+ methods: {
33
+ handleClick(evt) {
34
+ this.$emit("click", evt);
35
+ }
36
+ }
71
37
  };
72
38
  </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,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:'ThTable',
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