@shijiu/jsview-vue-samples 2.2.426-test.0 → 2.3.0

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.
Files changed (170) hide show
  1. package/BakeViewDemo/AnimatePic.vue +1 -1
  2. package/Basic/components/text/TextDirection.vue +7 -1
  3. package/BasicFocusControl/components/BaseBlock.vue +65 -18
  4. package/BreakRender/assets/imageList.json +235 -235
  5. package/ColorSpace/App.vue +2 -2
  6. package/CoupletsTest/App.vue +1 -1
  7. package/CoupletsTest/widget/Banger/Banger.vue +3 -3
  8. package/CoupletsTest/widget/Banger/MaroonLoader.vue +5 -5
  9. package/CoupletsTest/widget/Couplets/Couplets.vue +4 -4
  10. package/CoupletsTest/widget/Fireworks/Fireworks.vue +13 -13
  11. package/CustomShader/App.vue +4 -4
  12. package/CustomShader/gaussianBlur.glsl +1 -1
  13. package/DashPath/App.vue +79 -0
  14. package/DashPath/AppForOperator.vue +35 -0
  15. package/DashPath/DashPath.vue +118 -0
  16. package/DemoForOperator/AnimPic/AnimPic.vue +47 -0
  17. package/DemoForOperator/AnimPic/App.vue +28 -0
  18. package/DemoForOperator/Banger/App.vue +26 -0
  19. package/DemoForOperator/Banger/Banger/Banger.vue +252 -0
  20. package/DemoForOperator/Banger/Banger/Maroon.vue +123 -0
  21. package/DemoForOperator/Banger/Banger/MaroonLoader.vue +78 -0
  22. package/DemoForOperator/Banger/Banger/SpriteDeal.js +30 -0
  23. package/DemoForOperator/Bounce/App.vue +43 -0
  24. package/DemoForOperator/Bounce/Bounce.vue +49 -0
  25. package/DemoForOperator/Bounce/FreeMoveBuilder.js +139 -0
  26. package/DemoForOperator/ChunLian/App.vue +47 -0
  27. package/DemoForOperator/ChunLian/Couplets.vue +248 -0
  28. package/DemoForOperator/EpisodeList/App.vue +80 -0
  29. package/DemoForOperator/EpisodeList/EpisodeList/Controller.vue +113 -0
  30. package/DemoForOperator/EpisodeList/EpisodeList/EpisodeList.vue +176 -0
  31. package/DemoForOperator/EpisodeList/GroupItem.vue +65 -0
  32. package/DemoForOperator/EpisodeList/ListItem.vue +48 -0
  33. package/DemoForOperator/Firework1/App.vue +25 -0
  34. package/DemoForOperator/Firework1/Fireworks.vue +358 -0
  35. package/DemoForOperator/Firework1/SpriteDeal.js +30 -0
  36. package/DemoForOperator/FlipPage/App.vue +75 -0
  37. package/DemoForOperator/FlipPage/FlipPage/FlipPage.vue +150 -0
  38. package/DemoForOperator/FlipPage/FlipPage/flipIn.glsl +41 -0
  39. package/DemoForOperator/FlipPage/FlipPage/flipOut.glsl +41 -0
  40. package/DemoForOperator/Focus/Alpha/AlphaFocusBox.vue +70 -0
  41. package/DemoForOperator/Focus/Alpha/AlphaPage.vue +40 -0
  42. package/DemoForOperator/Focus/Alpha/Item.vue +64 -0
  43. package/DemoForOperator/Focus/App.vue +124 -0
  44. package/DemoForOperator/Focus/CommonPageSetting.js +30 -0
  45. package/DemoForOperator/Focus/Item.vue +46 -0
  46. package/DemoForOperator/Focus/Light/Item.vue +67 -0
  47. package/DemoForOperator/Focus/Light/LightFocusBox.vue +46 -0
  48. package/DemoForOperator/Focus/Light/LightPage.vue +43 -0
  49. package/DemoForOperator/Focus/Light/utils/FrameCanvasStore.ts +68 -0
  50. package/DemoForOperator/Focus/Light/utils/RotateFrame.vue +146 -0
  51. package/DemoForOperator/Focus/Light/utils/circleHaloMask.png +0 -0
  52. package/DemoForOperator/Focus/Normal/Item.vue +64 -0
  53. package/DemoForOperator/Focus/Normal/NormalFocusBox.vue +53 -0
  54. package/DemoForOperator/Focus/Normal/NormalPage.vue +41 -0
  55. package/DemoForOperator/Focus/SwipeLight/Item.vue +73 -0
  56. package/DemoForOperator/Focus/SwipeLight/SwipeLightBox.vue +62 -0
  57. package/DemoForOperator/Focus/SwipeLight/SwipeLightPage.vue +44 -0
  58. package/DemoForOperator/FullscreenIn/App.vue +105 -0
  59. package/DemoForOperator/FullscreenIn/FullscreenPoster.vue +41 -0
  60. package/DemoForOperator/FullscreenIn/Item.vue +50 -0
  61. package/DemoForOperator/Genie/App.vue +78 -0
  62. package/DemoForOperator/Genie/geniePakcer/Genie.vue +699 -0
  63. package/DemoForOperator/Genie/geniePakcer/genieBottom.glsl +49 -0
  64. package/DemoForOperator/Genie/geniePakcer/genieLeft.glsl +50 -0
  65. package/DemoForOperator/Genie/geniePakcer/genieRight.glsl +57 -0
  66. package/DemoForOperator/Genie/geniePakcer/genieTop.glsl +50 -0
  67. package/DemoForOperator/GrayFilter/App.vue +51 -0
  68. package/DemoForOperator/GrayFilter/GrayFilter.vue +38 -0
  69. package/DemoForOperator/Jigsaw/App.vue +45 -0
  70. package/DemoForOperator/Jigsaw/JigsawFull.vue +100 -0
  71. package/DemoForOperator/Jigsaw/JigsawSingle.vue +86 -0
  72. package/DemoForOperator/Particle/App.vue +69 -0
  73. package/DemoForOperator/Particle/Drop/DropParticle.vue +176 -0
  74. package/DemoForOperator/Particle/Explode/ExplodeParticle.vue +99 -0
  75. package/DemoForOperator/PosterAnim/App.vue +125 -0
  76. package/DemoForOperator/PosterAnim/Bounce/BouncePage.vue +54 -0
  77. package/DemoForOperator/PosterAnim/Bounce/Item.vue +85 -0
  78. package/DemoForOperator/PosterAnim/Breath/BreathPage.vue +47 -0
  79. package/DemoForOperator/PosterAnim/Breath/Item.vue +58 -0
  80. package/DemoForOperator/PosterAnim/CommonPageSetting.js +30 -0
  81. package/DemoForOperator/PosterAnim/Item.vue +46 -0
  82. package/DemoForOperator/PosterAnim/PosterAnim.js +58 -0
  83. package/DemoForOperator/PosterAnim/Scale/Item.vue +72 -0
  84. package/DemoForOperator/PosterAnim/Scale/ScalePage.vue +48 -0
  85. package/DemoForOperator/PosterAnim/Shake/Item.vue +85 -0
  86. package/DemoForOperator/PosterAnim/Shake/ShakePage.vue +53 -0
  87. package/DemoForOperator/PosterOverflow/App.vue +116 -0
  88. package/DemoForOperator/PosterOverflow/Item.vue +67 -0
  89. package/DemoForOperator/PosterOverflow/PosterOverflow.vue +23 -0
  90. package/DemoForOperator/Ripple/App.vue +54 -0
  91. package/DemoForOperator/Ripple/Ripple.vue +50 -0
  92. package/DemoForOperator/ScalePoster/App.vue +4 -0
  93. package/DemoForOperator/ScalePoster/ScalePoster.vue +0 -0
  94. package/DemoForOperator/Sprite/App.vue +33 -0
  95. package/DemoForOperator/Sprite/Sprite.vue +90 -0
  96. package/DemoForOperator/Stretch/App.vue +103 -0
  97. package/DemoForOperator/Stretch/Stretch/Item.vue +192 -0
  98. package/DemoForOperator/Stretch/Stretch/Stretch.vue +168 -0
  99. package/DemoForOperator/TabContent/App.vue +89 -0
  100. package/DemoForOperator/TabContent/ContentPage.vue +66 -0
  101. package/DemoForOperator/TabContent/Item.vue +85 -0
  102. package/DemoForOperator/TabContent/PageItem.vue +40 -0
  103. package/DemoForOperator/TabContent/TabContent/CreepFocus.vue +160 -0
  104. package/DemoForOperator/TabContent/TabContent/Item.vue +63 -0
  105. package/DemoForOperator/TabContent/TabContent/TabContent.vue +146 -0
  106. package/DemoForOperator/TabContent/TabContent/TabItem.vue +368 -0
  107. package/DemoForOperator/TabContent/TabContent/TabWidget.vue +243 -0
  108. package/DemoForOperator/TabContent/TabContent/Util.js +3 -0
  109. package/DemoForOperator/TabContent/TabContent/ViewSwiper.vue +110 -0
  110. package/DemoForOperator/TabContent/testData.js +241 -0
  111. package/DemoForOperator/Vortex/App.vue +78 -0
  112. package/DemoForOperator/Vortex/Vortex/Vortex.vue +154 -0
  113. package/DemoForOperator/Vortex/Vortex/vortexIn.glsl +38 -0
  114. package/DemoForOperator/Vortex/Vortex/vortexOut.glsl +38 -0
  115. package/DemoForOperator/index.js +6 -0
  116. package/DemoForOperator/routeList.js +142 -0
  117. package/DemoHomepage/App.vue +50 -30
  118. package/DemoHomepage/components/Dialog.vue +1 -0
  119. package/DemoHomepage/components/TabFrame.vue +7 -0
  120. package/DemoHomepage/router.js +104 -81
  121. package/DemoHomepage/views/Homepage.vue +7 -2
  122. package/DivMetroPerformance/data.js +3 -3
  123. package/DriftScopeTest/App.vue +1 -1
  124. package/FilterDemo/AnimatePic.vue +1 -1
  125. package/FilterDemo/VideoLayer.vue +2 -2
  126. package/FullScreenFlex/TestFrame2.vue +1 -1
  127. package/GiftRain/App.vue +12 -12
  128. package/JsvPreDownloader/App.vue +4 -4
  129. package/MediaDemo/components/frames/AudioFrame.vue +1 -1
  130. package/MediaDemo/components/frames/VideoFrame.vue +1 -1
  131. package/MetroWidgetDemos/MassiveItems/ContentItem.vue +1 -1
  132. package/MetroWidgetDemos/MassiveItems/data.js +1 -1
  133. package/MetroWidgetDemos/PerformanceTest/data.js +3 -3
  134. package/MetroWidgetDemos/RefreshDemo/assets/imageList.json +235 -235
  135. package/MetroWidgetDemos/SkeletonDiagram/assets/imageList.json +235 -235
  136. package/MetroWidgetDemos/focusableItemMetroWidget/WidgetItem.vue +3 -1
  137. package/MetroWidgetDemos/routeList.js +17 -17
  138. package/Poster3d/App.vue +69 -0
  139. package/Poster3d/Poster3d.vue +92 -0
  140. package/PosterPacker/App.vue +3 -3
  141. package/PosterPacker/tools/vortexPacker/Vortex.vue +1 -1
  142. package/QrcodeDemo/App.vue +1 -1
  143. package/Ripple/App.vue +1 -1
  144. package/ScaleDownNeon/App.vue +4 -4
  145. package/SceneTransition/App.vue +2 -2
  146. package/SceneTransition/maskConfig/config2.js +12 -12
  147. package/SceneTransition/maskConfig/config3.js +14 -14
  148. package/SprayView/App.vue +96 -51
  149. package/SpringFestival/App.vue +73 -0
  150. package/SpringFestival/SpringFestivalScene/ChunLian.vue +211 -0
  151. package/SpringFestival/SpringFestivalScene/FreeMoveBuilder.js +139 -0
  152. package/SpringFestival/SpringFestivalScene/LanternAnim.js +60 -0
  153. package/SpringFestival/SpringFestivalScene/Rain.vue +137 -0
  154. package/SpringFestival/SpringFestivalScene/Scene.vue +218 -0
  155. package/SpringFestival/SpringFestivalScene/imageConfig.js +87 -0
  156. package/SpringFestival/SpringFestivalScene/index.js +1 -0
  157. package/Swiper/App.vue +28 -29
  158. package/Swiper/Item.vue +19 -0
  159. package/SwiperTest/App.vue +9 -9
  160. package/TestNativeSharedView/AckEventDefine.ts +82 -0
  161. package/TestNativeSharedView/App.vue +4 -6
  162. package/TestNativeSharedView/JsvDemoTester.js +131 -0
  163. package/TextureAnimation/App.vue +16 -6
  164. package/TextureAnimation/App3.vue +100 -0
  165. package/TextureAnimation/utils/FrameCanvasStore.ts +68 -0
  166. package/TextureAnimation/utils/RotateFrame.vue +146 -0
  167. package/TextureAnimation/utils/circleHaloMask.png +0 -0
  168. package/TombSweepingDayTest/Raining/RainScene.vue +4 -4
  169. package/ViewOpacity/App.vue +2 -2
  170. package/package.json +1 -1
@@ -0,0 +1,368 @@
1
+ <!--
2
+ * @Author: ChenChanghua
3
+ * @Date: 2023-03-08 14:52:17
4
+ * @Description: file content
5
+ -->
6
+ <script setup>
7
+ import { ref, inject, shallowRef, provide, computed } from "vue";
8
+ import {
9
+ ListWidget,
10
+ HORIZONTAL,
11
+ useFocusHub,
12
+ getKeyFramesGroup,
13
+ EdgeDirection,
14
+ } from "jsview";
15
+ import Item from "./Item.vue";
16
+ import CreepFocus from "./CreepFocus.vue";
17
+ import { getTouchFlag } from "./Util.js";
18
+
19
+ const tabFocus = inject("tabFocus");
20
+
21
+ const touchFlag = getTouchFlag();
22
+ const globalInfo = inject("globalInfo");
23
+ const modeIsKey = inject("modeIsKey");
24
+ const DURATION = 200;
25
+ const props = defineProps({
26
+ data: Object,
27
+ query: Object,
28
+ onAction: Object,
29
+ onItemEdge: Function,
30
+ onItemFocus: Function,
31
+ onItemClick: Function,
32
+ creepFocusColor: String,
33
+ });
34
+ const focusHub = useFocusHub();
35
+ const folded = ref(true);
36
+ const creepFocus = ref(null);
37
+ const showFocus = ref(true);
38
+ const styleShell = getKeyFramesGroup();
39
+ const itemKeepScale = ref(false);
40
+ provide("itemKeepScale", itemKeepScale);
41
+
42
+ const keepOpen = ref(false);
43
+ const focused = ref(false);
44
+ const width = ref(props.data.width);
45
+ const widgetRef = shallowRef(null);
46
+ const widgetLeft = ref(0);
47
+ const customCallbacks = {};
48
+ const selfOnAction = {
49
+ register: (name, func) => {
50
+ customCallbacks[name] = func;
51
+ },
52
+ unregister: (name) => {
53
+ delete customCallbacks[name];
54
+ },
55
+ };
56
+
57
+ const focusRectController = {
58
+ onFocusChange: (rect) => {
59
+ creepFocus.value?.changeRect(rect);
60
+ },
61
+ };
62
+ const focusFrameController = inject("focusFrameController");
63
+
64
+ const provideData = () => {
65
+ return props.data.childTab.list;
66
+ };
67
+
68
+ const measures = (data) => {
69
+ return {
70
+ width: data.width,
71
+ height: data.height,
72
+ marginRight: data.marginRight,
73
+ enableTap: touchFlag == 1,
74
+ };
75
+ };
76
+ const openTab = () => {
77
+ itemKeepScale.value = false;
78
+ showFocus.value = true;
79
+ widgetLeft.value = 0;
80
+ folded.value = false;
81
+ width.value = props.data.childTab.width;
82
+ //为了居中而计算锚点
83
+ const anchor = getAnchor(0);
84
+ //创建动画
85
+ const anim = getClipAnimation(props.data.width, width.value, anchor);
86
+ clipAnimStr.value = anim.clip;
87
+ slideAnimStr.value = anim.slide;
88
+
89
+ props.query.updateItemSize(
90
+ props.query.index,
91
+ {
92
+ width: width.value,
93
+ height: props.data.height,
94
+ },
95
+ {
96
+ anchor,
97
+ duration: DURATION,
98
+ onEnd: () => {
99
+ console.log("unfold anim end.");
100
+ },
101
+ }
102
+ );
103
+ focusHub.setFocus(props.data.name);
104
+ focusFrameController.focusVisible(false);
105
+ if (!modeIsKey()) {
106
+ props.onItemClick(null, onBlur);
107
+ }
108
+ };
109
+
110
+ // 注册回调
111
+ const onFocus = () => {
112
+ console.log("onFocus", focused.value);
113
+ if (!keepOpen.value) {
114
+ focusFrameController.focusVisible(true);
115
+ folded.value = true;
116
+ props.onItemFocus(props.data, onBlur);
117
+ } else {
118
+ focusHub.setFocus(props.data.name);
119
+ // folded.value = false;
120
+ }
121
+ focused.value = true;
122
+ if (folded.value && props.data.childTab) {
123
+ openTab();
124
+ } else {
125
+ keepOpen.value = false;
126
+ }
127
+ customCallbacks.onFocus?.();
128
+ };
129
+
130
+ const onItemFocus = (data) => {
131
+ focusFrameController.focusVisible(false);
132
+ showFocus.value = true;
133
+ props.onItemFocus(data);
134
+ };
135
+
136
+ const foldSubTab = () => {
137
+ if (!folded.value) {
138
+ if (width.value == props.data.childTab.width) {
139
+ width.value = props.data.width;
140
+ let index = widgetRef.value?.getCurrentFocusIndex() ?? 0;
141
+
142
+ const anchor = getAnchor(index);
143
+ widgetLeft.value = -Math.round(
144
+ (props.data.childTab.width - props.data.width) * anchor
145
+ );
146
+
147
+ //创建动画
148
+ const anim = getClipAnimation(
149
+ props.data.childTab.width,
150
+ width.value,
151
+ anchor
152
+ );
153
+ clipAnimStr.value = anim.clip;
154
+ slideAnimStr.value = anim.slide;
155
+
156
+ props.query.updateItemSize(
157
+ props.query.index,
158
+ {
159
+ width: width.value,
160
+ height: props.data.height,
161
+ },
162
+ {
163
+ duration: DURATION,
164
+ onEnd: () => {
165
+ focusFrameController.focusVisible(true);
166
+ folded.value = true;
167
+ },
168
+ }
169
+ );
170
+ }
171
+ focusHub.returnFocusToParent();
172
+ }
173
+ };
174
+
175
+ const onBlur = () => {
176
+ customCallbacks.onBlur?.();
177
+ if (!itemKeepScale.value) {
178
+ showFocus.value = false;
179
+ }
180
+ if (keepOpen.value) {
181
+ return;
182
+ }
183
+ focused.value = false;
184
+ };
185
+
186
+ let animToken = 1;
187
+ const clipAnimStr = ref("");
188
+ const slideAnimStr = ref("");
189
+ const animationCache = {};
190
+ const getClipAnimation = (from, to, anchor) => {
191
+ animToken++;
192
+ const name = "foldableItemClipAnim" + animToken;
193
+ if (animationCache.hasOwnProperty(name)) {
194
+ styleShell.removeRule(name);
195
+ delete animationCache[name];
196
+ }
197
+ const clipAnimStr = `@keyframes ${name} { from { width: ${from}; } to { width: ${to}; } }`;
198
+ animationCache[name] = clipAnimStr;
199
+ styleShell.insertRule(clipAnimStr);
200
+
201
+ //平移动画
202
+ const anchorPosition = Math.round((to - from) * anchor);
203
+ const slideName = "foldableItemSlideAnim" + animToken;
204
+ if (animationCache.hasOwnProperty(slideName)) {
205
+ styleShell.removeRule(slideName);
206
+ delete animationCache[slideName];
207
+ }
208
+ const slideAnimStr = `@keyframes ${slideName} { from { transform: translate3d(${-anchorPosition},0,0); } to { transform: translate3d(0,0,0); } }`;
209
+
210
+ animationCache[slideName] = slideAnimStr;
211
+ styleShell.insertRule(slideAnimStr);
212
+
213
+ return {
214
+ clip: `${name} ${DURATION / 1000}s`,
215
+ slide: `${slideName} ${DURATION / 1000}s`,
216
+ };
217
+ };
218
+
219
+ const getAnchor = (index) => {
220
+ let anchor = 0;
221
+ const l = props.data.childTab.list;
222
+ if (index <= 0) {
223
+ anchor = 0;
224
+ } else if (index > l.length - 1) {
225
+ anchor = 1;
226
+ } else {
227
+ let focusMiddle = 0;
228
+ for (let i = 0; i <= index - 1; ++i) {
229
+ focusMiddle += l[i].width + l[i].marginRight;
230
+ }
231
+ focusMiddle += l[index].width / 2;
232
+ const scaleRate = props.data.childTab.width / props.data.width;
233
+ const targetPercent = focusMiddle / props.data.childTab.width; // 居中目标位置的百分比
234
+ /**
235
+ * anchor计算说明
236
+ * 考虑[0,1]的线段, 以a(0 <= a <= 1)为锚点, 放大n倍(n > 1)
237
+ * 坐标的映射关系为 x -> n(x - a) + a
238
+ * 此处我们想要的是目标焦点的中线对齐0.5, 即targetPercent放大后的位置是0.5
239
+ * 所以方程为 scaleRate * (targetPercent - anchor) + anchor = 0.5
240
+ */
241
+ anchor = (scaleRate * targetPercent - 0.5) / (scaleRate - 1);
242
+ }
243
+ return anchor;
244
+ };
245
+
246
+ const onClick = () => {
247
+ if (folded.value && props.data.childTab) {
248
+ openTab();
249
+ } else {
250
+ if (!modeIsKey()) {
251
+ props.onItemClick(props.data, onBlur, onFocus);
252
+ }
253
+ }
254
+ customCallbacks.onClick?.();
255
+ };
256
+
257
+ console.log("tabitem", props.data, props.onAction);
258
+ props.onAction.register("onFocus", onFocus);
259
+ props.onAction.register("onBlur", onBlur);
260
+ props.onAction.register("onClick", onClick);
261
+
262
+ const onKeyDown = (ev) => {
263
+ if (ev.keyCode === 10000 || ev.keyCode === 8 || ev.keyCode === 27) {
264
+ keepOpen.value = true;
265
+ // itemKeepScale.value = false;
266
+ // foldSubTab();
267
+ }
268
+ return false;
269
+ };
270
+ const onItemEdge = (edgeInfo) => {
271
+ if (
272
+ edgeInfo.direction == EdgeDirection.top ||
273
+ edgeInfo.direction == EdgeDirection.bottom
274
+ ) {
275
+ keepOpen.value = true;
276
+ } else {
277
+ foldSubTab();
278
+ }
279
+ props.onItemEdge(edgeInfo);
280
+ };
281
+ const onItemClick2 = (data) => {
282
+ // widgetRef.value.setFocusId(data.tabIndex);
283
+ };
284
+ const isSlect = computed(() => {
285
+ if (modeIsKey()) {
286
+ return (
287
+ !tabFocus.value &&
288
+ !focused.value &&
289
+ globalInfo.updateTabId == props.data.indexId
290
+ );
291
+ } else {
292
+ return globalInfo.updateTabId == props.data.indexId;
293
+ }
294
+ });
295
+ </script>
296
+
297
+ <template>
298
+ <slot
299
+ v-if="folded"
300
+ name="tabItem"
301
+ :data="data"
302
+ :onAction="selfOnAction"
303
+ :query="query"
304
+ ></slot>
305
+ <div
306
+ v-else
307
+ :style="{
308
+ width: width,
309
+ height: data.height,
310
+ overflow: 'hidden',
311
+ animation: clipAnimStr,
312
+ }"
313
+ >
314
+ <jsv-focus-block
315
+ v-if="data.childTab"
316
+ :onAction="{
317
+ onKeyDown,
318
+ }"
319
+ :style="{
320
+ left: widgetLeft,
321
+ width: data.childTab.width - 10,
322
+ height: data.height,
323
+ animation: slideAnimStr,
324
+ }"
325
+ >
326
+ <list-widget
327
+ ref="widgetRef"
328
+ :name="data.name"
329
+ :width="data.childTab.width"
330
+ :height="data.height"
331
+ :provideData="provideData"
332
+ :direction="HORIZONTAL"
333
+ :measures="measures"
334
+ :onEdge="onItemEdge"
335
+ :initFocusId="0"
336
+ :touchFlag="touchFlag"
337
+ >
338
+ <template #renderItem="{ data, onAction, query }">
339
+ <item
340
+ :focusRectController="focusRectController"
341
+ :data="data"
342
+ :onAction="onAction"
343
+ :query="query"
344
+ :onItemFocus="onItemFocus"
345
+ :onItemClick="onItemClick2"
346
+ >
347
+ <template #tabItem="{ data, onAction, query }">
348
+ <slot
349
+ name="tabItem"
350
+ :data="data"
351
+ :query="query"
352
+ :onAction="onAction"
353
+ ></slot>
354
+ </template>
355
+ </item>
356
+ </template>
357
+ <template #background>
358
+ <creep-focus
359
+ v-show="showFocus && modeIsKey()"
360
+ ref="creepFocus"
361
+ :color="creepFocusColor"
362
+ >
363
+ </creep-focus>
364
+ </template>
365
+ </list-widget>
366
+ </jsv-focus-block>
367
+ </div>
368
+ </template>
@@ -0,0 +1,243 @@
1
+ <script setup>
2
+ import { onMounted, inject, ref, provide, shallowRef, computed } from "vue";
3
+ import {
4
+ getTextWidth,
5
+ ListWidget,
6
+ useFocusHub,
7
+ FixPositionSlide,
8
+ EdgeDirection,
9
+ HORIZONTAL,
10
+ } from "jsview";
11
+ import TabItem from "./TabItem.vue";
12
+ import CreepFocus from "./CreepFocus.vue";
13
+ import { getTouchFlag } from "./Util.js";
14
+
15
+ const touchFlag = getTouchFlag();
16
+ const modeIsKey = inject("modeIsKey");
17
+
18
+ const tabFocus = inject("tabFocus");
19
+ const focusHub = useFocusHub();
20
+ const props = defineProps({
21
+ data: Array,
22
+ name: String,
23
+ onEdge: Function,
24
+ layout: Object,
25
+ padding: Object,
26
+ itemGap: Number,
27
+ initFocusId: Number,
28
+ tabTextFontSize: Number,
29
+ creepFocusColor: String,
30
+ });
31
+ console.log("layout", props.layout);
32
+ const itemWidthExpand = 60;
33
+ const globalInfo = inject("globalInfo");
34
+ const slideType = new FixPositionSlide();
35
+
36
+ const creepFocus = ref(null);
37
+ const showFocus = ref(true);
38
+ let currentFocusRect = {};
39
+ const focusFrameController = {
40
+ focusVisible: (visible) => {
41
+ showFocus.value = visible ? true : false;
42
+ },
43
+ onFocusChange: (rect, focusIndex, doAnim) => {
44
+ creepFocus.value?.changeRect(rect, doAnim);
45
+ currentFocusRect = rect;
46
+ },
47
+ };
48
+ provide("focusFrameController", focusFrameController);
49
+ const itemHeight = computed(
50
+ () =>
51
+ props.layout.height -
52
+ (props.padding?.top ?? 0) -
53
+ (props.padding?.bottom ?? 0)
54
+ );
55
+
56
+ const SizeObj = {
57
+ fontSize: props.tabTextFontSize,
58
+ };
59
+ const data = [];
60
+ const getChildTabList = (childTab) => {
61
+ if (!childTab) {
62
+ return null;
63
+ }
64
+ const list = [];
65
+ for (let i = 0; i < childTab.length; ++i) {
66
+ const childTextSize = getTextWidth(childTab[i].itemTitle, SizeObj);
67
+ let obj = {
68
+ width: childTextSize + itemWidthExpand,
69
+ height: itemHeight.value,
70
+ marginRight: props.itemGap,
71
+ content: childTab[i].itemTitle,
72
+ index: i,
73
+ ...childTab[i],
74
+ };
75
+ list.push(obj);
76
+ }
77
+ return list;
78
+ };
79
+
80
+ for (let i = 0; i < props.data.length; ++i) {
81
+ const textSize = getTextWidth(props.data[i].itemTitle, SizeObj);
82
+ const childList = getChildTabList(props.data[i].childTab);
83
+ let totalWidth = 0;
84
+ if (childList) {
85
+ childList.forEach((item) => {
86
+ totalWidth += item.width + item.marginRight;
87
+ });
88
+ }
89
+ let obj = {
90
+ width: textSize + itemWidthExpand,
91
+ height: itemHeight.value,
92
+ content: props.data[i].itemTitle,
93
+ marginRight: props.itemGap,
94
+ name: "item_" + i, // focus name
95
+ ...props.data[i],
96
+ };
97
+ if (childList) {
98
+ obj.childTab = {
99
+ width: totalWidth,
100
+ list: childList,
101
+ };
102
+ }
103
+ data.push(obj);
104
+ }
105
+ const provideData = () => {
106
+ return data;
107
+ };
108
+
109
+ const measures = (item) => {
110
+ return {
111
+ width: item.width,
112
+ height: item.height,
113
+ marginRight: item.marginRight,
114
+ enableTap: touchFlag == 1,
115
+ };
116
+ };
117
+
118
+ const widgetRef = shallowRef();
119
+ onMounted(() => {
120
+ provide("parentWidget", widgetRef);
121
+ });
122
+
123
+ const onFocusRectChange = () => {
124
+ //展开时的滑动不需要更新焦点大小
125
+ if (showFocus.value) {
126
+ const curFocusIndex = widgetRef.value.getCurrentFocusIndex();
127
+ const rect = widgetRef.value.getTemplatePosition(curFocusIndex);
128
+ focusFrameController.onFocusChange(rect, curFocusIndex);
129
+ }
130
+ };
131
+ const onAllResizeDone = () => {
132
+ console.log("onAllResizeDone");
133
+ };
134
+
135
+ const onItemFocus = (item_data, onBlur) => {
136
+ console.log("testtest onItemFocus", item_data);
137
+ globalInfo.tabId = item_data.indexId;
138
+ if (globalInfo.updateTabId == -1 || !modeIsKey()) {
139
+ globalInfo.updateTabId = item_data.indexId;
140
+ }
141
+ if (globalInfo.tabCode != item_data.itemCode) {
142
+ globalInfo.tabCode = item_data.itemCode;
143
+ // if (props.data.icon4) {
144
+ // changeBg(props.data.icon4);
145
+ // }
146
+ }
147
+ };
148
+
149
+ const onEdge = (edgeInfo) => {
150
+ props.onEdge(edgeInfo);
151
+ };
152
+
153
+ const onItemClick = (data, onBlur, onFocus) => {
154
+ // manager.onItemTap({ onBlur: onBlur, onFocus: onFocus });
155
+ // if (data) {
156
+ // focusHub.setFocus(props.name);
157
+ // widgetRef.value.setFocusId(data.index);
158
+ // }
159
+ };
160
+
161
+ const onBlur = () => {
162
+ showFocus.value = false;
163
+ tabFocus.value = false;
164
+ };
165
+
166
+ const onFocus = () => {
167
+ showFocus.value = true;
168
+ tabFocus.value = true;
169
+ };
170
+
171
+ // Manager 实现
172
+ const manager = {
173
+ previousItem: null,
174
+
175
+ // 注册 onBlur 方法
176
+ registerOnBlur(item) {
177
+ if (this.previousItem && this.previousItem.onBlur) {
178
+ this.previousItem.onBlur(); // 调用上一个 item 的 onBlur
179
+ }
180
+ if (item.onFocus) {
181
+ item.onFocus();
182
+ }
183
+ this.previousItem = item; // 更新上一个 item
184
+ },
185
+
186
+ // 处理 item 被点击
187
+ onItemTap(item) {
188
+ this.registerOnBlur(item);
189
+ },
190
+ };
191
+ </script>
192
+
193
+ <template>
194
+ <div :style="{ left: layout.left, top: layout.top }">
195
+ <list-widget
196
+ ref="widgetRef"
197
+ :name="name"
198
+ :onFocusRectChange="onFocusRectChange"
199
+ :onAllItemResizeDone="onAllResizeDone"
200
+ :width="layout.width"
201
+ :height="layout.height"
202
+ :slideSetting="slideType"
203
+ :direction="HORIZONTAL"
204
+ :provideData="provideData"
205
+ :measures="measures"
206
+ :padding="padding"
207
+ :initFocusId="initFocusId"
208
+ :onEdge="onEdge"
209
+ :onFocus="onFocus"
210
+ :onBlur="onBlur"
211
+ :touchFlag="touchFlag"
212
+ >
213
+ <template #renderItem="{ data, onAction, query, onItemEdge }">
214
+ <tab-item
215
+ :data="data"
216
+ :onAction="onAction"
217
+ :query="query"
218
+ :onItemEdge="onItemEdge"
219
+ :onItemFocus="onItemFocus"
220
+ :onItemClick="onItemClick"
221
+ :creepFocusColor="creepFocusColor"
222
+ >
223
+ <template #tabItem="{ data, onAction, query }">
224
+ <slot
225
+ name="tabItem"
226
+ :data="data"
227
+ :query="query"
228
+ :onAction="onAction"
229
+ ></slot>
230
+ </template>
231
+ </tab-item>
232
+ </template>
233
+ <template #background>
234
+ <creep-focus
235
+ v-show="showFocus && modeIsKey()"
236
+ ref="creepFocus"
237
+ :color="creepFocusColor"
238
+ >
239
+ </creep-focus>
240
+ </template>
241
+ </list-widget>
242
+ </div>
243
+ </template>
@@ -0,0 +1,3 @@
1
+ export function getTouchFlag() {
2
+ return 0;
3
+ }
@@ -0,0 +1,110 @@
1
+ <script setup>
2
+ import { onMounted, inject, ref, watch } from "vue";
3
+
4
+ const props = defineProps({
5
+ onEdge: Function,
6
+ name: String,
7
+ layout: Object,
8
+ dataLoader: Function, // (tabId) => Promise
9
+ animDuration: { type: Number, default: 200 },
10
+ onFocus: Function,
11
+ onBlur: Function,
12
+ });
13
+
14
+ const globalInfo = inject("globalInfo");
15
+ const animState = inject("animState");
16
+
17
+ const page0Show = ref(false);
18
+ let page0Data = null;
19
+ const page0Anim = ref({ anim: null, onend: null });
20
+ const appSwiper_onFocus = () => {
21
+ console.log("testtest swiper on focus")
22
+ props.onFocus();
23
+ };
24
+ const appSwiper_onBlur = () => {
25
+ console.log("testtest swiper on blur")
26
+ props.onBlur();
27
+ };
28
+
29
+ const appSwiper_tabIdWatcher = (newValue, oldValue) => {
30
+ let direction = newValue > oldValue ? "left" : "right";
31
+ page0Show.value = false;
32
+ page0Data = null;
33
+ page0Anim.value = ref({ anim: null, onend: null });
34
+ props.dataLoader(newValue).then((data) => {
35
+ console.log("testtest swiper data", data);
36
+ if (oldValue > -1) {
37
+ animState.value = 1;
38
+ }
39
+ page0Anim.value = {
40
+ anim:
41
+ oldValue != -1
42
+ ? `app-swiper-${direction}-slide-in ${
43
+ props.animDuration / 1000
44
+ }s cubic-bezier(0.05, 0.55, 0.13, 0.78) 1`
45
+ : null,
46
+ onend: () => {
47
+ animState.value = 0;
48
+ },
49
+ };
50
+ page0Data = data;
51
+ page0Show.value = true;
52
+ });
53
+ };
54
+
55
+ watch(
56
+ () => globalInfo.updateTabId,
57
+ (newValue, oldValue) => {
58
+ console.log("ccht updateTabId changed", globalInfo.updateTabId);
59
+ appSwiper_tabIdWatcher(newValue, oldValue);
60
+ }
61
+ );
62
+ </script>
63
+
64
+ <template>
65
+ <jsv-focus-block
66
+ :name="name"
67
+ ref="focusNode"
68
+ :onAction="{
69
+ onFocus: appSwiper_onFocus,
70
+ onBlur: appSwiper_onBlur,
71
+ }"
72
+ >
73
+ <div
74
+ id="page0"
75
+ :style="{
76
+ left: layout.left,
77
+ top: layout.top,
78
+ width: layout.width,
79
+ height: layout.height,
80
+ animation: page0Anim.anim,
81
+ animationFillMode: 'forwards',
82
+ }"
83
+ @animationend="page0Anim.onend"
84
+ >
85
+ <slot v-if="page0Show" :data="page0Data" :onEdge="onEdge"></slot>
86
+ </div>
87
+ </jsv-focus-block>
88
+ </template>
89
+
90
+ <style>
91
+ @keyframes app-swiper-left-slide-in {
92
+ from {
93
+ transform: translate3d(280px, 0px, 0px);
94
+ }
95
+ to {
96
+ transform: translate3d(0px, 0px, 0px);
97
+ /* animation-timing-function: cubic-bezier(0.05, 0.55, 0.13, 0.78); */
98
+ }
99
+ }
100
+
101
+ @keyframes app-swiper-right-slide-in {
102
+ from {
103
+ transform: translate3d(-280px, 0px, 0px);
104
+ }
105
+ to {
106
+ transform: translate3d(0px, 0px, 0px);
107
+ /* animation-timing-function: cubic-bezier(0.05, 0.55, 0.13, 0.78); */
108
+ }
109
+ }
110
+ </style>