@netang/quasar 0.0.49 → 0.0.50

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.
@@ -1,23 +1,23 @@
1
- <template>
2
- <slot :data="data" />
3
- </template>
4
-
5
- <script>
6
- export default {
7
- /**
8
- * 标识
9
- */
10
- name: 'NData',
11
-
12
- /**
13
- * 传参
14
- */
15
- props: {
16
- // 数据
17
- data: {},
18
- },
19
- }
20
- </script>
21
-
22
- <style>
23
- </style>
1
+ <template>
2
+ <slot :data="data" />
3
+ </template>
4
+
5
+ <script>
6
+ export default {
7
+ /**
8
+ * 标识
9
+ */
10
+ name: 'NData',
11
+
12
+ /**
13
+ * 传参
14
+ */
15
+ props: {
16
+ // 数据
17
+ data: {},
18
+ },
19
+ }
20
+ </script>
21
+
22
+ <style>
23
+ </style>
@@ -0,0 +1,282 @@
1
+ <template>
2
+ <!-- :style="currentStyle" -->
3
+ <div
4
+ ref="targetRef"
5
+ :style="currentStyle"
6
+ ></div>
7
+ </template>
8
+
9
+ <script>
10
+ import { ref, watch, computed, onMounted } from 'vue'
11
+
12
+ import script from '@netang/utils/script'
13
+
14
+ export default {
15
+
16
+ /**
17
+ * 标识
18
+ */
19
+ name: 'NEditorCode',
20
+
21
+ /**
22
+ * 声明属性
23
+ */
24
+ props: {
25
+ // 值 v-model
26
+ modelValue: {
27
+ type: [ String, Number ],
28
+ default: '',
29
+ },
30
+ // 宽度
31
+ width: {
32
+ type: [ String, Number ],
33
+ default: '100%',
34
+ },
35
+ // 高度
36
+ height: [ String, Number ],
37
+ // 脚本语言
38
+ language: String,
39
+ // 是否只读
40
+ readonly: Boolean,
41
+ // 代码视图
42
+ minimap: Boolean,
43
+ // tab 长度
44
+ tabSize: {
45
+ type: Number,
46
+ default: 4,
47
+ },
48
+ // 主题
49
+ theme: {
50
+ type: String,
51
+ default: 'vs',
52
+ },
53
+ },
54
+
55
+ /**
56
+ * 声明事件
57
+ */
58
+ emits: [
59
+ 'update:modelValue',
60
+ ],
61
+
62
+ /**
63
+ * 组合式
64
+ */
65
+ setup(props, { emit }) {
66
+
67
+ // ==========【计算属性】=========================================================================================
68
+
69
+ /**
70
+ * 当前样式
71
+ */
72
+ const currentStyle = computed(function () {
73
+ return {
74
+ width: $n.isNumeric(props.width) ? $n.px(props.width) : props.width,
75
+ height: $n.isNumeric(props.height) ? $n.px(props.height) : props.height,
76
+ }
77
+ })
78
+
79
+ // ==========【数据】=============================================================================================
80
+
81
+ // 根节点
82
+ const targetRef = ref(null)
83
+
84
+ // 编辑器实例
85
+ let $editor = null
86
+
87
+ // 停止值观察
88
+ let stopValueWatcher = false
89
+
90
+ // 创建防抖睡眠方法
91
+ const sleep = $n.debounceSleep()
92
+
93
+ // ==========【监听数据】=========================================================================================
94
+
95
+ /**
96
+ * 监听声明值
97
+ */
98
+ watch(() => props.modelValue, function (val) {
99
+
100
+ // 如果停止值观察
101
+ if (stopValueWatcher) {
102
+
103
+ // 则无任何操作
104
+ return
105
+ }
106
+
107
+ // 取消停止值观察
108
+ stopValueWatcher = false
109
+
110
+ // 设置值
111
+ setValue(val)
112
+ })
113
+
114
+ // ==========【方法】============================================================================================
115
+
116
+ function load() {
117
+
118
+ // 如果已加载
119
+ if (window.monaco) {
120
+ // 创建编辑器
121
+ create()
122
+ return
123
+ }
124
+
125
+ // 版本
126
+ const version = '0.34.1'
127
+
128
+ // 加载 script
129
+ script([
130
+ [
131
+ `https://cdn.staticfile.org/monaco-editor/${version}/min/vs/loader.js`,
132
+ `https://fastly.jsdelivr.net/npm/monaco-editor@${version}/min/vs/loader.js`,
133
+ `https://unpkg.com/monaco-editor@${version}/min/vs/loader.js`,
134
+ ]
135
+ ])
136
+ .then(function ([ url ]) {
137
+
138
+ // 按需加载
139
+ const _require = window.require
140
+
141
+ // 配置
142
+ _require.config({
143
+ // 路径
144
+ paths: {
145
+ vs: url.replace('/loader.js', ''),
146
+ },
147
+ // 语言
148
+ 'vs/nls' : {
149
+ availableLanguages: {
150
+ '*': 'zh-cn',
151
+ }
152
+ }
153
+ })
154
+
155
+ // 加载
156
+ _require(['vs/editor/editor.main'], function () {
157
+ // 创建编辑器
158
+ create()
159
+ })
160
+ })
161
+ }
162
+
163
+ /**
164
+ * 创建编辑器
165
+ */
166
+ function create() {
167
+
168
+ // 创建编辑器
169
+ $editor = monaco.editor.create(targetRef.value, {
170
+ // 主题
171
+ theme: props.theme,
172
+ // 脚本语言
173
+ language: props.language,
174
+ // 自动布局
175
+ automaticLayout: true,
176
+ // 自动换行
177
+ wordWrap: 'on',
178
+ // tab 长度
179
+ tabSize: props.tabSize,
180
+ // 代码略缩图
181
+ minimap: {
182
+ enabled: props.minimap,
183
+ },
184
+ // 右键
185
+ contextmenu: true,
186
+ // 是否只读
187
+ readOnly: props.readonly,
188
+ })
189
+
190
+ // 监听失去焦点事件
191
+ $editor.onDidBlurEditorText(function () {
192
+
193
+ // 获取编辑器内容
194
+ const value = getValue()
195
+ if (value === void 0) {
196
+ return
197
+ }
198
+
199
+ // 停止值观察
200
+ stopValueWatcher = true
201
+
202
+ // 触发更新值
203
+ emit('update:modelValue', value)
204
+ })
205
+
206
+ // 等编辑器全部加载完成后, 设置内容值
207
+ sleep(300)
208
+ .then(function () {
209
+ // 设置值
210
+ setValue(props.modelValue)
211
+ })
212
+ }
213
+
214
+ /**
215
+ * 设置值
216
+ */
217
+ function setValue(value) {
218
+ if ($editor) {
219
+
220
+ // 编辑器设置内容
221
+ $editor.setValue(value)
222
+
223
+ // 代码格式化
224
+ $editor.getAction('editor.action.formatDocument').run()
225
+ }
226
+ }
227
+
228
+ /**
229
+ * 获取值
230
+ */
231
+ function getValue() {
232
+
233
+ if ($editor) {
234
+
235
+ // 获取编辑器的值
236
+ let value = $editor.getValue()
237
+
238
+ // 如果语言为 json
239
+ if (
240
+ props.language === 'json'
241
+ && $n.isValidValue(value)
242
+ ) {
243
+ try {
244
+ value = JSON.stringify(JSON.parse(value))
245
+
246
+ } catch (e) {
247
+ // 轻提示
248
+ $n.toast({
249
+ message: 'JSON 语法错误'
250
+ })
251
+ return
252
+ }
253
+ }
254
+
255
+ return value
256
+ }
257
+
258
+ return ''
259
+ }
260
+
261
+ // ==========【生命周期】=========================================================================================
262
+
263
+ /**
264
+ * 实例被挂载后调用
265
+ */
266
+ onMounted(function() {
267
+
268
+ // 加载
269
+ load()
270
+ })
271
+
272
+ // ==========【返回】=========================================================================================
273
+
274
+ return {
275
+ // 根节点
276
+ targetRef,
277
+ // 当前样式
278
+ currentStyle,
279
+ }
280
+ }
281
+ }
282
+ </script>
@@ -1,6 +1,15 @@
1
1
  <template>
2
- <div class="q-pa-lg flex flex-center absolute-full">
3
- {{description || '发生未知错误'}}
2
+ <div class="q-pa-lg column flex-center absolute-full q-gutter-sm">
3
+
4
+ <!-- 图标 -->
5
+ <q-icon
6
+ :name="icon"
7
+ color="grey-5"
8
+ :size="$n.px(iconSize)"
9
+ />
10
+
11
+ <!-- 描述文字 -->
12
+ <div class="text-subtitle1 text-grey-7" v-if="description">{{description}}</div>
4
13
  </div>
5
14
  </template>
6
15
 
@@ -16,7 +25,17 @@ export default {
16
25
  * 声明属性
17
26
  */
18
27
  props: {
19
- // 空状态描述
28
+ // 图标
29
+ icon: {
30
+ type: String,
31
+ default: 'info',
32
+ },
33
+ // 图标大小
34
+ iconSize: {
35
+ type: [ String, Number ],
36
+ default: 70,
37
+ },
38
+ // 描述文字
20
39
  description: String,
21
40
  },
22
41
  }
@@ -308,7 +308,7 @@ export default {
308
308
  if (showAfter && $table.tableSelected.value.length > 1) {
309
309
 
310
310
  // 如果有多条已选数据, 则只取第一条数据
311
- $table.tableSelected.value = [ $table.tableSelected.value[0] ]
311
+ $table.tableSelected.value = [ $table.tableSelected.value[$table.tableSelected.value.length - 1] ]
312
312
  }
313
313
  }
314
314
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netang/quasar",
3
- "version": "0.0.49",
3
+ "version": "0.0.50",
4
4
  "description": "netang-quasar",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -149,6 +149,11 @@
149
149
  transform: translateY(-80%) scale(0.85) !important;
150
150
  }
151
151
  }
152
+
153
+ // 文本框的上边距
154
+ &.q-textarea.q-field--labeled .q-field__control-container {
155
+ padding-top: 5px;
156
+ }
152
157
  }
153
158
 
154
159
  &--labeled {
@@ -11,6 +11,12 @@ $dark-td-bg-color: $dark;
11
11
 
12
12
  .n-table {
13
13
 
14
+ // 单元格换行
15
+ &__col-wrap {
16
+ word-wrap: break-word !important;
17
+ white-space: pre-wrap !important;
18
+ }
19
+
14
20
  &.q-table {
15
21
  &--dense {
16
22
  // 复选框
package/utils/$table.js CHANGED
@@ -651,6 +651,9 @@ function create(params) {
651
651
  */
652
652
  async function tableRequest(props) {
653
653
 
654
+ // 加载
655
+ tableLoading.value = true
656
+
654
657
  // 解构数据
655
658
  const {
656
659
  // filter,