@conecli/cone-render 0.10.1-shop-beta.35 → 0.10.1-shop-beta.36

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, { useEffect, useMemo, useState } from 'react';
2
1
  const getThisLeGaoTagKey = `${tagId}-${tagText}}`;
3
2
  const getLeGaoTagCacheNode = shopLeGaoTagNodeMap.get(getThisLeGaoTagKey) || false;
4
3
  return getLeGaoTagCacheNode
5
4
  ? getLeGaoTagCacheNode
6
5
  : useMemo(() => {
7
6
  const createCanVasTag = (
8
7
  <canvas-tag
9
8
  className={classNames(shopTagStyle['d-tag-item-canvas'])}
10
9
  tagId={tagId}
11
10
  text={tagText}
12
11
  appVersion={getJdAppVersionStr}
13
12
  lang={languageNowType}
14
13
  />
15
14
  );
16
15
  shopLeGaoTagNodeMap.set(getThisLeGaoTagKey, createCanVasTag);
17
16
  return createCanVasTag;
18
17
  }, [tagId, tagText]);
19
18
  const {
20
19
  tagInfoList = [],
21
20
  className,
22
21
  itemClassName,
23
22
  isSkuBaseTag = false,
24
23
  itemClickCallback,
25
24
  } = props;
26
25
  const getTagInfoList = Array.isArray(tagInfoList) ? tagInfoList : [];
27
26
  const getTagInfoListNum = getTagInfoList.length;
28
27
  const isCallBackFn = typeof itemClickCallback === 'function';
29
28
  const needAsyncLoad = useMemo(() => {
30
29
  if (window.CanvasTag) return false;
31
30
  const h5TagJs = taroJdBaseInfo.loadJsSdkList.find((e) => e.fileName === 'h5TagJs');
32
31
  return !!(h5TagJs && h5TagJs.initTriggerType === LoadJsInitTriggerType.NRXT_TICK);
33
32
  }, []);
34
33
  const [loadOver, setLoadOver] = useState(!needAsyncLoad);
35
34
  useEffect(() => {
36
35
  async function loadTagSdk() {
37
36
  try {
38
37
  await taroJdBaseInfo.loadH5tagReayPromise();
39
38
  } catch (error) {}
40
39
  setLoadOver(true);
41
40
  }
42
41
  needAsyncLoad && loadTagSdk();
43
42
  }, []);
44
43
  if (!loadOver) return null;
45
44
  return getTagInfoListNum > 0 ? (
46
45
  <View
47
46
  className={classNames(
48
47
  shopTagStyle['d-shop-tag-list'],
49
48
  {
50
49
  [shopTagStyle['d-shop-sku-tag-list']]: isSkuBaseTag,
51
50
  },
52
51
  className,
53
52
  )}
54
53
  >
55
54
  {}
56
55
  <View style={{ width: '1px', height: '100%' }} />
57
56
  {getTagInfoList.map((item, index) => {
58
57
  const { tagId, tabIconId, tagText, type, tabIconType, tabText } = item;
59
58
  const getTagId = tagId || tabIconId;
60
59
  const getTagType = type || tabIconType;
61
60
  const getTagText = tagText || tabText;
62
61
  return getTagId ? (
63
62
  <View
64
63
  role="text"
65
64
  tabindex="0"
66
65
  aria-label={getTagText}
67
66
  key={getTagId + getTagType + index}
68
67
  className={classNames(shopTagStyle['d-tag-item'], itemClassName)}
69
68
  onClick={isCallBackFn && itemClickCallback.bind(this, item, index)}
70
69
  >
71
70
  <LeGaoTagComponent tagId={getTagId} tagText={getTagText} />
72
71
  </View>
73
72
  ) : null;
74
73
  })}
75
74
  </View>
76
75
  ) : null;
76
+ import React, { useEffect, useMemo, useState } from 'react';
77
77
  const getThisLeGaoTagKey = `${tagId}-${tagText}}`;
78
78
  const getLeGaoTagCacheNode = shopLeGaoTagNodeMap.get(getThisLeGaoTagKey) || false;
79
79
  return getLeGaoTagCacheNode
80
80
  ? getLeGaoTagCacheNode
81
81
  : useMemo(() => {
82
82
  const createCanVasTag = (
83
83
  <canvas-tag
84
84
  className={classNames(shopTagStyle['d-tag-item-canvas'])}
85
85
  tagId={tagId}
86
86
  text={tagText}
87
87
  appVersion={getJdAppVersionStr}
88
88
  lang={languageNowType}
89
89
  />
90
90
  );
91
91
  shopLeGaoTagNodeMap.set(getThisLeGaoTagKey, createCanVasTag);
92
92
  return createCanVasTag;
93
93
  }, [tagId, tagText]);
94
94
  const {
95
95
  tagInfoList = [],
96
96
  className,
97
97
  itemClassName,
98
98
  isSkuBaseTag = false,
99
99
  itemClickCallback,
100
100
  } = props;
101
101
  const getTagInfoList = Array.isArray(tagInfoList) ? tagInfoList : [];
102
102
  const getTagInfoListNum = getTagInfoList.length;
103
103
  const isCallBackFn = typeof itemClickCallback === 'function';
104
104
  const needAsyncLoad = useMemo(() => {
105
105
  if (window.CanvasTag) return false;
106
106
  const h5TagJs = taroJdBaseInfo.loadJsSdkList.find((e) => e.fileName === 'h5TagJs');
107
107
  return !!(h5TagJs && h5TagJs.initTriggerType === LoadJsInitTriggerType.NRXT_TICK);
108
108
  }, []);
109
109
  const [loadOver, setLoadOver] = useState(!needAsyncLoad);
110
110
  useEffect(() => {
111
111
  async function loadTagSdk() {
112
112
  try {
113
113
  await taroJdBaseInfo.loadH5tagReayPromise();
114
114
  } catch (error) {}
115
115
  setLoadOver(true);
116
116
  }
117
117
  needAsyncLoad && loadTagSdk();
118
118
  }, []);
119
119
  if (!loadOver) return null;
120
120
  return getTagInfoListNum > 0 ? (
121
121
  <View
122
122
  className={classNames(
123
123
  shopTagStyle['d-shop-tag-list'],
124
124
  {
125
125
  [shopTagStyle['d-shop-sku-tag-list']]: isSkuBaseTag,
126
126
  },
127
127
  className,
128
128
  )}
129
129
  >
130
130
  {}
131
131
  <View style={{ width: '1px', height: '100%' }} />
132
132
  {getTagInfoList.map((item, index) => {
133
133
  const { tagId, tabIconId, tagText, type, tabIconType, tabText } = item;
134
134
  const getTagId = tagId || tabIconId;
135
135
  const getTagType = type || tabIconType;
136
136
  const getTagText = tagText || tabText;
137
137
  return getTagId ? (
138
138
  <View
139
139
  key={getTagId + getTagType + index}
140
140
  className={classNames(shopTagStyle['d-tag-item'], itemClassName)}
141
141
  onClick={isCallBackFn && itemClickCallback.bind(this, item, index)}
142
142
  >
143
143
  <LeGaoTagComponent tagId={getTagId} tagText={getTagText} />
144
144
  </View>
145
145
  ) : null;
146
146
  })}
147
147
  </View>
148
148
  ) : null;