@shijiu/jsview-vue-samples 1.9.747

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 (213) hide show
  1. package/AnimPicture/App.vue +207 -0
  2. package/AnimPicture/assets/animated_webp.webp +0 -0
  3. package/AnimPicture/assets/ball_3.webp +0 -0
  4. package/AnimPicture/assets/girl_run.gif +0 -0
  5. package/AnimPicture/assets/quan.webp +0 -0
  6. package/Basic/App.vue +134 -0
  7. package/Basic/assets/border.png +0 -0
  8. package/Basic/assets/border2.png +0 -0
  9. package/Basic/assets/icon.png +0 -0
  10. package/Basic/assets/test.jpg +0 -0
  11. package/Basic/components/ContentBlock.vue +38 -0
  12. package/Basic/components/FontStyle.css +16 -0
  13. package/Basic/components/anim/AnimGroup.vue +66 -0
  14. package/Basic/components/anim/AnimKeyframeBasic.vue +119 -0
  15. package/Basic/components/anim/AnimKeyframeComposite.vue +52 -0
  16. package/Basic/components/anim/AnimTransition.vue +157 -0
  17. package/Basic/components/div/DivBackground.vue +44 -0
  18. package/Basic/components/div/DivClip.vue +159 -0
  19. package/Basic/components/div/DivCssScoped.vue +20 -0
  20. package/Basic/components/div/DivCssVar.vue +53 -0
  21. package/Basic/components/div/DivGroup1.vue +47 -0
  22. package/Basic/components/div/DivGroup2.vue +65 -0
  23. package/Basic/components/div/DivLayout.vue +70 -0
  24. package/Basic/components/div/DivRadius.vue +65 -0
  25. package/Basic/components/div/DivTransform.vue +32 -0
  26. package/Basic/components/img/ImageGroup.vue +31 -0
  27. package/Basic/components/img/ImgLayout.vue +41 -0
  28. package/Basic/components/panel/Panel1.vue +55 -0
  29. package/Basic/components/panel/Panel2.vue +31 -0
  30. package/Basic/components/panel/TitleBar.vue +29 -0
  31. package/Basic/components/text/TextAlign.vue +66 -0
  32. package/Basic/components/text/TextEmoji.vue +26 -0
  33. package/Basic/components/text/TextFontStyle.vue +89 -0
  34. package/Basic/components/text/TextGroup1.vue +49 -0
  35. package/Basic/components/text/TextGroup2.vue +28 -0
  36. package/Basic/components/text/TextOverflow.vue +110 -0
  37. package/BasicFocusControl/App.vue +104 -0
  38. package/BasicFocusControl/components/BaseBlock.vue +50 -0
  39. package/BasicFocusControl/components/MainArea.vue +83 -0
  40. package/BasicFocusControl/components/MainAreaLeftBlock.vue +17 -0
  41. package/BasicFocusControl/components/MainAreaRightBlock.vue +27 -0
  42. package/BasicFocusControl/components/SideBar.vue +58 -0
  43. package/BasicFocusControl/components/SideBarBlock.vue +27 -0
  44. package/Collision/App.vue +452 -0
  45. package/ColorSpace/App.vue +126 -0
  46. package/ColorSpace/bmpDemo.bmp +0 -0
  47. package/ColorSpace/jpegDemo.jpeg +0 -0
  48. package/ColorSpace/pngDemo.png +0 -0
  49. package/ColorSpace/pngNoAlphaDemo.png +0 -0
  50. package/DemoHomepage/App.vue +27 -0
  51. package/DemoHomepage/components/BodyFrame.vue +95 -0
  52. package/DemoHomepage/components/Dialog.vue +94 -0
  53. package/DemoHomepage/components/Item.vue +77 -0
  54. package/DemoHomepage/components/TabFrame.vue +85 -0
  55. package/DemoHomepage/router.js +196 -0
  56. package/DemoHomepage/views/Homepage.vue +195 -0
  57. package/FilterDemo/AnimatePic.vue +58 -0
  58. package/FilterDemo/App.vue +159 -0
  59. package/FilterDemo/VideoLayer.vue +62 -0
  60. package/FilterDemo/jpegDemo.jpeg +0 -0
  61. package/FilterDemo/webpDemo.webp +0 -0
  62. package/FlipCard/App.vue +71 -0
  63. package/FlipCard/FlipCard.vue +118 -0
  64. package/FlipCard/assets/blue_egg.png +0 -0
  65. package/FlipCard/assets/red_egg.png +0 -0
  66. package/FlipCard/data.js +13 -0
  67. package/GridDemo/App.vue +215 -0
  68. package/GridDemo/ButtonBlock.vue +112 -0
  69. package/GridDemo/FocusItem.vue +37 -0
  70. package/GridDemo/Item.vue +93 -0
  71. package/HashHistory/App.vue +115 -0
  72. package/HashHistory/components/HorizontalButtonList.vue +91 -0
  73. package/HashHistory/components/Item.vue +60 -0
  74. package/HashHistory/router.js +41 -0
  75. package/HashHistory/views/MainPage.vue +57 -0
  76. package/HashHistory/views/SubPage.vue +66 -0
  77. package/ImpactStop/App.vue +435 -0
  78. package/Input/App.vue +164 -0
  79. package/Input/FullKeyboard.vue +87 -0
  80. package/Input/InputPanel.vue +131 -0
  81. package/Input/KeyboardItem.vue +58 -0
  82. package/LongImage/App.vue +80 -0
  83. package/LongImage/Button.vue +58 -0
  84. package/LongImage/ButtonItem.vue +44 -0
  85. package/LongImage/LongImageScroll.vue +92 -0
  86. package/LongImage/Scroll.vue +14 -0
  87. package/LongImage/assets/1280x7200.jpg +0 -0
  88. package/LongText/App.vue +96 -0
  89. package/LongText/Button.vue +51 -0
  90. package/LongText/ButtonItem.vue +44 -0
  91. package/LongText/LongTextScroll.vue +192 -0
  92. package/LongText/Scroll.vue +14 -0
  93. package/Marquee/App.vue +247 -0
  94. package/Marquee/longText.js +14 -0
  95. package/MaskClip/App.vue +122 -0
  96. package/MaskClip/images/mask-025/config.json +29 -0
  97. package/MaskClip/images/mask-025/res/1.png +0 -0
  98. package/MaskClip/images/mask-025/res/2.png +0 -0
  99. package/MaskClip/images/mask-025/res/3.png +0 -0
  100. package/MaskClip/images/mask-025/res/4.png +0 -0
  101. package/MaskClip/images/mask-025/res/icon.png +0 -0
  102. package/MaskClip/images/mask-025/res/stroke.png +0 -0
  103. package/MaskClip/images/php.jpg +0 -0
  104. package/MetroWidgetDemos/Advanced/App.vue +46 -0
  105. package/MetroWidgetDemos/Advanced/ButtonItem.vue +90 -0
  106. package/MetroWidgetDemos/Advanced/Buttons.vue +70 -0
  107. package/MetroWidgetDemos/Advanced/Mixed.vue +77 -0
  108. package/MetroWidgetDemos/Advanced/widgets/Item.vue +83 -0
  109. package/MetroWidgetDemos/Advanced/widgets/WidgetItem.vue +89 -0
  110. package/MetroWidgetDemos/Advanced/widgets/Widgets.vue +116 -0
  111. package/MetroWidgetDemos/Advanced/widgets/focus1.png +0 -0
  112. package/MetroWidgetDemos/Item.vue +85 -0
  113. package/MetroWidgetDemos/PerformanceTest/App.vue +210 -0
  114. package/MetroWidgetDemos/PerformanceTest/Item.vue +90 -0
  115. package/MetroWidgetDemos/PerformanceTest/assets/bg.jpg +0 -0
  116. package/MetroWidgetDemos/PerformanceTest/assets/coupon_content.png +0 -0
  117. package/MetroWidgetDemos/PerformanceTest/assets/coupon_left.png +0 -0
  118. package/MetroWidgetDemos/PerformanceTest/assets/coupon_mid.png +0 -0
  119. package/MetroWidgetDemos/PerformanceTest/assets/coupon_right.png +0 -0
  120. package/MetroWidgetDemos/PerformanceTest/assets/focus_border.png +0 -0
  121. package/MetroWidgetDemos/PerformanceTest/assets/holder_logo.png +0 -0
  122. package/MetroWidgetDemos/PerformanceTest/assets/jrbm.png +0 -0
  123. package/MetroWidgetDemos/PerformanceTest/assets/line_left.png +0 -0
  124. package/MetroWidgetDemos/PerformanceTest/assets/line_mid.png +0 -0
  125. package/MetroWidgetDemos/PerformanceTest/assets/line_right.png +0 -0
  126. package/MetroWidgetDemos/PerformanceTest/assets/loading.png +0 -0
  127. package/MetroWidgetDemos/PerformanceTest/assets/logo.png +0 -0
  128. package/MetroWidgetDemos/PerformanceTest/assets/mcjx.png +0 -0
  129. package/MetroWidgetDemos/PerformanceTest/assets/tao.png +0 -0
  130. package/MetroWidgetDemos/PerformanceTest/assets/tmall.png +0 -0
  131. package/MetroWidgetDemos/PerformanceTest/border.png +0 -0
  132. package/MetroWidgetDemos/PerformanceTest/components/ContentItem.vue +386 -0
  133. package/MetroWidgetDemos/PerformanceTest/components/MyTab.vue +129 -0
  134. package/MetroWidgetDemos/PerformanceTest/data.js +45 -0
  135. package/MetroWidgetDemos/PingPong/App.vue +135 -0
  136. package/MetroWidgetDemos/PingPong/AppPage.vue +73 -0
  137. package/MetroWidgetDemos/PingPong/AppTab.vue +62 -0
  138. package/MetroWidgetDemos/PingPong/TabItem.vue +84 -0
  139. package/MetroWidgetDemos/PingPong/ViewSwiper.vue +214 -0
  140. package/MetroWidgetDemos/Simple/AbsoluteTemplate.vue +75 -0
  141. package/MetroWidgetDemos/Simple/App.vue +45 -0
  142. package/MetroWidgetDemos/Simple/RelativeTemplate.vue +111 -0
  143. package/MetroWidgetDemos/WidgetItem.vue +89 -0
  144. package/MetroWidgetDemos/data.js +205 -0
  145. package/NinePatchDemo/App.vue +145 -0
  146. package/NinePatchDemo/Item.vue +69 -0
  147. package/NinePatchDemo/assets/border.png +0 -0
  148. package/Preload/App.vue +135 -0
  149. package/Preload/Item.vue +32 -0
  150. package/Preload/data.js +23 -0
  151. package/Preload/images/awesomeface.png +0 -0
  152. package/Preload/images/cat.jpg +0 -0
  153. package/Preload/images/rank.png +0 -0
  154. package/Preload/images/rank_focus.png +0 -0
  155. package/Preload/images/rule.png +0 -0
  156. package/Preload/images/rule_focus.png +0 -0
  157. package/Preload/images/start.png +0 -0
  158. package/Preload/images/start_focus.png +0 -0
  159. package/QrcodeDemo/App.vue +68 -0
  160. package/ScaleDownNeon/App.vue +107 -0
  161. package/SoundPool/App.vue +134 -0
  162. package/SoundPool/bgmusic.mp3 +0 -0
  163. package/SoundPool/coin.mp3 +0 -0
  164. package/SoundPool/jump.mp3 +0 -0
  165. package/SoundPool/lose.mp3 +0 -0
  166. package/SoundPool/run.mp3 +0 -0
  167. package/SprayView/App.vue +272 -0
  168. package/SprayView/assets/snow.png +0 -0
  169. package/SpriteImage/App.vue +173 -0
  170. package/SpriteImage/images/cat_run.png +0 -0
  171. package/SpriteImage/images/egg_break.json +116 -0
  172. package/SpriteImage/images/egg_break.png +0 -0
  173. package/SpriteImage/images/sprite.png +0 -0
  174. package/TextBox/App.vue +91 -0
  175. package/TextBox/RenderCenter.vue +133 -0
  176. package/TextBox/RenderLeft.vue +138 -0
  177. package/TextBox/RenderOneLine.vue +101 -0
  178. package/TextBox/RenderRight.vue +131 -0
  179. package/TextShadowDemo/App.vue +91 -0
  180. package/TextureAnimation/App.vue +336 -0
  181. package/TextureAnimation/App2.vue +111 -0
  182. package/TextureAnimation/assets/blackWhiteGrid.png +0 -0
  183. package/TextureAnimation/assets/light.png +0 -0
  184. package/TextureAnimation/assets/light2.png +0 -0
  185. package/TextureAnimation/assets/mask.png +0 -0
  186. package/TextureAnimation/assets/php.jpg +0 -0
  187. package/TextureAnimation/assets/php2.png +0 -0
  188. package/TextureAnimation/assets/swipLight.png +0 -0
  189. package/TextureSize/App.vue +132 -0
  190. package/TextureSize/bmpDemo.bmp +0 -0
  191. package/TextureSize/jpegDemo.jpeg +0 -0
  192. package/TextureSize/jpgDemo.jpg +0 -0
  193. package/TextureSize/pngDemo.png +0 -0
  194. package/TextureSize/pngNoAlphaDemo.png +0 -0
  195. package/ThrowMoveDemo/AccelerateDemo.vue +116 -0
  196. package/ThrowMoveDemo/App.vue +114 -0
  197. package/ThrowMoveDemo/LRParabolicDemo.vue +115 -0
  198. package/ThrowMoveDemo/TargetDemo.vue +116 -0
  199. package/ThrowMoveDemo/UDParabolicDemo.vue +121 -0
  200. package/TouchSample/App.vue +136 -0
  201. package/TouchSample/Item.vue +103 -0
  202. package/TouchSample/MetroWidgetHorizontal.vue +144 -0
  203. package/TouchSample/MetroWidgetVertical.vue +144 -0
  204. package/TouchSample/TouchContainerHorizontal.vue +160 -0
  205. package/TouchSample/TouchContainerVertical.vue +160 -0
  206. package/TouchSample/data.js +81 -0
  207. package/TransitPage/App.vue +29 -0
  208. package/VideoDemo/App.vue +121 -0
  209. package/VideoDemo/components/Button.vue +58 -0
  210. package/VideoDemo/components/Controllor.vue +197 -0
  211. package/VideoDemo/components/VideoFrame.vue +140 -0
  212. package/VisibleSensorDemo/App.vue +234 -0
  213. package/package.json +17 -0
@@ -0,0 +1,89 @@
1
+
2
+ <script setup>
3
+ import { HORIZONTAL, MetroWidget, useFocusHub } from "jsview";
4
+ import { ref, shallowRef } from "vue";
5
+ import Item from "./Item.vue";
6
+
7
+ const props = defineProps({
8
+ data: Object,
9
+ query: Object,
10
+ onItemEdge: Function,
11
+ onAction: Object,
12
+ });
13
+ const focusHub = useFocusHub();
14
+ const mwRef = shallowRef(null);
15
+
16
+ const measures = (item) => {
17
+ return item;
18
+ };
19
+ const randomColor = () => {
20
+ let randomColor = Math.round(Math.random() * 2 ** 24).toString(16);
21
+ return (
22
+ "#" + new Array(6 - randomColor.length).fill("0").join("") + randomColor
23
+ );
24
+ };
25
+ const provideData = () => {
26
+ const data = [];
27
+ for (let i = 0; i < 10; i++) {
28
+ data.push({
29
+ width: 90,
30
+ height: 90,
31
+ marginRight: 10,
32
+ marginBottom: 10,
33
+ content: i,
34
+ color: randomColor(),
35
+ });
36
+ }
37
+ return data;
38
+ };
39
+ const onFocus = (rect) => {
40
+ //获得焦点时需要做就近移动的处理, 因此需要通过setEnterFocusRect设置寻找最近焦点的区域
41
+ mwRef.value?.setEnterFocusRect(rect);
42
+ focusHub.setFocus(props.data.name);
43
+ };
44
+ const onBlur = () => {
45
+ //onBlur时需要返还焦点给父MetroWidget
46
+ mwRef.value?.getFocusBlockRef().returnFocusToParent();
47
+ };
48
+
49
+ props.onAction.register("onFocus", onFocus);
50
+ props.onAction.register("onBlur", onBlur);
51
+ </script>
52
+
53
+ <template>
54
+ <div
55
+ :style="{
56
+ width: 900,
57
+ height: 50,
58
+ fontSize: 30,
59
+ color: '#FFFFFF',
60
+ }"
61
+ >
62
+ {{ data.name }}
63
+ </div>
64
+ <!-- sendFocusRectEvent可以让MetroWidget的item在获焦时发送事件, 通知父的MetroWidget进行滚动 -->
65
+ <!-- onItemEdge直接作为onEdge回调, 既子MetroWidget到达边缘时触发父的onItemEdge -->
66
+ <metro-widget
67
+ ref="mwRef"
68
+ :top="50"
69
+ :name="data.name"
70
+ :provideData="provideData"
71
+ :width="data.width"
72
+ :height="data.height"
73
+ :direction="HORIZONTAL"
74
+ :padding="{
75
+ left: 10,
76
+ right: 10,
77
+ top: 10,
78
+ bottom: 10,
79
+ }"
80
+ :measures="measures"
81
+ :slideSetting="seamlessSlide"
82
+ :onEdge="onItemEdge"
83
+ :sendFocusRectEvent="true"
84
+ >
85
+ <template #renderItem="{ data, query, onAction }">
86
+ <item :data="data" :query="query" :onAction="onAction" />
87
+ </template>
88
+ </metro-widget>
89
+ </template>
@@ -0,0 +1,205 @@
1
+ /*
2
+ * @Author: ChenChanghua
3
+ * @Date: 2022-07-11 14:00:33
4
+ * @LastEditors: ChenChanghua
5
+ * @LastEditTime: 2022-11-02 15:23:08
6
+ * @Description: file content
7
+ */
8
+
9
+ const randomColor = () => {
10
+ let randomColor = Math.round(Math.random() * 2 ** 24).toString(16);
11
+ return (
12
+ "#" + new Array(6 - randomColor.length).fill("0").join("") + randomColor
13
+ );
14
+ };
15
+
16
+ const simpleData = [
17
+ {
18
+ width: 90,
19
+ height: 90,
20
+ marginRight: 10,
21
+ marginBottom: 10,
22
+ color: randomColor(),
23
+ content: "0",
24
+ },
25
+ {
26
+ width: 90,
27
+ height: 90,
28
+ marginRight: 10,
29
+ marginBottom: 10,
30
+ color: randomColor(),
31
+ content: "1",
32
+ },
33
+ {
34
+ width: 90,
35
+ height: 90,
36
+ marginRight: 10,
37
+ marginBottom: 10,
38
+ color: randomColor(),
39
+ content: "2",
40
+ },
41
+ {
42
+ width: 190,
43
+ height: 190,
44
+ marginRight: 10,
45
+ marginBottom: 10,
46
+ color: randomColor(),
47
+ content: "3",
48
+ },
49
+ {
50
+ width: 90,
51
+ height: 90,
52
+ marginRight: 10,
53
+ marginBottom: 10,
54
+ color: randomColor(),
55
+ content: "4",
56
+ },
57
+ {
58
+ width: 90,
59
+ height: 90,
60
+ marginRight: 10,
61
+ marginBottom: 10,
62
+ color: randomColor(),
63
+ content: "5",
64
+ },
65
+ {
66
+ width: 90,
67
+ height: 190,
68
+ marginRight: 10,
69
+ marginBottom: 10,
70
+ color: randomColor(),
71
+ content: "6",
72
+ },
73
+ {
74
+ width: 90,
75
+ height: 90,
76
+ marginRight: 10,
77
+ marginBottom: 10,
78
+ color: randomColor(),
79
+ content: "7",
80
+ },
81
+ {
82
+ width: 90,
83
+ height: 190,
84
+ marginRight: 10,
85
+ marginBottom: 10,
86
+ color: randomColor(),
87
+ content: "8",
88
+ },
89
+ {
90
+ width: 90,
91
+ height: 90,
92
+ marginRight: 10,
93
+ marginBottom: 10,
94
+ color: randomColor(),
95
+ content: "9",
96
+ },
97
+ ];
98
+
99
+ const simpleDataAbs = [
100
+ {
101
+ left: 0,
102
+ top: 0,
103
+ width: 90,
104
+ height: 90,
105
+ marginRight: 10,
106
+ marginBottom: 10,
107
+ color: randomColor(),
108
+ content: "0",
109
+ },
110
+ {
111
+ left: 0,
112
+ top: 200,
113
+ width: 90,
114
+ height: 90,
115
+ marginRight: 10,
116
+ marginBottom: 10,
117
+ color: randomColor(),
118
+ content: "1",
119
+ },
120
+ {
121
+ left: 200,
122
+ top: 0,
123
+ width: 90,
124
+ height: 90,
125
+ marginRight: 10,
126
+ marginBottom: 10,
127
+ color: randomColor(),
128
+ content: "2",
129
+ },
130
+ {
131
+ left: 200,
132
+ top: 200,
133
+ width: 90,
134
+ height: 90,
135
+ marginRight: 10,
136
+ marginBottom: 10,
137
+ color: randomColor(),
138
+ content: "3",
139
+ },
140
+ {
141
+ left: 400,
142
+ top: 0,
143
+ width: 90,
144
+ height: 90,
145
+ marginRight: 10,
146
+ marginBottom: 10,
147
+ color: randomColor(),
148
+ content: "4",
149
+ },
150
+ {
151
+ left: 400,
152
+ top: 200,
153
+ width: 90,
154
+ height: 90,
155
+ marginRight: 10,
156
+ marginBottom: 10,
157
+ color: randomColor(),
158
+ content: "5",
159
+ },
160
+ ];
161
+
162
+ const advanceButton = [];
163
+ for (let i = 0; i < 6; i++) {
164
+ advanceButton.push({
165
+ width: 100,
166
+ height: 50,
167
+ name: "button_" + i,
168
+ marginRight: 10,
169
+ marginBottom: 10,
170
+ });
171
+ }
172
+
173
+ const advanceMetroWidget = [];
174
+ for (let i = 0; i < 10; i++) {
175
+ advanceMetroWidget.push({
176
+ width: 500,
177
+ height: 170,
178
+ name: "widget_" + i,
179
+ marginBottom: 10,
180
+ index: i,
181
+ });
182
+ }
183
+
184
+ const advanceMix = [];
185
+ for (let i = 0; i < 6; i++) {
186
+ advanceMix.push({
187
+ width: 100,
188
+ height: 50,
189
+ name: "mix_button_" + i,
190
+ marginRight: 10,
191
+ marginBottom: 10,
192
+ type: i % 3 == 0 ? "button" : "item",
193
+ color: randomColor(),
194
+ content: i,
195
+ });
196
+ }
197
+
198
+ export {
199
+ randomColor,
200
+ simpleData,
201
+ simpleDataAbs,
202
+ advanceButton,
203
+ advanceMetroWidget,
204
+ advanceMix,
205
+ };
@@ -0,0 +1,145 @@
1
+ <script setup>
2
+ import {
3
+ jJsvRuntimeBridge,
4
+ MetroWidget,
5
+ HORIZONTAL,
6
+ JsvNinePatch,
7
+ } from "jsview";
8
+ import Item from "./Item.vue";
9
+ import borderImageUrl from "./assets/border.png";
10
+ import { ref, shallowRef, onMounted } from "vue";
11
+ import { useRouter, useRoute } from "vue-router";
12
+
13
+ const router = useRouter();
14
+
15
+ const data = [
16
+ {
17
+ blocks: {
18
+ w: 160,
19
+ h: 160,
20
+ },
21
+ color: "#FF9900",
22
+ content: 0,
23
+ },
24
+ {
25
+ blocks: {
26
+ w: 300,
27
+ h: 300,
28
+ },
29
+ color: "#0099FF",
30
+ content: 1,
31
+ },
32
+ {
33
+ blocks: {
34
+ w: 160,
35
+ h: 160,
36
+ },
37
+ color: "#FF9900",
38
+ content: 2,
39
+ },
40
+ ];
41
+
42
+ const framePosition = ref({
43
+ x: 0,
44
+ y: 0,
45
+ width: 50,
46
+ height: 50,
47
+ });
48
+
49
+ const _onFramePositionChanged = (new_x, new_y, new_width, new_height) => {
50
+ console.log(
51
+ `new x=${new_x} y=${new_y} width=${new_width} height=${new_height}`
52
+ );
53
+
54
+ framePosition.value = {
55
+ x: new_x,
56
+ y: new_y,
57
+ width: new_width,
58
+ height: new_height,
59
+ };
60
+ };
61
+
62
+ const _measures = (item) => {
63
+ return {
64
+ width: item.blocks.w,
65
+ height: item.blocks.h,
66
+ marginRight: 10,
67
+ marginTop: 10,
68
+ };
69
+ };
70
+
71
+ const _onKeyDown = (ev) => {
72
+ // 8:Backspace, 27:Escape, 10000:盒子返回键
73
+ if (ev.keyCode == 8 || ev.keyCode == 27 || ev.keyCode == 10000) {
74
+ router?.go(-1); // 有router时,是从DemoHomepage进入,回退
75
+ return true;
76
+ }
77
+ return false;
78
+ };
79
+
80
+ const myFocusWidget = shallowRef(null);
81
+
82
+ onMounted(() => {
83
+ myFocusWidget.value.getFocusBlockRef().requestFocus();
84
+ jJsvRuntimeBridge.notifyPageLoaded();
85
+ });
86
+ </script>
87
+
88
+ <template>
89
+ <div :style="{ width: 1280, height: 720, backgroundColor: '#FFFFFF' }">
90
+ <jsv-focus-block ref="focusNode" :onKeyDown="_onKeyDown">
91
+ <div
92
+ :style="{
93
+ textAlign: 'center',
94
+ fontSize: 30,
95
+ lineHeight: 50,
96
+ color: '#ffffff',
97
+ left: 140,
98
+ top: 20,
99
+ width: 1000,
100
+ height: 50,
101
+ backgroundColor: 'rgba(27,38,151,0.8)',
102
+ }"
103
+ >
104
+ NinePatch展示,框的四个角的方形中心和项目的四个顶点严格对齐
105
+ </div>
106
+ <metro-widget
107
+ ref="myFocusWidget"
108
+ :top="100"
109
+ :left="250"
110
+ :width="1000"
111
+ :height="400"
112
+ :direction="HORIZONTAL"
113
+ :data="data"
114
+ :measures="_measures"
115
+ :padding="{ left: 50, right: 50, top: 50, height: 50 }"
116
+ >
117
+ <template #renderItem="{ data, query, onEdge, onAction }">
118
+ <item
119
+ :data="data"
120
+ :query="query"
121
+ :onEdge="onEdge"
122
+ :onAction="onAction"
123
+ :frameChanged="_onFramePositionChanged"
124
+ />
125
+ </template>
126
+ </metro-widget>
127
+ <div :style="{ top: 150, left: 300 }">
128
+ <jsv-nine-patch
129
+ :style="{
130
+ width: framePosition.width,
131
+ height: framePosition.height,
132
+ top: framePosition.y,
133
+ left: framePosition.x,
134
+ }"
135
+ :imageUrl="borderImageUrl"
136
+ :imageWidth="81"
137
+ :centerWidth="25"
138
+ :borderOutset="14"
139
+ :imageDspWidth="81"
140
+ :animTime="0.2"
141
+ ></jsv-nine-patch>
142
+ </div>
143
+ </jsv-focus-block>
144
+ </div>
145
+ </template>
@@ -0,0 +1,69 @@
1
+ <script setup>
2
+ import { ref, shallowRef, computed } from "vue";
3
+
4
+ const props = defineProps({
5
+ data: Object,
6
+ query: Object,
7
+ onEdge: Function,
8
+ onAction: Object,
9
+ frameChanged: Function,
10
+ });
11
+
12
+ let focused = ref(false);
13
+
14
+ let styleValue = computed(() => {
15
+ return {
16
+ width: props.data.blocks.w,
17
+ height: props.data.blocks.h,
18
+ color: "#FFFFFF",
19
+ backgroundColor: props.data.color,
20
+ };
21
+ });
22
+
23
+ const onFocus = () => {
24
+ focused.value = true;
25
+ if (props.frameChanged) {
26
+ let pos = props.query.position(props.query.id);
27
+
28
+ // 焦点时套在放大的item外缘,所以要计算按照中心放大后的焦点框x,y,width,height
29
+ const new_x = pos.left + (pos.width - pos.width * 1.05) / 2;
30
+ const new_y = pos.top + (pos.height - pos.height * 1.05) / 2;
31
+ const new_width = pos.width * 1.05;
32
+ const new_height = pos.height * 1.05;
33
+
34
+ props.frameChanged(new_x, new_y, new_width, new_height);
35
+ }
36
+ };
37
+
38
+ const onBlur = () => {
39
+ focused.value = false;
40
+ };
41
+
42
+ const onClicked = () => {
43
+ onsole.log(`item ${props.query.id} clicked`);
44
+ };
45
+
46
+ props.onAction.register("onFocus", onFocus);
47
+ props.onAction.register("onBlur", onBlur);
48
+ props.onAction.register("onClick", onClicked);
49
+ </script>
50
+
51
+ <template>
52
+ <div :class="focused ? 'focus' : 'blur'" :style="styleValue">
53
+ {{ "" + props.data.content }}
54
+ </div>
55
+ </template>
56
+
57
+ <style scoped>
58
+ .focus {
59
+ transform: scale3d(1.05, 1.05, 1);
60
+ transition: transform 0.25s linear;
61
+ font-size: 30px;
62
+ }
63
+
64
+ .blur {
65
+ transform: scale3d(1, 1, 1);
66
+ transition: transform 0.25s linear;
67
+ font-size: 30px;
68
+ }
69
+ </style>
Binary file
@@ -0,0 +1,135 @@
1
+ <script setup>
2
+ import {
3
+ HORIZONTAL,
4
+ MetroWidget,
5
+ JsvPreload,
6
+ buildPreloadInfo,
7
+ buildDownloadInfo,
8
+ useFocusHub,
9
+ } from "jsview";
10
+ import awesome from "./images/awesomeface.png";
11
+ import cat from "./images/cat.jpg";
12
+ import { data } from "./data.js";
13
+ import Item from "./Item.vue";
14
+ import { ref, shallowRef } from "vue";
15
+ import { useRouter } from "vue-router";
16
+
17
+ const name = "/preload";
18
+ const focusHub = useFocusHub();
19
+ const text = ref("");
20
+ let preloadInfo = [];
21
+ let downloadInfo = [];
22
+ const router = useRouter();
23
+
24
+ const _onPreloading = (percent) => {
25
+ console.log("preloading ", percent);
26
+ };
27
+
28
+ const _onPreloadDone = (imageInfo) => {
29
+ console.log("PRELOAD DONE!", imageInfo);
30
+ };
31
+
32
+ const _onDownloadDone = (urls, extra) => {
33
+ console.log("DOWNLOAD DONE!", urls, extra);
34
+ text.value = `图片下载完成\n${awesome}\n${cat}`;
35
+ };
36
+
37
+ const _measures = () => {
38
+ return {
39
+ width: 180,
40
+ height: 90,
41
+ focusable: true,
42
+ };
43
+ };
44
+
45
+ const _onKeyDown = (ev) => {
46
+ if (ev.keyCode == 8 || ev.keyCode == 27 || ev.keyCode == 10000) {
47
+ router?.go(-1); // 有router时,是从DemoHomepage进入,回退
48
+ }
49
+ return true;
50
+ };
51
+
52
+ const _onFocus = () => {
53
+ focusHub.setFocus(name);
54
+ };
55
+
56
+ for (const item of data) {
57
+ preloadInfo.push(buildPreloadInfo(item.url));
58
+ preloadInfo.push(buildPreloadInfo(item.focusUrl));
59
+ }
60
+ preloadInfo.push(null); // 测试item为null的加载
61
+ downloadInfo = [
62
+ buildDownloadInfo(awesome, null, true),
63
+ buildDownloadInfo(cat, null, true),
64
+ buildDownloadInfo(null), // 测试URL为null的加载
65
+ ];
66
+ </script>
67
+
68
+ <template>
69
+ <jsv-focus-block
70
+ autoFocus
71
+ :style="{
72
+ width: 1920,
73
+ height: 1080,
74
+ backgroundColor: '#FFFFFF',
75
+ }"
76
+ :onAction="{
77
+ onKeyDown: _onKeyDown,
78
+ onFocus: _onFocus,
79
+ }"
80
+ >
81
+ <div
82
+ :style="{
83
+ textAlign: 'center',
84
+ fontSize: '30px',
85
+ lineHeight: '50px',
86
+ color: '#ffffff',
87
+ left: 100,
88
+ top: 20,
89
+ width: 1280 - 200,
90
+ height: 50,
91
+ backgroundColor: 'rgba(27,38,151,0.8)',
92
+ }"
93
+ >
94
+ 预加载后,图片(按钮焦点切换)切换不闪屏
95
+ </div>
96
+ <div :style="{ top: 200, left: 300 }">
97
+ <metro-widget
98
+ :name="name"
99
+ :width="540"
100
+ :height="90"
101
+ :direction="HORIZONTAL"
102
+ :data="data"
103
+ :measures="_measures"
104
+ >
105
+ <template #renderItem="{ data, query, onEdge, onAction }">
106
+ <item
107
+ :data="data"
108
+ :query="query"
109
+ :onEdge="onEdge"
110
+ :onAction="onAction"
111
+ />
112
+ </template>
113
+ </metro-widget>
114
+ </div>
115
+ <div
116
+ :style="{
117
+ left: 100,
118
+ top: 350,
119
+ width: 800,
120
+ height: 800,
121
+ fontSize: '30px',
122
+ color: '#000000',
123
+ }"
124
+ >
125
+ {{ text }}
126
+ </div>
127
+ <jsv-preload
128
+ :preloadList="preloadInfo"
129
+ :downloadList="downloadInfo"
130
+ :onPreloadDone="_onPreloadDone"
131
+ :onDownloadDone="_onDownloadDone"
132
+ :onPreloading="_onPreloading"
133
+ />
134
+ </jsv-focus-block>
135
+ </template>
@@ -0,0 +1,32 @@
1
+ <script setup>
2
+ import { ref, shallowRef } from "vue";
3
+ const props = defineProps({
4
+ data: Object,
5
+ query: Object,
6
+ onEdge: Function,
7
+ onAction: Object,
8
+ });
9
+ const focus = ref(false);
10
+
11
+ const onFocus = () => {
12
+ focus.value = true;
13
+ };
14
+ const onBlur = () => {
15
+ focus.value = false;
16
+ };
17
+ props.onAction.register("onFocus", onFocus);
18
+ props.onAction.register("onBlur", onBlur);
19
+ props.onAction.register("onClick", () => {
20
+ console.log("cchtest item on click ", data);
21
+ });
22
+ </script>
23
+
24
+ <template>
25
+ <div
26
+ :style="{
27
+ width: 166,
28
+ height: 90,
29
+ backgroundImage: focus ? data.focusUrl : data.url,
30
+ }"
31
+ ></div>
32
+ </template>
@@ -0,0 +1,23 @@
1
+ import rank from "./images/rank.png";
2
+ import rankF from "./images/rank_focus.png";
3
+ import rule from "./images/rule.png";
4
+ import ruleF from "./images/rule_focus.png";
5
+ import start from "./images/start.png";
6
+ import startF from "./images/start_focus.png";
7
+
8
+ const data = [
9
+ {
10
+ url: rank,
11
+ focusUrl: rankF,
12
+ },
13
+ {
14
+ url: start,
15
+ focusUrl: startF
16
+ },
17
+ {
18
+ url: rule,
19
+ focusUrl: ruleF,
20
+ },
21
+ ];
22
+
23
+ export { data };
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file