@shijiu/jsview-vue-samples 2.3.0 → 2.3.151-test.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 (117) hide show
  1. package/DashPath/App.vue +17 -16
  2. package/DashPath/AppForOperator.vue +2 -4
  3. package/DemoForOperator/AnimPic/AnimPic.vue +24 -2
  4. package/DemoForOperator/Banger/Banger/Banger.vue +73 -9
  5. package/DemoForOperator/Blur/Blur.vue +146 -0
  6. package/DemoForOperator/Blur/BlurInOut/BlurInOut.vue +158 -0
  7. package/DemoForOperator/Blur/BlurInOut/StaticBgSlide.vue +162 -0
  8. package/DemoForOperator/Blur/BlurPopup/BlurPopup.vue +113 -0
  9. package/DemoForOperator/BookFlip/App.vue +115 -0
  10. package/DemoForOperator/BookFlip/BookFlip/FlipPage.vue +179 -0
  11. package/DemoForOperator/BookFlip/BookFlip/FlippingBook.vue +310 -0
  12. package/DemoForOperator/BookFlip/BookFlip/flip.glsl +135 -0
  13. package/DemoForOperator/BookFlip/BookPage.vue +82 -0
  14. package/DemoForOperator/Bounce/Bounce.vue +33 -1
  15. package/DemoForOperator/ChunLian/Couplets.vue +44 -1
  16. package/DemoForOperator/ClickSpriteAnim/App.vue +130 -0
  17. package/DemoForOperator/ClickSpriteAnim/Item.vue +74 -0
  18. package/DemoForOperator/DominantColor/App.vue +187 -0
  19. package/DemoForOperator/EpisodeList/EpisodeList/Controller.vue +0 -3
  20. package/DemoForOperator/EpisodeList/EpisodeList/EpisodeList.vue +76 -2
  21. package/DemoForOperator/Firework1/App.vue +1 -1
  22. package/DemoForOperator/Firework1/Fireworks.vue +50 -11
  23. package/DemoForOperator/FlipPage/FlipPage/FlipPage.vue +29 -1
  24. package/DemoForOperator/Focus/Alpha/AlphaFocusBox.vue +27 -2
  25. package/DemoForOperator/Focus/Light/LightFocusBox.vue +42 -1
  26. package/DemoForOperator/Focus/Normal/NormalFocusBox.vue +12 -0
  27. package/DemoForOperator/FrameShadow/App.vue +193 -0
  28. package/DemoForOperator/FrameShadow/FrameShadow.vue +61 -0
  29. package/DemoForOperator/FullscreenIn/App.vue +1 -1
  30. package/DemoForOperator/FullscreenIn/FullscreenPoster.vue +18 -3
  31. package/DemoForOperator/Genie/geniePakcer/Genie.vue +60 -18
  32. package/DemoForOperator/GrayFilter/GrayFilter.vue +21 -0
  33. package/DemoForOperator/Jigsaw/JigsawFull.vue +46 -4
  34. package/DemoForOperator/Jigsaw/JigsawSingle.vue +34 -2
  35. package/DemoForOperator/LongChatBox/App.vue +36 -0
  36. package/DemoForOperator/LongChatBox/Bubble.vue +104 -0
  37. package/DemoForOperator/LongChatBox/LongChat.vue +173 -0
  38. package/DemoForOperator/LongChatBox/TextManager.ts +147 -0
  39. package/DemoForOperator/LongChatBox/VirtualList.vue +298 -0
  40. package/DemoForOperator/LongChatBox/testData.js +51 -0
  41. package/DemoForOperator/LongChatBox/utile.js +331 -0
  42. package/DemoForOperator/Particle/Drop/DropParticle.vue +33 -1
  43. package/DemoForOperator/Particle/Explode/ExplodeParticle.vue +23 -2
  44. package/DemoForOperator/PosterAnim/PosterAnim.js +21 -0
  45. package/DemoForOperator/PosterOverflow/PosterOverflow.vue +16 -0
  46. package/DemoForOperator/Resize/App.vue +157 -0
  47. package/DemoForOperator/Resize/Resize/Item.vue +234 -0
  48. package/DemoForOperator/Resize/Resize/Resize.vue +96 -0
  49. package/DemoForOperator/Ripple/Ripple.vue +16 -1
  50. package/DemoForOperator/ScreenShootScale/App.vue +96 -0
  51. package/DemoForOperator/ScreenShootScale/Back.vue +86 -0
  52. package/DemoForOperator/ScreenShootScale/Front.vue +133 -0
  53. package/DemoForOperator/ScreenShootScale/Item.vue +62 -0
  54. package/DemoForOperator/ScreenShootScale/ScreenShootScale.vue +109 -0
  55. package/DemoForOperator/SmoothSwiper/App.vue +50 -0
  56. package/DemoForOperator/Sound/Bounce/App.vue +56 -0
  57. package/DemoForOperator/Sound/Bounce/Bounce.vue +87 -0
  58. package/DemoForOperator/Sound/Bounce/FreeMoveBuilder.js +146 -0
  59. package/DemoForOperator/Sound/Bounce/bgmusic.mp3 +0 -0
  60. package/DemoForOperator/Sound/Bounce/coin.mp3 +0 -0
  61. package/DemoForOperator/Sound/FocusMove/App.vue +134 -0
  62. package/DemoForOperator/Sound/FocusMove/Item.vue +43 -0
  63. package/DemoForOperator/Sound/FocusMove/move.mp3 +0 -0
  64. package/DemoForOperator/Sound/Rain/App.vue +11 -0
  65. package/DemoForOperator/Sound/Rain/Raining/Rain.vue +69 -0
  66. package/DemoForOperator/Sound/Rain/Raining/RainScene.vue +118 -0
  67. package/DemoForOperator/Sound/Sound/Sound.vue +24 -0
  68. package/DemoForOperator/Sound/Sound/index.js +4 -0
  69. package/DemoForOperator/Sound/Sound/useSound.js +112 -0
  70. package/DemoForOperator/Sprite/Sprite.vue +62 -5
  71. package/DemoForOperator/Stretch/Stretch/Stretch.vue +52 -2
  72. package/DemoForOperator/Swiper/App.vue +101 -0
  73. package/DemoForOperator/Swiper/Item.vue +56 -0
  74. package/DemoForOperator/Swiper/ParallaxSlide.vue +164 -0
  75. package/DemoForOperator/TabContent/TabContent/TabContent.vue +39 -1
  76. package/DemoForOperator/TabContentVertical/App.vue +104 -0
  77. package/DemoForOperator/TabContentVertical/ContentPage.vue +67 -0
  78. package/DemoForOperator/TabContentVertical/Item.vue +94 -0
  79. package/DemoForOperator/TabContentVertical/PageItem.vue +40 -0
  80. package/DemoForOperator/TabContentVertical/TabContent/CreepFocus.vue +160 -0
  81. package/DemoForOperator/TabContentVertical/TabContent/Item.vue +63 -0
  82. package/DemoForOperator/TabContentVertical/TabContent/TabContent.vue +184 -0
  83. package/DemoForOperator/TabContentVertical/TabContent/TabItem.vue +368 -0
  84. package/DemoForOperator/TabContentVertical/TabContent/TabWidget.vue +259 -0
  85. package/DemoForOperator/TabContentVertical/TabContent/Util.js +3 -0
  86. package/DemoForOperator/TabContentVertical/TabContent/ViewSwiper.vue +110 -0
  87. package/DemoForOperator/TabContentVertical/assets/children_science.png +0 -0
  88. package/DemoForOperator/TabContentVertical/assets/documentary.png +0 -0
  89. package/DemoForOperator/TabContentVertical/assets/free.png +0 -0
  90. package/DemoForOperator/TabContentVertical/assets/game.png +0 -0
  91. package/DemoForOperator/TabContentVertical/assets/home_selected.png +0 -0
  92. package/DemoForOperator/TabContentVertical/assets/movie_ticket.png +0 -0
  93. package/DemoForOperator/TabContentVertical/assets/my_account.png +0 -0
  94. package/DemoForOperator/TabContentVertical/assets/opera.png +0 -0
  95. package/DemoForOperator/TabContentVertical/assets/sports.png +0 -0
  96. package/DemoForOperator/TabContentVertical/assets/tv_drama.png +0 -0
  97. package/DemoForOperator/TabContentVertical/assets/variety_show.png +0 -0
  98. package/DemoForOperator/TabContentVertical/assets/vip.png +0 -0
  99. package/DemoForOperator/TabContentVertical/testData.js +76 -0
  100. package/DemoForOperator/Vortex/Vortex/Vortex.vue +26 -0
  101. package/DemoForOperator/routeList.js +118 -1
  102. package/DemoHomepage/components/Item.vue +11 -0
  103. package/DemoHomepage/router.js +75 -1
  104. package/GiftRain/components/SpriteTranslate.vue +68 -48
  105. package/HashHistory/App.vue +2 -2
  106. package/HashHistory/router.js +1 -1
  107. package/MetroWidgetDemos/TripleWidget/App.vue +7 -1
  108. package/MetroWidgetDemos/TripleWidget/Item.vue +16 -2
  109. package/MetroWidgetDemos/TripleWidget/SWidgetItem.vue +7 -1
  110. package/MetroWidgetDemos/TripleWidget/WidgetItem.vue +8 -2
  111. package/MetroWidgetDemos/routeList.js +17 -0
  112. package/PosterPacker/App.vue +2 -2
  113. package/ViewOpacity/App.vue +19 -0
  114. package/package.json +1 -1
  115. package/DashPath/DashPath.vue +0 -118
  116. package/DemoForOperator/ScalePoster/App.vue +0 -4
  117. package/DemoForOperator/ScalePoster/ScalePoster.vue +0 -0
@@ -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,259 @@
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
+ VERTICAL,
11
+ } from "jsview";
12
+ import TabItem from "./TabItem.vue";
13
+ import CreepFocus from "./CreepFocus.vue";
14
+ import { getTouchFlag } from "./Util.js";
15
+
16
+ const touchFlag = getTouchFlag();
17
+ const modeIsKey = inject("modeIsKey");
18
+
19
+ const tabFocus = inject("tabFocus");
20
+ const focusHub = useFocusHub();
21
+ const props = defineProps({
22
+ data: Array,
23
+ name: String,
24
+ onEdge: Function,
25
+ layout: Object,
26
+ padding: Object,
27
+ itemGap: Number,
28
+ initFocusId: Number,
29
+ tabTextFontSize: Number,
30
+ creepFocusColor: String,
31
+ });
32
+ console.log("layout", props.layout);
33
+ const itemWidthExpand = 60;
34
+ const globalInfo = inject("globalInfo");
35
+ const slideType = new FixPositionSlide({duration: 200});
36
+
37
+ const creepFocus = ref(null);
38
+ const showFocus = ref(true);
39
+ let currentFocusRect = {};
40
+ const focusFrameController = {
41
+ focusVisible: (visible) => {
42
+ showFocus.value = visible ? true : false;
43
+ },
44
+ onFocusChange: (rect, focusIndex, doAnim) => {
45
+ creepFocus.value?.changeRect(rect, doAnim);
46
+ currentFocusRect = rect;
47
+ },
48
+ };
49
+ provide("focusFrameController", focusFrameController);
50
+ const itemHeight = computed(
51
+ () =>
52
+ props.layout.height -
53
+ (props.padding?.top ?? 0) -
54
+ (props.padding?.bottom ?? 0)
55
+ );
56
+
57
+ const itemWidth = computed(
58
+ () =>
59
+ props.layout.width -
60
+ (props.padding?.left ?? 0) -
61
+ (props.padding?.right ?? 0)
62
+ );
63
+
64
+ const SizeObj = {
65
+ fontSize: props.tabTextFontSize,
66
+ };
67
+ const data = [];
68
+ const getChildTabList = (childTab) => {
69
+ if (!childTab) {
70
+ return null;
71
+ }
72
+ const list = [];
73
+ for (let i = 0; i < childTab.length; ++i) {
74
+ const childTextSize = getTextWidth(childTab[i].itemTitle, SizeObj);
75
+ let obj = {
76
+ // width: childTextSize + itemWidthExpand,
77
+ // height: itemHeight.value,
78
+ width: itemWidth.value,
79
+ height: itemWidth.value,
80
+ marginRight: props.itemGap,
81
+ marginBottom: props.itemGap,
82
+ content: childTab[i].itemTitle,
83
+ index: i,
84
+ ...childTab[i],
85
+ };
86
+ list.push(obj);
87
+ }
88
+ return list;
89
+ };
90
+
91
+ for (let i = 0; i < props.data.length; ++i) {
92
+ const textSize = getTextWidth(props.data[i].itemTitle, SizeObj);
93
+ const childList = getChildTabList(props.data[i].childTab);
94
+ let totalWidth = 0;
95
+ if (childList) {
96
+ childList.forEach((item) => {
97
+ totalWidth += item.width + item.marginRight;
98
+ });
99
+ }
100
+ let obj = {
101
+ // width: textSize + itemWidthExpand,
102
+ // height: itemHeight.value,
103
+ width: itemWidth.value,
104
+ height: itemWidth.value,
105
+
106
+ content: props.data[i].itemTitle,
107
+ marginRight: props.itemGap,
108
+ marginBottom: props.itemGap,
109
+ name: "item_" + i, // focus name
110
+ ...props.data[i],
111
+ };
112
+ if (childList) {
113
+ obj.childTab = {
114
+ width: totalWidth,
115
+ list: childList,
116
+ };
117
+ }
118
+ data.push(obj);
119
+ }
120
+ const provideData = () => {
121
+ return data;
122
+ };
123
+
124
+ const measures = (item) => {
125
+ return {
126
+ width: item.width,
127
+ height: item.height,
128
+ marginRight: item.marginRight,
129
+ marginBottom: item.marginBottom,
130
+ enableTap: touchFlag == 1,
131
+ };
132
+ };
133
+
134
+ const widgetRef = shallowRef();
135
+ onMounted(() => {
136
+ provide("parentWidget", widgetRef);
137
+ });
138
+
139
+ const onFocusRectChange = () => {
140
+ //展开时的滑动不需要更新焦点大小
141
+ if (showFocus.value) {
142
+ const curFocusIndex = widgetRef.value.getCurrentFocusIndex();
143
+ const rect = widgetRef.value.getTemplatePosition(curFocusIndex);
144
+ focusFrameController.onFocusChange(rect, curFocusIndex);
145
+ }
146
+ };
147
+ const onAllResizeDone = () => {
148
+ console.log("onAllResizeDone");
149
+ };
150
+
151
+ const onItemFocus = (item_data, onBlur) => {
152
+ console.log("testtest onItemFocus", item_data);
153
+ globalInfo.tabId = item_data.indexId;
154
+ if (globalInfo.updateTabId == -1 || !modeIsKey()) {
155
+ globalInfo.updateTabId = item_data.indexId;
156
+ }
157
+ if (globalInfo.tabCode != item_data.itemCode) {
158
+ globalInfo.tabCode = item_data.itemCode;
159
+ // if (props.data.icon4) {
160
+ // changeBg(props.data.icon4);
161
+ // }
162
+ }
163
+ };
164
+
165
+ const onEdge = (edgeInfo) => {
166
+ props.onEdge(edgeInfo);
167
+ };
168
+
169
+ const onItemClick = (data, onBlur, onFocus) => {
170
+ // manager.onItemTap({ onBlur: onBlur, onFocus: onFocus });
171
+ // if (data) {
172
+ // focusHub.setFocus(props.name);
173
+ // widgetRef.value.setFocusId(data.index);
174
+ // }
175
+ };
176
+
177
+ const onBlur = () => {
178
+ showFocus.value = false;
179
+ tabFocus.value = false;
180
+ };
181
+
182
+ const onFocus = () => {
183
+ showFocus.value = true;
184
+ tabFocus.value = true;
185
+ };
186
+
187
+ // Manager 实现
188
+ const manager = {
189
+ previousItem: null,
190
+
191
+ // 注册 onBlur 方法
192
+ registerOnBlur(item) {
193
+ if (this.previousItem && this.previousItem.onBlur) {
194
+ this.previousItem.onBlur(); // 调用上一个 item 的 onBlur
195
+ }
196
+ if (item.onFocus) {
197
+ item.onFocus();
198
+ }
199
+ this.previousItem = item; // 更新上一个 item
200
+ },
201
+
202
+ // 处理 item 被点击
203
+ onItemTap(item) {
204
+ this.registerOnBlur(item);
205
+ },
206
+ };
207
+ </script>
208
+
209
+ <template>
210
+ <div :style="{ left: layout.left, top: layout.top }">
211
+ <list-widget
212
+ ref="widgetRef"
213
+ :name="name"
214
+ :onFocusRectChange="onFocusRectChange"
215
+ :onAllItemResizeDone="onAllResizeDone"
216
+ :width="layout.width"
217
+ :height="layout.height"
218
+ :slideSetting="slideType"
219
+ :direction="VERTICAL"
220
+ :provideData="provideData"
221
+ :measures="measures"
222
+ :padding="padding"
223
+ :initFocusId="initFocusId"
224
+ :onEdge="onEdge"
225
+ :onFocus="onFocus"
226
+ :onBlur="onBlur"
227
+ :touchFlag="touchFlag"
228
+ >
229
+ <template #renderItem="{ data, onAction, query, onItemEdge }">
230
+ <tab-item
231
+ :data="data"
232
+ :onAction="onAction"
233
+ :query="query"
234
+ :onItemEdge="onItemEdge"
235
+ :onItemFocus="onItemFocus"
236
+ :onItemClick="onItemClick"
237
+ :creepFocusColor="creepFocusColor"
238
+ >
239
+ <template #tabItem="{ data, onAction, query }">
240
+ <slot
241
+ name="tabItem"
242
+ :data="data"
243
+ :query="query"
244
+ :onAction="onAction"
245
+ ></slot>
246
+ </template>
247
+ </tab-item>
248
+ </template>
249
+ <template #background>
250
+ <creep-focus
251
+ v-show="showFocus && modeIsKey()"
252
+ ref="creepFocus"
253
+ :color="creepFocusColor"
254
+ >
255
+ </creep-focus>
256
+ </template>
257
+ </list-widget>
258
+ </div>
259
+ </template>
@@ -0,0 +1,3 @@
1
+ export function getTouchFlag() {
2
+ return 0;
3
+ }