@shijiu/jsview-vue 0.9.502 → 0.9.631

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 (240) 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/target_core_revision.js +4 -3
  4. package/index.js +10 -0
  5. package/package.json +8 -1
  6. package/patches/node_modules/@vue/runtime-core/dist/runtime-core.esm-bundler.js +16 -5
  7. package/samples/AnimPicture/App.vue +89 -106
  8. package/samples/Basic/App.vue +65 -68
  9. package/samples/Basic/components/ContentBlock.vue +31 -36
  10. package/samples/Basic/components/anim/AnimGroup.vue +61 -75
  11. package/samples/Basic/components/anim/AnimKeyframeBasic.vue +54 -43
  12. package/samples/Basic/components/anim/AnimKeyframeComposite.vue +25 -31
  13. package/samples/Basic/components/anim/AnimTransition.vue +142 -105
  14. package/samples/Basic/components/div/DivBackground.vue +38 -16
  15. package/samples/Basic/components/div/DivClip.vue +143 -78
  16. package/samples/Basic/components/div/DivCssScoped.vue +10 -10
  17. package/samples/Basic/components/div/DivCssVar.vue +40 -42
  18. package/samples/Basic/components/div/DivGroup1.vue +45 -39
  19. package/samples/Basic/components/div/DivGroup2.vue +56 -45
  20. package/samples/Basic/components/div/DivLayout.vue +63 -5
  21. package/samples/Basic/components/div/DivRadius.vue +51 -42
  22. package/samples/Basic/components/div/DivTransform.vue +21 -16
  23. package/samples/Basic/components/panel/Panel1.vue +46 -44
  24. package/samples/Basic/components/panel/Panel2.vue +22 -26
  25. package/samples/Basic/components/panel/TitleBar.vue +12 -12
  26. package/samples/Basic/components/text/TextAlign.vue +54 -44
  27. package/samples/Basic/components/text/TextEmoji.vue +16 -20
  28. package/samples/Basic/components/text/TextFontStyle.vue +77 -53
  29. package/samples/Basic/components/text/TextGroup1.vue +46 -38
  30. package/samples/Basic/components/text/TextGroup2.vue +25 -28
  31. package/samples/Basic/components/text/TextOverflow.vue +78 -59
  32. package/samples/BasicFocusControl/App.vue +22 -43
  33. package/samples/BasicFocusControl/components/BaseBlock.vue +42 -43
  34. package/samples/BasicFocusControl/components/MainArea.vue +55 -70
  35. package/samples/BasicFocusControl/components/MainAreaLeftBlock.vue +11 -15
  36. package/samples/BasicFocusControl/components/MainAreaRightBlock.vue +21 -24
  37. package/samples/BasicFocusControl/components/SideBar.vue +32 -47
  38. package/samples/BasicFocusControl/components/SideBarBlock.vue +20 -23
  39. package/samples/Collision/App.vue +452 -0
  40. package/samples/ColorSpace/App.vue +15 -24
  41. package/samples/DemoHomepage/App.vue +7 -11
  42. package/samples/DemoHomepage/components/BodyFrame.vue +21 -9
  43. package/samples/DemoHomepage/components/TabFrame.vue +7 -8
  44. package/samples/DemoHomepage/router.js +52 -33
  45. package/samples/DemoHomepage/views/Homepage.vue +18 -9
  46. package/samples/FilterDemo/AnimatePic.vue +58 -0
  47. package/samples/FilterDemo/App.vue +99 -61
  48. package/samples/FilterDemo/VideoLayer.vue +62 -0
  49. package/samples/FlipCard/App.vue +32 -41
  50. package/samples/FlipCard/FlipCard.vue +48 -54
  51. package/samples/GridDemo/App.vue +109 -77
  52. package/samples/GridDemo/ButtonBlock.vue +50 -49
  53. package/samples/GridDemo/FocusItem.vue +19 -38
  54. package/samples/GridDemo/Item.vue +46 -54
  55. package/samples/HashHistory/App.vue +63 -79
  56. package/samples/HashHistory/components/HorizontalButtonList.vue +72 -95
  57. package/samples/HashHistory/components/Item.vue +42 -56
  58. package/samples/HashHistory/router.js +23 -12
  59. package/samples/HashHistory/views/MainPage.vue +35 -46
  60. package/samples/HashHistory/views/SubPage.vue +34 -47
  61. package/samples/ImpactStop/App.vue +435 -0
  62. package/samples/Input/App.vue +8 -18
  63. package/samples/Input/FullKeyboard.vue +2 -6
  64. package/samples/Input/InputPanel.vue +18 -12
  65. package/samples/Input/KeyboardItem.vue +1 -1
  66. package/samples/LongImage/App.vue +11 -27
  67. package/samples/LongImage/Button.vue +50 -145
  68. package/samples/LongImage/ButtonItem.vue +44 -0
  69. package/samples/LongImage/LongImageScroll.vue +71 -106
  70. package/samples/LongImage/Scroll.vue +7 -9
  71. package/samples/LongText/App.vue +13 -28
  72. package/samples/LongText/Button.vue +43 -145
  73. package/samples/LongText/ButtonItem.vue +44 -0
  74. package/samples/LongText/LongTextScroll.vue +68 -101
  75. package/samples/LongText/Scroll.vue +7 -9
  76. package/samples/Marquee/App.vue +34 -37
  77. package/samples/MaskClip/App.vue +17 -30
  78. package/samples/MetroWidgetDemos/Advanced/App.vue +47 -0
  79. package/samples/MetroWidgetDemos/Advanced/ButtonItem.vue +90 -0
  80. package/samples/MetroWidgetDemos/Advanced/Buttons.vue +70 -0
  81. package/samples/MetroWidgetDemos/Advanced/Mixed.vue +77 -0
  82. package/samples/MetroWidgetDemos/Advanced/Widgets.vue +71 -0
  83. package/samples/MetroWidgetDemos/Item.vue +67 -0
  84. package/samples/{SimpleWidgetDemo → MetroWidgetDemos/PerformanceTest}/App.vue +80 -104
  85. package/samples/{SimpleWidgetDemo → MetroWidgetDemos/PerformanceTest}/Item.vue +7 -0
  86. package/samples/{ClassNameDemo → MetroWidgetDemos/PerformanceTest}/assets/bg.jpg +0 -0
  87. package/samples/{ClassNameDemo → MetroWidgetDemos/PerformanceTest}/assets/coupon_content.png +0 -0
  88. package/samples/{ClassNameDemo → MetroWidgetDemos/PerformanceTest}/assets/coupon_left.png +0 -0
  89. package/samples/{ClassNameDemo → MetroWidgetDemos/PerformanceTest}/assets/coupon_mid.png +0 -0
  90. package/samples/{ClassNameDemo → MetroWidgetDemos/PerformanceTest}/assets/coupon_right.png +0 -0
  91. package/samples/{ClassNameDemo → MetroWidgetDemos/PerformanceTest}/assets/focus_border.png +0 -0
  92. package/samples/{ClassNameDemo → MetroWidgetDemos/PerformanceTest}/assets/holder_logo.png +0 -0
  93. package/samples/{ClassNameDemo → MetroWidgetDemos/PerformanceTest}/assets/jrbm.png +0 -0
  94. package/samples/{ClassNameDemo → MetroWidgetDemos/PerformanceTest}/assets/line_left.png +0 -0
  95. package/samples/{ClassNameDemo → MetroWidgetDemos/PerformanceTest}/assets/line_mid.png +0 -0
  96. package/samples/{ClassNameDemo → MetroWidgetDemos/PerformanceTest}/assets/line_right.png +0 -0
  97. package/samples/{ClassNameDemo → MetroWidgetDemos/PerformanceTest}/assets/loading.png +0 -0
  98. package/samples/{ClassNameDemo → MetroWidgetDemos/PerformanceTest}/assets/logo.png +0 -0
  99. package/samples/{ClassNameDemo → MetroWidgetDemos/PerformanceTest}/assets/mcjx.png +0 -0
  100. package/samples/{ClassNameDemo → MetroWidgetDemos/PerformanceTest}/assets/tao.png +0 -0
  101. package/samples/{ClassNameDemo → MetroWidgetDemos/PerformanceTest}/assets/tmall.png +0 -0
  102. package/samples/{SimpleWidgetDemo → MetroWidgetDemos/PerformanceTest}/border.png +0 -0
  103. package/samples/{SimpleWidgetDemo → MetroWidgetDemos/PerformanceTest}/components/ContentItem.vue +60 -86
  104. package/samples/{SimpleWidgetDemo → MetroWidgetDemos/PerformanceTest}/components/MyTab.vue +0 -0
  105. package/samples/MetroWidgetDemos/PerformanceTest/data.js +45 -0
  106. package/samples/MetroWidgetDemos/PingPong/App.vue +135 -0
  107. package/samples/MetroWidgetDemos/PingPong/AppPage.vue +73 -0
  108. package/samples/MetroWidgetDemos/PingPong/AppTab.vue +62 -0
  109. package/samples/MetroWidgetDemos/PingPong/TabItem.vue +84 -0
  110. package/samples/MetroWidgetDemos/PingPong/ViewSwiper.vue +214 -0
  111. package/samples/MetroWidgetDemos/Simple/AbsoluteTemplate.vue +75 -0
  112. package/samples/MetroWidgetDemos/Simple/App.vue +45 -0
  113. package/samples/MetroWidgetDemos/Simple/RelativeTemplate.vue +111 -0
  114. package/samples/MetroWidgetDemos/WidgetItem.vue +89 -0
  115. package/samples/MetroWidgetDemos/data.js +204 -0
  116. package/samples/NinePatchDemo/App.vue +114 -115
  117. package/samples/NinePatchDemo/Item.vue +7 -8
  118. package/samples/Preload/App.vue +67 -64
  119. package/samples/Preload/Item.vue +21 -29
  120. package/samples/QrcodeDemo/App.vue +24 -29
  121. package/samples/SoundPool/App.vue +77 -106
  122. package/samples/SprayView/App.vue +10 -8
  123. package/samples/SpriteImage/App.vue +1 -2
  124. package/samples/TextBox/App.vue +86 -101
  125. package/samples/TextBox/RenderCenter.vue +1 -1
  126. package/samples/TextBox/RenderLeft.vue +1 -1
  127. package/samples/TextBox/RenderOneLine.vue +1 -1
  128. package/samples/TextBox/RenderRight.vue +1 -1
  129. package/samples/TextShadowDemo/App.vue +1 -2
  130. package/samples/TextureAnimation/App.vue +16 -13
  131. package/samples/TextureAnimation/App2.vue +111 -0
  132. package/samples/TextureAnimation/assets/blackWhiteGrid.png +0 -0
  133. package/samples/TextureAnimation/assets/light.png +0 -0
  134. package/samples/TextureAnimation/assets/light2.png +0 -0
  135. package/samples/TextureAnimation/assets/mask.png +0 -0
  136. package/samples/TextureSize/App.vue +15 -25
  137. package/samples/ThrowMoveDemo/AccelerateDemo.vue +2 -4
  138. package/samples/ThrowMoveDemo/LRParabolicDemo.vue +2 -3
  139. package/samples/ThrowMoveDemo/TargetDemo.vue +3 -4
  140. package/samples/ThrowMoveDemo/UDParabolicDemo.vue +2 -3
  141. package/samples/TouchSample/App.vue +2 -3
  142. package/samples/TouchSample/Item.vue +15 -13
  143. package/samples/TouchSample/MetroWidgetHorizontal.vue +2 -2
  144. package/samples/TouchSample/MetroWidgetVertical.vue +1 -1
  145. package/samples/TouchSample/TouchContainerHorizontal.vue +4 -3
  146. package/samples/TouchSample/TouchContainerVertical.vue +3 -2
  147. package/samples/TransitPage/App.vue +20 -32
  148. package/samples/VideoDemo/App.vue +65 -81
  149. package/samples/VideoDemo/components/Button.vue +41 -52
  150. package/samples/VideoDemo/components/Controllor.vue +171 -169
  151. package/samples/VideoDemo/components/VideoFrame.vue +87 -99
  152. package/samples/VisibleSensorDemo/App.vue +234 -0
  153. package/scripts/jsview-jsmap-serve.js +42 -0
  154. package/scripts/jsview-post-install.js +1 -1
  155. package/tsconfig.json +3 -0
  156. package/utils/JsViewEngineWidget/JsvFocusBlock.vue +204 -193
  157. package/utils/JsViewEngineWidget/JsvFocusManager.js +30 -17
  158. package/utils/JsViewEngineWidget/MetroWidget/MetroWidget.vue +1561 -1656
  159. package/utils/JsViewEngineWidget/MetroWidget/PageUpdater.js +136 -0
  160. package/utils/JsViewEngineWidget/MetroWidget/ToolFunctions.js +18 -0
  161. package/utils/JsViewEngineWidget/TemplateParser.js +111 -1
  162. package/utils/JsViewEngineWidget/WidgetCommon.js +8 -2
  163. package/utils/JsViewEngineWidget/index.js +4 -4
  164. package/utils/JsViewPlugin/JsvPlayer/GetVersion.js +1 -1
  165. package/utils/JsViewPlugin/JsvPlayer/JsvMedia.js +301 -58
  166. package/utils/JsViewPlugin/JsvPlayer/JsvPlayer.vue +22 -3
  167. package/utils/JsViewPlugin/JsvPlayer/index.js +8 -1
  168. package/utils/JsViewPlugin/JsvPlayer/version.js +5 -5
  169. package/utils/JsViewVueTools/JsvImpactTracer.js +113 -0
  170. package/utils/JsViewVueTools/JsvRefTaker.js +35 -0
  171. package/utils/JsViewVueTools/index.js +20 -0
  172. package/utils/JsViewVueWidget/BrowserDebugWidget/BrowserPreload.vue +11 -1
  173. package/utils/JsViewVueWidget/BrowserDebugWidget/BrowserQrcode.vue +8 -4
  174. package/utils/JsViewVueWidget/BrowserDebugWidget/BrowserTextureAnim.vue +203 -14
  175. package/utils/JsViewVueWidget/JsvActorMove/JsvActorMove.vue +2 -2
  176. package/utils/JsViewVueWidget/JsvApic/JsvApic.vue +2 -2
  177. package/utils/JsViewVueWidget/JsvFilterView.vue +59 -51
  178. package/utils/JsViewVueWidget/JsvGrid.vue +139 -41
  179. package/utils/JsViewVueWidget/JsvInput/Cursor.vue +4 -2
  180. package/utils/JsViewVueWidget/JsvInput/JsvInput.vue +13 -12
  181. package/utils/JsViewVueWidget/JsvMaskClipDiv.vue +3 -1
  182. package/utils/JsViewVueWidget/JsvNativeSharedDiv.vue +8 -17
  183. package/utils/JsViewVueWidget/JsvNinePatch.vue +1 -1
  184. package/utils/JsViewVueWidget/JsvPosterDiv.vue +37 -7
  185. package/utils/JsViewVueWidget/JsvPosterImage.vue +34 -13
  186. package/utils/JsViewVueWidget/JsvPreload/JsvPreload.vue +39 -53
  187. package/utils/JsViewVueWidget/JsvQrcode/JsvQrcode.vue +1 -1
  188. package/utils/JsViewVueWidget/JsvSpray/JsvSpray.vue +13 -10
  189. package/utils/JsViewVueWidget/JsvSpriteAnim/JsvSpriteAnim.vue +282 -285
  190. package/utils/JsViewVueWidget/JsvSpriteAnim/index.js +2 -3
  191. package/utils/JsViewVueWidget/JsvSwiper/JsvSwiper.vue +6 -1
  192. package/utils/JsViewVueWidget/JsvSwiper3D/JsvSwiper.vue +6 -1
  193. package/utils/JsViewVueWidget/JsvTextureAnim/JsvTextureAnim.vue +142 -61
  194. package/utils/JsViewVueWidget/JsvTextureAnim/index.js +9 -5
  195. package/utils/JsViewVueWidget/JsvTransparentDiv.vue +7 -8
  196. package/utils/JsViewVueWidget/JsvVideo.vue +9 -12
  197. package/utils/JsViewVueWidget/JsvVisibleSensor/JsvVisibleSensor.vue +141 -0
  198. package/utils/JsViewVueWidget/JsvVisibleSensor/index.js +9 -0
  199. package/utils/JsViewVueWidget/index.js +42 -0
  200. package/samples/AdvanceMetroWidget/App.vue +0 -123
  201. package/samples/AdvanceMetroWidget/Frame.vue +0 -102
  202. package/samples/AdvanceMetroWidget/Item.vue +0 -63
  203. package/samples/AdvanceMetroWidget/data.js +0 -137
  204. package/samples/ClassNameDemo/App.vue +0 -119
  205. package/samples/ClassNameDemo/components/ContentItem.vue +0 -253
  206. package/samples/ClassNameDemo/components/LoadingView.vue +0 -43
  207. package/samples/ClassNameDemo/components/TitleView.vue +0 -24
  208. package/samples/ClassNameDemo/data.js +0 -24
  209. package/samples/FlowMultiWidget/App.vue +0 -91
  210. package/samples/FlowMultiWidget/assets/nine_patch_focus.png +0 -0
  211. package/samples/FlowMultiWidget/components/Block.vue +0 -107
  212. package/samples/FlowMultiWidget/components/FlowPage.vue +0 -60
  213. package/samples/FlowMultiWidget/components/Item.vue +0 -103
  214. package/samples/FlowMultiWidget/components/MenuItem.vue +0 -72
  215. package/samples/FlowMultiWidget/components/MyMenu.vue +0 -90
  216. package/samples/FlowMultiWidget/data.js +0 -446
  217. package/samples/HashHistory/views/BasePage.vue +0 -19
  218. package/samples/HashHistory/views/SubPageFirst.vue +0 -10
  219. package/samples/HashHistory/views/SubPageSecond.vue +0 -10
  220. package/samples/SimpleWidgetDemo/assets/bg.jpg +0 -0
  221. package/samples/SimpleWidgetDemo/assets/coupon_content.png +0 -0
  222. package/samples/SimpleWidgetDemo/assets/coupon_left.png +0 -0
  223. package/samples/SimpleWidgetDemo/assets/coupon_mid.png +0 -0
  224. package/samples/SimpleWidgetDemo/assets/coupon_right.png +0 -0
  225. package/samples/SimpleWidgetDemo/assets/focus_border.png +0 -0
  226. package/samples/SimpleWidgetDemo/assets/holder_logo.png +0 -0
  227. package/samples/SimpleWidgetDemo/assets/jrbm.png +0 -0
  228. package/samples/SimpleWidgetDemo/assets/line_left.png +0 -0
  229. package/samples/SimpleWidgetDemo/assets/line_mid.png +0 -0
  230. package/samples/SimpleWidgetDemo/assets/line_right.png +0 -0
  231. package/samples/SimpleWidgetDemo/assets/loading.png +0 -0
  232. package/samples/SimpleWidgetDemo/assets/logo.png +0 -0
  233. package/samples/SimpleWidgetDemo/assets/mcjx.png +0 -0
  234. package/samples/SimpleWidgetDemo/assets/tao.png +0 -0
  235. package/samples/SimpleWidgetDemo/assets/tmall.png +0 -0
  236. package/samples/SimpleWidgetDemo/data.js +0 -124
  237. package/utils/JsViewEngineWidget/MetroWidget/ContentView.vue +0 -63
  238. package/utils/JsViewEngineWidget/MetroWidget/DivWrapper.vue +0 -51
  239. package/utils/JsViewEngineWidget/MetroWidget/ItemView.vue +0 -213
  240. package/utils/JsViewEngineWidget/MetroWidget/RootView.vue +0 -154
@@ -2,62 +2,54 @@
2
2
  * @Author: ChenChanghua
3
3
  * @Date: 2022-05-10 15:21:24
4
4
  * @LastEditors: ChenChanghua
5
- * @LastEditTime: 2022-05-17 11:13:07
5
+ * @LastEditTime: 2022-07-08 11:48:32
6
6
  * @Description: file content
7
7
  -->
8
- <!--
9
- * @Author: ChenChanghua
10
- * @Date: 2022-05-07 10:22:33
11
- * @LastEditors: ChenChanghua
12
- * @LastEditTime: 2022-05-09 09:19:43
13
- * @Description: file content
14
- -->
15
- <script>
16
- import { ref } from "vue";
17
- export default {
18
- props: ["userData", "widgetData", "onAction", "query"],
19
- setup() {
20
- function randomColor() {
21
- let randomColor = Math.round(Math.random() * 2 ** 24).toString(16);
22
- return (
23
- "#" + new Array(6 - randomColor.length).fill("0").join("") + randomColor
24
- );
25
- }
26
- return {
27
- focused: ref(false),
28
- randomColor,
29
- divNumber: new Array(50),
30
- blurAction: false,
31
- };
32
- },
33
- methods: {
34
- onFocus() {
35
- console.log("item onfocus", this.userData);
36
- this.focused = true;
37
- this.blurAction = false;
38
- },
39
- onBlur() {
40
- console.log("item onblur", this.userData, this.widgetData.getCurrentFocusId(), this.widgetData.dataIndex);
41
- this.focused = false;
42
- if (this.widgetData.getCurrentFocusId() == this.widgetData.dataIndex) {
43
- this.blurAction = true;
44
- }
45
- },
46
- onClick() {
47
- console.log("item onclick ", this.userData);
48
- },
49
- },
50
- created() {
51
- if (this.onAction) {
52
- this.onAction.register("onFocus", this.onFocus);
53
- this.onAction.register("onBlur", this.onBlur);
54
- this.onAction.register("onClick", this.onClick);
55
- }
56
- },
57
- mounted() {
58
- // console.log("item mounted", this.userData, this.widgetData);
59
- },
8
+ <script setup>
9
+ import { ref, onUpdated, onMounted } from "vue";
10
+
11
+ const props = defineProps({
12
+ userData: Object,
13
+ widgetData: Object,
14
+ onAction: Object,
15
+ });
16
+ const randomColor = () => {
17
+ let randomColor = Math.round(Math.random() * 2 ** 24).toString(16);
18
+ return (
19
+ "#" + new Array(6 - randomColor.length).fill("0").join("") + randomColor
20
+ );
60
21
  };
22
+ const focused = ref(false);
23
+ const divNumber = new Array(50);
24
+ const blurAction = false;
25
+
26
+ const onFocus = () => {
27
+ console.log("item onfocus", props.userData);
28
+ focused.value = true;
29
+ };
30
+ const onBlur = () => {
31
+ console.log(
32
+ "item onblur",
33
+ props.userData,
34
+ props.widgetData.getCurrentFocusId(),
35
+ props.widgetData.dataIndex
36
+ );
37
+ focused.value = false;
38
+ };
39
+ const onClick = () => {
40
+ console.log("item onclick ", props.userData);
41
+ };
42
+
43
+ props.onAction.register("onFocus", onFocus);
44
+ props.onAction.register("onBlur", onBlur);
45
+ props.onAction.register("onClick", onClick);
46
+
47
+ onUpdated(() => {
48
+ console.log("item updated", props.userData, props.widgetData);
49
+ });
50
+ onMounted(() => {
51
+ console.log("item mounted", props.userData, props.widgetData);
52
+ });
61
53
  </script>
62
54
 
63
55
  <template>
@@ -91,7 +83,7 @@ export default {
91
83
  ></div>
92
84
  <div
93
85
  :style="{
94
- visibility: blurAction ? 'visible' : 'hidden',
86
+ visibility: !focused && widgetData.selected ? 'visible' : 'hidden',
95
87
  left: 50,
96
88
  width: 20,
97
89
  height: 20,
@@ -1,92 +1,76 @@
1
- <script lang="ts">
2
- import { Options, Vue } from "vue-class-component";
3
- import { jJsvRuntimeBridge } from "jsview/utils/JsViewVueTools/JsvRuntimeBridge";
4
- import { router, routeList } from './router.js'
5
- import { useRouter, useRoute, Router } from 'vue-router'
6
-
7
- @Options({
8
- props: {
9
- routePath: String
10
- },
11
- })
12
- class App extends Vue {
13
- constructor(props: any) {
14
- super(props)
15
-
16
- let currentRouter: Router;
17
-
18
- // props.routePath在DemoHomepage中被设置, 此处作为内嵌router使用.
19
- // 此时已经有router, 则作为children动态添加到当前route
20
- if(props.routePath) {
21
- const currentRoute = useRoute()
22
- currentRouter = useRouter()
23
-
24
- let redirectPath; // 自动跳转路径
25
- for(const route of routeList) {
26
- if(route.path === "/") { // 不需要添加home
27
- redirectPath = route.redirect;
28
- continue;
29
- }
30
-
31
- const subRoute = {...route, path: route.path.substring(1)} // 去掉字符'/'
32
- currentRouter.addRoute(currentRoute.name as string, subRoute)
33
- }
34
-
35
- currentRouter.replace(props.routePath + redirectPath) // 自动跳转到redirectPath
36
- } else { // 作为全局router使用
37
- currentRouter = App.Router;
1
+ <script setup>
2
+ import { jJsvRuntimeBridge } from "jsview";
3
+ import { router, routeList } from "./router.js";
4
+ import { useRouter, useRoute } from "vue-router";
5
+ import { onMounted, ref } from "vue";
6
+
7
+ const props = defineProps({
8
+ routePath: String,
9
+ });
10
+
11
+ const displayUrl = ref("");
12
+ let topRef = ref(null);
13
+ let routePage = ref(null);
14
+ let currentRouter;
15
+ if (props.routePath) {
16
+ const currentRoute = useRoute();
17
+ currentRouter = useRouter();
18
+
19
+ let redirectPath; // 自动跳转路径
20
+ for (const route of routeList) {
21
+ if (route.path === "/") {
22
+ // 不需要添加home
23
+ redirectPath = route.redirect;
24
+ continue;
38
25
  }
39
26
 
40
- this.watchRouterChanged(currentRouter);
41
- }
42
-
43
- // Override
44
- mounted() {
45
- // 调试接口,对接JSCenter平台去掉启动图的处理
46
- jJsvRuntimeBridge.notifyPageLoaded();
47
- }
48
-
49
- private onRequestFocus(branchName: string) {
50
- this.topRef.findBlockByname(branchName)?.requestFocus();
27
+ const subRoute = { ...route, path: route.path.substring(1) }; // 去掉字符'/'
28
+ currentRouter.addRoute(currentRoute.name, subRoute);
51
29
  }
52
30
 
53
- private watchRouterChanged(route: Router) {
54
- route.afterEach(() => {
55
- this.displayUrl = window.location.href;
56
- })
57
- }
58
-
59
- private onKeyDown(event: any) {
60
- return this.routePage?.onKeyDown(event);
61
- }
62
-
63
- private topRef!: any;
64
- private displayUrl: string = "";
65
- private routePage: any = null;
66
-
67
- static Router: Router = router;
31
+ currentRouter.replace(props.routePath + redirectPath); // 自动跳转到redirectPath
32
+ } else {
33
+ currentRouter = router;
68
34
  }
69
-
70
- export default App;
35
+ currentRouter.afterEach(() => {
36
+ displayUrl.value = window.location.href;
37
+ });
38
+
39
+ const onRequestFocus = (branchName) => {
40
+ topRef.value.findBlockByname(branchName)?.requestFocus();
41
+ };
42
+
43
+ const watchRouterChanged = (route) => {
44
+ route.afterEach(() => {
45
+ displayUrl.value = window.location.href;
46
+ });
47
+ };
48
+
49
+ const onKeyDown = (event) => {
50
+ return routePage.value.onKeyDown(event);
51
+ };
52
+
53
+ onMounted(() => {
54
+ jJsvRuntimeBridge.notifyPageLoaded();
55
+ });
71
56
  </script>
72
57
 
73
58
  <template>
74
- <div class="root">
75
- <div class="address">
76
- 当前URL: {{ displayUrl }}
77
- </div>
78
- <div class="split" />
59
+ <div class="root">
60
+ <div class="address">当前URL: {{ displayUrl }}</div>
61
+ <div class="split"></div>
79
62
  <jsv-focus-block ref="topRef">
80
63
  <!-- 这种router-view的写法可以获取到component的ref,vue标准写法 -->
81
64
  <router-view v-slot="{ Component }">
82
- <component :is="Component"
83
- ref="routePage"
84
- class="router"
85
- @requestFocus="onRequestFocus"
65
+ <component
66
+ :is="Component"
67
+ ref="routePage"
68
+ class="router"
69
+ @requestFocus="onRequestFocus"
86
70
  />
87
71
  </router-view>
88
72
  </jsv-focus-block>
89
- </div>
73
+ </div>
90
74
  </template>
91
75
 
92
76
  <style scoped>
@@ -95,7 +79,7 @@ export default App;
95
79
  top: 0;
96
80
  width: 1280;
97
81
  height: 1080;
98
- background-color: rgb(222,211,140)
82
+ background-color: rgb(222, 211, 140);
99
83
  }
100
84
 
101
85
  .address {
@@ -111,12 +95,12 @@ export default App;
111
95
  top: 150;
112
96
  width: 1200;
113
97
  height: 3;
114
- background-color: #00F000;
98
+ background-color: #00f000;
115
99
  }
116
100
 
117
101
  .router {
118
- left:0;
119
- top:150;
102
+ left: 0;
103
+ top: 150;
120
104
  width: 1920;
121
105
  height: 930;
122
106
  overflow: hidden;
@@ -1,114 +1,91 @@
1
- <script lang="ts">
2
- import { JsvFocusEvent } from "jsview/utils/JsViewEngineWidget";
3
- import { Options, Vue } from "vue-class-component";
1
+ <script setup>
4
2
  import Item from "./Item.vue";
5
3
 
6
- @Options({
7
- props: {
8
- style: Object,
9
- buttonConfig: Object,
10
- onButtonClick: Function,
11
- onBack: Function,
12
- },
13
- components: {
14
- Item,
15
- }
16
- })
17
-
18
-
19
- class HorizontalButtonList extends Vue {
20
- constructor(props: object) {
21
- super(props);
4
+ const props = defineProps({
5
+ style: Object,
6
+ buttonConfig: Object,
7
+ onButtonClick: Function,
8
+ onBack: Function,
9
+ });
10
+ const maxWidth = 1280;
11
+ const listPadding = 10;
12
+ const buttonWidth = 400;
13
+ const buttonHeight = 80;
14
+ const buttonGap = 50;
15
+ let focusedItemIndex = 0;
16
+
17
+ let listLeft = 0;
18
+ const listWidth = (buttonWidth + buttonGap) * props.buttonConfig.length;
19
+
20
+ // 根据maxWidth,计算buttons的左边位置
21
+ const widthCenter = listWidth - buttonGap; // 减去最后一个元素的gap
22
+ if (widthCenter < maxWidth) {
23
+ listLeft = Math.floor((maxWidth - widthCenter) / 2);
24
+ }
22
25
 
23
- this.listSize = this.computeSize(props);
26
+ const listSize = {
27
+ left: listLeft,
28
+ width: listWidth,
29
+ height: buttonHeight,
30
+ };
31
+
32
+ const onKeyDown = (ev) => {
33
+ if (ev.keyCode === 13) {
34
+ // Enter
35
+ props.onButtonClick?.(focusedItemIndex);
36
+ return true;
37
+ } else if (ev.keyCode == 8 || ev.keyCode == 27 || ev.keyCode == 10000) {
38
+ // 8:Backspace, 27:Escape, 10000:盒子返回键
39
+ props.onBack?.();
40
+ return true;
24
41
  }
25
42
 
26
- private computeSize(props: any) : object {
27
- let listLeft = 0;
28
- const listWidth = (this.buttonWidth + this.buttonGap) * props.buttonConfig.length;
29
-
30
- // 根据maxWidth,计算buttons的左边位置
31
- const widthCenter = listWidth - this.buttonGap; // 减去最后一个元素的gap
32
- if (widthCenter < this.maxWidth) {
33
- listLeft = Math.floor((this.maxWidth - widthCenter) / 2);
34
- }
35
-
36
- let listSize = {
37
- left: listLeft,
38
- width: listWidth,
39
- height: this.buttonHeight,
40
- };
41
-
42
- return listSize;
43
+ let changeFocusTo = -1;
44
+ switch (ev.keyCode) {
45
+ case 37: // Left
46
+ changeFocusTo =
47
+ (focusedItemIndex - 1 + props.buttonConfig.length) %
48
+ props.buttonConfig.length;
49
+ break;
50
+ case 39: // Right
51
+ changeFocusTo = (focusedItemIndex + 1) % props.buttonConfig.length;
52
+ break;
53
+ default:
54
+ break;
43
55
  }
44
-
45
- private onKeyDown(ev: JsvFocusEvent) {
46
- if(ev.keyCode === 13) { // Enter
47
- this.onButtonClick?.(this.focusedItemIndex);
48
- return true;
49
- } else if(ev.keyCode == 8 || ev.keyCode == 27 || ev.keyCode == 10000) { // 8:Backspace, 27:Escape, 10000:盒子返回键
50
- this.onBack?.();
51
- return true;
52
- }
53
-
54
- let changeFocusTo = -1;
55
- switch (ev.keyCode) {
56
- case 37: // Left
57
- changeFocusTo = (this.focusedItemIndex - 1 + this.buttonConfig.length) % this.buttonConfig.length;
58
- break;
59
- case 39: // Right
60
- changeFocusTo = (this.focusedItemIndex + 1) % this.buttonConfig.length;
61
- break;
62
- default:
63
- break;
64
- }
65
- if (changeFocusTo >= 0) {
66
- ev.ownerNode.findBlockByName(changeFocusTo.toString()).requestFocus();
67
- this.focusedItemIndex = changeFocusTo;
68
- return true;
69
- }
70
-
71
- return false;
56
+ if (changeFocusTo >= 0) {
57
+ ev.ownerNode.findBlockByName(changeFocusTo.toString()).requestFocus();
58
+ focusedItemIndex = changeFocusTo;
59
+ return true;
72
60
  }
73
61
 
74
- private listSize: object;
75
-
76
- private focusedItemIndex = 0;
77
-
78
- private readonly buttonConfig!: any;
79
- private readonly onButtonClick?: Function;
80
- private readonly onBack?: Function;
81
-
82
- private readonly maxWidth: number = 1280;
83
- private readonly listPadding: number = 10;
84
- private readonly buttonWidth: number = 400;
85
- private readonly buttonHeight: number = 80;
86
- private readonly buttonGap: number = 50;
87
- }
88
-
89
- export default HorizontalButtonList;
62
+ return false;
63
+ };
90
64
  </script>
91
65
 
92
66
  <template>
93
- <div :style="style">
94
- <jsv-focus-block
67
+ <div :style="style">
68
+ <jsv-focus-block
95
69
  :style="{
96
70
  left: listSize.left,
97
71
  width: listSize.width + listPadding * 2,
98
72
  height: listSize.height + listPadding * 2,
99
73
  }"
100
74
  :onKeyDown="onKeyDown"
101
- >
102
- <Item v-for="(item,index) in buttonConfig" :key="index"
103
- :style="{ left: (buttonWidth+10)*index, width:buttonWidth, height:buttonHeight }"
75
+ >
76
+ <Item
77
+ v-for="(item, index) in buttonConfig"
78
+ :key="index"
79
+ :style="{
80
+ left: (buttonWidth + 10) * index,
81
+ width: buttonWidth,
82
+ height: buttonHeight,
83
+ }"
104
84
  :name="index.toString()"
105
85
  :autoFocus="index === 0"
106
- >
107
- {{ item.name }}
108
- </Item>
109
- </jsv-focus-block>
110
- </div>
111
- </template>
112
-
113
- <style>
114
- </style>
86
+ >
87
+ {{ item.name }}
88
+ </Item>
89
+ </jsv-focus-block>
90
+ </div>
91
+ </template>
@@ -1,69 +1,55 @@
1
- <script lang="ts">
2
- import { Options, Vue } from "vue-class-component";
3
-
4
- @Options({
5
- props: {
6
- style: Object,
7
- name: String,
8
- autoFocus: Boolean
9
- },
10
- })
11
-
12
- class Item extends Vue {
13
- constructor(props: object) {
14
- super(props);
15
- }
16
-
17
- onFocus() {
18
- this.hasFocused = true;
19
- }
20
-
21
- onBlur() {
22
- this.hasFocused = false;
23
- }
24
-
25
- getFocusStyle() {
26
- return {
27
- width: this.style.width + 10,
28
- height: this.style.height + 10,
29
- }
30
- }
31
-
32
- getItemStyle() {
33
- return {
34
- width: this.style.width,
35
- height: this.style.height,
36
- backgroundColor: '#0FF000',
37
- lineHeight: this.style.height,
38
- fontSize: `${Math.floor(this.style.height * 0.55)}px`,
39
- }
40
- }
41
-
42
- private hasFocused: boolean = false;
43
- private style!: any;
44
- }
45
-
46
- export default Item;
1
+ <script setup>
2
+ import { ref } from "vue";
3
+ const props = defineProps({
4
+ style: Object,
5
+ name: String,
6
+ autoFocus: Boolean,
7
+ });
8
+
9
+ const hasFocused = ref(false);
10
+ const onFocus = () => {
11
+ hasFocused.value = true;
12
+ };
13
+
14
+ const onBlur = () => {
15
+ hasFocused.value = false;
16
+ };
17
+
18
+ const focusStyle = {
19
+ width: props.style.width + 10,
20
+ height: props.style.height + 10,
21
+ };
22
+
23
+ const itemStyle = {
24
+ width: props.style.width,
25
+ height: props.style.height,
26
+ backgroundColor: "#0FF000",
27
+ lineHeight: props.style.height,
28
+ fontSize: `${Math.floor(props.style.height * 0.55)}px`,
29
+ };
47
30
  </script>
48
31
 
49
32
  <template>
50
- <jsv-focus-block :name="name" :autoFocus="autoFocus?'':undefined"
51
- :onFocus="onFocus" :onBlur="onBlur"
52
- >
53
- <div :style="style">
54
- <div class="focus" :style="getFocusStyle()" v-if="hasFocused" />
55
- <div class="item" :style="getItemStyle()">
56
- <slot/>
33
+ <jsv-focus-block
34
+ :name="name"
35
+ :autoFocus="autoFocus ? '' : undefined"
36
+ :onFocus="onFocus"
37
+ :onBlur="onBlur"
38
+ >
39
+ <div :style="style">
40
+ <div class="focus" :style="focusStyle" v-if="hasFocused"></div>
41
+ <div class="item" :style="itemStyle">
42
+ <slot></slot>
43
+ </div>
57
44
  </div>
58
- </div>
59
- </jsv-focus-block>
45
+ </jsv-focus-block>
60
46
  </template>
61
47
 
62
48
  <style scoped>
63
49
  .focus {
64
50
  top: -5;
65
51
  left: -5;
66
- background-color: #0000FF;
52
+ background-color: #0000ff;
67
53
  }
68
54
  .item {
69
55
  text-align: center;
@@ -1,30 +1,41 @@
1
- import { createRouter } from "vue-router";
2
- import { createJsvHashHistory } from "jsview/utils/JsViewVueTools/JsvHashHistory";
1
+ import { createRouter } from "vue-router";
2
+ import { createJsvHashHistory } from "jsview";
3
3
 
4
4
  const routeList = [
5
5
  // 功能实例
6
- {
6
+ {
7
7
  name: "Home",
8
8
  path: "/",
9
- redirect: "/__MainJsvApp/MainPage",
10
- }, {
9
+ redirect: "/__MainJsvApp/MainPage",
10
+ },
11
+ {
11
12
  name: "MainPage",
12
13
  path: "/__MainJsvApp/MainPage",
13
- component: () => import('./views/MainPage')
14
- }, {
14
+ component: () => import("./views/MainPage"),
15
+ },
16
+ {
15
17
  name: "SubPageFirst",
16
18
  path: "/__MainJsvApp/SubPageFirst",
17
- component: () => import('./views/SubPageFirst')
18
- }, {
19
+ component: () => import("./views/SubPage"),
20
+ props: {
21
+ name: "First",
22
+ jumpTo: "Second",
23
+ },
24
+ },
25
+ {
19
26
  name: "SubPageSecond",
20
27
  path: "/__MainJsvApp/SubPageSecond",
21
- component: () => import('./views/SubPageSecond')
28
+ component: () => import("./views/SubPage"),
29
+ props: {
30
+ name: "Second",
31
+ jumpTo: "First",
32
+ },
22
33
  },
23
34
  ];
24
35
 
25
36
  const router = createRouter({
26
37
  history: createJsvHashHistory(),
27
38
  routes: routeList,
28
- })
39
+ });
29
40
 
30
- export { router, routeList }
41
+ export { router, routeList };