@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
@@ -2,15 +2,15 @@
2
2
  * @Author: ChenChanghua
3
3
  * @Date: 2021-09-29 16:13:35
4
4
  * @LastEditors: ChenChanghua
5
- * @LastEditTime: 2021-09-29 17:07:19
5
+ * @LastEditTime: 2022-12-02 16:14:11
6
6
  * @Description: file content
7
7
  -->
8
8
  <script>
9
- import { ref } from "vue";
9
+ import { ref, shallowRef } from "vue";
10
10
 
11
11
  export default {
12
12
  props: {
13
- name: Object,
13
+ name: String,
14
14
  onEdgeDown: Function,
15
15
  onItemFocus: Function,
16
16
  },
@@ -1,8 +1,8 @@
1
1
  <!--
2
2
  * @Author: ChenChanghua
3
3
  * @Date: 2021-12-21 15:36:29
4
- * @LastEditors: ChenChanghua
5
- * @LastEditTime: 2022-09-01 17:08:21
4
+ * @LastEditors: Please set LastEditors
5
+ * @LastEditTime: 2023-03-09 16:28:50
6
6
  * @Description: file content
7
7
  -->
8
8
  <script>
@@ -10,12 +10,18 @@ import ViewSwiper from "./ViewSwiper.vue";
10
10
  import AppTab from "./AppTab.vue";
11
11
  import { reactive } from "vue";
12
12
  import { EdgeDirection } from "jsview";
13
- import { advanceMetroWidget, randomColor } from "../data.js";
14
13
 
15
14
  const pageList = [];
16
15
  const tabData = [];
17
16
 
18
- for (let i = 0; i < 5; i++) {
17
+ const randomColor = () => {
18
+ let randomColor = Math.round(Math.random() * 2 ** 24).toString(16);
19
+ return (
20
+ "#" + new Array(6 - randomColor.length).fill("0").join("") + randomColor
21
+ );
22
+ };
23
+
24
+ for (let i = 0; i < 10; ++i) {
19
25
  tabData.push({
20
26
  width: 100,
21
27
  height: 50,
@@ -23,15 +29,20 @@ for (let i = 0; i < 5; i++) {
23
29
  content: "Tab_" + i,
24
30
  color: randomColor(),
25
31
  });
26
-
27
- let data = JSON.parse(JSON.stringify(advanceMetroWidget));
28
- data.forEach((item) => {
29
- item.name = "testPage_" + i + "-" + item.name;
30
- });
32
+ const pageData = [];
33
+ for (let j = 0; j < 10; ++j) {
34
+ pageData.push({
35
+ width: 500,
36
+ height: 170,
37
+ name: "testPage_" + i + "-" + "widget_" + j,
38
+ marginBottom: 10,
39
+ index: j,
40
+ });
41
+ }
31
42
  pageList.push({
32
43
  width: 600,
33
44
  height: 600,
34
- data: data,
45
+ data: pageData,
35
46
  name: "testPage-" + i,
36
47
  });
37
48
  }
@@ -112,7 +123,7 @@ export default {
112
123
  <app-tab
113
124
  :data="tabData"
114
125
  :name="appTabName"
115
- :layout="{ width: 1920, height: 100 }"
126
+ :layout="{ width: 600, height: 100 }"
116
127
  :onEdge="$_app_tabOnEdge"
117
128
  :style="{
118
129
  top: 15,
@@ -1,14 +1,14 @@
1
1
  <!--
2
2
  * @Author: ChenChanghua
3
3
  * @Date: 2022-07-12 10:45:38
4
- * @LastEditors: ChenChanghua
5
- * @LastEditTime: 2022-09-01 17:04:31
4
+ * @LastEditors: Please set LastEditors
5
+ * @LastEditTime: 2023-03-09 16:27:44
6
6
  * @Description: file content
7
7
  -->
8
8
  <script setup>
9
9
  import { VERTICAL, MetroWidget } from "jsview";
10
- import WidgetItem from "../WidgetItem.vue";
11
- import { ref, watch, onBeforeUnmount } from "vue";
10
+ import WidgetItem from "./WidgetItem.vue";
11
+ import { ref, shallowRef, watch, onBeforeUnmount } from "vue";
12
12
 
13
13
  const props = defineProps({
14
14
  data: {
@@ -24,7 +24,7 @@ const props = defineProps({
24
24
  },
25
25
  });
26
26
 
27
- const widgetRef = ref(null);
27
+ const widgetRef = shallowRef(null);
28
28
 
29
29
  const provideData = () => {
30
30
  return props.data.data;
@@ -1,12 +1,10 @@
1
1
  <!--
2
2
  * @Author: ChenChanghua
3
- * @Date: 2022-05-10 15:21:24
4
- * @LastEditors: ChenChanghua
5
- * @LastEditTime: 2022-11-01 15:24:26
3
+ * @Date: 2023-03-09 16:28:25
6
4
  * @Description: file content
7
5
  -->
8
6
  <script setup>
9
- import { ref, inject } from "vue";
7
+ import { ref, shallowRef, inject } from "vue";
10
8
 
11
9
  const props = defineProps({
12
10
  data: Object,
@@ -14,28 +12,12 @@ const props = defineProps({
14
12
  onAction: Object,
15
13
  });
16
14
 
17
- const divRef = ref(null);
15
+ const divRef = shallowRef(null);
18
16
  const focused = ref(false);
19
17
 
20
- const focusSize = inject("focusSize");
21
-
22
18
  // 自身的焦点状态自己记录, 通过回调来改变
23
19
  const onFocus = () => {
24
20
  focused.value = true;
25
- if (focusSize) {
26
- divRef.value?.getBoundingClientRect().then(
27
- (data) => {
28
- console.log("testtest focus size", data)
29
- focusSize.width = data.width;
30
- focusSize.height = data.height;
31
- focusSize.left = data.left;
32
- focusSize.top = data.top;
33
- },
34
- (error) => {
35
- console.log("testtest abs failed", error);
36
- }
37
- );
38
- }
39
21
  };
40
22
  const onBlur = () => {
41
23
  focused.value = false;
@@ -6,7 +6,7 @@
6
6
  * @Description: file content
7
7
  -->
8
8
  <script setup>
9
- import { ref, inject } from "vue";
9
+ import { ref, shallowRef, inject } from "vue";
10
10
 
11
11
  const props = defineProps({
12
12
  data: Object,
@@ -1,14 +1,14 @@
1
1
  <!--
2
2
  * @Author: ChenChanghua
3
3
  * @Date: 2022-07-12 10:30:33
4
- * @LastEditors: ChenChanghua
5
- * @LastEditTime: 2022-09-01 17:05:07
4
+ * @LastEditors: Please set LastEditors
5
+ * @LastEditTime: 2023-03-09 16:00:38
6
6
  * @Description: file content
7
7
  -->
8
8
  <script>
9
9
  import AppPage from "./AppPage.vue";
10
10
  import { getKeyFramesGroup } from "jsview";
11
- import { reactive, ref } from "vue";
11
+ import { reactive } from "vue";
12
12
 
13
13
  export default {
14
14
  components: {
@@ -187,7 +187,7 @@ export default {
187
187
  animation: page0Anim.anim,
188
188
  animationFillMode: 'forwards',
189
189
  }"
190
- :onAnimationEnd="page0Anim.onend"
190
+ @animationend="page0Anim.onend"
191
191
  >
192
192
  <app-page
193
193
  v-if="page0Show"
@@ -201,7 +201,7 @@ export default {
201
201
  animation: page1Anim.anim,
202
202
  animationFillMode: 'forwards',
203
203
  }"
204
- :onAnimationEnd="page1Anim.onend"
204
+ @animationend="page1Anim.onend"
205
205
  >
206
206
  <app-page
207
207
  v-if="page1Show"
@@ -1,7 +1,12 @@
1
+ <!--
2
+ * @Author: ChenChanghua
3
+ * @Date: 2023-03-09 16:27:38
4
+ * @Description: file content
5
+ -->
1
6
 
2
7
  <script setup>
3
8
  import { HORIZONTAL, MetroWidget, useFocusHub } from "jsview";
4
- import { ref } from "vue";
9
+ import { ref, shallowRef } from "vue";
5
10
  import Item from "./Item.vue";
6
11
 
7
12
  const props = defineProps({
@@ -11,7 +16,7 @@ const props = defineProps({
11
16
  onAction: Object,
12
17
  });
13
18
  const focusHub = useFocusHub();
14
- const mwRef = ref(null);
19
+ const mwRef = shallowRef(null);
15
20
 
16
21
  const measures = (item) => {
17
22
  return item;
@@ -43,7 +48,7 @@ const onFocus = (rect) => {
43
48
  };
44
49
  const onBlur = () => {
45
50
  //onBlur时需要返还焦点给父MetroWidget
46
- mwRef.value?.getFocusBlockRef().returnFocusToParent();
51
+ focusHub.returnFocusToParent();
47
52
  };
48
53
 
49
54
  props.onAction.register("onFocus", onFocus);
@@ -78,7 +83,6 @@ props.onAction.register("onBlur", onBlur);
78
83
  bottom: 10,
79
84
  }"
80
85
  :measures="measures"
81
- :slideSetting="seamlessSlide"
82
86
  :onEdge="onItemEdge"
83
87
  :sendFocusRectEvent="true"
84
88
  >
@@ -0,0 +1,162 @@
1
+ <!--
2
+ * @Author: ChenChanghua
3
+ * @Date: 2023-03-08 14:52:08
4
+ * @Description: file content
5
+ -->
6
+ <script setup>
7
+ import { MetroWidget, HORIZONTAL, useFocusHub } from "jsview";
8
+ import Item from "./Item.vue";
9
+ import { onMounted } from "vue";
10
+
11
+ const TAG = "MetroWidgetDemo";
12
+
13
+ const focusHub = useFocusHub();
14
+
15
+ const randomColor = () => {
16
+ let randomColor = Math.round(Math.random() * 2 ** 24).toString(16);
17
+ return (
18
+ "#" + new Array(6 - randomColor.length).fill("0").join("") + randomColor
19
+ );
20
+ };
21
+
22
+ const provideData = () => {
23
+ const data = [
24
+ {
25
+ width: 90,
26
+ height: 90,
27
+ marginRight: 10,
28
+ marginBottom: 10,
29
+ color: randomColor(),
30
+ content: 0,
31
+ },
32
+ {
33
+ width: 90,
34
+ height: 90,
35
+ marginRight: 10,
36
+ marginBottom: 10,
37
+ color: randomColor(),
38
+ content: 1,
39
+ },
40
+ {
41
+ width: 90,
42
+ height: 90,
43
+ marginRight: 10,
44
+ marginBottom: 10,
45
+ color: randomColor(),
46
+ content: 2,
47
+ },
48
+ {
49
+ width: 190,
50
+ height: 190,
51
+ marginRight: 10,
52
+ marginBottom: 10,
53
+ color: randomColor(),
54
+ content: 3,
55
+ },
56
+ {
57
+ width: 90,
58
+ height: 90,
59
+ marginRight: 10,
60
+ marginBottom: 10,
61
+ color: randomColor(),
62
+ content: 4,
63
+ },
64
+ {
65
+ width: 90,
66
+ height: 90,
67
+ marginRight: 10,
68
+ marginBottom: 10,
69
+ color: randomColor(),
70
+ content: 5,
71
+ },
72
+ ];
73
+
74
+ for (let i = 0; i < 5; i++) {
75
+ data.push(
76
+ {
77
+ width: 90,
78
+ height: 190,
79
+ marginRight: 10,
80
+ marginBottom: 10,
81
+ color: randomColor(),
82
+ content: 6 + i * 2,
83
+ },
84
+ {
85
+ width: 90,
86
+ height: 90,
87
+ marginRight: 10,
88
+ marginBottom: 10,
89
+ color: randomColor(),
90
+ content: 6 + i * 2 + 1,
91
+ }
92
+ );
93
+ }
94
+ return data;
95
+ };
96
+
97
+ const measures = (data) => {
98
+ return {
99
+ width: data.width,
100
+ height: data.height,
101
+ marginRight: data.marginRight,
102
+ marginBottom: data.marginBottom,
103
+ };
104
+ };
105
+
106
+ // callbacks
107
+ const onEdge = (edgeInfo) => {
108
+ console.log(TAG, "onEdge", edgeInfo);
109
+ };
110
+
111
+ const onFocus = () => {
112
+ console.log(TAG, "onFocus");
113
+ };
114
+
115
+ const onBlur = () => {
116
+ console.log(TAG, "onBlur");
117
+ };
118
+
119
+ const onScroll = (start, range, totalSize) => {
120
+ console.log(TAG, "onScroll", start, range, totalSize);
121
+ };
122
+
123
+ const widgetLayout = {
124
+ left: 50,
125
+ top: 50,
126
+ width: 500,
127
+ height: 300,
128
+ };
129
+
130
+ onMounted(() => {
131
+ //组件mount后设置焦点
132
+ focusHub.setFocus("mainMw");
133
+ });
134
+ </script>
135
+
136
+ <template>
137
+ <div
138
+ :style="{
139
+ width: 1920,
140
+ height: 1080,
141
+ backgroundColor: '#007788',
142
+ }"
143
+ />
144
+ <metro-widget
145
+ name="mainMw"
146
+ :left="widgetLayout.left"
147
+ :top="widgetLayout.top"
148
+ :width="widgetLayout.width"
149
+ :height="widgetLayout.height"
150
+ :provideData="provideData"
151
+ :direction="HORIZONTAL"
152
+ :measures="measures"
153
+ :onEdge="onEdge"
154
+ :onFocus="onFocus"
155
+ :onBlur="onBlur"
156
+ :onScroll="onScroll"
157
+ >
158
+ <template #renderItem="{ data, onAction }">
159
+ <item :data="data" :onAction="onAction" />
160
+ </template>
161
+ </metro-widget>
162
+ </template>
@@ -0,0 +1,43 @@
1
+ <!--
2
+ * @Author: ChenChanghua
3
+ * @Date: 2023-03-08 14:52:17
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,158 @@
1
+ <!--
2
+ * @Author: ChenChanghua
3
+ * @Date: 2023-03-08 15:17:44
4
+ * @Description: file content
5
+ -->
6
+ <script setup>
7
+ import {
8
+ MetroWidget,
9
+ HORIZONTAL,
10
+ VERTICAL,
11
+ useFocusHub,
12
+ EdgeDirection,
13
+ } from "jsview";
14
+ import Item from "./Item.vue";
15
+ import { onMounted } from "vue";
16
+
17
+ const TAG = "MetroWidgetDemo";
18
+
19
+ const focusHub = useFocusHub();
20
+
21
+ const randomColor = () => {
22
+ let randomColor = Math.round(Math.random() * 2 ** 24).toString(16);
23
+ return (
24
+ "#" + new Array(6 - randomColor.length).fill("0").join("") + randomColor
25
+ );
26
+ };
27
+
28
+ const data = [];
29
+ for (let i = 0; i < 30; i++) {
30
+ data.push({
31
+ width: 90,
32
+ height: 90,
33
+ marginRight: 10,
34
+ marginBottom: 10,
35
+ color: randomColor(),
36
+ content: i,
37
+ });
38
+ }
39
+
40
+ const horizontalWidget = {
41
+ provideData: () => {
42
+ return data;
43
+ },
44
+ measures: (data) => {
45
+ return {
46
+ width: data.width,
47
+ height: data.height,
48
+ marginRight: data.marginRight,
49
+ marginBottom: data.marginBottom,
50
+ };
51
+ },
52
+ onEdge: (edgeInfo) => {
53
+ if (edgeInfo.direction == EdgeDirection.bottom) {
54
+ focusHub.setFocus("widget2");
55
+ }
56
+ },
57
+ widgetLayout: {
58
+ left: 50,
59
+ top: 50,
60
+ width: 300,
61
+ height: 200,
62
+ },
63
+ };
64
+
65
+ const verticalWidget = {
66
+ provideData: () => {
67
+ return data;
68
+ },
69
+ measures: (data) => {
70
+ return {
71
+ width: data.width,
72
+ height: data.height,
73
+ marginRight: data.marginRight,
74
+ marginBottom: data.marginBottom,
75
+ };
76
+ },
77
+ onEdge: (edgeInfo) => {
78
+ if (edgeInfo.direction == EdgeDirection.top) {
79
+ focusHub.setFocus("widget1");
80
+ }
81
+ },
82
+ widgetLayout: {
83
+ left: 50,
84
+ top: 300,
85
+ width: 200,
86
+ height: 300,
87
+ },
88
+ };
89
+
90
+ onMounted(() => {
91
+ //组件mount后设置焦点
92
+ focusHub.setFocus("widget1");
93
+ });
94
+ </script>
95
+
96
+ <template>
97
+ <div
98
+ :style="{
99
+ width: 1920,
100
+ height: 1080,
101
+ backgroundColor: '#007788',
102
+ }"
103
+ />
104
+ <div
105
+ :style="{
106
+ left: 50,
107
+ width: 1280,
108
+ height: 50,
109
+ fontSize: 25,
110
+ color: '#FFFFFF',
111
+ }"
112
+ >
113
+ {{ "HORIZONTAL: 向右延伸. 排列顺序从上往下, 从左往右" }}
114
+ </div>
115
+ <metro-widget
116
+ name="widget1"
117
+ :left="horizontalWidget.widgetLayout.left"
118
+ :top="horizontalWidget.widgetLayout.top"
119
+ :width="horizontalWidget.widgetLayout.width"
120
+ :height="horizontalWidget.widgetLayout.height"
121
+ :provideData="horizontalWidget.provideData"
122
+ :measures="horizontalWidget.measures"
123
+ :onEdge="horizontalWidget.onEdge"
124
+ :direction="HORIZONTAL"
125
+ >
126
+ <template #renderItem="{ data, onAction }">
127
+ <item :data="data" :onAction="onAction" />
128
+ </template>
129
+ </metro-widget>
130
+
131
+ <div
132
+ :style="{
133
+ left: 50,
134
+ top: 250,
135
+ width: 1280,
136
+ height: 50,
137
+ fontSize: 25,
138
+ color: '#FFFFFF',
139
+ }"
140
+ >
141
+ {{ "VERTICAL: 向下延伸. 排列顺序从左往右, 从上往下" }}
142
+ </div>
143
+ <metro-widget
144
+ name="widget2"
145
+ :left="verticalWidget.widgetLayout.left"
146
+ :top="verticalWidget.widgetLayout.top"
147
+ :width="verticalWidget.widgetLayout.width"
148
+ :height="verticalWidget.widgetLayout.height"
149
+ :provideData="verticalWidget.provideData"
150
+ :measures="verticalWidget.measures"
151
+ :onEdge="verticalWidget.onEdge"
152
+ :direction="VERTICAL"
153
+ >
154
+ <template #renderItem="{ data, onAction }">
155
+ <item :data="data" :onAction="onAction" />
156
+ </template>
157
+ </metro-widget>
158
+ </template>
@@ -0,0 +1,45 @@
1
+ <!--
2
+ * @Author: ChenChanghua
3
+ * @Date: 2023-03-08 14:52:17
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 divRef = shallowRef(null);
15
+ const focused = ref(false);
16
+
17
+ // 注册回调
18
+ const onFocus = () => {
19
+ focused.value = true;
20
+ };
21
+ const onBlur = () => {
22
+ focused.value = false;
23
+ };
24
+ const onClick = () => {
25
+ console.log("item onclick ", props.data);
26
+ };
27
+ props.onAction.register("onFocus", onFocus);
28
+ props.onAction.register("onBlur", onBlur);
29
+ props.onAction.register("onClick", onClick);
30
+ </script>
31
+
32
+ <template>
33
+ <div
34
+ ref="divRef"
35
+ :style="{
36
+ width: data.width,
37
+ height: data.height,
38
+ fontSize: 30,
39
+ color: focused ? '#FF0000' : '#FFFFFF',
40
+ backgroundColor: data.color,
41
+ }"
42
+ >
43
+ {{ data.content }}
44
+ </div>
45
+ </template>