@shijiu/jsview-vue-samples 2.0.1073 → 2.0.1106

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 (90) hide show
  1. package/Basic/components/div/DivBackground.vue +13 -25
  2. package/Basic/components/img/ImageGroup.vue +14 -20
  3. package/Basic/components/img/ImgLayout.vue +59 -68
  4. package/BasicFocusControl/components/BaseBlock.vue +11 -17
  5. package/BasicFocusControl/components/MainAreaLeftBlock.vue +2 -2
  6. package/BasicFocusControl/components/MainAreaRightBlock.vue +2 -2
  7. package/BasicFocusControl/components/SideBarBlock.vue +2 -2
  8. package/CssPreprocessor/App.vue +40 -51
  9. package/CssPreprocessor/Less/App.vue +6 -14
  10. package/CssPreprocessor/Scss/App.vue +6 -14
  11. package/CssPreprocessor/Scss/components/scss-group1/ScssOperations.vue +0 -1
  12. package/CssPreprocessor/Stylus/App.vue +6 -14
  13. package/CssPreprocessor/utils/ContentBlock.vue +30 -12
  14. package/CssPreprocessor/utils/ContentList.vue +23 -14
  15. package/CssPreprocessor/utils/Panel.vue +34 -23
  16. package/CssPreprocessor/utils/TitleBar.vue +7 -9
  17. package/DemoHomepage/components/BodyFrame.vue +54 -78
  18. package/DemoHomepage/components/Dialog.vue +38 -43
  19. package/DemoHomepage/components/Item.vue +52 -55
  20. package/DemoHomepage/components/TabFrame.vue +43 -72
  21. package/DemoHomepage/router.js +1 -1
  22. package/GiftRain/App.vue +10 -4
  23. package/GridDemo/App.vue +5 -5
  24. package/GridDemo/FocusItem.vue +3 -5
  25. package/GridDemo/Item.vue +4 -24
  26. package/HashHistory/App.vue +0 -10
  27. package/HashHistory/views/MainPage.vue +0 -1
  28. package/ImpactStop/App.vue +0 -1
  29. package/Input/App.vue +106 -150
  30. package/Input/FullKeyboard.vue +18 -28
  31. package/Input/InputPanel.vue +87 -109
  32. package/Input/KeyboardItem.vue +35 -45
  33. package/JsvRadarChart/App.vue +16 -19
  34. package/LongImage/Button.vue +2 -3
  35. package/LongText/App.vue +0 -3
  36. package/LongText/Button.vue +0 -1
  37. package/LongText/LongTextScroll.vue +0 -4
  38. package/Marquee/App.vue +1 -0
  39. package/MetroWidgetDemos/PerformanceTest/App.vue +2 -3
  40. package/MetroWidgetDemos/PerformanceTest/Item.vue +52 -55
  41. package/MetroWidgetDemos/PerformanceTest/components/ContentItem.vue +26 -26
  42. package/MetroWidgetDemos/PerformanceTest/components/MyTab.vue +86 -95
  43. package/MetroWidgetDemos/PingPong/App.vue +56 -89
  44. package/MetroWidgetDemos/PingPong/AppPage.vue +3 -3
  45. package/MetroWidgetDemos/PingPong/Item.vue +1 -1
  46. package/MetroWidgetDemos/PingPong/TabItem.vue +3 -3
  47. package/MetroWidgetDemos/PingPong/WidgetItem.vue +1 -1
  48. package/MetroWidgetDemos/SkeletonDiagram/App.vue +2 -4
  49. package/MetroWidgetDemos/basic/Item.vue +1 -1
  50. package/MetroWidgetDemos/direction/App.vue +0 -2
  51. package/MetroWidgetDemos/direction/Item.vue +1 -1
  52. package/MetroWidgetDemos/focusableItemBasic/App.vue +1 -1
  53. package/MetroWidgetDemos/focusableItemBasic/ButtonItem.vue +1 -1
  54. package/MetroWidgetDemos/focusableItemMetroWidget/App.vue +1 -1
  55. package/MetroWidgetDemos/focusableItemMetroWidget/Item.vue +1 -1
  56. package/MetroWidgetDemos/focusableItemMetroWidget/WidgetItem.vue +1 -1
  57. package/MetroWidgetDemos/focusableItemMix/App.vue +1 -1
  58. package/MetroWidgetDemos/focusableItemMix/ButtonItem.vue +1 -1
  59. package/MetroWidgetDemos/focusableItemMix/Item.vue +1 -1
  60. package/MetroWidgetDemos/itemSizeUpdate/backward/Item.vue +23 -25
  61. package/MetroWidgetDemos/layoutType/App.vue +0 -2
  62. package/MetroWidgetDemos/layoutType/Item.vue +1 -1
  63. package/MetroWidgetDemos/ninePatchFocusPage/App.vue +0 -1
  64. package/MetroWidgetDemos/ninePatchFocusPage/PageRow.vue +1 -1
  65. package/MetroWidgetDemos/padding/App.vue +0 -2
  66. package/MetroWidgetDemos/padding/Item.vue +1 -1
  67. package/MetroWidgetDemos/slideSetting/Item.vue +1 -1
  68. package/MockjsDemo/App.vue +26 -11
  69. package/MockjsDemo/mock/index.js +9 -1
  70. package/QrcodeDemo/App.vue +0 -1
  71. package/SoundPool/App.vue +1 -2
  72. package/SpriteImage/App.vue +89 -125
  73. package/Swiper/App.vue +1 -3
  74. package/TestNativeSharedView/App.vue +104 -48
  75. package/TextBox/RenderCenter.vue +89 -113
  76. package/TextBox/RenderLeft.vue +89 -113
  77. package/TextBox/RenderOneLine.vue +7 -10
  78. package/TextBox/RenderRight.vue +8 -11
  79. package/TextShadowDemo/App.vue +54 -75
  80. package/TextureAnimation/App.vue +175 -287
  81. package/TextureAnimation/App2.vue +1 -5
  82. package/ThrowMoveDemo/AccelerateDemo.vue +40 -71
  83. package/ThrowMoveDemo/App.vue +13 -23
  84. package/ThrowMoveDemo/TargetDemo.vue +24 -53
  85. package/ThrowMoveDemo/UDParabolicDemo.vue +31 -60
  86. package/VideoDemo/App.vue +71 -116
  87. package/package.json +1 -1
  88. package/VideoDemo/components/Button.vue +0 -58
  89. package/VideoDemo/components/Controllor.vue +0 -197
  90. package/VideoDemo/components/VideoFrame.vue +0 -140
@@ -1,4 +1,4 @@
1
- <script>
1
+ <script setup>
2
2
  import {
3
3
  jJsvRuntimeBridge,
4
4
  getKeyFramesGroup,
@@ -6,314 +6,202 @@ import {
6
6
  } from "jsview";
7
7
  import img from "./assets/php2.png";
8
8
  import swipLight from "./assets/swipLight.png";
9
+ import { onMounted, onBeforeUnmount } from "vue";
10
+ import { useRouter } from "vue-router";
11
+ const router = useRouter()
12
+ const styleShell = getKeyFramesGroup();
13
+ const translateTransform = "translate3d(50%, 50%, 0)";
14
+ const rotateTransform = "rotate3d(1,1,1, 30deg)";
15
+ const scaleTransform = "scale3d(0.5, 1.5, 1.0)";
16
+ const borderRadius = 40;
17
+ const repeat = -1;
18
+ const duration = 3000;
9
19
 
10
- export default {
11
- components: {
12
- JsvTextureAnim,
13
- },
14
- setup() {
15
- let styleShell = getKeyFramesGroup();
20
+ const translateAnim =
21
+ "{from {transform: translate3d(-100%, -50%, 0);} to {transform: translate3d(100%, 50%, 0);}}";
22
+ const rotateAnim =
23
+ "{from {transform: rotate3d(1,-1,1,0);} to {transform: rotate3d(1,-1,1,360deg);}}";
24
+ const scaleAnim =
25
+ "{from {transform: scale3d(0.5, 0.5, 1);} to {transform: scale3d(1.5, 1.5, 1);}}";
26
+ const swipAnim =
27
+ "{from {transform: translate3d(-100%, 0, 0);} to {transform: translate3d(100%, 0, 0);}}";
16
28
 
17
- const translateAnim =
18
- "{from {transform: translate3d(-100%, -50%, 0);} to {transform: translate3d(100%, 50%, 0);}}";
19
- const rotateAnim =
20
- "{from {transform: rotate3d(1,-1,1,0);} to {transform: rotate3d(1,-1,1,360deg);}}";
21
- const scaleAnim =
22
- "{from {transform: scale3d(0.5, 0.5, 1);} to {transform: scale3d(1.5, 1.5, 1);}}";
29
+ styleShell.insertRule(
30
+ "@keyframes texture-anim-translate " + translateAnim
31
+ );
32
+ styleShell.insertRule(
33
+ "@keyframes texture-anim-rotate " + rotateAnim
34
+ );
35
+ styleShell.insertRule(
36
+ "@keyframes texture-anim-scale " + scaleAnim
37
+ );
23
38
 
24
- const swipAnim =
25
- "{from {transform: translate3d(-100%, 0, 0);} to {transform: translate3d(100%, 0, 0);}}";
39
+ const onKeyDown = (ev) => {
40
+ // 8:Backspace, 27:Escape, 10000:盒子返回键
41
+ if (ev.keyCode == 8 || ev.keyCode == 27 || ev.keyCode == 10000) {
42
+ router?.go(-1); // 有router时,是从DemoHomepage进入,回退
43
+ }
44
+ return true;
45
+ }
46
+
47
+ onMounted(() => {
48
+ jJsvRuntimeBridge.notifyPageLoaded();
49
+ })
50
+
51
+ onBeforeUnmount(() => {
52
+ styleShell.removeRule("texture-anim-translate");
53
+ styleShell.removeRule("texture-anim-rotate");
54
+ styleShell.removeRule("texture-anim-scale");
55
+ })
26
56
 
27
- return {
28
- styleShell,
29
- img,
30
- borderRadius: 40,
31
- repeat: -1,
32
- duration: 3000,
33
- translateAnim,
34
- rotateAnim,
35
- scaleAnim,
36
- swipAnim,
37
- translateTransform: "translate3d(50%, 50%, 0)",
38
- rotateTransform: "rotate3d(1,1,1, 30deg)",
39
- scaleTransform: "scale3d(0.5, 1.5, 1.0)",
40
- swipLight,
41
- };
42
- },
43
- methods: {
44
- onKeyDown(ev) {
45
- // 8:Backspace, 27:Escape, 10000:盒子返回键
46
- if (ev.keyCode == 8 || ev.keyCode == 27 || ev.keyCode == 10000) {
47
- this.$router?.go(-1); // 有router时,是从DemoHomepage进入,回退
48
- }
49
- return true;
50
- },
51
- },
52
- created() {
53
- this.styleShell.insertRule(
54
- "@keyframes texture-anim-translate " + this.translateAnim
55
- );
56
- this.styleShell.insertRule(
57
- "@keyframes texture-anim-rotate " + this.rotateAnim
58
- );
59
- this.styleShell.insertRule(
60
- "@keyframes texture-anim-scale " + this.scaleAnim
61
- );
62
- },
63
- mounted() {
64
- jJsvRuntimeBridge.notifyPageLoaded();
65
- },
66
- beforeUnmount() {
67
- this.styleShell.removeRule("texture-anim-translate");
68
- this.styleShell.removeRule("texture-anim-rotate");
69
- this.styleShell.removeRule("texture-anim-scale");
70
- },
71
- };
72
57
  </script>
73
58
  <template>
74
- <jsv-focus-block
75
- autoFocus
76
- :onKeyDown="onKeyDown"
77
- :style="{
78
- width: 1920,
79
- height: 1080,
80
- backgroundColor: '#007788',
81
- }"
82
- >
83
- <div
84
- :style="{
85
- left: 100,
86
- top: 20,
87
- }"
88
- >
89
- <div
90
- :style="{
91
- width: 300,
92
- height: 150,
93
- backgroundColor: 'rgba(0,255,0,0.5)',
94
- }"
95
- />
96
- <jsv-texture-anim
97
- :src="img"
98
- :width="300"
99
- :height="150"
100
- :animation="translateAnim"
101
- :duration="duration"
102
- :transform="null"
103
- :borderRadius="borderRadius"
104
- :repeat="repeat"
105
- :autoStart="true"
106
- ></jsv-texture-anim>
107
- <div
108
- :style="{
109
- width: 300,
110
- height: 150,
111
- backgroundColor: 'rgba(255,0,0,0.5)',
112
- transform: null,
113
- animation: `texture-anim-translate ${
114
- duration / 1000
59
+ <jsv-focus-block autoFocus :onKeyDown="onKeyDown" :style="{
60
+ width: 1920,
61
+ height: 1080,
62
+ backgroundColor: '#007788',
63
+ }">
64
+ <div :style="{
65
+ left: 100,
66
+ top: 20,
67
+ }">
68
+ <div :style="{
69
+ width: 300,
70
+ height: 150,
71
+ backgroundColor: 'rgba(0,255,0,0.5)',
72
+ }" />
73
+ <jsv-texture-anim :src="img" :width="300" :height="150" :animation="translateAnim" :duration="duration"
74
+ :transform="null" :borderRadius="borderRadius" :repeat="repeat" :autoStart="true"></jsv-texture-anim>
75
+ <div :style="{
76
+ width: 300,
77
+ height: 150,
78
+ backgroundColor: 'rgba(255,0,0,0.5)',
79
+ transform: null,
80
+ animation: `texture-anim-translate ${duration / 1000
115
81
  }s linear infinite`,
116
- }"
117
- />
82
+ }" />
118
83
  </div>
119
84
 
120
- <div
121
- :style="{
122
- left: 100,
123
- top: 230,
124
- }"
125
- >
126
- <div
127
- :style="{
128
- width: 300,
129
- height: 150,
130
- backgroundColor: 'rgba(0,255,0,0.5)',
131
- }"
132
- />
133
- <jsv-texture-anim
134
- :src="img"
135
- :width="300"
136
- :height="150"
137
- :animation="rotateAnim"
138
- :duration="duration"
139
- :transform="null"
140
- :borderRadius="borderRadius"
141
- :repeat="repeat"
142
- :autoStart="true"
143
- ></jsv-texture-anim>
144
- <div
145
- :style="{
146
- width: 300,
147
- height: 150,
148
- backgroundColor: 'rgba(255,0,0,0.5)',
149
- transform: null,
150
- animation: `texture-anim-rotate ${duration / 1000}s linear infinite`,
151
- }"
152
- />
85
+ <div :style="{
86
+ left: 100,
87
+ top: 230,
88
+ }">
89
+ <div :style="{
90
+ width: 300,
91
+ height: 150,
92
+ backgroundColor: 'rgba(0,255,0,0.5)',
93
+ }" />
94
+ <jsv-texture-anim :src="img" :width="300" :height="150" :animation="rotateAnim" :duration="duration"
95
+ :transform="null" :borderRadius="borderRadius" :repeat="repeat" :autoStart="true"></jsv-texture-anim>
96
+ <div :style="{
97
+ width: 300,
98
+ height: 150,
99
+ backgroundColor: 'rgba(255,0,0,0.5)',
100
+ transform: null,
101
+ animation: `texture-anim-rotate ${duration / 1000}s linear infinite`,
102
+ }" />
153
103
  </div>
154
104
 
155
- <div
156
- :style="{
157
- left: 100,
158
- top: 460,
159
- }"
160
- >
161
- <div
162
- :style="{
163
- width: 300,
164
- height: 150,
165
- backgroundColor: 'rgba(0,255,0,0.5)',
166
- }"
167
- />
168
- <jsv-texture-anim
169
- :src="img"
170
- :width="300"
171
- :height="150"
172
- :animation="scaleAnim"
173
- :duration="duration"
174
- :transform="null"
175
- :borderRadius="borderRadius"
176
- :repeat="repeat"
177
- :autoStart="true"
178
- ></jsv-texture-anim>
179
- <div
180
- :style="{
181
- width: 300,
182
- height: 150,
183
- backgroundColor: 'rgba(255,0,0,0.5)',
184
- transform: null,
185
- animation: `texture-anim-scale ${duration / 1000}s linear infinite`,
186
- }"
187
- />
105
+ <div :style="{
106
+ left: 100,
107
+ top: 460,
108
+ }">
109
+ <div :style="{
110
+ width: 300,
111
+ height: 150,
112
+ backgroundColor: 'rgba(0,255,0,0.5)',
113
+ }" />
114
+ <jsv-texture-anim :src="img" :width="300" :height="150" :animation="scaleAnim" :duration="duration"
115
+ :transform="null" :borderRadius="borderRadius" :repeat="repeat" :autoStart="true"></jsv-texture-anim>
116
+ <div :style="{
117
+ width: 300,
118
+ height: 150,
119
+ backgroundColor: 'rgba(255,0,0,0.5)',
120
+ transform: null,
121
+ animation: `texture-anim-scale ${duration / 1000}s linear infinite`,
122
+ }" />
188
123
  </div>
189
124
  <!-- transform sample -->
190
- <div
191
- :style="{
192
- left: 500,
193
- top: 20,
194
- }"
195
- >
196
- <div
197
- :style="{
198
- width: 300,
199
- height: 150,
200
- backgroundColor: 'rgba(0,255,0,0.5)',
201
- }"
202
- />
203
- <jsv-texture-anim
204
- :src="img"
205
- :width="300"
206
- :height="150"
207
- :transform="translateTransform"
208
- :borderRadius="borderRadius"
209
- ></jsv-texture-anim>
210
- <div
211
- :style="{
212
- width: 300,
213
- height: 150,
214
- backgroundColor: 'rgba(255,0,0,0.5)',
215
- transform: translateTransform,
216
- }"
217
- />
125
+ <div :style="{
126
+ left: 500,
127
+ top: 20,
128
+ }">
129
+ <div :style="{
130
+ width: 300,
131
+ height: 150,
132
+ backgroundColor: 'rgba(0,255,0,0.5)',
133
+ }" />
134
+ <jsv-texture-anim :src="img" :width="300" :height="150" :transform="translateTransform"
135
+ :borderRadius="borderRadius"></jsv-texture-anim>
136
+ <div :style="{
137
+ width: 300,
138
+ height: 150,
139
+ backgroundColor: 'rgba(255,0,0,0.5)',
140
+ transform: translateTransform,
141
+ }" />
218
142
  </div>
219
143
 
220
- <div
221
- :style="{
222
- left: 500,
223
- top: 230,
224
- }"
225
- >
226
- <div
227
- :style="{
228
- width: 300,
229
- height: 150,
230
- backgroundColor: 'rgba(0,255,0,0.5)',
231
- }"
232
- />
233
- <jsv-texture-anim
234
- :src="img"
235
- :width="300"
236
- :height="150"
237
- :transform="rotateTransform"
238
- :borderRadius="borderRadius"
239
- ></jsv-texture-anim>
240
- <div
241
- :style="{
242
- width: 300,
243
- height: 150,
244
- backgroundColor: 'rgba(255,0,0,0.5)',
245
- transform: rotateTransform,
246
- }"
247
- />
144
+ <div :style="{
145
+ left: 500,
146
+ top: 230,
147
+ }">
148
+ <div :style="{
149
+ width: 300,
150
+ height: 150,
151
+ backgroundColor: 'rgba(0,255,0,0.5)',
152
+ }" />
153
+ <jsv-texture-anim :src="img" :width="300" :height="150" :transform="rotateTransform"
154
+ :borderRadius="borderRadius"></jsv-texture-anim>
155
+ <div :style="{
156
+ width: 300,
157
+ height: 150,
158
+ backgroundColor: 'rgba(255,0,0,0.5)',
159
+ transform: rotateTransform,
160
+ }" />
248
161
  </div>
249
162
 
250
- <div
251
- :style="{
252
- left: 500,
253
- top: 460,
254
- }"
255
- >
256
- <div
257
- :style="{
258
- width: 300,
259
- height: 150,
260
- backgroundColor: 'rgba(0,255,0,0.5)',
261
- }"
262
- />
263
- <jsv-texture-anim
264
- :src="img"
265
- :width="300"
266
- :height="150"
267
- :transform="scaleTransform"
268
- :borderRadius="borderRadius"
269
- ></jsv-texture-anim>
270
- <div
271
- :style="{
272
- width: 300,
273
- height: 150,
274
- backgroundColor: 'rgba(255,0,0,0.5)',
275
- transform: scaleTransform,
276
- }"
277
- />
163
+ <div :style="{
164
+ left: 500,
165
+ top: 460,
166
+ }">
167
+ <div :style="{
168
+ width: 300,
169
+ height: 150,
170
+ backgroundColor: 'rgba(0,255,0,0.5)',
171
+ }" />
172
+ <jsv-texture-anim :src="img" :width="300" :height="150" :transform="scaleTransform"
173
+ :borderRadius="borderRadius"></jsv-texture-anim>
174
+ <div :style="{
175
+ width: 300,
176
+ height: 150,
177
+ backgroundColor: 'rgba(255,0,0,0.5)',
178
+ transform: scaleTransform,
179
+ }" />
278
180
  </div>
279
181
  <!-- swip light -->
280
- <div
281
- :style="{
282
- left: 850,
283
- top: 460,
284
- }"
285
- >
286
- <div
287
- :style="{
288
- width: 300,
289
- height: 150,
290
- backgroundColor: 'rgba(0,255,0,0.5)',
291
- }"
292
- />
293
- <jsv-texture-anim
294
- :src="swipLight"
295
- :animation="swipAnim"
296
- :width="300"
297
- :height="150"
298
- :duration="duration"
299
- transform="scale3d(0.5, 1, 1) rotate3d(0,0,1, 30deg)"
300
- :borderRadius="borderRadius"
301
- :repeat="repeat"
302
- :autoStart="true"
303
- ></jsv-texture-anim>
182
+ <div :style="{
183
+ left: 850,
184
+ top: 460,
185
+ }">
186
+ <div :style="{
187
+ width: 300,
188
+ height: 150,
189
+ backgroundColor: 'rgba(0,255,0,0.5)',
190
+ }" />
191
+ <jsv-texture-anim :src="swipLight" :animation="swipAnim" :width="300" :height="150" :duration="duration"
192
+ transform="scale3d(0.5, 1, 1) rotate3d(0,0,1, 30deg)" :borderRadius="borderRadius" :repeat="repeat"
193
+ :autoStart="true"></jsv-texture-anim>
304
194
  </div>
305
195
 
306
196
  <!-- 说明文字 -->
307
- <div
308
- :style="{
309
- left: 100,
310
- top: 620,
311
- width: 1920,
312
- height: 200,
313
- fontSize: 30,
314
- color: '#000000',
315
- }"
316
- >
197
+ <div :style="{
198
+ left: 100,
199
+ top: 620,
200
+ width: 1920,
201
+ height: 200,
202
+ fontSize: 30,
203
+ color: '#000000',
204
+ }">
317
205
  {{ "1. 注意圆角\n2. 红色半透明的view为标准, 图片的动画需要与其一致" }}
318
206
  </div>
319
207
  </jsv-focus-block>
@@ -1,13 +1,9 @@
1
1
  <script setup>
2
- import { ref, reactive } from "vue";
2
+ import { ref } from "vue";
3
3
  import { useRouter } from "vue-router";
4
4
  import {
5
- jJsvRuntimeBridge,
6
- getKeyFramesGroup,
7
5
  JsvTextureAnim,
8
- TexAlignAnchor,
9
6
  DECORATE_NINEPATCH_ALPHA_MIX,
10
- DECORATE_BORDER_RADIUS,
11
7
  } from "jsview";
12
8
  import img from "./assets/light.png";
13
9
  import img2 from "./assets/light2.png";
@@ -1,92 +1,61 @@
1
1
  <!--
2
2
  * @Author: ChenChanghua
3
3
  * @Date: 2021-10-20 18:27:25
4
- * @LastEditors: ChenChanghua
5
- * @LastEditTime: 2022-07-08 14:11:05
4
+ * @LastEditors: ZhengYi
5
+ * @LastEditTime: 2023-05-05
6
6
  * @Description: file content
7
7
  -->
8
- <script>
8
+ <script setup>
9
9
  import { JsvActorMoveControl, JsvActorMove } from "jsview";
10
- export default {
11
- components: {
12
- JsvActorMove,
13
- },
14
- props: {
15
- name: String,
16
- },
17
- data() {
18
- return {
19
- direction: 1,
20
- };
21
- },
22
- computed: {
23
- directionDetail() {
24
- return this.direction > 0 ? "上" : "下";
25
- },
26
- },
27
- setup() {
28
- let throwControl = new JsvActorMoveControl(); // 抛物运动体控制器
29
- let moveControl = new JsvActorMoveControl(); // 平移运动体控制器
10
+ import { shallowRef, computed } from "vue"
11
+ const props = defineProps({
12
+ name: String,
13
+ })
14
+ let direction = shallowRef(1)
15
+ let throwControl = new JsvActorMoveControl(); // 抛物运动体控制器
16
+ let moveControl = new JsvActorMoveControl(); // 平移运动体控制器
17
+ let focusNode = shallowRef(null)
30
18
 
31
- return {
32
- throwControl,
33
- moveControl,
34
- };
35
- },
36
- methods: {
37
- onKeyDown(ev) {
38
- if (ev.keyCode === 13) {
39
- let preDirection = this.direction;
40
- this.direction = -this.direction;
41
- this.throwControl.throwAlongY(
42
- 0,
43
- 750 * preDirection,
44
- {
45
- type: "catch",
46
- position: 200 * preDirection,
47
- direction: preDirection,
48
- },
49
- (x, y) => {
50
- console.log(`Throw end with x=${x} y=${y}`);
51
- }
52
- );
53
- return true;
19
+ const directionDetail = computed(() => {
20
+ return direction.value > 0 ? "上" : "下";
21
+ })
22
+
23
+ const onKeyDown = (ev) => {
24
+ if (ev.keyCode === 13) {
25
+ let preDirection = direction.value;
26
+ direction.value = -direction.value;
27
+ throwControl.throwAlongY(
28
+ 0,
29
+ 750 * preDirection,
30
+ {
31
+ type: "catch",
32
+ position: 200 * preDirection,
33
+ direction: preDirection,
34
+ },
35
+ (x, y) => {
36
+ console.log(`Throw end with x=${x} y=${y}`);
54
37
  }
55
- return false;
56
- },
57
- },
58
- };
38
+ );
39
+ return true;
40
+ }
41
+ return false;
42
+ }
59
43
  </script>
60
44
 
61
45
  <template>
62
- <jsv-focus-block
63
- ref="focusNode"
64
- :name="name"
65
- autoFocus
66
- :onAction="{
67
- onKeyDown: onKeyDown,
68
- }"
69
- >
70
- <div
71
- key="sample1"
72
- class="detail-font"
73
- :style="{ top: 150, left: 425, width: 430, height: 40 }"
74
- >
46
+ <jsv-focus-block ref="focusNode" :name="props.name" autoFocus :onAction="{
47
+ onKeyDown: onKeyDown,
48
+ }">
49
+ <div key="sample1" class="detail-font" :style="{ top: 150, left: 425, width: 430, height: 40 }">
75
50
  {{ `向${directionDetail}加速` }}
76
51
  </div>
77
- <div
78
- key="DirectText"
79
- class="font"
80
- :style="{ top: 250, left: 425, width: 430, height: 40 }"
81
- >
52
+ <div key="DirectText" class="font" :style="{ top: 250, left: 425, width: 430, height: 40 }">
82
53
  {{ `当前方向:${directionDetail}` }}
83
54
  </div>
84
55
  <div :style="{ top: 590, left: 625 }">
85
56
  <jsv-actor-move key="move" :control="moveControl">
86
57
  <jsv-actor-move key="throw" :control="throwControl">
87
- <div
88
- :style="{ backgroundColor: '#FF0000', width: 30, height: 30 }"
89
- ></div>
58
+ <div :style="{ backgroundColor: '#FF0000', width: 30, height: 30 }"></div>
90
59
  </jsv-actor-move>
91
60
  </jsv-actor-move>
92
61
  </div>