@shijiu/jsview-vue-samples 2.3.151-test.0 → 3.0.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 (228) hide show
  1. package/ABImageAlt/App.vue +114 -0
  2. package/ABImageAlt/Item.vue +133 -0
  3. package/{MetroWidgetDemos/SkeletonDiagram/assets/imageList.json → ABImageAlt/assets/imageList.js} +9 -1
  4. package/ABImageAlt/data.js +17 -0
  5. package/AI_Check_Rules.txt +5 -0
  6. package/AnimPicture/App.vue +20 -10
  7. package/ApicSwitch/App.vue +90 -0
  8. package/ApicSwitch/TabItem.vue +65 -0
  9. package/ApicSwitch/WebpShow.vue +24 -0
  10. package/ApicSwitch/data.js +50 -0
  11. package/Basic/AI_skills_update.md +1 -0
  12. package/Basic/components/div/ColorFormatTest.vue +93 -0
  13. package/Basic/components/div/DivRadius.vue +97 -15
  14. package/Basic/components/div/DivTag3Group.vue +30 -0
  15. package/Basic/components/img/ImageType.vue +65 -0
  16. package/Basic/components/panel/Panel2.vue +13 -1
  17. package/Basic/components/text/TextAlign.vue +7 -1
  18. package/BlobLoadTest/App.vue +201 -0
  19. package/BreakLinesApi/App.vue +82 -0
  20. package/CanvasDrawChart/App.vue +11 -0
  21. package/CanvasDrawChart/Graph1.vue +104 -0
  22. package/CanvasDrawChart/Graph2.vue +115 -0
  23. package/CssPreprocessor/Scss/PanelData.js +1 -1
  24. package/CssPreprocessor/Scss/components/scss-group4/ScssMaps.vue +4 -3
  25. package/CssPreprocessor/Scss/components/scss-group5/ScssImporting.vue +2 -2
  26. package/DemoForOperator/Bounce/FreeMoveBuilder.js +1 -1
  27. package/DemoForOperator/Firework1/App.vue +12 -1
  28. package/DemoForOperator/Firework1/Fireworks.vue +18 -0
  29. package/DemoForOperator/FlipPage/FlipPage/FlipPage.vue +1 -0
  30. package/DemoForOperator/Focus/Alpha/Item.vue +1 -0
  31. package/DemoForOperator/Focus/Light/Item.vue +1 -0
  32. package/DemoForOperator/Focus/Normal/Item.vue +1 -0
  33. package/DemoForOperator/FrameShadow/FrameShadow.vue +1 -1
  34. package/DemoForOperator/Genie/App.vue +20 -6
  35. package/DemoForOperator/Genie/App2.vue +61 -0
  36. package/DemoForOperator/Genie/geniePakcer/GenieImage.vue +298 -0
  37. package/DemoForOperator/Genie/geniePakcer/GenieSlot.vue +292 -0
  38. package/DemoForOperator/Genie/geniePakcer/GenieTools.ts +463 -0
  39. package/DemoForOperator/Jigsaw/JigsawFull.vue +12 -7
  40. package/DemoForOperator/Jigsaw/JigsawSingle.vue +13 -7
  41. package/DemoForOperator/LongChatBox/App.vue +13 -13
  42. package/DemoForOperator/LongChatBox/Bubble.vue +78 -66
  43. package/DemoForOperator/LongChatBox/LongChat.vue +68 -36
  44. package/DemoForOperator/LongChatBox/testData.js +7 -44
  45. package/DemoForOperator/Sound/Bounce/FreeMoveBuilder.js +1 -1
  46. package/DemoForOperator/routeList.js +8 -2
  47. package/DemoHomepage/App.vue +74 -1
  48. package/DemoHomepage/components/BodyFrame.vue +1 -0
  49. package/DemoHomepage/components/TabFrame.vue +1 -1
  50. package/DemoHomepage/router.js +723 -160
  51. package/DemoHomepage/views/Homepage.vue +60 -2
  52. package/DemoHomepage/watchTest.vue +50 -0
  53. package/FilterDemo/AnimatePic.vue +63 -17
  54. package/FilterDemo/App.vue +3 -3
  55. package/FlexCellDemo/AI_skills_update.md +4 -0
  56. package/FlexCellDemo/TestFrame1.vue +12 -2
  57. package/FlexCellDemo/TestFrame2.vue +10 -1
  58. package/FlexCellDemo/TestFrame3.vue +114 -59
  59. package/FpsLimit/App.vue +102 -0
  60. package/FreeMoveChildAttract/App.vue +18 -8
  61. package/FreeMoveLink/App.vue +49 -20
  62. package/Hover/App.vue +144 -0
  63. package/HttpRequestSSE/SSEReader.js +200 -0
  64. package/ImpactStop/App.vue +2 -2
  65. package/Input/FullKeyboard.vue +3 -3
  66. package/Input/InputPanel.vue +63 -3
  67. package/JsvLine/App.vue +53 -38
  68. package/LatexDemo/App.vue +3 -1
  69. package/LatexFormula/App.vue +196 -0
  70. package/LongImage/App.vue +1 -1
  71. package/LongImage/LongImageScroll.vue +100 -47
  72. package/LongImage/Scroll.vue +28 -9
  73. package/LongText/LongTextScroll.vue +1 -0
  74. package/Markdown/App.vue +36 -0
  75. package/Markdown/Bubble.vue +109 -0
  76. package/Markdown/LongChat.vue +206 -0
  77. package/Markdown/Markdown/Markdown.vue +156 -0
  78. package/Markdown/Markdown/index.ts +1 -0
  79. package/Markdown/Markdown/marked/LICENSE.md +45 -0
  80. package/Markdown/Markdown/marked/index.ts +2 -0
  81. package/Markdown/Markdown/marked/marked.d.ts +756 -0
  82. package/Markdown/Markdown/marked/marked.js +71 -0
  83. package/Markdown/Markdown/parser.ts +1365 -0
  84. package/Markdown/data.js +581 -0
  85. package/MetroWidgetDemos/AI_skills_update.md +2 -0
  86. package/MetroWidgetDemos/ListExpand/ChildItem.vue +130 -0
  87. package/MetroWidgetDemos/ListExpand/ExpandItem.vue +375 -0
  88. package/MetroWidgetDemos/ListExpand/ExpandItem1.vue +403 -0
  89. package/MetroWidgetDemos/ListExpand/assets/arrow-down.png +0 -0
  90. package/MetroWidgetDemos/ListExpand/assets/up-arrow.png +0 -0
  91. package/MetroWidgetDemos/ListExpand/components/WidgetListHandler.vue +150 -0
  92. package/MetroWidgetDemos/ListExpand/index.vue +88 -0
  93. package/MetroWidgetDemos/ListExpand/list.js +2421 -0
  94. package/MetroWidgetDemos/RefreshDemo/App.vue +14 -1
  95. package/MetroWidgetDemos/RenderAccelerate/App.vue +142 -0
  96. package/MetroWidgetDemos/RenderAccelerate/AppPage.vue +78 -0
  97. package/MetroWidgetDemos/RenderAccelerate/AppTab.vue +62 -0
  98. package/MetroWidgetDemos/RenderAccelerate/ContentItem.vue +409 -0
  99. package/MetroWidgetDemos/RenderAccelerate/Item.vue +67 -0
  100. package/MetroWidgetDemos/RenderAccelerate/TabItem.vue +100 -0
  101. package/MetroWidgetDemos/RenderAccelerate/ViewSwiper.vue +215 -0
  102. package/MetroWidgetDemos/RenderAccelerate/WidgetItem.vue +107 -0
  103. package/MetroWidgetDemos/SkeletonDiagram/App.vue +35 -8
  104. package/MetroWidgetDemos/SkeletonDiagram/Item.vue +11 -2
  105. package/MetroWidgetDemos/SkeletonDiagram/assets/imageList.js +245 -0
  106. package/MetroWidgetDemos/SkeletonDiagram/data.js +3 -3
  107. package/MetroWidgetDemos/SpatialNav/App.vue +177 -0
  108. package/MetroWidgetDemos/SpatialNav/Buttons.vue +83 -0
  109. package/MetroWidgetDemos/SpatialNav/CustomFocus.vue +57 -0
  110. package/MetroWidgetDemos/{TripleWidget → SpatialNav}/Item.vue +1 -8
  111. package/MetroWidgetDemos/{TripleWidget/WidgetItem.vue → SpatialNav/SimpleFloor.vue} +14 -45
  112. package/MetroWidgetDemos/SpatialNav/StepMw.vue +113 -0
  113. package/MetroWidgetDemos/SpatialNav/TabContent/TabContent.vue +185 -0
  114. package/MetroWidgetDemos/SpatialNav/TripleSection/TripleSection.vue +69 -0
  115. package/MetroWidgetDemos/SpatialNav/TripleSection/WidgetItem.vue +100 -0
  116. package/MetroWidgetDemos/SpatialNav/TvSection/List.vue +75 -0
  117. package/MetroWidgetDemos/SpatialNav/TvSection/TvSection.vue +91 -0
  118. package/MetroWidgetDemos/basic2/App.vue +407 -0
  119. package/MetroWidgetDemos/basic2/Item.vue +68 -0
  120. package/MetroWidgetDemos/direction/App.vue +22 -0
  121. package/MetroWidgetDemos/gazeFocusDiff/App.vue +126 -0
  122. package/MetroWidgetDemos/gazeFocusDiff/Item.vue +87 -0
  123. package/MetroWidgetDemos/minimalUsage/App.vue +66 -0
  124. package/MetroWidgetDemos/minimalUsage/Item.vue +54 -0
  125. package/MetroWidgetDemos/ninePatchFocusPage/App.vue +22 -7
  126. package/MetroWidgetDemos/ninePatchFocusPage/Item.vue +7 -5
  127. package/MetroWidgetDemos/ninePatchFocusPage/focusConstants.js +2 -0
  128. package/MetroWidgetDemos/routeList.js +203 -12
  129. package/MetroWidgetDemos/slideSetting/App.vue +288 -99
  130. package/MetroWidgetDemos/zIndex/App.vue +117 -0
  131. package/MetroWidgetDemos/zIndex/Item.vue +61 -0
  132. package/NinePatchTester/App.vue +24 -31
  133. package/PreDecode/App.vue +140 -0
  134. package/ReactiveTest/App.vue +115 -0
  135. package/ReactiveTest/Item.vue +92 -0
  136. package/ReactiveTest/assets/imageList.js +245 -0
  137. package/ReactiveTest/component/TestSmartDiv.vue +50 -0
  138. package/ReactiveTest/component/TestSmartDivSrcList.vue +74 -0
  139. package/ReactiveTest/component/TestSmartImage.vue +46 -0
  140. package/ReactiveTest/component/TestSmartImageSrcList.vue +90 -0
  141. package/ReactiveTest/component/TestSmartImageStyle.vue +41 -0
  142. package/ReactiveTest/data.js +49 -0
  143. package/ScreenToBlob/App.vue +250 -0
  144. package/SecTorTest/App.vue +9 -3
  145. package/SpringFestival/SpringFestivalScene/FreeMoveBuilder.js +3 -3
  146. package/SyncDecode/App.vue +137 -0
  147. package/TextSizeLimit/App.vue +211 -0
  148. package/TransitPage/App.vue +2 -0
  149. package/assets/logo.png +0 -0
  150. package/package.json +5 -5
  151. package/DemoForOperator/Genie/geniePakcer/Genie.vue +0 -741
  152. package/DemoForOperator/LongChatBox/TextManager.ts +0 -147
  153. package/DemoForOperator/LongChatBox/VirtualList.vue +0 -298
  154. package/DemoForOperator/LongChatBox/utile.js +0 -331
  155. package/DivMetroPerformance/App.vue +0 -157
  156. package/DivMetroPerformance/Item.vue +0 -58
  157. package/DivMetroPerformance/assets/bg.jpg +0 -0
  158. package/DivMetroPerformance/assets/coupon_content.png +0 -0
  159. package/DivMetroPerformance/assets/coupon_left.png +0 -0
  160. package/DivMetroPerformance/assets/coupon_mid.png +0 -0
  161. package/DivMetroPerformance/assets/coupon_right.png +0 -0
  162. package/DivMetroPerformance/assets/focus_border.png +0 -0
  163. package/DivMetroPerformance/assets/holder_logo.png +0 -0
  164. package/DivMetroPerformance/assets/jrbm.png +0 -0
  165. package/DivMetroPerformance/assets/line_left.png +0 -0
  166. package/DivMetroPerformance/assets/line_mid.png +0 -0
  167. package/DivMetroPerformance/assets/line_right.png +0 -0
  168. package/DivMetroPerformance/assets/loading.png +0 -0
  169. package/DivMetroPerformance/assets/logo.png +0 -0
  170. package/DivMetroPerformance/assets/mcjx.png +0 -0
  171. package/DivMetroPerformance/assets/tao.png +0 -0
  172. package/DivMetroPerformance/assets/tmall.png +0 -0
  173. package/DivMetroPerformance/border.png +0 -0
  174. package/DivMetroPerformance/components/ContentItem.vue +0 -384
  175. package/DivMetroPerformance/components/MyTab.vue +0 -129
  176. package/DivMetroPerformance/data.js +0 -124
  177. package/DivMetroPerformance/utils/GridItem.vue +0 -28
  178. package/DivMetroPerformance/utils/GridPlate.vue +0 -85
  179. package/MediaDemo/App.vue +0 -127
  180. package/MediaDemo/assets/audio-poster.png +0 -0
  181. package/MediaDemo/components/Button.vue +0 -69
  182. package/MediaDemo/components/Controllor.vue +0 -286
  183. package/MediaDemo/components/StatusBar.vue +0 -100
  184. package/MediaDemo/components/frames/AudioFrame.vue +0 -39
  185. package/MediaDemo/components/frames/AudioPoster.vue +0 -48
  186. package/MediaDemo/components/frames/MediaFrame.vue +0 -153
  187. package/MediaDemo/components/frames/VideoFrame.vue +0 -39
  188. package/MetroWidgetDemos/TripleWidget/App.vue +0 -87
  189. package/MetroWidgetDemos/TripleWidget/SWidgetItem.vue +0 -99
  190. package/Parkour/App.vue +0 -13
  191. package/Parkour/Common/Context.js +0 -21
  192. package/Parkour/Common/MatchmanInfo.js +0 -62
  193. package/Parkour/Common/Random.js +0 -61
  194. package/Parkour/Common/Sound.js +0 -50
  195. package/Parkour/appConfig/HOW_TO_CONFIG.md +0 -20
  196. package/Parkour/appConfig/app.config.mjs +0 -5
  197. package/Parkour/appConfig/app_sign_private_key_sample.crt +0 -28
  198. package/Parkour/appConfig/app_sign_public_key_sample.pem +0 -9
  199. package/Parkour/appConfig/jsview.config.mjs +0 -39
  200. package/Parkour/assets/Bgimages/bg1.png +0 -0
  201. package/Parkour/assets/Bgimages/bg2.png +0 -0
  202. package/Parkour/assets/Bgimages/bg3.png +0 -0
  203. package/Parkour/assets/Bgimages/bg4.png +0 -0
  204. package/Parkour/assets/Bgimages/bg5.png +0 -0
  205. package/Parkour/assets/audio/jump.mp3 +0 -0
  206. package/Parkour/assets/audio/lose.mp3 +0 -0
  207. package/Parkour/assets/role_skin1/fail.json +0 -44
  208. package/Parkour/assets/role_skin1/fail.png +0 -0
  209. package/Parkour/assets/role_skin1/jump_down.json +0 -20
  210. package/Parkour/assets/role_skin1/jump_down.png +0 -0
  211. package/Parkour/assets/role_skin1/jump_up.json +0 -44
  212. package/Parkour/assets/role_skin1/jump_up.png +0 -0
  213. package/Parkour/assets/role_skin1/roll.json +0 -44
  214. package/Parkour/assets/role_skin1/roll.png +0 -0
  215. package/Parkour/assets/role_skin1/run.json +0 -52
  216. package/Parkour/assets/role_skin1/run.png +0 -0
  217. package/Parkour/components/Backdrop.vue +0 -61
  218. package/Parkour/components/GameSence.vue +0 -602
  219. package/Parkour/components/Matchman.vue +0 -85
  220. package/ThrowMoveDemo/AccelerateDemo.vue +0 -85
  221. package/ThrowMoveDemo/App.vue +0 -104
  222. package/ThrowMoveDemo/LRParabolicDemo.vue +0 -101
  223. package/ThrowMoveDemo/TargetDemo.vue +0 -87
  224. package/ThrowMoveDemo/UDParabolicDemo.vue +0 -92
  225. /package/{AnimPicture/assets → assets}/animated_webp.webp +0 -0
  226. /package/{AnimPicture/assets → assets}/ball_3.webp +0 -0
  227. /package/{AnimPicture/assets → assets}/girl_run.gif +0 -0
  228. /package/{AnimPicture/assets → assets}/quan.webp +0 -0
@@ -9,7 +9,6 @@ import { ref, onMounted, onUnmounted } from "vue";
9
9
  const props = defineProps({
10
10
  data: Object,
11
11
  onAction: Object,
12
- rowNum: Number,
13
12
  queryInfo: Object,
14
13
  });
15
14
 
@@ -32,15 +31,9 @@ props.onAction.register("onBlur", onBlur);
32
31
  props.onAction.register("onClick", onClick);
33
32
 
34
33
  onMounted(() => {
35
- console.log(
36
- `+++++++++ 加载 item 所在行列: ${props.rowNum} ${props.queryInfo.id}`
37
- );
38
34
  });
39
35
 
40
36
  onUnmounted(() => {
41
- console.log(
42
- `---------卸载 item 所在行列: ${props.rowNum} ${props.queryInfo.id}`
43
- );
44
37
  });
45
38
  </script>
46
39
 
@@ -49,7 +42,7 @@ onUnmounted(() => {
49
42
  :style="{
50
43
  width: data.width,
51
44
  height: data.height,
52
- transform: focused ? 'scale3d(1.2, 1.2, 1.2)' : '',
45
+ transform: focused ? 'scale3d(1.05, 1.05, 1.05)' : '',
53
46
  transition: 'transform 0.2s linear',
54
47
  }"
55
48
  >
@@ -1,19 +1,19 @@
1
1
  <script setup>
2
- import { HORIZONTAL, MetroWidget, useFocusHub } from "jsview";
2
+ import { HORIZONTAL, MetroWidget, useFocusHub, ONEDGE_TYPE } from "jsview";
3
3
  import { shallowRef } from "vue";
4
4
  import Item from "./Item.vue";
5
5
 
6
6
  const props = defineProps({
7
7
  data: Object,
8
- onItemEdge: Function,
9
8
  onAction: Object,
10
- rowNum: Object,
9
+ queryInfo: Object,
11
10
  });
12
11
  const focusHub = useFocusHub();
13
- const mwRef = shallowRef(null);
14
-
15
12
  const measures = (item) => {
16
- return item;
13
+ return {
14
+ ...item,
15
+ bindSpatialNav: true,
16
+ };
17
17
  };
18
18
  const randomColor = () => {
19
19
  let randomColor = Math.round(Math.random() * 2 ** 24).toString(16);
@@ -25,8 +25,8 @@ const provideData = () => {
25
25
  const data = [];
26
26
  for (let i = 0; i < 10; i++) {
27
27
  data.push({
28
- width: (i + props.data.index) % 2 == 0 ? 90 : 180,
29
- height: 90,
28
+ width: 160,
29
+ height: 100,
30
30
  marginRight: 10,
31
31
  marginBottom: 10,
32
32
  content: i,
@@ -36,33 +36,6 @@ const provideData = () => {
36
36
  return data;
37
37
  };
38
38
  const onFocus = (rect) => {
39
- /** 重要代码: 参数rect为父MetroWidget传递的, 焦点过来的区域
40
- * 因此需要调用setEnterFocusRect来设置焦点进入区域, 以寻找最近的焦点
41
- */
42
- //多层嵌套时, EnterFocusRect需要根据子的信息设置
43
- if (rect) {
44
- let rectInfo = {
45
- x: 0,
46
- y: 0,
47
- width: 0,
48
- height: 0,
49
- };
50
- let curRect = rect;
51
- while (curRect) {
52
- let { x, y, width, height } = curRect.rect;
53
- rectInfo.x += x;
54
- rectInfo.y += y;
55
- rectInfo.width = width;
56
- rectInfo.height = height;
57
- curRect = curRect.childEdgeInfo;
58
- }
59
- mwRef.value?.setEnterFocusRect({
60
- direction: rect.direction,
61
- rect: rectInfo,
62
- });
63
- }
64
-
65
- // mwRef.value?.setEnterFocusRect(rect);
66
39
  focusHub.setFocus(props.data.name);
67
40
  };
68
41
  const onBlur = () => {
@@ -85,31 +58,27 @@ props.onAction.register("onBlur", onBlur);
85
58
  >
86
59
  {{ data.name }}
87
60
  </div>
88
- <!-- 重要代码: sendFocusRectEvent可以让MetroWidget的item在获焦时发送事件, 通知父的MetroWidget进行滚动 -->
89
- <!-- 重要代码: onItemEdge直接作为onEdge回调, 既子MetroWidget到达边缘时触发父的onItemEdge -->
90
61
  <metro-widget
91
- ref="mwRef"
92
62
  :name="data.name"
93
- :top="50"
94
- :width="data.width"
95
- :height="data.height"
63
+ :top="40"
64
+ :width="900"
65
+ :height="250"
96
66
  :provideData="provideData"
97
67
  :direction="HORIZONTAL"
98
68
  :padding="{
99
- left: 30,
100
- right: 30,
69
+ left: 20,
70
+ right: 20,
101
71
  top: 10,
102
72
  bottom: 10,
103
73
  }"
104
74
  :measures="measures"
105
- :onEdge="onItemEdge"
106
75
  :sendFocusRectEvent="true"
76
+ :onEdge="ONEDGE_TYPE.SPATIAL_NAV"
107
77
  >
108
78
  <template #renderItem="{ data, onAction, query }">
109
79
  <item
110
80
  :data="data"
111
81
  :onAction="onAction"
112
- :rowNum="props.rowNum"
113
82
  :queryInfo="query"
114
83
  />
115
84
  </template>
@@ -0,0 +1,113 @@
1
+ <script setup>
2
+ import {
3
+ HORIZONTAL,
4
+ MetroWidget,
5
+ useFocusHub,
6
+ ONEDGE_TYPE,
7
+ EdgeDirection,
8
+ SPATIAL_NAV_PROVIDER_NAME,
9
+ } from "jsview";
10
+ import { inject, shallowRef } from "vue";
11
+ import Item from "./Item.vue";
12
+
13
+ const props = defineProps({
14
+ data: Object,
15
+ onAction: Object,
16
+ queryInfo: Object,
17
+ });
18
+ const focusHub = useFocusHub();
19
+ const spatialNavProvider = inject(SPATIAL_NAV_PROVIDER_NAME, undefined);
20
+ const measures = (item) => {
21
+ return {
22
+ ...item,
23
+ bindSpatialNav: true,
24
+ };
25
+ };
26
+ const randomColor = () => {
27
+ let randomColor = Math.round(Math.random() * 2 ** 24).toString(16);
28
+ return (
29
+ "#" + new Array(6 - randomColor.length).fill("0").join("") + randomColor
30
+ );
31
+ };
32
+ const provideData = () => {
33
+ const data = [];
34
+ for (let i = 0; i < 6; i++) {
35
+ data.push({
36
+ left: i * 110,
37
+ width: 100,
38
+ height: 50,
39
+ marginRight: 10,
40
+ marginBottom: 10,
41
+ content: i,
42
+ color: randomColor(),
43
+ });
44
+ }
45
+ if (props.data.revert) {
46
+ data[0].top = 100;
47
+ data[1].top = 90;
48
+ data[2].top = 80;
49
+ data[3].top = 30;
50
+ data[4].top = 10;
51
+ data[5].top = 0;
52
+ } else {
53
+ data[0].top = 0;
54
+ data[1].top = 10;
55
+ data[2].top = 30;
56
+ data[3].top = 80;
57
+ data[4].top = 90;
58
+ data[5].top = 100;
59
+ }
60
+
61
+ return data;
62
+ };
63
+ const onFocus = (rect) => {
64
+ focusHub.setFocus(props.data.name);
65
+ };
66
+ const onBlur = () => {
67
+ //onBlur时需要返还焦点给父MetroWidget
68
+ focusHub.returnFocusToParent();
69
+ };
70
+
71
+ props.onAction.register("onFocus", onFocus);
72
+ props.onAction.register("onBlur", onBlur);
73
+
74
+ const onEdge = (rect) => {
75
+ console.log("myt onEdge", rect);
76
+ spatialNavProvider.moveTo(rect.direction, { yMoveType: "layerFirst" });
77
+ };
78
+ </script>
79
+
80
+ <template>
81
+ <div
82
+ :style="{
83
+ width: 900,
84
+ height: 50,
85
+ fontSize: 30,
86
+ color: '#FFFFFF',
87
+ }"
88
+ >
89
+ {{ data.name }}
90
+ </div>
91
+ <metro-widget
92
+ :name="data.name"
93
+ :top="40"
94
+ :width="900"
95
+ :height="250"
96
+ :provideData="provideData"
97
+ :direction="HORIZONTAL"
98
+ layoutType="absolute"
99
+ :padding="{
100
+ left: 20,
101
+ right: 20,
102
+ top: 10,
103
+ bottom: 10,
104
+ }"
105
+ :measures="measures"
106
+ :sendFocusRectEvent="true"
107
+ :onEdge="onEdge"
108
+ >
109
+ <template #renderItem="{ data, onAction, query }">
110
+ <item :data="data" :onAction="onAction" :queryInfo="query" />
111
+ </template>
112
+ </metro-widget>
113
+ </template>
@@ -0,0 +1,185 @@
1
+ <script setup>
2
+ import {
3
+ HORIZONTAL,
4
+ MetroWidget,
5
+ useFocusHub,
6
+ EdgeDirection,
7
+ SPATIAL_NAV_PROVIDER_NAME,
8
+ ONEDGE_TYPE,
9
+ } from "jsview";
10
+ import { shallowRef, inject } from "vue";
11
+ import Item from "../Item.vue";
12
+
13
+ /**
14
+ * 此组件由于tab和content的焦点切换逻辑不是就近原则,所以不需要设置autoOnEdge, 而是在onEdge回调中处理逻辑,并使用spatialNavProvider实现往外移动时的就近寻找焦点
15
+ */
16
+ const props = defineProps({
17
+ data: Object,
18
+ onAction: Object,
19
+ queryInfo: Object,
20
+ });
21
+ const focusHub = useFocusHub();
22
+ const spatialNavProvider = inject(SPATIAL_NAV_PROVIDER_NAME, undefined);
23
+ const randomColor = () => {
24
+ let randomColor = Math.round(Math.random() * 2 ** 24).toString(16);
25
+ return (
26
+ "#" + new Array(6 - randomColor.length).fill("0").join("") + randomColor
27
+ );
28
+ };
29
+
30
+ const tabName = props.data.name + "-tab";
31
+ const tabRef = shallowRef(null);
32
+ const tabData = [
33
+ {
34
+ name: "tab1",
35
+ content: "tab1",
36
+ width: 120,
37
+ height: 50,
38
+ marginRight: 10,
39
+ color: randomColor(),
40
+ },
41
+ {
42
+ name: "tab2",
43
+ content: "tab2",
44
+ width: 120,
45
+ height: 50,
46
+ marginRight: 10,
47
+ color: randomColor(),
48
+ },
49
+ {
50
+ name: "tab3",
51
+ content: "tab3",
52
+ width: 120,
53
+ height: 50,
54
+ marginRight: 10,
55
+ color: randomColor(),
56
+ },
57
+ ];
58
+ function tabProvideData() {
59
+ return tabData;
60
+ }
61
+ function tabMeasures(item) {
62
+ return {
63
+ ...item,
64
+ bindSpatialNav: true,
65
+ };
66
+ }
67
+ function tabOnFocus(item) {
68
+ focusHub.setFocus(tabName);
69
+ }
70
+ function tabOnBlur(item) {
71
+ focusHub.returnFocusToParent();
72
+ }
73
+ function tabOnEdge(rect) {
74
+ if (rect.direction == EdgeDirection.bottom) {
75
+ focusHub.setFocus(contentName);
76
+ } else {
77
+ spatialNavProvider.moveTo(rect.direction);
78
+ }
79
+ }
80
+ function tabOnFocusChange(id) {
81
+ if (id === curTab) return;
82
+ curTab = id;
83
+ contentRef.value.setFocusId(0);
84
+ contentRef.value.refreshData(true);
85
+ }
86
+
87
+ let curTab = 0;
88
+ const contentRef = shallowRef(null);
89
+ const contentName = props.data.name + "-content";
90
+ const contentData = {};
91
+ for (let i = 0; i < tabData.length; ++i) {
92
+ contentData[tabData[i].name] = [];
93
+ for (let j = 0; j < 10; ++j) {
94
+ contentData[tabData[i].name].push({
95
+ width: 100,
96
+ height: 170,
97
+ marginRight: 10,
98
+ marginBottom: 10,
99
+ content: j + " " + tabData[i].name,
100
+ color: randomColor(),
101
+ });
102
+ }
103
+ }
104
+ function contentProvideData() {
105
+ return contentData[tabData[curTab].name];
106
+ }
107
+ function contentMeasures(item) {
108
+ return {
109
+ ...item,
110
+ bindSpatialNav: true,
111
+ };
112
+ }
113
+ function contentOnFocus(item) {
114
+ focusHub.setFocus(item.name);
115
+ }
116
+ function contentOnBlur(item) {
117
+ focusHub.returnFocusToParent();
118
+ }
119
+ function contentOnEdge(rect) {
120
+ if (rect.direction == EdgeDirection.top) {
121
+ focusHub.setFocus(tabName);
122
+ } else {
123
+ spatialNavProvider.moveTo(rect.direction);
124
+ }
125
+ }
126
+
127
+ const onFocus = (rect) => {
128
+ focusHub.setFocus(tabName);
129
+ };
130
+ const onBlur = () => {
131
+ //onBlur时需要返还焦点给父MetroWidget
132
+ focusHub.returnFocusToParent();
133
+ };
134
+
135
+ props.onAction.register("onFocus", onFocus);
136
+ props.onAction.register("onBlur", onBlur);
137
+ </script>
138
+
139
+ <template>
140
+ <metro-widget
141
+ :name="tabName"
142
+ ref="tabRef"
143
+ :width="900"
144
+ :height="80"
145
+ :provideData="tabProvideData"
146
+ :direction="HORIZONTAL"
147
+ :padding="{
148
+ left: 10,
149
+ right: 10,
150
+ top: 10,
151
+ bottom: 10,
152
+ }"
153
+ :measures="tabMeasures"
154
+ :sendFocusRectEvent="true"
155
+ :onEdge="tabOnEdge"
156
+ :onFocusChange="tabOnFocusChange"
157
+ >
158
+ <template #renderItem="{ data, onAction, query }">
159
+ <item :data="data" :onAction="onAction" :queryInfo="query" />
160
+ </template>
161
+ </metro-widget>
162
+
163
+ <metro-widget
164
+ :name="contentName"
165
+ ref="contentRef"
166
+ :top="100"
167
+ :width="900"
168
+ :height="200"
169
+ :provideData="contentProvideData"
170
+ :direction="HORIZONTAL"
171
+ :padding="{
172
+ left: 10,
173
+ right: 10,
174
+ top: 10,
175
+ bottom: 10,
176
+ }"
177
+ :measures="contentMeasures"
178
+ :sendFocusRectEvent="true"
179
+ :onEdge="contentOnEdge"
180
+ >
181
+ <template #renderItem="{ data, onAction, query }">
182
+ <item :data="data" :onAction="onAction" :queryInfo="query" />
183
+ </template>
184
+ </metro-widget>
185
+ </template>
@@ -0,0 +1,69 @@
1
+ <script setup>
2
+ import {
3
+ MetroWidget,
4
+ VERTICAL,
5
+ HORIZONTAL,
6
+ useFocusHub,
7
+ METRO_WIDGET_CONST,
8
+ } from "jsview";
9
+ import WidgetItem from "./WidgetItem.vue";
10
+ import { onMounted, ref, shallowRef } from "vue";
11
+
12
+ const props = defineProps({
13
+ data: Object,
14
+ onAction: Object,
15
+ queryInfo: Object,
16
+ });
17
+
18
+ const focusHub = useFocusHub();
19
+ const mwWidget2 = ref(null);
20
+
21
+ const provideData = () => {
22
+ const data = [];
23
+ for (let i = 0; i < 4; i++) {
24
+ data.push({
25
+ width: 300,
26
+ height: 170,
27
+ name: "tripleSection" + i,
28
+ marginRight: 10,
29
+ index: i,
30
+ });
31
+ }
32
+ return data;
33
+ };
34
+
35
+ const measures = (item) => {
36
+ return {
37
+ width: item.width,
38
+ height: item.height,
39
+ marginRight: item.marginRight,
40
+ marginBottom: item.marginBottom,
41
+ itemSlide: METRO_WIDGET_CONST.ITEM_SLIDE.ACT_FOCUS_RECT_EVENT,
42
+ };
43
+ };
44
+
45
+ onMounted(() => {});
46
+
47
+ const onFocus = (rect) => {
48
+ focusHub.setFocus(props.data.name);
49
+ };
50
+
51
+ props.onAction.register("onFocus", onFocus);
52
+ </script>
53
+
54
+ <template>
55
+ <metro-widget
56
+ :name="data.name"
57
+ :width="900"
58
+ :height="250"
59
+ :provideData="provideData"
60
+ :padding="{ left: 10, right: 10, top: 10, bottom: 10 }"
61
+ :direction="HORIZONTAL"
62
+ :measures="measures"
63
+ :sendFocusRectEvent="true"
64
+ >
65
+ <template #renderItem="{ data, onAction, query }">
66
+ <widget-item :data="data" :onAction="onAction" :queryInfo="query" />
67
+ </template>
68
+ </metro-widget>
69
+ </template>
@@ -0,0 +1,100 @@
1
+ <script setup>
2
+ import {
3
+ HORIZONTAL,
4
+ MetroWidget,
5
+ useFocusHub,
6
+ EdgeDirection,
7
+ SPATIAL_NAV_PROVIDER_NAME,
8
+ ONEDGE_TYPE,
9
+ } from "jsview";
10
+ import { inject, ref } from "vue";
11
+ import Item from "../Item.vue";
12
+
13
+ const props = defineProps({
14
+ data: Object,
15
+ onAction: Object,
16
+ queryInfo: Object,
17
+ });
18
+ const focusHub = useFocusHub();
19
+
20
+ const measures = (item) => {
21
+ return {
22
+ ...item,
23
+ bindSpatialNav: true,
24
+ };
25
+ };
26
+ const isFocused = ref(false);
27
+ const randomColor = () => {
28
+ let randomColor = Math.round(Math.random() * 2 ** 24).toString(16);
29
+ return (
30
+ "#" + new Array(6 - randomColor.length).fill("0").join("") + randomColor
31
+ );
32
+ };
33
+ const provideData = () => {
34
+ const data = [];
35
+ for (let i = 0; i < 4; i++) {
36
+ data.push({
37
+ width: 100,
38
+ height: 150,
39
+ marginRight: 10,
40
+ content: i,
41
+ color: randomColor(),
42
+ });
43
+ }
44
+ return data;
45
+ };
46
+ const onFocus = (rect) => {
47
+ console.log("myt onFocus", props.data.name);
48
+ focusHub.setFocus(props.data.name);
49
+ isFocused.value = true;
50
+ };
51
+ const onBlur = () => {
52
+ isFocused.value = false;
53
+ console.log("myt onBlur", props.data.name);
54
+ };
55
+
56
+ props.onAction.register("onFocus", onFocus);
57
+ props.onAction.register("onBlur", onBlur);
58
+
59
+ </script>
60
+
61
+ <template>
62
+ <div
63
+ :style="{
64
+ width: 900,
65
+ height: 50,
66
+ fontSize: 30,
67
+ color: '#FFFFFF',
68
+ }"
69
+ >
70
+ {{ data.name }}
71
+ </div>
72
+ <div
73
+ :style="{
74
+ width: data.width,
75
+ height: data.height,
76
+ backgroundColor: isFocused ? '#009900' : '#000099',
77
+ }"
78
+ ></div>
79
+ <metro-widget
80
+ :name="data.name"
81
+ :top="50"
82
+ :width="data.width"
83
+ :height="data.height"
84
+ :provideData="provideData"
85
+ :direction="HORIZONTAL"
86
+ :padding="{
87
+ left: 10,
88
+ right: 10,
89
+ top: 10,
90
+ bottom: 10,
91
+ }"
92
+ :measures="measures"
93
+ :sendFocusRectEvent="true"
94
+ :onEdge="ONEDGE_TYPE.SPATIAL_NAV"
95
+ >
96
+ <template #renderItem="{ data, onAction, query }">
97
+ <item :data="data" :onAction="onAction" :queryInfo="query" />
98
+ </template>
99
+ </metro-widget>
100
+ </template>
@@ -0,0 +1,75 @@
1
+ <script setup>
2
+ import { VERTICAL, MetroWidget, useFocusHub, ONEDGE_TYPE } from "jsview";
3
+ import { shallowRef } from "vue";
4
+ import Item from "../Item.vue";
5
+
6
+ const props = defineProps({
7
+ data: Object,
8
+ onAction: Object,
9
+ queryInfo: Object,
10
+ });
11
+ const focusHub = useFocusHub();
12
+ const measures = (item) => {
13
+ return {
14
+ ...item,
15
+ bindSpatialNav: true,
16
+ };
17
+ };
18
+ const randomColor = () => {
19
+ let randomColor = Math.round(Math.random() * 2 ** 24).toString(16);
20
+ return (
21
+ "#" + new Array(6 - randomColor.length).fill("0").join("") + randomColor
22
+ );
23
+ };
24
+ const provideData = () => {
25
+ const data = [];
26
+ for (let i = 0; i < 5; i++) {
27
+ data.push({
28
+ width: 160,
29
+ height: 90,
30
+ marginBottom: 10,
31
+ content: i,
32
+ color: randomColor(),
33
+ });
34
+ }
35
+ return data;
36
+ };
37
+ const onFocus = (rect) => {
38
+ focusHub.setFocus(props.data.name);
39
+ };
40
+ const onBlur = () => {
41
+ //onBlur时需要返还焦点给父MetroWidget
42
+ focusHub.returnFocusToParent();
43
+ };
44
+
45
+ props.onAction.register("onFocus", onFocus);
46
+ props.onAction.register("onBlur", onBlur);
47
+ </script>
48
+
49
+ <template>
50
+ <div
51
+ :style="{
52
+ width: 900,
53
+ height: 50,
54
+ fontSize: 30,
55
+ color: '#FFFFFF',
56
+ }"
57
+ >
58
+ {{ data.name }}
59
+ </div>
60
+ <metro-widget
61
+ :name="data.name"
62
+ :width="180"
63
+ :height="600"
64
+ :provideData="provideData"
65
+ :direction="VERTICAL"
66
+ :measures="measures"
67
+ :sendFocusRectEvent="true"
68
+ :onEdge="ONEDGE_TYPE.SPATIAL_NAV"
69
+ :disableClip="true"
70
+ >
71
+ <template #renderItem="{ data, onAction, query }">
72
+ <item :data="data" :onAction="onAction" :queryInfo="query" />
73
+ </template>
74
+ </metro-widget>
75
+ </template>