@conecli/cone-render 0.10.1-beta.1 → 0.10.1-beta.3

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 +1 @@
1
- import React, { useCallback, useEffect, useRef, useState } from 'react'
2
1
  getQualityImage,
3
2
  isH5AndJdShopView,
4
3
  isJdApp,
5
4
  isChartH5,
6
5
  isH5AndJdShopViewH5Scroll,
7
6
  isAppStowShop,
8
7
  sgmCustomReport,
9
8
  isImageOptimizeEnable,
10
9
  getNativePageScrollRes,
11
10
  latestFromNativeMsgStorage,
12
11
  'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEsAAAAeCAMAAABT0xOcAAAAe1BMVEUAAADx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fELy0NOAAAAKHRSTlMApwmfFtYm9rWveHDm70yJHYJaD2k8IeIr6pY2X0HHfsGRZDHdu1XNmO+CqgAAAu9JREFUSMfNlNmymzAQRAchkCUhdrMZbLze/v8vjIRMKN8kRR7ykFNeVIPV9Ewj039P1TR8+eILjL7RdLFFJUO8QMS7ZmyDJvZ0nDYGY+aKKDSJpY3OwWX6uFUEY/peCNEbY4Rp6AABixFYkLQRAK3VOmAjUrawMt1GrfWtXD7rlFF3uiA6HV/p0TF1tBECEVskYe+7qqW08mqT1jruneu21/72JfHoSZ7faj2bJu6mOlgEa3qjEXKeL/ACV1s5YSbqYP6stXUeX2FZnV3wuBSZqnVWqDNCIvaFRzZIiGAIw+CS/1brQCslgOQdUBoW10C2EFJei7AkygOlAnmGeMprJq/NjhZpAIrepOpOte2Oq9EXjupIMVoiXduQ9rTo7KsODhxJYaAGuJPjgRvdkRD1KP9CawRwettyF5SbVLZ49ZbuMJxGW93XisXPKA/oXNMDEReJT6N0OfZ2V4RqX4tFQPbOQbntwrl8oXCOQmu2hVosSr6j5QcW+uvukZJP37CWzL7tQs2lH8B53Nd6eq192N/72mdfa52XhdXPx6zcXKYgikLXbaNP66M27edoAO2X+RkQ9tVRhoWC6IZkCZAbHHa1SgDHNdHDsbrLr0ojKTkfDWp6+WPh1APakMAXbVrb6B/Mn+311zlETJZOCJYChttWxedUIyvyi9bLt+J4IPcLvVYypBNaDG5TguCzmct3rUkAPSdHJRLyDEjXQ6Un3GZQBamxaU09gJg+/r+4gqV0uzixXjBfLnDzixrjhDJGNoDXXqvK76OEJaO3L1bx/FQOCSxqcfJVUWiXCydEPowHeIqaZnf3wmvNRsBiC28ttEnS+1oy+lNtOMVAzayZCwsQ5ESNREgvKKuNjjI/ewNHr9Y4N5Is98llx2U8iOQXcKczhDwAM6ObayaanfWDDwhJcMvpU8ucr6+cPji5a8+UEVMCMNo97tLm0MU2uoMmi850yrc8s8Khyzuj7+Q6U7GPMCt8mOtGljP6l/wAUcBZ6lceL/8AAAAASUVORK5CYII='
13
12
  'https://img14.360buyimg.com/imagetools/jfs/t1/222907/25/7012/5824/61c4797cEbcd17c7f/6c76fc71e4fdb5a5.png'
14
13
  const {
15
14
  src,
16
15
  lazyLoad,
17
16
  imagRenderingSet,
18
17
  width,
19
18
  height,
20
19
  className,
21
20
  isSkuImage,
22
21
  hideErrorImage,
23
22
  style,
24
23
  backgroundColor,
25
24
  errorSrc,
26
25
  onLoad,
27
26
  onError,
28
27
  ...otherOption
29
28
  } = props
30
29
  getNetWorkType === NetWorkTypeQuality.default &&
31
30
  (getNetWorkType = taroJdBaseInfo.info.sysInfo.netWorkType)
32
31
  const [loadSuccess, setLoadSuccess] = useState(false)
33
32
  const [imageErrState, setImageErrState] = useState(false)
34
33
  const [componentShowState, setComponentShowState] = useState(false)
35
34
  const measureRef = useRef<HTMLElement | null>(null)
36
35
  const [measureComplete, setMeasureComplete] = useState(false)
37
36
  const [imgSrc, setImgSrc] = useState(src)
38
37
  const componentLazyRef = useRef<HTMLElement | null>(null)
39
38
  const componentShowStateRef = useRef(false)
40
39
  const requestSrcRef = useRef(src)
41
40
  const needShowHighVersion =
42
41
  isH5AndJdShopViewH5Scroll &&
43
42
  !(
44
43
  global.info.queryInfo?.downgraded &&
45
44
  global.info.queryInfo.downgraded === 'true'
46
45
  )
47
46
  const enableAvifOptimize = isImageOptimizeEnable()
48
47
 
49
48
  const getRequestSrc = useCallback(
50
49
  src => {
51
50
  const requestSrc = getQualityImage(imgSrc, {
52
51
  isSkuImage,
53
52
  size: measureRef?.current?.offsetWidth,
54
53
  })
55
54
  requestSrcRef.current = requestSrc
56
55
  return requestSrc
57
56
  },
58
57
  [src],
59
58
  )
60
59
  const imageError = useCallback(
61
60
  e => {
62
61
  console.log(' ==============> 图片加载错误', e)
63
62
  errorSrc && setImgSrc(errorSrc)
64
63
  hideErrorImage && setImageErrState(true)
65
64
  typeof onError === 'function' && onError(e, src, props)
66
65
  const { shopId, venderId } = global.info.queryInfo || {}
67
66
  sgmCustomReport({
68
67
  code: 'jshopViewImageLoadError',
69
68
  msg: {
70
69
  shopId,
71
70
  venderId,
72
71
  buildType,
73
72
  originSrc: src,
74
73
  requestSrc: requestSrcRef.current,
75
74
  },
76
75
  })
77
76
  },
78
77
  [src],
79
78
  )
80
79
 
81
80
  const imageLoad = useCallback(
82
81
  (_src, event) => {
83
82
  setLoadSuccess(true)
84
83
  typeof onLoad === 'function' && onLoad(event, src, props)
85
84
  },
86
85
  [src],
87
86
  )
88
87
 
89
88
  const changeStyleIncludeWidthAndHeightAndBgColor = () => {
90
89
  const changeStyle = {}
91
90
  width && (changeStyle['width'] = width)
92
91
  height && (changeStyle['height'] = height)
93
92
  backgroundColor && (changeStyle['backgroundColor'] = backgroundColor)
94
93
  return changeStyle
95
94
  }
96
95
  useEffect(() => {
97
96
  setMeasureComplete(true)
98
97
  if (needShowHighVersion) return
99
98
  const latestRes =
100
99
  latestFromNativeMsgStorage[TaroEventType.PAGE_SCROLL] || {}
101
100
  !componentShowStateRef.current && dealPageScrollInfo(latestRes)
102
101
  Taro.eventCenter.on(TaroEventType.PAGE_SCROLL, res => {
103
102
  !componentShowStateRef.current && dealPageScrollInfo(res)
104
103
  })
105
104
  }, [])
106
105
 
107
106
  const dealPageScrollInfo = res => {
108
107
  const { displayHeight, offSetY } = getNativePageScrollRes(res) || {}
109
108
  if (typeof displayHeight === 'undefined' || typeof offSetY === 'undefined')
110
109
  return
111
110
  if (measureRef.current) {
112
111
  const eleClientRect = measureRef.current.getBoundingClientRect()
113
112
  const getContainerHeightOffSetY = displayHeight * 1.5 + offSetY
114
113
  const eleOffsetTop = Math.ceil(eleClientRect.top)
115
114
  const eleOffsetHeight = Math.ceil(eleClientRect.height)
116
115
  if (!componentShowStateRef.current) {
117
116
  if (getContainerHeightOffSetY > eleOffsetTop) {
118
117
  componentShowStateRef.current = true
119
118
  setComponentShowState(true)
120
119
  }
121
120
  }
122
121
  }
123
122
  }
124
123
  return isH5AndJdShopView &&
125
124
  global?.config?.needImageLazy !== false &&
126
125
  !needShowHighVersion &&
127
126
  !isAppStowShop ? (
128
127
  <View
129
128
  ref={measureRef}
130
129
  className={classNames(
131
130
  imageStyle['d-app-lazy-image'],
132
131
  {
133
132
  [imageStyle['d-lazy-sku-image']]: isSkuImage,
134
133
  },
135
134
  {
136
135
  [imageStyle['d-hide-image-error']]: imageErrState,
137
136
  },
138
137
  {
139
138
  [imageStyle['d-load-completed']]: loadSuccess,
140
139
  },
141
140
  {
142
141
  'd-imag-rendering-crisp-edges':
143
142
  !taroJdBaseInfo.info.pageInfo.isVipShop && imagRenderingSet,
144
143
  },
145
144
  'J_html5ImageBg',
146
145
  className,
147
146
  )}
148
147
  style={{
149
148
  ...style,
150
149
  ...changeStyleIncludeWidthAndHeightAndBgColor(),
151
150
  }}
152
151
  {...otherOption}
153
152
  >
154
153
  {(componentShowState || lazyLoad === false) && (
155
154
  <img
156
155
  src={getQualityImage(
157
156
  imgSrc,
158
157
  taroJdBaseInfo.info.pageInfo.isVipShop
159
158
  ? NetWorkTypeQuality['perfect']
160
159
  : NetWorkTypeQuality[getNetWorkType],
161
160
  )}
162
161
  onLoad={imageLoad.bind(this, imgSrc)}
163
162
  onError={imageError}
164
163
  />
165
164
  )}
166
165
  </View>
167
166
  ) : enableAvifOptimize ? (
168
167
  [
169
168
  measureComplete ? (
170
169
  <Image
171
170
  key={'realImage'}
172
171
  style={{
173
172
  ...style,
174
173
  ...changeStyleIncludeWidthAndHeightAndBgColor(),
175
174
  }}
176
175
  className={classNames(
177
176
  imageStyle['d-lazy-image'],
178
177
  {
179
178
  [imageStyle['d-lazy-sku-image']]: isSkuImage,
180
179
  },
181
180
  {
182
181
  [imageStyle['d-hide-image-error']]: imageErrState,
183
182
  },
184
183
  {
185
184
  [imageStyle['d-load-completed']]: loadSuccess,
186
185
  },
187
186
  {
188
187
  'd-imag-rendering-crisp-edges': imagRenderingSet,
189
188
  },
190
189
  className,
191
190
  )}
192
191
  src={getRequestSrc(imgSrc)}
193
192
  lazyLoad={isChartH5 ? false : lazyLoad}
194
193
  onError={imageError}
195
194
  onLoad={imageLoad.bind(this, imgSrc)}
196
195
  {...otherOption}
197
196
  />
198
197
  ) : (
199
198
  <Image
200
199
  key={'defaultImage'}
201
200
  style={{
202
201
  ...style,
203
202
  ...changeStyleIncludeWidthAndHeightAndBgColor(),
204
203
  }}
205
204
  className={classNames(
206
205
  imageStyle['d-lazy-image'],
207
206
  {
208
207
  [imageStyle['d-lazy-sku-image']]: isSkuImage,
209
208
  },
210
209
  {
211
210
  [imageStyle['d-hide-image-error']]: imageErrState,
212
211
  },
213
212
  {
214
213
  [imageStyle['d-load-completed']]: loadSuccess,
215
214
  },
216
215
  {
217
216
  'd-imag-rendering-crisp-edges': imagRenderingSet,
218
217
  },
219
218
  className,
220
219
  )}
221
220
  src={isSkuImage ? DEFAULT_SKU_SRC : DEFAULT_SRC}
222
221
  />
223
222
  ),
224
223
  loadSuccess ? null : <View key={'measureRef'} ref={measureRef}></View>,
225
224
  ]
226
225
  ) : (
227
226
  <Image
228
227
  style={{
229
228
  ...style,
230
229
  ...changeStyleIncludeWidthAndHeightAndBgColor(),
231
230
  }}
232
231
  className={classNames(
233
232
  imageStyle['d-lazy-image'],
234
233
  {
235
234
  [imageStyle['d-lazy-sku-image']]: isSkuImage,
236
235
  },
237
236
  {
238
237
  [imageStyle['d-hide-image-error']]: imageErrState,
239
238
  },
240
239
  {
241
240
  [imageStyle['d-load-completed']]: loadSuccess,
242
241
  },
243
242
  {
244
243
  'd-imag-rendering-crisp-edges': imagRenderingSet,
245
244
  },
246
245
  className,
247
246
  )}
248
247
  src={getQualityImage(imgSrc, NetWorkTypeQuality[getNetWorkType])}
249
248
  lazyLoad={isChartH5 ? false : lazyLoad}
250
249
  onError={imageError}
251
250
  onLoad={imageLoad.bind(this, imgSrc)}
252
251
  {...otherOption}
253
252
  />
254
253
  )
255
254
  lazyLoad: true,
256
255
  isSkuImage: false,
257
256
  hideErrorImage: false,
258
257
  imagRenderingSet: true,
259
258
  src: null,
260
259
  style: null,
261
260
  width: null,
262
261
  height: null,
263
262
  backgroundColor: null,
264
263
  className: null,
265
264
  errorSrc: null,
266
265
  onLoad: null,
267
266
  onError: null,
267
+ import React, { useCallback, useEffect, useRef, useState } from 'react'
268
268
  getQualityImage,
269
269
  isH5AndJdShopView,
270
270
  isJdApp,
271
271
  isChartH5,
272
272
  isH5AndJdShopViewH5Scroll,
273
273
  isAppStowShop,
274
274
  sgmCustomReport,
275
275
  isImageOptimizeEnable,
276
276
  getNativePageScrollRes,
277
277
  latestFromNativeMsgStorage,
278
278
  'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEsAAAAeCAMAAABT0xOcAAAAe1BMVEUAAADx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fELy0NOAAAAKHRSTlMApwmfFtYm9rWveHDm70yJHYJaD2k8IeIr6pY2X0HHfsGRZDHdu1XNmO+CqgAAAu9JREFUSMfNlNmymzAQRAchkCUhdrMZbLze/v8vjIRMKN8kRR7ykFNeVIPV9Ewj039P1TR8+eILjL7RdLFFJUO8QMS7ZmyDJvZ0nDYGY+aKKDSJpY3OwWX6uFUEY/peCNEbY4Rp6AABixFYkLQRAK3VOmAjUrawMt1GrfWtXD7rlFF3uiA6HV/p0TF1tBECEVskYe+7qqW08mqT1jruneu21/72JfHoSZ7faj2bJu6mOlgEa3qjEXKeL/ACV1s5YSbqYP6stXUeX2FZnV3wuBSZqnVWqDNCIvaFRzZIiGAIw+CS/1brQCslgOQdUBoW10C2EFJei7AkygOlAnmGeMprJq/NjhZpAIrepOpOte2Oq9EXjupIMVoiXduQ9rTo7KsODhxJYaAGuJPjgRvdkRD1KP9CawRwettyF5SbVLZ49ZbuMJxGW93XisXPKA/oXNMDEReJT6N0OfZ2V4RqX4tFQPbOQbntwrl8oXCOQmu2hVosSr6j5QcW+uvukZJP37CWzL7tQs2lH8B53Nd6eq192N/72mdfa52XhdXPx6zcXKYgikLXbaNP66M27edoAO2X+RkQ9tVRhoWC6IZkCZAbHHa1SgDHNdHDsbrLr0ojKTkfDWp6+WPh1APakMAXbVrb6B/Mn+311zlETJZOCJYChttWxedUIyvyi9bLt+J4IPcLvVYypBNaDG5TguCzmct3rUkAPSdHJRLyDEjXQ6Un3GZQBamxaU09gJg+/r+4gqV0uzixXjBfLnDzixrjhDJGNoDXXqvK76OEJaO3L1bx/FQOCSxqcfJVUWiXCydEPowHeIqaZnf3wmvNRsBiC28ttEnS+1oy+lNtOMVAzayZCwsQ5ESNREgvKKuNjjI/ewNHr9Y4N5Is98llx2U8iOQXcKczhDwAM6ObayaanfWDDwhJcMvpU8ucr6+cPji5a8+UEVMCMNo97tLm0MU2uoMmi850yrc8s8Khyzuj7+Q6U7GPMCt8mOtGljP6l/wAUcBZ6lceL/8AAAAASUVORK5CYII='
279
279
  'https://img14.360buyimg.com/imagetools/jfs/t1/222907/25/7012/5824/61c4797cEbcd17c7f/6c76fc71e4fdb5a5.png'
280
280
  const {
281
281
  src = null,
282
282
  lazyLoad = true,
283
283
  imagRenderingSet = true,
284
284
  width = null,
285
285
  height = null,
286
286
  className = null,
287
287
  isSkuImage = false,
288
288
  hideErrorImage = false,
289
289
  style = null,
290
290
  backgroundColor = null,
291
291
  errorSrc = null,
292
292
  onLoad = null,
293
293
  onError = null,
294
294
  ...otherOption
295
295
  } = props
296
296
  getNetWorkType === NetWorkTypeQuality.default &&
297
297
  (getNetWorkType = taroJdBaseInfo.info.sysInfo.netWorkType)
298
298
  const [loadSuccess, setLoadSuccess] = useState(false)
299
299
  const [imageErrState, setImageErrState] = useState(false)
300
300
  const [componentShowState, setComponentShowState] = useState(false)
301
301
  const measureRef = useRef<HTMLElement | null>(null)
302
302
  const [measureComplete, setMeasureComplete] = useState(false)
303
303
  const [imgSrc, setImgSrc] = useState(src)
304
304
  const componentLazyRef = useRef<HTMLElement | null>(null)
305
305
  const componentShowStateRef = useRef(false)
306
306
  const requestSrcRef = useRef(src)
307
307
  const needShowHighVersion =
308
308
  isH5AndJdShopViewH5Scroll &&
309
309
  !(
310
310
  global.info.queryInfo?.downgraded &&
311
311
  global.info.queryInfo.downgraded === 'true'
312
312
  )
313
313
  const enableAvifOptimize = isImageOptimizeEnable()
314
314
 
315
315
  const getRequestSrc = useCallback(
316
316
  (src) => {
317
317
  const requestSrc = getQualityImage(imgSrc, {
318
318
  isSkuImage,
319
319
  size: measureRef?.current?.offsetWidth,
320
320
  })
321
321
  requestSrcRef.current = requestSrc
322
322
  return requestSrc
323
323
  },
324
324
  [src],
325
325
  )
326
326
  const imageError = useCallback(
327
327
  (e) => {
328
328
  console.log(' ==============> 图片加载错误', e)
329
329
  errorSrc && setImgSrc(errorSrc)
330
330
  hideErrorImage && setImageErrState(true)
331
331
  typeof onError === 'function' && onError(e, src, props)
332
332
  const { shopId, venderId } = global.info.queryInfo || {}
333
333
  sgmCustomReport({
334
334
  code: 'jshopViewImageLoadError',
335
335
  msg: {
336
336
  shopId,
337
337
  venderId,
338
338
  buildType,
339
339
  originSrc: src,
340
340
  requestSrc: requestSrcRef.current,
341
341
  },
342
342
  })
343
343
  },
344
344
  [src],
345
345
  )
346
346
 
347
347
  const imageLoad = useCallback(
348
348
  (_src, event) => {
349
349
  setLoadSuccess(true)
350
350
  typeof onLoad === 'function' && onLoad(event, src, props)
351
351
  },
352
352
  [src],
353
353
  )
354
354
 
355
355
  const changeStyleIncludeWidthAndHeightAndBgColor = () => {
356
356
  const changeStyle = {}
357
357
  width && (changeStyle['width'] = width)
358
358
  height && (changeStyle['height'] = height)
359
359
  backgroundColor && (changeStyle['backgroundColor'] = backgroundColor)
360
360
  return changeStyle
361
361
  }
362
362
  useEffect(() => {
363
363
  setMeasureComplete(true)
364
364
  if (needShowHighVersion) return
365
365
  const latestRes =
366
366
  latestFromNativeMsgStorage[TaroEventType.PAGE_SCROLL] || {}
367
367
  !componentShowStateRef.current && dealPageScrollInfo(latestRes)
368
368
  Taro.eventCenter.on(TaroEventType.PAGE_SCROLL, (res) => {
369
369
  !componentShowStateRef.current && dealPageScrollInfo(res)
370
370
  })
371
371
  }, [])
372
372
 
373
373
  const dealPageScrollInfo = (res) => {
374
374
  const { displayHeight, offSetY } = getNativePageScrollRes(res) || {}
375
375
  if (typeof displayHeight === 'undefined' || typeof offSetY === 'undefined')
376
376
  return
377
377
  if (measureRef.current) {
378
378
  const eleClientRect = measureRef.current.getBoundingClientRect()
379
379
  const getContainerHeightOffSetY = displayHeight * 1.5 + offSetY
380
380
  const eleOffsetTop = Math.ceil(eleClientRect.top)
381
381
  const eleOffsetHeight = Math.ceil(eleClientRect.height)
382
382
  if (!componentShowStateRef.current) {
383
383
  if (getContainerHeightOffSetY > eleOffsetTop) {
384
384
  componentShowStateRef.current = true
385
385
  setComponentShowState(true)
386
386
  }
387
387
  }
388
388
  }
389
389
  }
390
390
  return isH5AndJdShopView &&
391
391
  global?.config?.needImageLazy !== false &&
392
392
  !needShowHighVersion &&
393
393
  !isAppStowShop ? (
394
394
  <View
395
395
  ref={measureRef}
396
396
  className={classNames(
397
397
  imageStyle['d-app-lazy-image'],
398
398
  {
399
399
  [imageStyle['d-lazy-sku-image']]: isSkuImage,
400
400
  },
401
401
  {
402
402
  [imageStyle['d-hide-image-error']]: imageErrState,
403
403
  },
404
404
  {
405
405
  [imageStyle['d-load-completed']]: loadSuccess,
406
406
  },
407
407
  {
408
408
  'd-imag-rendering-crisp-edges':
409
409
  !taroJdBaseInfo.info.pageInfo.isVipShop && imagRenderingSet,
410
410
  },
411
411
  'J_html5ImageBg',
412
412
  className,
413
413
  )}
414
414
  style={{
415
415
  ...style,
416
416
  ...changeStyleIncludeWidthAndHeightAndBgColor(),
417
417
  }}
418
418
  {...otherOption}
419
419
  >
420
420
  {(componentShowState || lazyLoad === false) && (
421
421
  <img
422
422
  src={getQualityImage(
423
423
  imgSrc,
424
424
  taroJdBaseInfo.info.pageInfo.isVipShop
425
425
  ? NetWorkTypeQuality['perfect']
426
426
  : NetWorkTypeQuality[getNetWorkType],
427
427
  )}
428
428
  onLoad={imageLoad.bind(this, imgSrc)}
429
429
  onError={imageError}
430
430
  />
431
431
  )}
432
432
  </View>
433
433
  ) : enableAvifOptimize ? (
434
434
  [
435
435
  measureComplete ? (
436
436
  <Image
437
437
  key={'realImage'}
438
438
  style={{
439
439
  ...style,
440
440
  ...changeStyleIncludeWidthAndHeightAndBgColor(),
441
441
  }}
442
442
  className={classNames(
443
443
  imageStyle['d-lazy-image'],
444
444
  {
445
445
  [imageStyle['d-lazy-sku-image']]: isSkuImage,
446
446
  },
447
447
  {
448
448
  [imageStyle['d-hide-image-error']]: imageErrState,
449
449
  },
450
450
  {
451
451
  [imageStyle['d-load-completed']]: loadSuccess,
452
452
  },
453
453
  {
454
454
  'd-imag-rendering-crisp-edges': imagRenderingSet,
455
455
  },
456
456
  className,
457
457
  )}
458
458
  src={getRequestSrc(imgSrc)}
459
459
  lazyLoad={isChartH5 ? false : lazyLoad}
460
460
  onError={imageError}
461
461
  onLoad={imageLoad.bind(this, imgSrc)}
462
462
  {...otherOption}
463
463
  />
464
464
  ) : (
465
465
  <Image
466
466
  key={'defaultImage'}
467
467
  style={{
468
468
  ...style,
469
469
  ...changeStyleIncludeWidthAndHeightAndBgColor(),
470
470
  }}
471
471
  className={classNames(
472
472
  imageStyle['d-lazy-image'],
473
473
  {
474
474
  [imageStyle['d-lazy-sku-image']]: isSkuImage,
475
475
  },
476
476
  {
477
477
  [imageStyle['d-hide-image-error']]: imageErrState,
478
478
  },
479
479
  {
480
480
  [imageStyle['d-load-completed']]: loadSuccess,
481
481
  },
482
482
  {
483
483
  'd-imag-rendering-crisp-edges': imagRenderingSet,
484
484
  },
485
485
  className,
486
486
  )}
487
487
  src={isSkuImage ? DEFAULT_SKU_SRC : DEFAULT_SRC}
488
488
  />
489
489
  ),
490
490
  loadSuccess ? null : <View key={'measureRef'} ref={measureRef}></View>,
491
491
  ]
492
492
  ) : (
493
493
  <Image
494
494
  style={{
495
495
  ...style,
496
496
  ...changeStyleIncludeWidthAndHeightAndBgColor(),
497
497
  }}
498
498
  className={classNames(
499
499
  imageStyle['d-lazy-image'],
500
500
  {
501
501
  [imageStyle['d-lazy-sku-image']]: isSkuImage,
502
502
  },
503
503
  {
504
504
  [imageStyle['d-hide-image-error']]: imageErrState,
505
505
  },
506
506
  {
507
507
  [imageStyle['d-load-completed']]: loadSuccess,
508
508
  },
509
509
  {
510
510
  'd-imag-rendering-crisp-edges': imagRenderingSet,
511
511
  },
512
512
  className,
513
513
  )}
514
514
  src={getQualityImage(imgSrc, NetWorkTypeQuality[getNetWorkType])}
515
515
  lazyLoad={isChartH5 ? false : lazyLoad}
516
516
  onError={imageError}
517
517
  onLoad={imageLoad.bind(this, imgSrc)}
518
518
  {...otherOption}
519
519
  />
520
520
  )
@@ -1 +1 @@
1
- import React, {useCallback, useState} from 'react'
1
+ import React, { useCallback, useState } from 'react'
2
2
  const {
3
3
  src = null,
4
4
  lazyLoad = true,
5
5
  imagRenderingSet = true,
6
6
  width = null,
7
7
  height = null,
8
8
  className = null,
9
9
  isSkuImage = false,
10
10
  hideErrorImage = false,
11
11
  style = null,
12
12
  backgroundColor = null,
13
13
  errorSrc = null,
14
14
  onLoad = null,
15
15
  onError = null,
16
16
  ...otherOption
17
17
  } = props
18
18
  getNetWorkType === NetWorkTypeQuality.default &&
19
19
  (getNetWorkType = taroJdBaseInfo.info.sysInfo.netWorkType)
20
20
  const [loadSuccess, setLoadSuccess] = useState(false)
21
21
  const [imgSrc, setImgSrc] = useState(src)
22
22
  const [imageErrState, setImageErrState] = useState(false)
23
23
  const imageError = useCallback(
24
24
  (e) => {
25
25
  console.log('图片加载错误', e)
26
26
  errorSrc && setImgSrc(errorSrc)
27
27
  hideErrorImage && setImageErrState(true)
28
28
  typeof onError === 'function' && onError(e, src, props)
29
29
  },
30
30
  [src],
31
31
  )
32
32
 
33
33
  const imageLoad = useCallback(
34
34
  (event) => {
35
35
  setLoadSuccess(true)
36
36
  typeof onLoad === 'function' && onLoad(event, src, props)
37
37
  },
38
38
  [src],
39
39
  )
40
40
 
41
41
  const changeStyleIncludeWidthAndHeightAndBgColor = () => {
42
42
  const changeStyle = {}
43
43
  width && (changeStyle['width'] = width)
44
44
  height && (changeStyle['height'] = height)
45
45
  backgroundColor && (changeStyle['backgroundColor'] = backgroundColor)
46
46
  return changeStyle
47
47
  }
48
48
  return (
49
49
  <Image
50
50
  style={{
51
51
  ...style,
52
52
  ...changeStyleIncludeWidthAndHeightAndBgColor(),
53
53
  }}
54
54
  className={classNames(
55
55
  imageStyle['d-lazy-image'],
56
56
  {
57
57
  [imageStyle['d-lazy-sku-image']]: isSkuImage,
58
58
  },
59
59
  {
60
60
  [imageStyle['d-hide-image-error']]: imageErrState,
61
61
  },
62
62
  {
63
63
  [imageStyle['d-load-completed']]: loadSuccess,
64
64
  },
65
65
  {
66
66
  'd-imag-rendering-crisp-edges': imagRenderingSet,
67
67
  },
68
68
  className,
69
69
  )}
70
70
  src={getQualityImage(imgSrc, NetWorkTypeQuality[getNetWorkType])}
71
71
  lazyLoad={lazyLoad}
72
72
  onError={imageError}
73
73
  onLoad={imageLoad}
74
74
  {...otherOption}
75
75
  />
76
76
  )
@@ -1 +1 @@
1
- import { View, Text } from '@tarojs/components'
1
+ import { View, Text } from '@tarojs/components'
2
2
  const { placeHolderPreContainerId = '-1', containerId } = props
3
3
  return (
4
4
  <View
5
5
  className={classNames(placeHolderStyle['d-place-holder'], {
6
6
  [placeHolderStyle['d-place-holder-active']]:
7
7
  placeHolderPreContainerId === containerId ||
8
8
  placeHolderPreContainerId === EMPTY_LIST_PREFLOOR_ID,
9
9
  })}
10
10
  >
11
11
  <View
12
12
  className={classNames(
13
13
  placeHolderStyle['d-place-holder-border'],
14
14
  'flexible-center-box',
15
15
  )}
16
16
  >
17
17
  <Text className={placeHolderStyle['d-place-holder-text']}>
18
18
  松开鼠标模块会放到这里
19
19
  </Text>
20
20
  </View>
21
21
  </View>
22
22
  )
@@ -1 +1 @@
1
- import React from 'react'
2
1
  return FloorContentItem ? (
3
2
  <FloorContentItem {...props} dataDefines={dataDefines} />
4
3
  ) : isDevMode ? (
5
4
  renderDecorateDefaultModule()
6
5
  ) : null
6
+ import React from 'react'
7
7
  const {
8
8
  floorData,
9
9
  renderSourceType = BUSINESS_TYPE.ONLINE,
10
10
  builtInComponents = {},
11
11
  updateContainerFloorListDataFn,
12
12
  } = props
13
13
  const isDevMode = renderSourceType === BUSINESS_TYPE.DECORATE
14
14
  const floorModuleType = floorData?.floorExtInfo?.moduleFlag
15
15
  const FloorContentItem =
16
16
  (floorModuleType && builtInComponents[floorModuleType]) || null
17
17
  const dataDefines = getFloorDataToDataDefines(floorData)
18
18
 
19
19
  const renderDecorateDefaultModule = () => {
20
20
  return (
21
21
  <View
22
22
  style={{
23
23
  lineHeight: '120px',
24
24
  textAlign: 'center',
25
25
  }}
26
26
  >
27
27
  当前模块是{floorData.moduleName}
28
28
  </View>
29
29
  )
30
30
  }
31
31
  return FloorContentItem ? (
32
32
  <FloorContentItem {...props} dataDefines={dataDefines} />
33
33
  ) : isDevMode ? (
34
34
  renderDecorateDefaultModule()
35
35
  ) : null
36
36
  switch (moduleId) {
37
37
  case 83158:
38
38
  return 'freeLayout'
39
39
  case 99654:
40
40
  return 'activeText'
41
41
  case 100382:
42
42
  return 'superGoods'
43
43
  }
44
44
  floorList.map((item) => {
45
45
  if (!item.floorExtInfo) {
46
46
  return null
47
47
  }
48
48
  const moduleFlag = item.floorExtInfo.moduleFlag
49
49
  if (!moduleFlag) {
50
50
  const newModuleFlag = moduleId2ModuleFlag(item.moduleId)
51
51
  if (newModuleFlag) {
52
52
  item.floorExtInfo.moduleFlag = newModuleFlag
53
53
  }
54
54
  }
55
55
  })