@shijiu/jsview-vue 0.9.684 → 0.9.783

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 (154) hide show
  1. package/dom/bin/jsview-browser-debug-dom.min.js +1 -1
  2. package/dom/bin/jsview-dom.min.js +1 -1
  3. package/dom/bin/jsview-engine-js-browser.min.js +1 -1
  4. package/dom/bin/jsview-forge-define.min.js +1 -1
  5. package/dom/jsv-engine-js-browser.js +6 -0
  6. package/dom/target_core_revision.js +4 -4
  7. package/loader/loader.js +4 -0
  8. package/package.json +1 -1
  9. package/patches/node_modules/@vue/cli-service/lib/config/base.js +1 -1
  10. package/samples/AnimPicture/App.vue +5 -5
  11. package/samples/Basic/components/div/DivLayout.vue +1 -1
  12. package/samples/Basic/components/img/ImageGroup.vue +2 -2
  13. package/samples/Basic/components/img/ImgLayout.vue +79 -15
  14. package/samples/Basic/components/text/TextDirection.vue +104 -0
  15. package/samples/Basic/components/text/TextEmoji.vue +1 -1
  16. package/samples/Basic/components/text/TextGroup1.vue +1 -1
  17. package/samples/Basic/components/text/TextGroup2.vue +11 -1
  18. package/samples/BasicFocusControl/components/BaseBlock.vue +2 -2
  19. package/samples/Collision/App.vue +11 -11
  20. package/samples/DemoHomepage/App.vue +67 -8
  21. package/samples/DemoHomepage/components/TabFrame.vue +7 -0
  22. package/samples/DemoHomepage/router.js +27 -26
  23. package/samples/DemoHomepage/views/Homepage.vue +89 -98
  24. package/samples/FilterDemo/App.vue +1 -1
  25. package/samples/FlipCard/App.vue +2 -2
  26. package/samples/FlipCard/FlipCard.vue +3 -3
  27. package/samples/FocusBlockDemos/AutoFocus/App.vue +51 -0
  28. package/samples/FocusBlockDemos/AutoFocus/BaseBlock.vue +82 -0
  29. package/samples/FocusBlockDemos/AutoFocus/DialogBlock.vue +89 -0
  30. package/samples/FocusBlockDemos/AutoFocus/DialogContorls.js +42 -0
  31. package/samples/FocusBlockDemos/AutoFocus/FocusNamesDefine.js +9 -0
  32. package/samples/FocusBlockDemos/AutoFocus/PlaneBlock.vue +71 -0
  33. package/samples/FocusBlockDemos/ProgressiveFocusControl/App.vue +78 -0
  34. package/samples/FocusBlockDemos/ProgressiveFocusControl/BaseBlock.vue +77 -0
  35. package/samples/FocusBlockDemos/ProgressiveFocusControl/DownPlaneBlock.vue +83 -0
  36. package/samples/FocusBlockDemos/ProgressiveFocusControl/FocusNamesDefine.js +12 -0
  37. package/samples/FocusBlockDemos/ProgressiveFocusControl/UpPlaneBlock.vue +83 -0
  38. package/samples/GridDemo/App.vue +3 -3
  39. package/samples/GridDemo/ButtonBlock.vue +2 -2
  40. package/samples/GridDemo/FocusItem.vue +2 -2
  41. package/samples/GridDemo/Item.vue +1 -1
  42. package/samples/HashHistory/App.vue +10 -3
  43. package/samples/HashHistory/components/Item.vue +1 -1
  44. package/samples/ImpactStop/App.vue +15 -11
  45. package/samples/Input/InputPanel.vue +1 -1
  46. package/samples/LongImage/Button.vue +1 -1
  47. package/samples/LongImage/ButtonItem.vue +1 -1
  48. package/samples/LongImage/LongImageScroll.vue +2 -2
  49. package/samples/LongText/App.vue +1 -1
  50. package/samples/LongText/Button.vue +1 -1
  51. package/samples/LongText/ButtonItem.vue +1 -1
  52. package/samples/LongText/LongTextScroll.vue +3 -3
  53. package/samples/Marquee/App.vue +34 -3
  54. package/samples/Marquee/longText.js +2 -2
  55. package/samples/MetroWidgetDemos/PerformanceTest/App.vue +4 -4
  56. package/samples/MetroWidgetDemos/PerformanceTest/components/ContentItem.vue +1 -1
  57. package/samples/MetroWidgetDemos/PerformanceTest/components/MyTab.vue +3 -3
  58. package/samples/MetroWidgetDemos/PingPong/App.vue +22 -11
  59. package/samples/MetroWidgetDemos/PingPong/AppPage.vue +5 -5
  60. package/samples/MetroWidgetDemos/{Item.vue → PingPong/Item.vue} +3 -21
  61. package/samples/MetroWidgetDemos/PingPong/TabItem.vue +1 -1
  62. package/samples/MetroWidgetDemos/PingPong/ViewSwiper.vue +5 -5
  63. package/samples/MetroWidgetDemos/{WidgetItem.vue → PingPong/WidgetItem.vue} +8 -4
  64. package/samples/MetroWidgetDemos/basic/App.vue +162 -0
  65. package/samples/MetroWidgetDemos/basic/Item.vue +43 -0
  66. package/samples/MetroWidgetDemos/direction/App.vue +158 -0
  67. package/samples/MetroWidgetDemos/direction/Item.vue +45 -0
  68. package/samples/MetroWidgetDemos/focusableItemBasic/App.vue +67 -0
  69. package/samples/MetroWidgetDemos/{Advanced → focusableItemBasic}/ButtonItem.vue +17 -21
  70. package/samples/MetroWidgetDemos/focusableItemMetroWidget/App.vue +74 -0
  71. package/samples/MetroWidgetDemos/{Advanced/widgets → focusableItemMetroWidget}/Item.vue +13 -32
  72. package/samples/MetroWidgetDemos/{Advanced/widgets → focusableItemMetroWidget}/WidgetItem.vue +12 -12
  73. package/samples/MetroWidgetDemos/focusableItemMix/App.vue +88 -0
  74. package/samples/MetroWidgetDemos/focusableItemMix/ButtonItem.vue +86 -0
  75. package/samples/MetroWidgetDemos/focusableItemMix/Item.vue +43 -0
  76. package/samples/MetroWidgetDemos/index.js +6 -0
  77. package/samples/MetroWidgetDemos/layoutType/App.vue +180 -0
  78. package/samples/MetroWidgetDemos/layoutType/Item.vue +45 -0
  79. package/samples/MetroWidgetDemos/padding/App.vue +222 -0
  80. package/samples/MetroWidgetDemos/padding/Item.vue +64 -0
  81. package/samples/MetroWidgetDemos/routeList.js +64 -0
  82. package/samples/MetroWidgetDemos/slideSetting/App.vue +225 -0
  83. package/samples/MetroWidgetDemos/slideSetting/Item.vue +45 -0
  84. package/samples/NinePatchDemo/App.vue +78 -122
  85. package/samples/NinePatchDemo/Item.vue +29 -27
  86. package/samples/Preload/App.vue +1 -1
  87. package/samples/Preload/Item.vue +1 -1
  88. package/samples/QrcodeDemo/App.vue +1 -1
  89. package/samples/SoundPool/App.vue +3 -3
  90. package/samples/SpriteImage/App.vue +5 -0
  91. package/samples/Swiper/App.vue +148 -0
  92. package/samples/TextBox/App.vue +2 -1
  93. package/samples/TextureAnimation/App2.vue +1 -1
  94. package/samples/ThrowMoveDemo/LRParabolicDemo.vue +33 -47
  95. package/samples/TouchSample/MetroWidgetHorizontal.vue +1 -1
  96. package/samples/TouchSample/MetroWidgetVertical.vue +1 -1
  97. package/samples/TransitPage/App.vue +1 -1
  98. package/samples/VideoDemo/App.vue +8 -8
  99. package/samples/VideoDemo/components/Button.vue +1 -1
  100. package/samples/VideoDemo/components/Controllor.vue +1 -1
  101. package/samples/VisibleSensorDemo/App.vue +3 -3
  102. package/scripts/jsview-run-android.js +5 -4
  103. package/utils/JsViewEngineWidget/JsvFocusBlock.vue +4 -4
  104. package/utils/JsViewEngineWidget/MetroWidget/MetroWidget.vue +79 -50
  105. package/utils/JsViewEngineWidget/TemplateParser.js +144 -147
  106. package/utils/JsViewEngineWidget/WidgetCommon.js +12 -3
  107. package/utils/JsViewPlugin/BrowserPluginLoader.js +4 -2
  108. package/utils/JsViewPlugin/JsvAudio/AudioProxy.js +302 -0
  109. package/utils/JsViewPlugin/JsvAudio/CheckType.js +68 -0
  110. package/utils/JsViewPlugin/JsvAudio/Events.js +17 -0
  111. package/utils/JsViewPlugin/JsvAudio/JsvAudio.vue +176 -0
  112. package/utils/JsViewPlugin/JsvAudio/JsvAudioBridgeProxy.js +40 -0
  113. package/utils/JsViewPlugin/JsvAudio/JsvAudioBrowser.vue +46 -0
  114. package/utils/JsViewPlugin/JsvAudio/PluginLoader.js +140 -0
  115. package/utils/JsViewPlugin/JsvAudio/index.js +26 -0
  116. package/utils/JsViewPlugin/JsvAudio/version.js +24 -0
  117. package/utils/JsViewPlugin/JsvPlayer/index.js +1 -1
  118. package/utils/JsViewPlugin/JsvPlayer/version.js +5 -5
  119. package/utils/JsViewVueTools/JsvHashHistory.js +34 -8
  120. package/utils/JsViewVueTools/JsvImpactTracer.js +2 -2
  121. package/utils/JsViewVueTools/JsvRuntimeBridge.js +46 -8
  122. package/utils/JsViewVueTools/JsvStyleClass.js +9 -0
  123. package/utils/{JsViewVueWidget/utils/text.js → JsViewVueTools/JsvTextTools.js} +24 -4
  124. package/utils/JsViewVueTools/TypeCheckAndSet.js +3 -3
  125. package/utils/JsViewVueTools/index.js +2 -1
  126. package/utils/JsViewVueWidget/BrowserDebugWidget/BrowserTextureAnim.vue +5 -7
  127. package/utils/JsViewVueWidget/JsvActorMove/JsvActorMove.vue +20 -22
  128. package/utils/JsViewVueWidget/JsvApic/JsvApic.vue +4 -4
  129. package/utils/JsViewVueWidget/JsvGrid.vue +1 -9
  130. package/utils/JsViewVueWidget/JsvInput/Cursor.vue +1 -1
  131. package/utils/JsViewVueWidget/JsvMarquee.vue +91 -20
  132. package/utils/JsViewVueWidget/JsvMaskClipDiv.vue +1 -1
  133. package/utils/JsViewVueWidget/JsvNinePatch.vue +63 -53
  134. package/utils/JsViewVueWidget/JsvSpray/JsvSpray.vue +10 -5
  135. package/utils/JsViewVueWidget/JsvSpriteAnim/JsvSpriteAnim.vue +2 -2
  136. package/utils/JsViewVueWidget/JsvSwiper/JsvSwiper.vue +116 -80
  137. package/utils/JsViewVueWidget/JsvSwiper/index.js +3 -2
  138. package/utils/JsViewVueWidget/JsvSwiper3D/JsvSwiper.vue +1 -1
  139. package/utils/JsViewVueWidget/JsvTextBox.vue +11 -31
  140. package/utils/JsViewVueWidget/JsvTouchContainer.vue +2 -2
  141. package/utils/JsViewVueWidget/JsvTransparentDiv.vue +1 -1
  142. package/utils/JsViewVueWidget/JsvVisibleSensor/JsvVisibleSensor.vue +5 -5
  143. package/utils/JsViewVueWidget/index.js +8 -8
  144. package/samples/MetroWidgetDemos/Advanced/App.vue +0 -46
  145. package/samples/MetroWidgetDemos/Advanced/Buttons.vue +0 -70
  146. package/samples/MetroWidgetDemos/Advanced/Mixed.vue +0 -77
  147. package/samples/MetroWidgetDemos/Advanced/widgets/Widgets.vue +0 -116
  148. package/samples/MetroWidgetDemos/Advanced/widgets/focus1.png +0 -0
  149. package/samples/MetroWidgetDemos/Simple/AbsoluteTemplate.vue +0 -75
  150. package/samples/MetroWidgetDemos/Simple/App.vue +0 -45
  151. package/samples/MetroWidgetDemos/Simple/RelativeTemplate.vue +0 -111
  152. package/samples/MetroWidgetDemos/data.js +0 -205
  153. package/utils/JsViewVueWidget/JsvSwiper/Indicator.vue +0 -35
  154. package/utils/JsViewVueWidget/utils/index.js +0 -8
@@ -0,0 +1,67 @@
1
+ <!--
2
+ * @Author: ChenChanghua
3
+ * @Date: 2022-07-11 13:31:36
4
+ * @Description: file content
5
+ -->
6
+ <script setup>
7
+ import { MetroWidget, HORIZONTAL, EdgeDirection, useFocusHub } from "jsview";
8
+ import { onMounted } from "vue";
9
+ import ButtonItem from "./ButtonItem.vue";
10
+
11
+ const focusHub = useFocusHub();
12
+ window.focusHub = focusHub
13
+ const provideData = () => {
14
+ const data = [];
15
+ for (let i = 0; i < 20; i++) {
16
+ data.push({
17
+ width: 200,
18
+ height: 100,
19
+ name: "button_" + i,
20
+ marginRight: 10,
21
+ marginBottom: 10,
22
+ });
23
+ }
24
+ return data;
25
+ };
26
+ const measures = (item) => {
27
+ return {
28
+ width: item.width,
29
+ height: item.height,
30
+ marginRight: item.marginRight,
31
+ marginBottom: item.marginBottom,
32
+ };
33
+ };
34
+
35
+ onMounted(() => {
36
+ focusHub.setFocus("mwButton");
37
+ });
38
+ </script>
39
+
40
+ <template>
41
+ <div
42
+ :style="{
43
+ left: 50,
44
+ top: 20,
45
+ width: 600,
46
+ height: 400,
47
+ fontSize: 30,
48
+ color: '#FFFFFF',
49
+ }"
50
+ >
51
+ {{ "item组件包含JsvFocusBlock, 从而每个item可以在自己内部处理按键事件" }}
52
+ </div>
53
+ <metro-widget
54
+ name="mwButton"
55
+ :top="120"
56
+ :left="50"
57
+ :provideData="provideData"
58
+ :width="600"
59
+ :height="400"
60
+ :direction="HORIZONTAL"
61
+ :measures="measures"
62
+ >
63
+ <template #renderItem="{ data, onAction }">
64
+ <button-item :data="data" :onAction="onAction" />
65
+ </template>
66
+ </metro-widget>
67
+ </template>
@@ -1,37 +1,34 @@
1
1
  <!--
2
2
  * @Author: ChenChanghua
3
- * @Date: 2022-07-11 13:26:24
4
- * @LastEditors: ChenChanghua
5
- * @LastEditTime: 2022-11-02 15:37:33
6
- * @Description: file content
3
+ * @Date: 2023-03-09 14:19:01
4
+ * @Description: 一个简单的按左右键, 焦点在左右两个view来回切换的控件
7
5
  -->
8
6
  <script setup>
9
- import { ref } from "vue";
7
+ import { ref, shallowRef } from "vue";
10
8
  import { useFocusHub } from "jsview";
11
9
 
12
10
  const props = defineProps({
13
11
  data: Object,
14
- query: String,
15
12
  onAction: Object,
16
- onItemEdge: Function,
17
13
  });
18
14
  const focusHub = useFocusHub();
19
15
 
20
- let focusIndex = ref(0);
21
16
  let focused = ref(false);
22
- let focusBlock = ref(null);
23
-
17
+ let focusIndex = ref(0);
24
18
  const onFocus = () => {
25
- //onFocus时, 获得焦点, 以处理自己内部的焦点逻辑
19
+ /**重要代码: onFocus时, 获得焦点, 以处理自己内部的焦点逻辑*/
26
20
  focusHub.setFocus(props.data.name);
21
+ /*******/
27
22
  focused.value = true;
28
23
  };
29
24
  const onBlur = () => {
30
25
  focused.value = false;
31
26
  focusIndex.value = 0;
32
- //onBlur的时候, 需要将焦点返还给父
33
- focusBlock.value?.returnFocusToParent();
27
+ /**重要代码: onBlur的时候, 需要将焦点返还给父*/
28
+ focusHub.returnFocusToParent();
29
+ /*******/
34
30
  };
31
+
35
32
  const onKeyDown = (ev) => {
36
33
  if (ev.keyCode == 37 && focusIndex.value == 1) {
37
34
  focusIndex.value = 0;
@@ -52,7 +49,6 @@ props.onAction.register("onBlur", onBlur);
52
49
 
53
50
  <template>
54
51
  <jsv-focus-block
55
- ref="focusBlock"
56
52
  :name="data.name"
57
53
  :onAction="{
58
54
  onKeyDown: onKeyDown,
@@ -60,8 +56,8 @@ props.onAction.register("onBlur", onBlur);
60
56
  >
61
57
  <div
62
58
  :style="{
63
- width: 50,
64
- height: 50,
59
+ width: 100,
60
+ height: 100,
65
61
  fontSize: 20,
66
62
  color: '#FFFFFF',
67
63
  backgroundColor: '#00AA00',
@@ -70,17 +66,17 @@ props.onAction.register("onBlur", onBlur);
70
66
 
71
67
  <div
72
68
  :style="{
73
- left: 50,
74
- width: 50,
75
- height: 50,
69
+ left: 100,
70
+ width: 100,
71
+ height: 100,
76
72
  backgroundColor: '#0000AA',
77
73
  }"
78
74
  ></div>
79
75
 
80
76
  <div
81
77
  :style="{
82
- visibility: this.focused ? 'visible' : 'hidden',
83
- left: 50 * focusIndex,
78
+ visibility: focused ? 'visible' : 'hidden',
79
+ left: 100 * focusIndex,
84
80
  width: 10,
85
81
  height: 10,
86
82
  backgroundColor: '#FF0000',
@@ -0,0 +1,74 @@
1
+ <!--
2
+ * @Author: ChenChanghua
3
+ * @Date: 2022-07-11 13:31:36
4
+ * @Description: file content
5
+ -->
6
+ <script setup>
7
+ import { MetroWidget, VERTICAL, EdgeDirection, useFocusHub } from "jsview";
8
+ import WidgetItem from "./WidgetItem.vue";
9
+ import { onMounted } from "vue";
10
+
11
+ const focusHub = useFocusHub();
12
+
13
+ const provideData = () => {
14
+ const data = [];
15
+ for (let i = 0; i < 10; i++) {
16
+ data.push({
17
+ width: 500,
18
+ height: 170,
19
+ name: "widget_" + i,
20
+ marginBottom: 10,
21
+ index: i,
22
+ });
23
+ }
24
+ return data;
25
+ };
26
+
27
+ const measures = (item) => {
28
+ return {
29
+ width: item.width,
30
+ height: item.height,
31
+ marginRight: item.marginRight,
32
+ marginBottom: item.marginBottom,
33
+ /**重要代码: doSlide设置为false, 由子MetroWidget控制滚动 */
34
+ doSlide: false,
35
+ };
36
+ };
37
+
38
+ onMounted(() => {
39
+ focusHub.setFocus("mwWidget");
40
+ });
41
+ </script>
42
+
43
+ <template>
44
+ <div :style="{ width: 1920, height: 1080, backgroundColor: '#007788' }" />
45
+ <div
46
+ :style="{
47
+ left: 100,
48
+ top: 20,
49
+ width: 600,
50
+ height: 400,
51
+ fontSize: 30,
52
+ color: '#FFFFFF',
53
+ }"
54
+ >
55
+ {{ `MetroWidget的item是包含MetroWidget的组件` }}
56
+ </div>
57
+ <!-- 为了保证边缘的item缩放后依旧完整显示, 需要设置padding, 注意width/height是包含padding的 -->
58
+ <metro-widget
59
+ name="mwWidget"
60
+ :top="140"
61
+ :left="50"
62
+ :width="660"
63
+ :height="600"
64
+ :provideData="provideData"
65
+ :padding="{ left: 30, right: 30 }"
66
+ :direction="VERTICAL"
67
+ :measures="measures"
68
+ >
69
+ <!-- 重要代码: 为了实现焦点就近移动, 需要传递onItemEdge回调 -->
70
+ <template #renderItem="{ data, onAction, onItemEdge }">
71
+ <widget-item :data="data" :onAction="onAction" :onItemEdge="onItemEdge" />
72
+ </template>
73
+ </metro-widget>
74
+ </template>
@@ -1,47 +1,21 @@
1
1
  <!--
2
2
  * @Author: ChenChanghua
3
- * @Date: 2022-11-01 15:30:14
4
- * @LastEditors: ChenChanghua
5
- * @LastEditTime: 2022-11-02 15:39:17
6
- * @Description: file content
7
- -->
8
- <!--
9
- * @Author: ChenChanghua
10
- * @Date: 2022-05-10 15:21:24
11
- * @LastEditors: ChenChanghua
12
- * @LastEditTime: 2022-11-01 15:24:26
3
+ * @Date: 2023-03-09 15:33:54
13
4
  * @Description: file content
14
5
  -->
15
6
  <script setup>
16
- import { ref, inject } from "vue";
7
+ import { ref, shallowRef, inject } from "vue";
17
8
 
18
9
  const props = defineProps({
19
10
  data: Object,
20
- query: Object,
21
11
  onAction: Object,
22
12
  });
23
13
 
24
- const divRef = ref(null);
25
14
  const focused = ref(false);
26
15
 
27
- const focusSize = inject("focusSize");
28
-
29
16
  // 自身的焦点状态自己记录, 通过回调来改变
30
17
  const onFocus = () => {
31
18
  focused.value = true;
32
- if (focusSize) {
33
- divRef.value?.getBoundingClientRect().then(
34
- (data) => {
35
- focusSize.width = data.width;
36
- focusSize.height = data.height;
37
- focusSize.left = data.left;
38
- focusSize.top = data.top;
39
- },
40
- (error) => {
41
- console.log("get absolute position failed", error);
42
- }
43
- );
44
- }
45
19
  };
46
20
  const onBlur = () => {
47
21
  focused.value = false;
@@ -66,15 +40,22 @@ props.onAction.register("onClick", onClick);
66
40
  }"
67
41
  >
68
42
  <div
69
- ref="divRef"
43
+ v-if="focused"
44
+ :style="{
45
+ left: -2,
46
+ top: -2,
47
+ width: data.width + 4,
48
+ height: data.height + 4,
49
+ backgroundColor: '#FF0000',
50
+ }"
51
+ />
52
+ <div
70
53
  :style="{
71
54
  width: data.width,
72
55
  height: data.height,
73
- fontSize: '30px',
56
+ fontSize: 30,
74
57
  color: '#FFFFFF',
75
58
  backgroundColor: data.color,
76
- borderRadius: '10px',
77
- animation: animation,
78
59
  }"
79
60
  >
80
61
  {{ data.content }}
@@ -1,17 +1,16 @@
1
1
 
2
2
  <script setup>
3
3
  import { HORIZONTAL, MetroWidget, useFocusHub } from "jsview";
4
- import { ref } from "vue";
4
+ import { ref, shallowRef } from "vue";
5
5
  import Item from "./Item.vue";
6
6
 
7
7
  const props = defineProps({
8
8
  data: Object,
9
- query: Object,
10
9
  onItemEdge: Function,
11
10
  onAction: Object,
12
11
  });
13
12
  const focusHub = useFocusHub();
14
- const mwRef = ref(null);
13
+ const mwRef = shallowRef(null);
15
14
 
16
15
  const measures = (item) => {
17
16
  return item;
@@ -37,13 +36,15 @@ const provideData = () => {
37
36
  return data;
38
37
  };
39
38
  const onFocus = (rect) => {
40
- //获得焦点时需要做就近移动的处理, 因此需要通过setEnterFocusRect设置寻找最近焦点的区域
39
+ /** 重要代码: 参数rect为父MetroWidget传递的, 焦点过来的区域
40
+ * 因此需要调用setEnterFocusRect来设置焦点进入区域, 以寻找最近的焦点
41
+ */
41
42
  mwRef.value?.setEnterFocusRect(rect);
42
43
  focusHub.setFocus(props.data.name);
43
44
  };
44
45
  const onBlur = () => {
45
46
  //onBlur时需要返还焦点给父MetroWidget
46
- mwRef.value?.getFocusBlockRef().returnFocusToParent();
47
+ focusHub.returnFocusToParent();
47
48
  };
48
49
 
49
50
  props.onAction.register("onFocus", onFocus);
@@ -61,15 +62,15 @@ props.onAction.register("onBlur", onBlur);
61
62
  >
62
63
  {{ data.name }}
63
64
  </div>
64
- <!-- sendFocusRectEvent可以让MetroWidget的item在获焦时发送事件, 通知父的MetroWidget进行滚动 -->
65
- <!-- onItemEdge直接作为onEdge回调, 既子MetroWidget到达边缘时触发父的onItemEdge -->
65
+ <!-- 重要代码: sendFocusRectEvent可以让MetroWidget的item在获焦时发送事件, 通知父的MetroWidget进行滚动 -->
66
+ <!-- 重要代码: onItemEdge直接作为onEdge回调, 既子MetroWidget到达边缘时触发父的onItemEdge -->
66
67
  <metro-widget
67
68
  ref="mwRef"
68
- :top="50"
69
69
  :name="data.name"
70
- :provideData="provideData"
70
+ :top="50"
71
71
  :width="data.width"
72
72
  :height="data.height"
73
+ :provideData="provideData"
73
74
  :direction="HORIZONTAL"
74
75
  :padding="{
75
76
  left: 30,
@@ -78,12 +79,11 @@ props.onAction.register("onBlur", onBlur);
78
79
  bottom: 10,
79
80
  }"
80
81
  :measures="measures"
81
- :slideSetting="seamlessSlide"
82
82
  :onEdge="onItemEdge"
83
83
  :sendFocusRectEvent="true"
84
84
  >
85
- <template #renderItem="{ data, query, onAction }">
86
- <item :data="data" :query="query" :onAction="onAction" />
85
+ <template #renderItem="{ data, onAction }">
86
+ <item :data="data" :onAction="onAction" />
87
87
  </template>
88
88
  </metro-widget>
89
89
  </template>
@@ -0,0 +1,88 @@
1
+ <!--
2
+ * @Author: ChenChanghua
3
+ * @Date: 2022-07-11 13:31:36
4
+ * @LastEditors: Please set LastEditors
5
+ * @LastEditTime: 2023-03-09 15:31:53
6
+ * @Description: file content
7
+ -->
8
+ <script setup>
9
+ import { MetroWidget, HORIZONTAL, EdgeDirection, useFocusHub } from "jsview";
10
+ import ButtonItem from "./ButtonItem.vue";
11
+ import Item from "./Item.vue";
12
+ import { onMounted } from "vue";
13
+
14
+ const focusHub = useFocusHub();
15
+
16
+ const randomColor = () => {
17
+ let randomColor = Math.round(Math.random() * 2 ** 24).toString(16);
18
+ return (
19
+ "#" + new Array(6 - randomColor.length).fill("0").join("") + randomColor
20
+ );
21
+ };
22
+ //item混排的回调
23
+ const provideData = () => {
24
+ const advanceMix = [];
25
+ for (let i = 0; i < 20; i++) {
26
+ advanceMix.push({
27
+ width: 200,
28
+ height: 100,
29
+ name: "mix_button_" + i,
30
+ marginRight: 10,
31
+ marginBottom: 10,
32
+ type: i % 2 == 0 ? "button" : "item",
33
+ color: randomColor(),
34
+ content: i,
35
+ });
36
+ }
37
+ return advanceMix;
38
+ };
39
+ const measures = (item) => {
40
+ return {
41
+ width: item.width,
42
+ height: item.height,
43
+ marginRight: item.marginRight,
44
+ marginBottom: item.marginBottom,
45
+ };
46
+ };
47
+
48
+ const onEdge = (edgeInfo) => {};
49
+
50
+ onMounted(() => {
51
+ focusHub.setFocus("mwMix");
52
+ });
53
+ </script>
54
+
55
+ <template>
56
+ <div
57
+ :style="{
58
+ left: 50,
59
+ top: 10,
60
+ width: 600,
61
+ height: 400,
62
+ fontSize: 30,
63
+ color: '#FFFFFF',
64
+ }"
65
+ >
66
+ {{ "包含JsvFocusBlock的组件和纯描画组件混排" }}
67
+ </div>
68
+ <metro-widget
69
+ name="mwMix"
70
+ :top="100"
71
+ :left="50"
72
+ :provideData="provideData"
73
+ :width="600"
74
+ :height="400"
75
+ :direction="VERTICAL"
76
+ :measures="measures"
77
+ :onEdge="onEdge"
78
+ >
79
+ <template #renderItem="{ data, onAction }">
80
+ <button-item
81
+ v-if="data.type == 'button'"
82
+ :data="data"
83
+ :onAction="onAction"
84
+ />
85
+ <item v-else :data="data" :onAction="onAction" />
86
+ </template>
87
+ </metro-widget>
88
+ </template>
@@ -0,0 +1,86 @@
1
+ <!--
2
+ * @Author: ChenChanghua
3
+ * @Date: 2023-03-09 14:19:01
4
+ * @Description: 一个简单的按左右键, 焦点在左右两个view来回切换的控件
5
+ -->
6
+ <script setup>
7
+ import { ref, shallowRef } from "vue";
8
+ import { useFocusHub } from "jsview";
9
+
10
+ const props = defineProps({
11
+ data: Object,
12
+ onAction: Object,
13
+ });
14
+ const focusHub = useFocusHub();
15
+
16
+ let focused = ref(false);
17
+ let focusIndex = ref(0);
18
+ const onFocus = () => {
19
+ /**重要代码: onFocus时, 获得焦点, 以处理自己内部的焦点逻辑*/
20
+ focusHub.setFocus(props.data.name);
21
+ /*******/
22
+ focused.value = true;
23
+ };
24
+ const onBlur = () => {
25
+ focused.value = false;
26
+ focusIndex.value = 0;
27
+ /**重要代码: onBlur的时候, 需要将焦点返还给父*/
28
+ focusHub.returnFocusToParent();
29
+ /*******/
30
+ };
31
+
32
+ const onKeyDown = (ev) => {
33
+ if (ev.keyCode == 37 && focusIndex.value == 1) {
34
+ focusIndex.value = 0;
35
+ return true;
36
+ } else if (ev.keyCode == 39 && focusIndex.value == 0) {
37
+ focusIndex.value = 1;
38
+ return true;
39
+ } else if (ev.keyCode == 13) {
40
+ console.log("button click", props.data);
41
+ return true;
42
+ }
43
+ return false;
44
+ };
45
+
46
+ props.onAction.register("onFocus", onFocus);
47
+ props.onAction.register("onBlur", onBlur);
48
+ </script>
49
+
50
+ <template>
51
+ <jsv-focus-block
52
+ :name="data.name"
53
+ :onAction="{
54
+ onKeyDown: onKeyDown,
55
+ }"
56
+ >
57
+ <div
58
+ :style="{
59
+ width: 100,
60
+ height: 100,
61
+ fontSize: 20,
62
+ color: '#FFFFFF',
63
+ backgroundColor: '#00AA00',
64
+ }"
65
+ ></div>
66
+
67
+ <div
68
+ :style="{
69
+ left: 100,
70
+ width: 100,
71
+ height: 100,
72
+ backgroundColor: '#0000AA',
73
+ }"
74
+ ></div>
75
+
76
+ <div
77
+ :style="{
78
+ visibility: focused ? 'visible' : 'hidden',
79
+ left: 100 * focusIndex,
80
+ width: 10,
81
+ height: 10,
82
+ backgroundColor: '#FF0000',
83
+ }"
84
+ ></div>
85
+ </jsv-focus-block>
86
+ </template>
@@ -0,0 +1,43 @@
1
+ <!--
2
+ * @Author: ChenChanghua
3
+ * @Date: 2023-03-09 15:05:27
4
+ * @Description: file content
5
+ -->
6
+ <script setup>
7
+ import { ref, shallowRef, inject } from "vue";
8
+
9
+ const props = defineProps({
10
+ data: Object,
11
+ onAction: Object,
12
+ });
13
+
14
+ const focused = ref(false);
15
+
16
+ // 注册回调
17
+ const onFocus = () => {
18
+ focused.value = true;
19
+ };
20
+ const onBlur = () => {
21
+ focused.value = false;
22
+ };
23
+ const onClick = () => {
24
+ console.log("item onclick ", props.data);
25
+ };
26
+ props.onAction.register("onFocus", onFocus);
27
+ props.onAction.register("onBlur", onBlur);
28
+ props.onAction.register("onClick", onClick);
29
+ </script>
30
+
31
+ <template>
32
+ <div
33
+ :style="{
34
+ width: data.width,
35
+ height: data.height,
36
+ fontSize: 30,
37
+ color: focused ? '#FF0000' : '#FFFFFF',
38
+ backgroundColor: data.color,
39
+ }"
40
+ >
41
+ {{ data.content }}
42
+ </div>
43
+ </template>
@@ -0,0 +1,6 @@
1
+ /*
2
+ * @Author: ChenChanghua
3
+ * @Date: 2023-03-09 14:03:58
4
+ * @Description: file content
5
+ */
6
+ export { default as metroWidgetRouteList } from "./routeList"