@shijiu/jsview-vue-samples 2.2.426-test.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 (246) 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 +80 -0
  14. package/DashPath/AppForOperator.vue +33 -0
  15. package/DemoForOperator/AnimPic/AnimPic.vue +69 -0
  16. package/DemoForOperator/AnimPic/App.vue +28 -0
  17. package/DemoForOperator/Banger/App.vue +26 -0
  18. package/DemoForOperator/Banger/Banger/Banger.vue +316 -0
  19. package/DemoForOperator/Banger/Banger/Maroon.vue +123 -0
  20. package/DemoForOperator/Banger/Banger/MaroonLoader.vue +78 -0
  21. package/DemoForOperator/Banger/Banger/SpriteDeal.js +30 -0
  22. package/DemoForOperator/Blur/Blur.vue +146 -0
  23. package/DemoForOperator/Blur/BlurInOut/BlurInOut.vue +158 -0
  24. package/DemoForOperator/Blur/BlurInOut/StaticBgSlide.vue +162 -0
  25. package/DemoForOperator/Blur/BlurPopup/BlurPopup.vue +113 -0
  26. package/DemoForOperator/BookFlip/App.vue +115 -0
  27. package/DemoForOperator/BookFlip/BookFlip/FlipPage.vue +179 -0
  28. package/DemoForOperator/BookFlip/BookFlip/FlippingBook.vue +310 -0
  29. package/DemoForOperator/BookFlip/BookFlip/flip.glsl +135 -0
  30. package/DemoForOperator/BookFlip/BookPage.vue +82 -0
  31. package/DemoForOperator/Bounce/App.vue +43 -0
  32. package/DemoForOperator/Bounce/Bounce.vue +81 -0
  33. package/DemoForOperator/Bounce/FreeMoveBuilder.js +139 -0
  34. package/DemoForOperator/ChunLian/App.vue +47 -0
  35. package/DemoForOperator/ChunLian/Couplets.vue +291 -0
  36. package/DemoForOperator/ClickSpriteAnim/App.vue +130 -0
  37. package/DemoForOperator/ClickSpriteAnim/Item.vue +74 -0
  38. package/DemoForOperator/DominantColor/App.vue +187 -0
  39. package/DemoForOperator/EpisodeList/App.vue +80 -0
  40. package/DemoForOperator/EpisodeList/EpisodeList/Controller.vue +110 -0
  41. package/DemoForOperator/EpisodeList/EpisodeList/EpisodeList.vue +250 -0
  42. package/DemoForOperator/EpisodeList/GroupItem.vue +65 -0
  43. package/DemoForOperator/EpisodeList/ListItem.vue +48 -0
  44. package/DemoForOperator/Firework1/App.vue +25 -0
  45. package/DemoForOperator/Firework1/Fireworks.vue +397 -0
  46. package/DemoForOperator/Firework1/SpriteDeal.js +30 -0
  47. package/DemoForOperator/FlipPage/App.vue +75 -0
  48. package/DemoForOperator/FlipPage/FlipPage/FlipPage.vue +178 -0
  49. package/DemoForOperator/FlipPage/FlipPage/flipIn.glsl +41 -0
  50. package/DemoForOperator/FlipPage/FlipPage/flipOut.glsl +41 -0
  51. package/DemoForOperator/Focus/Alpha/AlphaFocusBox.vue +95 -0
  52. package/DemoForOperator/Focus/Alpha/AlphaPage.vue +40 -0
  53. package/DemoForOperator/Focus/Alpha/Item.vue +64 -0
  54. package/DemoForOperator/Focus/App.vue +124 -0
  55. package/DemoForOperator/Focus/CommonPageSetting.js +30 -0
  56. package/DemoForOperator/Focus/Item.vue +46 -0
  57. package/DemoForOperator/Focus/Light/Item.vue +67 -0
  58. package/DemoForOperator/Focus/Light/LightFocusBox.vue +87 -0
  59. package/DemoForOperator/Focus/Light/LightPage.vue +43 -0
  60. package/DemoForOperator/Focus/Light/utils/FrameCanvasStore.ts +68 -0
  61. package/DemoForOperator/Focus/Light/utils/RotateFrame.vue +146 -0
  62. package/DemoForOperator/Focus/Light/utils/circleHaloMask.png +0 -0
  63. package/DemoForOperator/Focus/Normal/Item.vue +64 -0
  64. package/DemoForOperator/Focus/Normal/NormalFocusBox.vue +65 -0
  65. package/DemoForOperator/Focus/Normal/NormalPage.vue +41 -0
  66. package/DemoForOperator/Focus/SwipeLight/Item.vue +73 -0
  67. package/DemoForOperator/Focus/SwipeLight/SwipeLightBox.vue +62 -0
  68. package/DemoForOperator/Focus/SwipeLight/SwipeLightPage.vue +44 -0
  69. package/DemoForOperator/FrameShadow/App.vue +193 -0
  70. package/DemoForOperator/FrameShadow/FrameShadow.vue +61 -0
  71. package/DemoForOperator/FullscreenIn/App.vue +105 -0
  72. package/DemoForOperator/FullscreenIn/FullscreenPoster.vue +56 -0
  73. package/DemoForOperator/FullscreenIn/Item.vue +50 -0
  74. package/DemoForOperator/Genie/App.vue +78 -0
  75. package/DemoForOperator/Genie/geniePakcer/Genie.vue +741 -0
  76. package/DemoForOperator/Genie/geniePakcer/genieBottom.glsl +49 -0
  77. package/DemoForOperator/Genie/geniePakcer/genieLeft.glsl +50 -0
  78. package/DemoForOperator/Genie/geniePakcer/genieRight.glsl +57 -0
  79. package/DemoForOperator/Genie/geniePakcer/genieTop.glsl +50 -0
  80. package/DemoForOperator/GrayFilter/App.vue +51 -0
  81. package/DemoForOperator/GrayFilter/GrayFilter.vue +59 -0
  82. package/DemoForOperator/Jigsaw/App.vue +45 -0
  83. package/DemoForOperator/Jigsaw/JigsawFull.vue +142 -0
  84. package/DemoForOperator/Jigsaw/JigsawSingle.vue +118 -0
  85. package/DemoForOperator/LongChatBox/App.vue +36 -0
  86. package/DemoForOperator/LongChatBox/Bubble.vue +104 -0
  87. package/DemoForOperator/LongChatBox/LongChat.vue +173 -0
  88. package/DemoForOperator/LongChatBox/TextManager.ts +147 -0
  89. package/DemoForOperator/LongChatBox/VirtualList.vue +298 -0
  90. package/DemoForOperator/LongChatBox/testData.js +51 -0
  91. package/DemoForOperator/LongChatBox/utile.js +331 -0
  92. package/DemoForOperator/Particle/App.vue +69 -0
  93. package/DemoForOperator/Particle/Drop/DropParticle.vue +208 -0
  94. package/DemoForOperator/Particle/Explode/ExplodeParticle.vue +120 -0
  95. package/DemoForOperator/PosterAnim/App.vue +125 -0
  96. package/DemoForOperator/PosterAnim/Bounce/BouncePage.vue +54 -0
  97. package/DemoForOperator/PosterAnim/Bounce/Item.vue +85 -0
  98. package/DemoForOperator/PosterAnim/Breath/BreathPage.vue +47 -0
  99. package/DemoForOperator/PosterAnim/Breath/Item.vue +58 -0
  100. package/DemoForOperator/PosterAnim/CommonPageSetting.js +30 -0
  101. package/DemoForOperator/PosterAnim/Item.vue +46 -0
  102. package/DemoForOperator/PosterAnim/PosterAnim.js +79 -0
  103. package/DemoForOperator/PosterAnim/Scale/Item.vue +72 -0
  104. package/DemoForOperator/PosterAnim/Scale/ScalePage.vue +48 -0
  105. package/DemoForOperator/PosterAnim/Shake/Item.vue +85 -0
  106. package/DemoForOperator/PosterAnim/Shake/ShakePage.vue +53 -0
  107. package/DemoForOperator/PosterOverflow/App.vue +116 -0
  108. package/DemoForOperator/PosterOverflow/Item.vue +67 -0
  109. package/DemoForOperator/PosterOverflow/PosterOverflow.vue +39 -0
  110. package/DemoForOperator/Resize/App.vue +157 -0
  111. package/DemoForOperator/Resize/Resize/Item.vue +234 -0
  112. package/DemoForOperator/Resize/Resize/Resize.vue +96 -0
  113. package/DemoForOperator/Ripple/App.vue +54 -0
  114. package/DemoForOperator/Ripple/Ripple.vue +65 -0
  115. package/DemoForOperator/ScreenShootScale/App.vue +96 -0
  116. package/DemoForOperator/ScreenShootScale/Back.vue +86 -0
  117. package/DemoForOperator/ScreenShootScale/Front.vue +133 -0
  118. package/DemoForOperator/ScreenShootScale/Item.vue +62 -0
  119. package/DemoForOperator/ScreenShootScale/ScreenShootScale.vue +109 -0
  120. package/DemoForOperator/SmoothSwiper/App.vue +50 -0
  121. package/DemoForOperator/Sound/Bounce/App.vue +56 -0
  122. package/DemoForOperator/Sound/Bounce/Bounce.vue +87 -0
  123. package/DemoForOperator/Sound/Bounce/FreeMoveBuilder.js +146 -0
  124. package/DemoForOperator/Sound/Bounce/bgmusic.mp3 +0 -0
  125. package/DemoForOperator/Sound/Bounce/coin.mp3 +0 -0
  126. package/DemoForOperator/Sound/FocusMove/App.vue +134 -0
  127. package/DemoForOperator/Sound/FocusMove/Item.vue +43 -0
  128. package/DemoForOperator/Sound/FocusMove/move.mp3 +0 -0
  129. package/DemoForOperator/Sound/Rain/App.vue +11 -0
  130. package/DemoForOperator/Sound/Rain/Raining/Rain.vue +69 -0
  131. package/DemoForOperator/Sound/Rain/Raining/RainScene.vue +118 -0
  132. package/DemoForOperator/Sound/Sound/Sound.vue +24 -0
  133. package/DemoForOperator/Sound/Sound/index.js +4 -0
  134. package/DemoForOperator/Sound/Sound/useSound.js +112 -0
  135. package/DemoForOperator/Sprite/App.vue +33 -0
  136. package/DemoForOperator/Sprite/Sprite.vue +147 -0
  137. package/DemoForOperator/Stretch/App.vue +103 -0
  138. package/DemoForOperator/Stretch/Stretch/Item.vue +192 -0
  139. package/DemoForOperator/Stretch/Stretch/Stretch.vue +218 -0
  140. package/DemoForOperator/Swiper/App.vue +101 -0
  141. package/DemoForOperator/Swiper/Item.vue +56 -0
  142. package/DemoForOperator/Swiper/ParallaxSlide.vue +164 -0
  143. package/DemoForOperator/TabContent/App.vue +89 -0
  144. package/DemoForOperator/TabContent/ContentPage.vue +66 -0
  145. package/DemoForOperator/TabContent/Item.vue +85 -0
  146. package/DemoForOperator/TabContent/PageItem.vue +40 -0
  147. package/DemoForOperator/TabContent/TabContent/CreepFocus.vue +160 -0
  148. package/DemoForOperator/TabContent/TabContent/Item.vue +63 -0
  149. package/DemoForOperator/TabContent/TabContent/TabContent.vue +184 -0
  150. package/DemoForOperator/TabContent/TabContent/TabItem.vue +368 -0
  151. package/DemoForOperator/TabContent/TabContent/TabWidget.vue +243 -0
  152. package/DemoForOperator/TabContent/TabContent/Util.js +3 -0
  153. package/DemoForOperator/TabContent/TabContent/ViewSwiper.vue +110 -0
  154. package/DemoForOperator/TabContent/testData.js +241 -0
  155. package/DemoForOperator/TabContentVertical/App.vue +104 -0
  156. package/DemoForOperator/TabContentVertical/ContentPage.vue +67 -0
  157. package/DemoForOperator/TabContentVertical/Item.vue +94 -0
  158. package/DemoForOperator/TabContentVertical/PageItem.vue +40 -0
  159. package/DemoForOperator/TabContentVertical/TabContent/CreepFocus.vue +160 -0
  160. package/DemoForOperator/TabContentVertical/TabContent/Item.vue +63 -0
  161. package/DemoForOperator/TabContentVertical/TabContent/TabContent.vue +184 -0
  162. package/DemoForOperator/TabContentVertical/TabContent/TabItem.vue +368 -0
  163. package/DemoForOperator/TabContentVertical/TabContent/TabWidget.vue +259 -0
  164. package/DemoForOperator/TabContentVertical/TabContent/Util.js +3 -0
  165. package/DemoForOperator/TabContentVertical/TabContent/ViewSwiper.vue +110 -0
  166. package/DemoForOperator/TabContentVertical/assets/children_science.png +0 -0
  167. package/DemoForOperator/TabContentVertical/assets/documentary.png +0 -0
  168. package/DemoForOperator/TabContentVertical/assets/free.png +0 -0
  169. package/DemoForOperator/TabContentVertical/assets/game.png +0 -0
  170. package/DemoForOperator/TabContentVertical/assets/home_selected.png +0 -0
  171. package/DemoForOperator/TabContentVertical/assets/movie_ticket.png +0 -0
  172. package/DemoForOperator/TabContentVertical/assets/my_account.png +0 -0
  173. package/DemoForOperator/TabContentVertical/assets/opera.png +0 -0
  174. package/DemoForOperator/TabContentVertical/assets/sports.png +0 -0
  175. package/DemoForOperator/TabContentVertical/assets/tv_drama.png +0 -0
  176. package/DemoForOperator/TabContentVertical/assets/variety_show.png +0 -0
  177. package/DemoForOperator/TabContentVertical/assets/vip.png +0 -0
  178. package/DemoForOperator/TabContentVertical/testData.js +76 -0
  179. package/DemoForOperator/Vortex/App.vue +78 -0
  180. package/DemoForOperator/Vortex/Vortex/Vortex.vue +180 -0
  181. package/DemoForOperator/Vortex/Vortex/vortexIn.glsl +38 -0
  182. package/DemoForOperator/Vortex/Vortex/vortexOut.glsl +38 -0
  183. package/DemoForOperator/index.js +6 -0
  184. package/DemoForOperator/routeList.js +259 -0
  185. package/DemoHomepage/App.vue +50 -30
  186. package/DemoHomepage/components/Dialog.vue +1 -0
  187. package/DemoHomepage/components/Item.vue +11 -0
  188. package/DemoHomepage/components/TabFrame.vue +7 -0
  189. package/DemoHomepage/router.js +178 -81
  190. package/DemoHomepage/views/Homepage.vue +7 -2
  191. package/DivMetroPerformance/data.js +3 -3
  192. package/DriftScopeTest/App.vue +1 -1
  193. package/FilterDemo/AnimatePic.vue +1 -1
  194. package/FilterDemo/VideoLayer.vue +2 -2
  195. package/FullScreenFlex/TestFrame2.vue +1 -1
  196. package/GiftRain/App.vue +12 -12
  197. package/GiftRain/components/SpriteTranslate.vue +68 -48
  198. package/HashHistory/App.vue +2 -2
  199. package/HashHistory/router.js +1 -1
  200. package/JsvPreDownloader/App.vue +4 -4
  201. package/MediaDemo/components/frames/AudioFrame.vue +1 -1
  202. package/MediaDemo/components/frames/VideoFrame.vue +1 -1
  203. package/MetroWidgetDemos/MassiveItems/ContentItem.vue +1 -1
  204. package/MetroWidgetDemos/MassiveItems/data.js +1 -1
  205. package/MetroWidgetDemos/PerformanceTest/data.js +3 -3
  206. package/MetroWidgetDemos/RefreshDemo/assets/imageList.json +235 -235
  207. package/MetroWidgetDemos/SkeletonDiagram/assets/imageList.json +235 -235
  208. package/MetroWidgetDemos/TripleWidget/App.vue +7 -1
  209. package/MetroWidgetDemos/TripleWidget/Item.vue +16 -2
  210. package/MetroWidgetDemos/TripleWidget/SWidgetItem.vue +7 -1
  211. package/MetroWidgetDemos/TripleWidget/WidgetItem.vue +8 -2
  212. package/MetroWidgetDemos/focusableItemMetroWidget/WidgetItem.vue +3 -1
  213. package/MetroWidgetDemos/routeList.js +34 -17
  214. package/Poster3d/App.vue +69 -0
  215. package/Poster3d/Poster3d.vue +92 -0
  216. package/PosterPacker/App.vue +5 -5
  217. package/PosterPacker/tools/vortexPacker/Vortex.vue +1 -1
  218. package/QrcodeDemo/App.vue +1 -1
  219. package/Ripple/App.vue +1 -1
  220. package/ScaleDownNeon/App.vue +4 -4
  221. package/SceneTransition/App.vue +2 -2
  222. package/SceneTransition/maskConfig/config2.js +12 -12
  223. package/SceneTransition/maskConfig/config3.js +14 -14
  224. package/SprayView/App.vue +96 -51
  225. package/SpringFestival/App.vue +73 -0
  226. package/SpringFestival/SpringFestivalScene/ChunLian.vue +211 -0
  227. package/SpringFestival/SpringFestivalScene/FreeMoveBuilder.js +139 -0
  228. package/SpringFestival/SpringFestivalScene/LanternAnim.js +60 -0
  229. package/SpringFestival/SpringFestivalScene/Rain.vue +137 -0
  230. package/SpringFestival/SpringFestivalScene/Scene.vue +218 -0
  231. package/SpringFestival/SpringFestivalScene/imageConfig.js +87 -0
  232. package/SpringFestival/SpringFestivalScene/index.js +1 -0
  233. package/Swiper/App.vue +28 -29
  234. package/Swiper/Item.vue +19 -0
  235. package/SwiperTest/App.vue +9 -9
  236. package/TestNativeSharedView/AckEventDefine.ts +82 -0
  237. package/TestNativeSharedView/App.vue +4 -6
  238. package/TestNativeSharedView/JsvDemoTester.js +131 -0
  239. package/TextureAnimation/App.vue +16 -6
  240. package/TextureAnimation/App3.vue +100 -0
  241. package/TextureAnimation/utils/FrameCanvasStore.ts +68 -0
  242. package/TextureAnimation/utils/RotateFrame.vue +146 -0
  243. package/TextureAnimation/utils/circleHaloMask.png +0 -0
  244. package/TombSweepingDayTest/Raining/RainScene.vue +4 -4
  245. package/ViewOpacity/App.vue +21 -2
  246. package/package.json +1 -1
@@ -0,0 +1,184 @@
1
+ <template>
2
+ <jsv-focus-block
3
+ :name="name"
4
+ :onAction="{
5
+ onFocus,
6
+ onDispatchKeyUp,
7
+ }"
8
+ >
9
+ <tab-widget
10
+ :data="data"
11
+ :name="tabName"
12
+ :onEdge="tabOnEdge"
13
+ :layout="tabLayout"
14
+ :padding="tabPadding"
15
+ :itemGap="tagItemGap"
16
+ :initFocusId="initFocusId"
17
+ :tabTextFontSize="tabTextFontSize"
18
+ :creepFocusColor="creepFocusColor"
19
+ >
20
+ <template #tabItem="{ data, onAction, query }">
21
+ <slot
22
+ name="tabItem"
23
+ :data="data"
24
+ :query="query"
25
+ :onAction="onAction"
26
+ ></slot>
27
+ </template>
28
+ </tab-widget>
29
+ <view-swiper
30
+ :name="contentName"
31
+ :dataLoader="contentDataLoader"
32
+ :onEdge="contentOnEdge"
33
+ :layout="contentLayout"
34
+ :onFocus="contentOnFocus"
35
+ :onBlur="contentOnBlur"
36
+ >
37
+ <template #default="{ data, onEdge }">
38
+ <slot name="content" :data="data" :onEdge="onEdge"></slot>
39
+ </template>
40
+ </view-swiper>
41
+ </jsv-focus-block>
42
+ </template>
43
+
44
+ <script setup>
45
+ /**
46
+ * @slot tabItem - 自定义标签项内容
47
+ * @property {Object} data - 当前标签项数据
48
+ * @property {Object} query - 查询参数对象
49
+ * @property {Function} onAction - 动作处理函数
50
+ *
51
+ * @slot content - 自定义内容区域
52
+ * @property {Object} data - 内容区域数据
53
+ * @property {Function} onEdge - 边缘事件处理函数
54
+ */
55
+
56
+ import TabWidget from "./TabWidget.vue";
57
+ import ViewSwiper from "./ViewSwiper.vue";
58
+ import { ref, reactive, provide } from "vue";
59
+ import { useFocusHub, EdgeDirection } from "jsview";
60
+
61
+ const props = defineProps({
62
+ /** @type {String} 组件唯一标识名称 */
63
+ name: {
64
+ type: String,
65
+ required: true,
66
+ },
67
+ /** @type {Array} 标签数据源 */
68
+ data: {
69
+ type: Array,
70
+ required: true,
71
+ },
72
+ /** @type {Object} 标签栏布局配置 */
73
+ tabLayout: {
74
+ type: Object,
75
+ required: true,
76
+ },
77
+ /** @type {Object} 标签栏内边距配置 */
78
+ tabPadding: {
79
+ type: Object,
80
+ required: true,
81
+ },
82
+ /** @type {Number} 标签项之间的间隔 */
83
+ tagItemGap: {
84
+ type: Number,
85
+ required: true,
86
+ },
87
+ /** @type {Object} 内容区域布局配置 */
88
+ contentLayout: {
89
+ type: Object,
90
+ required: true,
91
+ },
92
+ /** @type {Function} 内容区域数据加载器 */
93
+ contentDataLoader: {
94
+ type: Function,
95
+ required: true,
96
+ },
97
+ /** @type {Number} 初始聚焦项的ID,默认0 */
98
+ initFocusId: {
99
+ type: Number,
100
+ default: 0,
101
+ },
102
+ /** @type {Number} 标签文字字体大小,默认30px */
103
+ tabTextFontSize: {
104
+ type: Number,
105
+ default: 30,
106
+ },
107
+ /** @type {Function} 内容区域获取焦点时的回调 */
108
+ contentOnFocus: {
109
+ type: Function,
110
+ default: () => {},
111
+ },
112
+ /** @type {Function} 内容区域失去焦点时的回调 */
113
+ contentOnBlur: {
114
+ type: Function,
115
+ default: () => {},
116
+ },
117
+ /** @type {String} 聚焦时的颜色,默认#e26c44 */
118
+ creepFocusColor: {
119
+ type: String,
120
+ default: "#e26c44",
121
+ },
122
+ });
123
+ const focusHub = useFocusHub();
124
+ const tabName = `${props.name}-tab`;
125
+ const contentName = `${props.name}-content`;
126
+ let focusName = tabName;
127
+
128
+ const animState = ref(0);
129
+ const globalInfo = reactive({
130
+ tabId: -1,
131
+ updateTabId: -1,
132
+ });
133
+ const getTouchFlag = () => {
134
+ return 0;
135
+ };
136
+ const tabFocus = ref(false);
137
+ const modeIsKey = () => {
138
+ return true;
139
+ };
140
+
141
+ /**
142
+ * 处理组件获取焦点事件
143
+ */
144
+ function onFocus() {
145
+ console.log("ccht onFocus", focusName);
146
+ focusHub.setFocus(focusName);
147
+ }
148
+
149
+ /**
150
+ * 处理标签栏边缘事件
151
+ * @param {Object} edgeInfo - 边缘事件信息
152
+ */
153
+ function tabOnEdge(edgeInfo) {
154
+ console.log("testtest tab on edge");
155
+ if (edgeInfo.direction == EdgeDirection.bottom) {
156
+ focusHub.setFocus(contentName);
157
+ focusName = contentName;
158
+ }
159
+ }
160
+
161
+ /**
162
+ * 处理内容区域边缘事件
163
+ * @param {Object} edgeInfo - 边缘事件信息
164
+ */
165
+ function contentOnEdge(edgeInfo) {
166
+ if (edgeInfo.direction == EdgeDirection.top) {
167
+ focusHub.setFocus(tabName);
168
+ focusName = tabName;
169
+ }
170
+ }
171
+
172
+ /**
173
+ * 处理按键抬起事件,更新当前标签ID
174
+ */
175
+ const onDispatchKeyUp = () => {
176
+ globalInfo.updateTabId = globalInfo.tabId;
177
+ };
178
+
179
+ provide("animState", animState);
180
+ provide("globalInfo", globalInfo);
181
+ provide("tabFocus", tabFocus);
182
+ provide("modeIsKey", modeIsKey);
183
+ provide("getTouchFlag", getTouchFlag);
184
+ </script>
@@ -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>