@cloudbase/weda-ui-mp 3.8.2 → 3.9.1
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/components/dataView/index.js +13 -0
- package/components/dataView/index.wxml +3 -0
- package/components/form/location/components/mapChoose/index.js +32 -7
- package/components/form/location/index.js +38 -10
- package/components/form/location/index.wxml +1 -1
- package/components/listView/index.js +52 -7
- package/components/wd-location/index.js +8 -0
- package/components/wd-location/index.wxml +2 -0
- package/components/wd-markdown/index.js +99 -0
- package/components/wd-markdown/index.json +7 -0
- package/components/wd-markdown/index.wxml +3 -0
- package/components/wd-markdown/index.wxss +128 -0
- package/components/wd-markdown/utils/highlight.min.js +1 -0
- package/components/wd-markdown/utils/hljs_css.min.js +1 -0
- package/components/wd-markdown/utils/hljs_javascript.min.js +1 -0
- package/components/wd-markdown/utils/markdown-it.min.js +3 -0
- package/components/wd-menu-layout/index.wxml +12 -0
- package/components/wd-menu-layout/wd-menu-layout.wxss +3 -3
- package/components/wd-menu-list/wd-menu-list.wxss +3 -3
- package/components/wd-menu-nav-tab-layout/index.js +20 -0
- package/components/wd-menu-nav-tab-layout/index.json +5 -0
- package/components/wd-menu-nav-tab-layout/index.wxml +3 -0
- package/components/web-view/index.js +0 -3
- package/index.json +2 -0
- package/package.json +1 -1
- package/utils/error.js +12 -0
- package/utils/getModelParams.js +79 -5
|
@@ -49,6 +49,18 @@ Component({
|
|
|
49
49
|
type: Object,
|
|
50
50
|
value: {},
|
|
51
51
|
},
|
|
52
|
+
selectFieldType: {
|
|
53
|
+
type: String,
|
|
54
|
+
value: 'main',
|
|
55
|
+
},
|
|
56
|
+
selectFields: {
|
|
57
|
+
type: Array,
|
|
58
|
+
value: [],
|
|
59
|
+
},
|
|
60
|
+
supportManyRelated: {
|
|
61
|
+
type: Boolean,
|
|
62
|
+
value: false,
|
|
63
|
+
},
|
|
52
64
|
},
|
|
53
65
|
data: {
|
|
54
66
|
innerBeforeDataChange: function (values) {
|
|
@@ -93,6 +105,7 @@ Component({
|
|
|
93
105
|
record: this.data._oldData,
|
|
94
106
|
refresh,
|
|
95
107
|
deleteOne,
|
|
108
|
+
dataSourceVersion: this.properties.supportManyRelated ? 'v2' : 'v1',
|
|
96
109
|
});
|
|
97
110
|
},
|
|
98
111
|
},
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import debounce from '../../../../../utils/debounce';
|
|
2
2
|
import { getCurrentLocation } from '../../../../../utils/getCustomInfo';
|
|
3
|
+
import { errorHandler } from '../../../../../utils/error';
|
|
4
|
+
|
|
3
5
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
4
6
|
let QQMapWX = require('../../../../../utils/qqmap-wx-jssdk1.2/qqmap-wx-jssdk');
|
|
5
7
|
let qqmapsdk;
|
|
@@ -9,6 +11,10 @@ Component({
|
|
|
9
11
|
* 组件的属性列表
|
|
10
12
|
*/
|
|
11
13
|
properties: {
|
|
14
|
+
id: {
|
|
15
|
+
Type: String,
|
|
16
|
+
value: '',
|
|
17
|
+
},
|
|
12
18
|
location: {
|
|
13
19
|
type: Object,
|
|
14
20
|
value: {
|
|
@@ -44,6 +50,7 @@ Component({
|
|
|
44
50
|
lifetimes: {
|
|
45
51
|
attached: function () {
|
|
46
52
|
this.getInitialization();
|
|
53
|
+
this.setData({ id: this.id });
|
|
47
54
|
},
|
|
48
55
|
},
|
|
49
56
|
|
|
@@ -273,7 +280,12 @@ Component({
|
|
|
273
280
|
});
|
|
274
281
|
},
|
|
275
282
|
fail: function (error) {
|
|
276
|
-
|
|
283
|
+
const { comErrorInfo } = errorHandler({
|
|
284
|
+
id: this.id,
|
|
285
|
+
code: 'WdLocation.SearchError',
|
|
286
|
+
error: error,
|
|
287
|
+
});
|
|
288
|
+
this.triggerEvent('error', { error: comErrorInfo });
|
|
277
289
|
_this.setData({
|
|
278
290
|
searchLoadingStatus: false,
|
|
279
291
|
});
|
|
@@ -297,11 +309,12 @@ Component({
|
|
|
297
309
|
}
|
|
298
310
|
},
|
|
299
311
|
fail: function (error) {
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
312
|
+
const { comErrorInfo } = errorHandler({
|
|
313
|
+
id: this.id,
|
|
314
|
+
code: 'WdLocation.GetSuggestionError',
|
|
315
|
+
error: error,
|
|
304
316
|
});
|
|
317
|
+
this.triggerEvent('error', { error: comErrorInfo });
|
|
305
318
|
},
|
|
306
319
|
});
|
|
307
320
|
}
|
|
@@ -332,7 +345,12 @@ Component({
|
|
|
332
345
|
}
|
|
333
346
|
},
|
|
334
347
|
fail: (error) => {
|
|
335
|
-
|
|
348
|
+
const { comErrorInfo } = errorHandler({
|
|
349
|
+
id: this.id,
|
|
350
|
+
code: 'WdLocation.ReverseGeocoderError',
|
|
351
|
+
error: error,
|
|
352
|
+
});
|
|
353
|
+
this.triggerEvent('error', { error: comErrorInfo });
|
|
336
354
|
let item = {
|
|
337
355
|
id: 'current-location',
|
|
338
356
|
location: {
|
|
@@ -479,7 +497,14 @@ Component({
|
|
|
479
497
|
latitude: Number(latitude.toFixed(6)),
|
|
480
498
|
longitude: Number(longitude.toFixed(6)),
|
|
481
499
|
};
|
|
482
|
-
} catch (e) {
|
|
500
|
+
} catch (e) {
|
|
501
|
+
const { comErrorInfo } = errorHandler({
|
|
502
|
+
id: this.id,
|
|
503
|
+
code: 'WdLocation.GetLatestLocationError',
|
|
504
|
+
error: e,
|
|
505
|
+
});
|
|
506
|
+
this.triggerEvent('error', { error: comErrorInfo });
|
|
507
|
+
}
|
|
483
508
|
return location;
|
|
484
509
|
},
|
|
485
510
|
},
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { callDataSource } from '../../../utils/tcb';
|
|
2
2
|
import classNames from '../../../utils/classnames';
|
|
3
3
|
import customInfo from '../../../utils/getCustomInfo';
|
|
4
|
+
import { errorHandler } from '../../../utils/error';
|
|
5
|
+
|
|
4
6
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
5
7
|
let QQMapWX = require('../../../utils/qqmap-wx-jssdk1.2/qqmap-wx-jssdk');
|
|
6
8
|
let qqmapsdk;
|
|
@@ -17,6 +19,10 @@ Component({
|
|
|
17
19
|
type: String,
|
|
18
20
|
value: '',
|
|
19
21
|
},
|
|
22
|
+
id: {
|
|
23
|
+
Type: String,
|
|
24
|
+
value: '',
|
|
25
|
+
},
|
|
20
26
|
style: {
|
|
21
27
|
type: String,
|
|
22
28
|
value: '',
|
|
@@ -97,6 +103,7 @@ Component({
|
|
|
97
103
|
|
|
98
104
|
lifetimes: {
|
|
99
105
|
attached: function () {
|
|
106
|
+
this.setData({ id: this.id });
|
|
100
107
|
const { locationType, dataSource } = this.properties;
|
|
101
108
|
const getReverseGeocoder = async (location) => {
|
|
102
109
|
const { isApikeyStatus } = this.data;
|
|
@@ -182,7 +189,12 @@ Component({
|
|
|
182
189
|
}
|
|
183
190
|
getReverseGeocoder(location);
|
|
184
191
|
} catch (err) {
|
|
185
|
-
|
|
192
|
+
const { comErrorInfo } = errorHandler({
|
|
193
|
+
id: this.id,
|
|
194
|
+
code: 'WdLocation.DrowMapMarksError',
|
|
195
|
+
error: err,
|
|
196
|
+
});
|
|
197
|
+
this.triggerEvent('error', { error: comErrorInfo });
|
|
186
198
|
}
|
|
187
199
|
};
|
|
188
200
|
const getCustomInfoLocation = () => {
|
|
@@ -206,6 +218,12 @@ Component({
|
|
|
206
218
|
},
|
|
207
219
|
currentLocations: {},
|
|
208
220
|
});
|
|
221
|
+
const { comErrorInfo } = errorHandler({
|
|
222
|
+
id: this.id,
|
|
223
|
+
code: 'WdLocation.GetCurrentLocationError',
|
|
224
|
+
error,
|
|
225
|
+
});
|
|
226
|
+
this.triggerEvent('error', { error: comErrorInfo });
|
|
209
227
|
});
|
|
210
228
|
} else {
|
|
211
229
|
drowMapMarks(customInfoLocation);
|
|
@@ -225,7 +243,6 @@ Component({
|
|
|
225
243
|
getCustomInfoLocation();
|
|
226
244
|
},
|
|
227
245
|
fail: (err) => {
|
|
228
|
-
console.log('authorize fail', err);
|
|
229
246
|
this.setData({
|
|
230
247
|
currentPosition: {
|
|
231
248
|
status: false,
|
|
@@ -236,10 +253,12 @@ Component({
|
|
|
236
253
|
this.triggerEvent('change', {
|
|
237
254
|
value: {},
|
|
238
255
|
});
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
256
|
+
const { comErrorInfo } = errorHandler({
|
|
257
|
+
id: this.id,
|
|
258
|
+
code: 'WdLocation.AuthorizeFail',
|
|
259
|
+
error: err,
|
|
242
260
|
});
|
|
261
|
+
this.triggerEvent('error', { error: comErrorInfo });
|
|
243
262
|
},
|
|
244
263
|
});
|
|
245
264
|
} else {
|
|
@@ -248,11 +267,12 @@ Component({
|
|
|
248
267
|
}
|
|
249
268
|
},
|
|
250
269
|
fail: (err) => {
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
270
|
+
const { comErrorInfo } = errorHandler({
|
|
271
|
+
id: this.id,
|
|
272
|
+
code: 'WdLocation.GetSettingFail',
|
|
273
|
+
error: err,
|
|
255
274
|
});
|
|
275
|
+
this.triggerEvent('error', { error: comErrorInfo });
|
|
256
276
|
},
|
|
257
277
|
});
|
|
258
278
|
}
|
|
@@ -336,7 +356,6 @@ Component({
|
|
|
336
356
|
});
|
|
337
357
|
}
|
|
338
358
|
} catch (error) {
|
|
339
|
-
console.log('getApikey error', error);
|
|
340
359
|
this.setData({
|
|
341
360
|
isApikeyStatus: {
|
|
342
361
|
status: false,
|
|
@@ -344,6 +363,12 @@ Component({
|
|
|
344
363
|
apiKey: '',
|
|
345
364
|
},
|
|
346
365
|
});
|
|
366
|
+
const { comErrorInfo } = errorHandler({
|
|
367
|
+
id: this.id,
|
|
368
|
+
code: 'WdLocation.GetApikeyError',
|
|
369
|
+
error,
|
|
370
|
+
});
|
|
371
|
+
this.triggerEvent('error', { error: comErrorInfo });
|
|
347
372
|
}
|
|
348
373
|
},
|
|
349
374
|
chooseLocation() {
|
|
@@ -434,6 +459,9 @@ Component({
|
|
|
434
459
|
isMapChooseVisible: false,
|
|
435
460
|
});
|
|
436
461
|
},
|
|
462
|
+
handleError: function (e) {
|
|
463
|
+
this.triggerEvent('error', e.detail);
|
|
464
|
+
},
|
|
437
465
|
},
|
|
438
466
|
observers: {
|
|
439
467
|
value: function (value) {
|
|
@@ -24,6 +24,6 @@
|
|
|
24
24
|
<view style="padding-left: 16px; padding-right: 16px; margin-top: 16px; padding-bottom: 16px" wx:if="{{showMap&&isAddrShow}}">
|
|
25
25
|
<map id="map" longitude="{{location.longitude}}" latitude="{{location.latitude}}" markers="{{markers}}" scale="16" enable-zoom="{{zoom}}" enable-scroll="{{drag}}" style="width: 100%; height: 200px"></map>
|
|
26
26
|
</view>
|
|
27
|
-
<mapChoose isVisible="{{isMapChooseVisible}}" bindonClose="mapChooseOnClose" bindonConfirm="mapChooseOnConfirm" location="{{location}}" apiKey="{{isApikeyStatus.apiKey}}" circleRadius="{{locationRange}}" customRange="{{customRange}}" currentLocations="{{currentLocations}}" />
|
|
27
|
+
<mapChoose id="{{id}}" isVisible="{{isMapChooseVisible}}" bindonClose="mapChooseOnClose" bindonConfirm="mapChooseOnConfirm" location="{{location}}" apiKey="{{isApikeyStatus.apiKey}}" circleRadius="{{locationRange}}" customRange="{{customRange}}" currentLocations="{{currentLocations}}" bind:error="handleError" />
|
|
28
28
|
</view>
|
|
29
29
|
</formcell>
|
|
@@ -126,6 +126,22 @@ Component({
|
|
|
126
126
|
type: Boolean,
|
|
127
127
|
value: false,
|
|
128
128
|
},
|
|
129
|
+
selectFieldType: {
|
|
130
|
+
type: String,
|
|
131
|
+
value: 'main',
|
|
132
|
+
},
|
|
133
|
+
selectFields: {
|
|
134
|
+
type: Array,
|
|
135
|
+
value: [],
|
|
136
|
+
},
|
|
137
|
+
pageIndex: {
|
|
138
|
+
type: Number,
|
|
139
|
+
value: 1,
|
|
140
|
+
},
|
|
141
|
+
supportManyRelated: {
|
|
142
|
+
type: Boolean,
|
|
143
|
+
value: false,
|
|
144
|
+
},
|
|
129
145
|
},
|
|
130
146
|
data: {
|
|
131
147
|
pageNo: 1,
|
|
@@ -186,7 +202,18 @@ Component({
|
|
|
186
202
|
this.onSuccessCb({ records, total, isTriggerEmpty: isRecords })
|
|
187
203
|
);
|
|
188
204
|
},
|
|
189
|
-
|
|
205
|
+
// 更新参数
|
|
206
|
+
getQueryParams: function ({ methodName, params }) {
|
|
207
|
+
if (methodName === 'wedaGetRecordsV2') {
|
|
208
|
+
params.getCount = true;
|
|
209
|
+
params.compatibleWithV1 = true;
|
|
210
|
+
params.pageNumber = params.pageNo;
|
|
211
|
+
if (params.orderBy && ['asc', 'desc'].includes(params.orderType)) {
|
|
212
|
+
params.orderBy = [{ [params.orderBy]: params.orderType }];
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
return params;
|
|
216
|
+
},
|
|
190
217
|
// 列表容器拉取数据
|
|
191
218
|
fetchData: async function (param = {}) {
|
|
192
219
|
const {
|
|
@@ -239,7 +266,7 @@ Component({
|
|
|
239
266
|
? extra?.methodName
|
|
240
267
|
: 'wedaGetRecords';
|
|
241
268
|
eventDataSource = datasource;
|
|
242
|
-
const modelParams = getModelParams(this.properties);
|
|
269
|
+
const modelParams = await getModelParams(this.properties);
|
|
243
270
|
tcbParams = { ...tcbParams, ...modelParams };
|
|
244
271
|
} else {
|
|
245
272
|
dataSourceName = bindConnectMetadata?.datasource?.name;
|
|
@@ -253,6 +280,14 @@ Component({
|
|
|
253
280
|
console.warn(`当前请求缺少必要参数 dataSourceName或methodName`);
|
|
254
281
|
return;
|
|
255
282
|
}
|
|
283
|
+
// select为空时,不触发请求
|
|
284
|
+
if (
|
|
285
|
+
methodName === 'wedaGetRecordsV2' &&
|
|
286
|
+
!Object.keys(tcbParams?.select)?.length
|
|
287
|
+
) {
|
|
288
|
+
console.warn(`当前请求缺少必要参数 select`);
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
256
291
|
this.setData({ _status: 'loading' });
|
|
257
292
|
|
|
258
293
|
// tcb 请求
|
|
@@ -272,7 +307,10 @@ Component({
|
|
|
272
307
|
{
|
|
273
308
|
dataSourceName,
|
|
274
309
|
methodName,
|
|
275
|
-
params:
|
|
310
|
+
params: this.getQueryParams({
|
|
311
|
+
methodName,
|
|
312
|
+
params: tcbParams,
|
|
313
|
+
}),
|
|
276
314
|
swr: { forceClear },
|
|
277
315
|
},
|
|
278
316
|
true
|
|
@@ -325,7 +363,10 @@ Component({
|
|
|
325
363
|
const temp = await app?.cloud?.callDataSource({
|
|
326
364
|
dataSourceName,
|
|
327
365
|
methodName,
|
|
328
|
-
params:
|
|
366
|
+
params: this.getQueryParams({
|
|
367
|
+
methodName,
|
|
368
|
+
params: tcbParams,
|
|
369
|
+
}),
|
|
329
370
|
swr,
|
|
330
371
|
});
|
|
331
372
|
records = records.concat(temp.records || []);
|
|
@@ -572,7 +613,7 @@ Component({
|
|
|
572
613
|
},
|
|
573
614
|
updateWidgetAPI() {
|
|
574
615
|
const { records, listTotal, pageNo, errorObj } = this.data;
|
|
575
|
-
let { pageSize } = this.properties;
|
|
616
|
+
let { pageSize, supportManyRelated } = this.properties;
|
|
576
617
|
this.setReadonlyAttributes &&
|
|
577
618
|
this.setReadonlyAttributes({
|
|
578
619
|
records,
|
|
@@ -582,17 +623,21 @@ Component({
|
|
|
582
623
|
refresh: this.methodRefresh.bind(this),
|
|
583
624
|
deleteOne: this.methodDeleteOne.bind(this),
|
|
584
625
|
error: errorObj,
|
|
626
|
+
dataSourceVersion: supportManyRelated ? 'v2' : 'v1',
|
|
585
627
|
});
|
|
586
628
|
},
|
|
587
629
|
},
|
|
588
630
|
observers: {
|
|
589
|
-
'datasource,bindConnectMetadata,connectorMethod,orderBy,orderType,pageSize,pagination,where,queryCondition,connectorParams,dataSourceType':
|
|
631
|
+
'datasource,bindConnectMetadata,connectorMethod,orderBy,orderType,selectFieldType,selectFields,pageIndex,pageSize,pagination,where,queryCondition,connectorParams,dataSourceType':
|
|
590
632
|
function (...rest) {
|
|
591
633
|
if (isEqual(this.data.paramRef, rest)) return;
|
|
592
634
|
this.data.paramRef = rest;
|
|
593
635
|
this._clearDelay();
|
|
594
636
|
this.data.delayRef.current.initTimer = setTimeout(() => {
|
|
595
|
-
this.fetchData({
|
|
637
|
+
this.fetchData({
|
|
638
|
+
pageNo: this.properties.pageIndex || 1,
|
|
639
|
+
records: [],
|
|
640
|
+
});
|
|
596
641
|
}, 500);
|
|
597
642
|
},
|
|
598
643
|
'dataSourceType,dataSourceData,total,enableTotal': function () {
|
|
@@ -14,6 +14,10 @@ Component({
|
|
|
14
14
|
customLocation: {
|
|
15
15
|
type: null,
|
|
16
16
|
},
|
|
17
|
+
id: {
|
|
18
|
+
Type: String,
|
|
19
|
+
value: '',
|
|
20
|
+
},
|
|
17
21
|
},
|
|
18
22
|
data: {
|
|
19
23
|
_oldLocationValue: null,
|
|
@@ -30,6 +34,9 @@ Component({
|
|
|
30
34
|
const e = { detail: { value: null } };
|
|
31
35
|
this.handleChange(e);
|
|
32
36
|
},
|
|
37
|
+
handleError: function (e) {
|
|
38
|
+
this.triggerEvent('error', e.detail);
|
|
39
|
+
},
|
|
33
40
|
},
|
|
34
41
|
observers: {
|
|
35
42
|
'name, value, label, required, visible, disabled, readOnly, before, after':
|
|
@@ -44,6 +51,7 @@ Component({
|
|
|
44
51
|
lifetimes: {
|
|
45
52
|
attached: function () {
|
|
46
53
|
this.updateWidgetAPI();
|
|
54
|
+
this.setData({ id: this.id });
|
|
47
55
|
},
|
|
48
56
|
},
|
|
49
57
|
});
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
<wd-input-group before="{{before}}" after="{{after}}" block="{{true}}" size="{{_size}}" classRoot="{{classRoot}}">
|
|
25
25
|
<wd-input-wrap block="{{block}}" classRoot="{{classRoot}}" before="{{before}}" after="{{after}}" disabled="{{disabled}}" prefixType="{{prefixType}}" prefixIcon="{{prefixIcon}}" prefixSrc="{{prefixSrc}}" suffixType="{{suffixType}}" suffixIcon="{{suffixIcon}}" suffixSrc="{{suffixSrc}}" hasClearIcon="{{hasClearIcon}}" bind:onClear="handleClear">
|
|
26
26
|
<old-location
|
|
27
|
+
id="{{id}}"
|
|
27
28
|
name="{{name}}"
|
|
28
29
|
labelVisible="{{false}}"
|
|
29
30
|
value="{{value}}"
|
|
@@ -40,6 +41,7 @@
|
|
|
40
41
|
readOnly="{{readOnly}}"
|
|
41
42
|
disabled="{{disabled || readOnly}}"
|
|
42
43
|
bind:change="handleChange"
|
|
44
|
+
bind:error="handleError"
|
|
43
45
|
/>
|
|
44
46
|
</wd-input-wrap>
|
|
45
47
|
</wd-input-group>
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import MarkdownIt from './utils/markdown-it.min.js';
|
|
2
|
+
import highlight from './utils/highlight.min.js';
|
|
3
|
+
import hljsJs from './utils/hljs_javascript.min.js';
|
|
4
|
+
import hljsCss from './utils/hljs_css.min.js';
|
|
5
|
+
Component({
|
|
6
|
+
options: {
|
|
7
|
+
virtualHost: true,
|
|
8
|
+
},
|
|
9
|
+
properties: {
|
|
10
|
+
className: {
|
|
11
|
+
type: String,
|
|
12
|
+
value: '',
|
|
13
|
+
},
|
|
14
|
+
style: {
|
|
15
|
+
type: String,
|
|
16
|
+
value: '',
|
|
17
|
+
},
|
|
18
|
+
id: {
|
|
19
|
+
type: String,
|
|
20
|
+
value: '',
|
|
21
|
+
},
|
|
22
|
+
value: {
|
|
23
|
+
type: String,
|
|
24
|
+
value: '这是一个markdown',
|
|
25
|
+
},
|
|
26
|
+
options: {
|
|
27
|
+
type: Object,
|
|
28
|
+
value: {},
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
data: {
|
|
32
|
+
__html: '',
|
|
33
|
+
mdInstance: null,
|
|
34
|
+
},
|
|
35
|
+
methods: {
|
|
36
|
+
init() {
|
|
37
|
+
const { options } = this.data;
|
|
38
|
+
|
|
39
|
+
const hljs = highlight();
|
|
40
|
+
const javascript = hljsJs();
|
|
41
|
+
const css = hljsCss();
|
|
42
|
+
hljs.registerLanguage('javascript', javascript);
|
|
43
|
+
hljs.registerLanguage('css', css);
|
|
44
|
+
const md = new MarkdownIt({
|
|
45
|
+
// 默认开启高亮
|
|
46
|
+
highlight: function (str, lang) {
|
|
47
|
+
if (lang && hljs.getLanguage(lang)) {
|
|
48
|
+
try {
|
|
49
|
+
return (
|
|
50
|
+
'<pre><code class="hljs">' +
|
|
51
|
+
hljs.highlight(str, { language: lang, ignoreIllegals: true })
|
|
52
|
+
.value +
|
|
53
|
+
'</code></pre>'
|
|
54
|
+
);
|
|
55
|
+
} catch (__) {}
|
|
56
|
+
}
|
|
57
|
+
return '<pre><code class="hljs">' + str + '</code></pre>';
|
|
58
|
+
},
|
|
59
|
+
...options,
|
|
60
|
+
});
|
|
61
|
+
this.setData({ mdInstance: md });
|
|
62
|
+
this.triggerEvent('onReady', { markdownInstance: md });
|
|
63
|
+
this.setData({
|
|
64
|
+
__html: md.render(this.data.value),
|
|
65
|
+
});
|
|
66
|
+
},
|
|
67
|
+
updateWidgetAPI() {
|
|
68
|
+
this.setReadonlyAttributes &&
|
|
69
|
+
this.setReadonlyAttributes({
|
|
70
|
+
value: this.properties.value,
|
|
71
|
+
markdownInstance: this.data.mdInstance,
|
|
72
|
+
updateMarkdownInstance: ({ markdownInstance }) =>
|
|
73
|
+
this.setData({ mdInstance: markdownInstance }),
|
|
74
|
+
});
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
observers: {
|
|
78
|
+
value: function () {
|
|
79
|
+
const { mdInstance } = this.data;
|
|
80
|
+
if (!mdInstance) return;
|
|
81
|
+
console.log(this.data.value);
|
|
82
|
+
this.setData({
|
|
83
|
+
__html: mdInstance.render(this.data.value),
|
|
84
|
+
});
|
|
85
|
+
},
|
|
86
|
+
options: function () {
|
|
87
|
+
this.init();
|
|
88
|
+
},
|
|
89
|
+
'value,mdInstance': function () {
|
|
90
|
+
this.updateWidgetAPI();
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
lifetimes: {
|
|
94
|
+
attached() {
|
|
95
|
+
this.init();
|
|
96
|
+
this.updateWidgetAPI();
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
});
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
@import '../../style/wd-design.wxss';
|
|
2
|
+
|
|
3
|
+
/*light*/
|
|
4
|
+
.wd-markdown {
|
|
5
|
+
padding: 1rem;
|
|
6
|
+
}
|
|
7
|
+
.pre ._code.hljs {
|
|
8
|
+
display: block;
|
|
9
|
+
overflow-x: auto;
|
|
10
|
+
padding: 1em;
|
|
11
|
+
}
|
|
12
|
+
._code.hljs {
|
|
13
|
+
padding: 3px 5px;
|
|
14
|
+
word-break: normal;
|
|
15
|
+
/* white-space: pre; */
|
|
16
|
+
background-color: transparent;
|
|
17
|
+
border: 0;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/*!
|
|
21
|
+
Theme: GitHub
|
|
22
|
+
Description: Light theme as seen on github.com
|
|
23
|
+
Author: github.com
|
|
24
|
+
Maintainer: @Hirse
|
|
25
|
+
Updated: 2021-05-15
|
|
26
|
+
|
|
27
|
+
Outdated base version: https://github.com/primer/github-syntax-light
|
|
28
|
+
Current colors taken from GitHub's CSS
|
|
29
|
+
*/
|
|
30
|
+
.hljs {
|
|
31
|
+
color: #24292e;
|
|
32
|
+
background: #ffffff;
|
|
33
|
+
}
|
|
34
|
+
.hljs-doctag,
|
|
35
|
+
.hljs-keyword,
|
|
36
|
+
.hljs-meta .hljs-keyword,
|
|
37
|
+
.hljs-template-tag,
|
|
38
|
+
.hljs-template-variable,
|
|
39
|
+
.hljs-type,
|
|
40
|
+
.hljs-variable.language_ {
|
|
41
|
+
/* prettylights-syntax-keyword */
|
|
42
|
+
color: #d73a49;
|
|
43
|
+
}
|
|
44
|
+
.hljs-title,
|
|
45
|
+
.hljs-title.class_,
|
|
46
|
+
.hljs-title.class_.inherited__,
|
|
47
|
+
.hljs-title.function_ {
|
|
48
|
+
/* prettylights-syntax-entity */
|
|
49
|
+
color: #6f42c1;
|
|
50
|
+
}
|
|
51
|
+
.hljs-attr,
|
|
52
|
+
.hljs-attribute,
|
|
53
|
+
.hljs-literal,
|
|
54
|
+
.hljs-meta,
|
|
55
|
+
.hljs-number,
|
|
56
|
+
.hljs-operator,
|
|
57
|
+
.hljs-variable,
|
|
58
|
+
.hljs-selector-attr,
|
|
59
|
+
.hljs-selector-class,
|
|
60
|
+
.hljs-selector-id {
|
|
61
|
+
/* prettylights-syntax-constant */
|
|
62
|
+
color: #005cc5;
|
|
63
|
+
}
|
|
64
|
+
.hljs-regexp,
|
|
65
|
+
.hljs-string,
|
|
66
|
+
.hljs-meta .hljs-string {
|
|
67
|
+
/* prettylights-syntax-string */
|
|
68
|
+
color: #032f62;
|
|
69
|
+
}
|
|
70
|
+
.hljs-built_in,
|
|
71
|
+
.hljs-symbol {
|
|
72
|
+
/* prettylights-syntax-variable */
|
|
73
|
+
color: #e36209;
|
|
74
|
+
}
|
|
75
|
+
.hljs-comment,
|
|
76
|
+
.hljs-code,
|
|
77
|
+
.hljs-formula {
|
|
78
|
+
/* prettylights-syntax-comment */
|
|
79
|
+
color: #6a737d;
|
|
80
|
+
}
|
|
81
|
+
.hljs-name,
|
|
82
|
+
.hljs-quote,
|
|
83
|
+
.hljs-selector-tag,
|
|
84
|
+
.hljs-selector-pseudo {
|
|
85
|
+
/* prettylights-syntax-entity-tag */
|
|
86
|
+
color: #22863a;
|
|
87
|
+
}
|
|
88
|
+
.hljs-subst {
|
|
89
|
+
/* prettylights-syntax-storage-modifier-import */
|
|
90
|
+
color: #24292e;
|
|
91
|
+
}
|
|
92
|
+
.hljs-section {
|
|
93
|
+
/* prettylights-syntax-markup-heading */
|
|
94
|
+
color: #005cc5;
|
|
95
|
+
font-weight: bold;
|
|
96
|
+
}
|
|
97
|
+
.hljs-bullet {
|
|
98
|
+
/* prettylights-syntax-markup-list */
|
|
99
|
+
color: #735c0f;
|
|
100
|
+
}
|
|
101
|
+
.hljs-emphasis {
|
|
102
|
+
/* prettylights-syntax-markup-italic */
|
|
103
|
+
color: #24292e;
|
|
104
|
+
font-style: italic;
|
|
105
|
+
}
|
|
106
|
+
.hljs-strong {
|
|
107
|
+
/* prettylights-syntax-markup-bold */
|
|
108
|
+
color: #24292e;
|
|
109
|
+
font-weight: bold;
|
|
110
|
+
}
|
|
111
|
+
.hljs-addition {
|
|
112
|
+
/* prettylights-syntax-markup-inserted */
|
|
113
|
+
color: #22863a;
|
|
114
|
+
background-color: #f0fff4;
|
|
115
|
+
}
|
|
116
|
+
.hljs-deletion {
|
|
117
|
+
/* prettylights-syntax-markup-deleted */
|
|
118
|
+
color: #b31d28;
|
|
119
|
+
background-color: #ffeef0;
|
|
120
|
+
}
|
|
121
|
+
.hljs-char.escape_,
|
|
122
|
+
.hljs-link,
|
|
123
|
+
.hljs-params,
|
|
124
|
+
.hljs-property,
|
|
125
|
+
.hljs-punctuation,
|
|
126
|
+
.hljs-tag {
|
|
127
|
+
/* purposely ignored */
|
|
128
|
+
}
|