@shijiu/jsview-vue 0.9.766 → 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 (64) 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/package.json +1 -1
  4. package/samples/DemoHomepage/App.vue +30 -6
  5. package/samples/DemoHomepage/components/TabFrame.vue +7 -0
  6. package/samples/DemoHomepage/router.js +16 -18
  7. package/samples/DemoHomepage/views/Homepage.vue +5 -1
  8. package/samples/FocusBlockDemos/AutoFocus/App.vue +51 -0
  9. package/samples/FocusBlockDemos/AutoFocus/BaseBlock.vue +82 -0
  10. package/samples/FocusBlockDemos/AutoFocus/DialogBlock.vue +89 -0
  11. package/samples/FocusBlockDemos/AutoFocus/DialogContorls.js +42 -0
  12. package/samples/FocusBlockDemos/AutoFocus/FocusNamesDefine.js +9 -0
  13. package/samples/FocusBlockDemos/AutoFocus/PlaneBlock.vue +71 -0
  14. package/samples/FocusBlockDemos/ProgressiveFocusControl/App.vue +78 -0
  15. package/samples/FocusBlockDemos/ProgressiveFocusControl/BaseBlock.vue +77 -0
  16. package/samples/FocusBlockDemos/ProgressiveFocusControl/DownPlaneBlock.vue +83 -0
  17. package/samples/FocusBlockDemos/ProgressiveFocusControl/FocusNamesDefine.js +12 -0
  18. package/samples/FocusBlockDemos/ProgressiveFocusControl/UpPlaneBlock.vue +83 -0
  19. package/samples/Marquee/App.vue +34 -3
  20. package/samples/MetroWidgetDemos/PingPong/App.vue +22 -11
  21. package/samples/MetroWidgetDemos/PingPong/AppPage.vue +3 -3
  22. package/samples/MetroWidgetDemos/{Item.vue → PingPong/Item.vue} +1 -3
  23. package/samples/MetroWidgetDemos/PingPong/ViewSwiper.vue +3 -3
  24. package/samples/MetroWidgetDemos/{WidgetItem.vue → PingPong/WidgetItem.vue} +6 -1
  25. package/samples/MetroWidgetDemos/basic/App.vue +162 -0
  26. package/samples/MetroWidgetDemos/basic/Item.vue +43 -0
  27. package/samples/MetroWidgetDemos/direction/App.vue +158 -0
  28. package/samples/MetroWidgetDemos/direction/Item.vue +45 -0
  29. package/samples/MetroWidgetDemos/focusableItemBasic/App.vue +67 -0
  30. package/samples/MetroWidgetDemos/{Advanced → focusableItemBasic}/ButtonItem.vue +16 -20
  31. package/samples/MetroWidgetDemos/focusableItemMetroWidget/App.vue +74 -0
  32. package/samples/MetroWidgetDemos/{Advanced/widgets → focusableItemMetroWidget}/Item.vue +12 -30
  33. package/samples/MetroWidgetDemos/{Advanced/widgets → focusableItemMetroWidget}/WidgetItem.vue +10 -9
  34. package/samples/MetroWidgetDemos/focusableItemMix/App.vue +88 -0
  35. package/samples/MetroWidgetDemos/focusableItemMix/ButtonItem.vue +86 -0
  36. package/samples/MetroWidgetDemos/focusableItemMix/Item.vue +43 -0
  37. package/samples/MetroWidgetDemos/index.js +6 -0
  38. package/samples/MetroWidgetDemos/layoutType/App.vue +180 -0
  39. package/samples/MetroWidgetDemos/layoutType/Item.vue +45 -0
  40. package/samples/MetroWidgetDemos/padding/App.vue +222 -0
  41. package/samples/MetroWidgetDemos/padding/Item.vue +64 -0
  42. package/samples/MetroWidgetDemos/routeList.js +64 -0
  43. package/samples/MetroWidgetDemos/slideSetting/App.vue +225 -0
  44. package/samples/MetroWidgetDemos/slideSetting/Item.vue +45 -0
  45. package/samples/NinePatchDemo/App.vue +78 -122
  46. package/samples/NinePatchDemo/Item.vue +28 -26
  47. package/samples/Swiper/App.vue +148 -0
  48. package/utils/JsViewEngineWidget/MetroWidget/MetroWidget.vue +15 -12
  49. package/utils/JsViewEngineWidget/TemplateParser.js +6 -1
  50. package/utils/JsViewPlugin/JsvPlayer/version.js +4 -4
  51. package/utils/JsViewVueTools/JsvTextTools.js +24 -3
  52. package/utils/JsViewVueWidget/JsvMarquee.vue +81 -20
  53. package/utils/JsViewVueWidget/JsvSwiper/JsvSwiper.vue +115 -79
  54. package/utils/JsViewVueWidget/JsvSwiper/index.js +3 -2
  55. package/samples/MetroWidgetDemos/Advanced/App.vue +0 -46
  56. package/samples/MetroWidgetDemos/Advanced/Buttons.vue +0 -70
  57. package/samples/MetroWidgetDemos/Advanced/Mixed.vue +0 -77
  58. package/samples/MetroWidgetDemos/Advanced/widgets/Widgets.vue +0 -116
  59. package/samples/MetroWidgetDemos/Advanced/widgets/focus1.png +0 -0
  60. package/samples/MetroWidgetDemos/Simple/AbsoluteTemplate.vue +0 -75
  61. package/samples/MetroWidgetDemos/Simple/App.vue +0 -45
  62. package/samples/MetroWidgetDemos/Simple/RelativeTemplate.vue +0 -111
  63. package/samples/MetroWidgetDemos/data.js +0 -205
  64. package/utils/JsViewVueWidget/JsvSwiper/Indicator.vue +0 -35
@@ -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,13 +1,13 @@
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";
10
+ import WidgetItem from "./WidgetItem.vue";
11
11
  import { ref, shallowRef, watch, onBeforeUnmount } from "vue";
12
12
 
13
13
  const props = defineProps({
@@ -1,8 +1,6 @@
1
1
  <!--
2
2
  * @Author: ChenChanghua
3
- * @Date: 2022-05-10 15:21:24
4
- * @LastEditors: ChenChanghua
5
- * @LastEditTime: 2022-12-02 16:12:43
3
+ * @Date: 2023-03-09 16:28:25
6
4
  * @Description: file content
7
5
  -->
8
6
  <script setup>
@@ -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, shallowRef } from "vue";
11
+ import { reactive } from "vue";
12
12
 
13
13
  export default {
14
14
  components: {
@@ -1,3 +1,8 @@
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";
@@ -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);
@@ -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>
@@ -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,9 +1,7 @@
1
1
  <!--
2
2
  * @Author: ChenChanghua
3
- * @Date: 2022-07-11 13:26:24
4
- * @LastEditors: ChenChanghua
5
- * @LastEditTime: 2022-12-02 16:10:16
6
- * @Description: file content
3
+ * @Date: 2023-03-09 14:19:01
4
+ * @Description: 一个简单的按左右键, 焦点在左右两个view来回切换的控件
7
5
  -->
8
6
  <script setup>
9
7
  import { ref, shallowRef } from "vue";
@@ -11,27 +9,26 @@ import { useFocusHub } from "jsview";
11
9
 
12
10
  const props = defineProps({
13
11
  data: Object,
14
- query: Object,
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 = shallowRef(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',