@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,131 @@
1
+ <!--
2
+ * @Author: ChenChanghua
3
+ * @Date: 2022-01-25 10:33:07
4
+ * @LastEditors: ChenChanghua
5
+ * @LastEditTime: 2022-09-02 13:44:41
6
+ * @Description: file content
7
+ -->
8
+ <script>
9
+ import FullKeyboard from "./FullKeyboard.vue";
10
+ import { EdgeDirection, JsvInput, useFocusHub } from "jsview";
11
+ import { ref, shallowRef } from "vue";
12
+
13
+ const blurColor = "#AAAAAA";
14
+ const focusColor = "#FFFF00";
15
+
16
+ export default {
17
+ components: {
18
+ FullKeyboard,
19
+ JsvInput,
20
+ },
21
+ props: {
22
+ name: String,
23
+ type: Number,
24
+ textAlign: String,
25
+ placeHolder: String,
26
+ onEdge: Function,
27
+ },
28
+ setup() {
29
+ return {
30
+ showCursor: ref(false),
31
+ focusHub: useFocusHub(),
32
+ cursorColor: ref(blurColor),
33
+ };
34
+ },
35
+ methods: {
36
+ _onFocus() {
37
+ this.showCursor = true;
38
+ this.cursorColor = blurColor;
39
+ this.focusHub.setFocus(`${this.name}/keyboard`);
40
+ },
41
+ _onBlur() {
42
+ console.log("testtest onblur");
43
+ this.showCursor = false;
44
+ this.cursorColor = blurColor;
45
+ },
46
+ _keyboardOnClick(item) {
47
+ const char = item.content;
48
+ if (char === "删除") {
49
+ this.$refs.input?.delete();
50
+ } else if (char === "清空") {
51
+ this.$refs.input?.clear();
52
+ } else {
53
+ this.$refs.input?.add(char);
54
+ }
55
+ },
56
+ _keyboardOnEdge(edgeInfo) {
57
+ if (edgeInfo.direction === EdgeDirection.top) {
58
+ this.focusHub.setFocus(`${this.name}/etext`);
59
+ this.cursorColor = focusColor;
60
+ } else {
61
+ this.onEdge?.(edgeInfo);
62
+ }
63
+ },
64
+ _onTextChange(str) {
65
+ console.log(this.name + " text change:", str);
66
+ },
67
+ _onTextOverflow() {
68
+ console.log(this.name + " text overflow.");
69
+ },
70
+ _inputOnEdge(edgeInfo) {
71
+ if (edgeInfo.direction === EdgeDirection.bottom) {
72
+ this.focusHub.setFocus(`${this.name}/keyboard`);
73
+ this.cursorColor = blurColor;
74
+ } else {
75
+ this.onEdge?.(edgeInfo);
76
+ }
77
+ return true;
78
+ },
79
+ },
80
+ };
81
+ </script>
82
+
83
+ <template>
84
+ <jsv-focus-block
85
+ :name="name"
86
+ ref="focusNode"
87
+ :onAction="{
88
+ onFocus: _onFocus,
89
+ onBlur: _onBlur,
90
+ }"
91
+ >
92
+ <div
93
+ :style="{
94
+ left: 50,
95
+ top: 50,
96
+ width: 150,
97
+ height: 40,
98
+ backgroundColor: '#33334f',
99
+ }"
100
+ />
101
+ <jsv-input
102
+ :name="`${this.name}/etext`"
103
+ ref="input"
104
+ :type="type"
105
+ :left="50"
106
+ :top="50"
107
+ :height="40"
108
+ :width="150"
109
+ :placeholder="placeHolder"
110
+ :cursorShow="showCursor"
111
+ :fontStyle="{
112
+ fontSize: 28,
113
+ color: '#ffff00',
114
+ textAlign: textAlign,
115
+ }"
116
+ :onEdge="_inputOnEdge"
117
+ :cursorWidth="2"
118
+ :onTextChange="_onTextChange"
119
+ :onTextOverflow="_onTextOverflow"
120
+ :cursorColor="cursorColor"
121
+ />
122
+
123
+ <div :style="{ top: 100 }">
124
+ <full-keyboard
125
+ :name="`${this.name}/keyboard`"
126
+ :onClick="_keyboardOnClick"
127
+ :onEdge="_keyboardOnEdge"
128
+ />
129
+ </div>
130
+ </jsv-focus-block>
131
+ </template>
@@ -0,0 +1,58 @@
1
+ <script>
2
+ export default {
3
+ props: {
4
+ data: Object,
5
+ query: Object,
6
+ onEdge: Function,
7
+ onAction: Object,
8
+ onClick: Function,
9
+ },
10
+ data() {
11
+ return {
12
+ focused: false,
13
+ };
14
+ },
15
+ computed: {
16
+ style() {
17
+ return {
18
+ width: this.data.width,
19
+ height: this.data.height,
20
+ fontSize: 20,
21
+ textAlign: "center",
22
+ lineHeight: this.data.height,
23
+ color: "#FFFFFF",
24
+ };
25
+ },
26
+ },
27
+ methods: {
28
+ _onFocus() {
29
+ this.focused = true;
30
+ },
31
+ _onBlur() {
32
+ this.focused = false;
33
+ },
34
+ _onClick() {
35
+ this.onClick(this.data);
36
+ },
37
+ },
38
+ created() {
39
+ this.onAction.register("onFocus", this._onFocus);
40
+ this.onAction.register("onBlur", this._onBlur);
41
+ this.onAction.register("onClick", this._onClick);
42
+ },
43
+ };
44
+ </script>
45
+
46
+ <template>
47
+ <div
48
+ v-if="focused"
49
+ :style="{
50
+ width: data.width,
51
+ height: data.height,
52
+ backgroundColor: '#00FF00',
53
+ }"
54
+ />
55
+ <div ref="element" :style="style">
56
+ {{ data.content }}
57
+ </div>
58
+ </template>
@@ -0,0 +1,80 @@
1
+ <!--
2
+ *
3
+ * 【界面概述】
4
+ * 带下拉条的长图片展示样例
5
+ *
6
+ * 【控件介绍】
7
+ * SimpleWidget:见simpleMetrowidget
8
+ *
9
+ * 【技巧说明】
10
+ * Q: 如何让图片的高度自适应?
11
+ * A: 使用img元素,并且style中高度不设置即可
12
+ * 通过element.clientHeight获取渲染后的自动高度,以决定滚动轴的总高度
13
+ *
14
+ * Q: 如何知道图片加载完成?
15
+ * A: 为img标签追加OnLoad回调函数来接收图片加载完成的消息
16
+ *
17
+ -->
18
+
19
+ <script setup>
20
+ import LongImageScroll from "./LongImageScroll.vue";
21
+ import Button from "./Button.vue";
22
+ import longImageSource from "./assets/1280x7200.jpg";
23
+ import { useRouter } from "vue-router";
24
+
25
+ const router = useRouter();
26
+
27
+ const onKeyDown = (ev) => {
28
+ if (ev.keyCode == 8 || ev.keyCode == 27 || ev.keyCode == 10000) {
29
+ router.go(-1); // 有router时,是从DemoHomepage进入,回退
30
+ }
31
+ return true;
32
+ };
33
+ </script>
34
+
35
+
36
+ <template>
37
+ <jsv-focus-block
38
+ autoFocus
39
+ :onAction="{
40
+ onKeyDown: onKeyDown,
41
+ }"
42
+ >
43
+ <div
44
+ :style="{
45
+ textAlign: 'center',
46
+ fontSize: '30px',
47
+ lineHeight: '50px',
48
+ color: '#ffffff',
49
+ left: 100,
50
+ top: 20,
51
+ width: 1000,
52
+ height: 50,
53
+ backgroundColor: 'rgba(27,38,151,0.8)',
54
+ }"
55
+ >
56
+ 可加载长或宽超过2048px的图片
57
+ </div>
58
+ <div :style="{ left: 100, top: 100 }">
59
+ <LongImageScroll
60
+ :style="{ width: 1000, height: 500, backgroundColor: '#EEEEEE' }"
61
+ :imageSrc="longImageSource"
62
+ :scrollBlockStyle="{
63
+ width: 10,
64
+ height: 30,
65
+ backgroundColor: '#555555',
66
+ }"
67
+ :scrollStyle="{
68
+ left: 1005,
69
+ width: 10,
70
+ height: 500,
71
+ backgroundColor: '#DDDDDD',
72
+ }"
73
+ :step="60"
74
+ />
75
+ <div :style="{ left: 400, top: 550 }">
76
+ <Button></Button>
77
+ </div>
78
+ </div>
79
+ </jsv-focus-block>
80
+ </template>
@@ -0,0 +1,58 @@
1
+ <!--
2
+ * @Author: ChenChanghua
3
+ * @Date: 2022-07-08 15:18:02
4
+ * @LastEditors: ChenChanghua
5
+ * @LastEditTime: 2022-07-08 17:47:25
6
+ * @Description: file content
7
+ -->
8
+ <script setup>
9
+ import { ref, shallowRef } from "vue";
10
+ import { HORIZONTAL, MetroWidget, EdgeDirection, useFocusHub } from "jsview";
11
+ import ButtonItem from "./ButtonItem.vue";
12
+
13
+ const focusHub = useFocusHub();
14
+ const data = [
15
+ {
16
+ width: 100,
17
+ height: 50,
18
+ marginRight: 100,
19
+ content: "同意",
20
+ },
21
+ {
22
+ width: 100,
23
+ height: 50,
24
+ content: "取消",
25
+ },
26
+ ];
27
+
28
+ const measures = (item) => {
29
+ return item;
30
+ };
31
+
32
+ const onEdge = (edgeInfo) => {
33
+ if (edgeInfo.direction == EdgeDirection.top) {
34
+ focusHub.setFocus("longImageScroll");
35
+ }
36
+ };
37
+ </script>
38
+
39
+ <template>
40
+ <metro-widget
41
+ name="button"
42
+ :width="500"
43
+ :height="50"
44
+ :data="data"
45
+ :direction="HORIZONTAL"
46
+ :measures="measures"
47
+ :onEdge="onEdge"
48
+ >
49
+ <template #renderItem="{ data, query, onEdge, onAction }">
50
+ <button-item
51
+ :data="data"
52
+ :query="query"
53
+ :onEdge="onEdge"
54
+ :onAction="onAction"
55
+ />
56
+ </template>
57
+ </metro-widget>
58
+ </template>
@@ -0,0 +1,44 @@
1
+ <!--
2
+ * @Author: ChenChanghua
3
+ * @Date: 2022-07-08 15:05:00
4
+ * @LastEditors: ChenChanghua
5
+ * @LastEditTime: 2022-07-08 17:46:39
6
+ * @Description: file content
7
+ -->
8
+ <script setup>
9
+ import { ref, shallowRef } from "vue";
10
+
11
+ const props = defineProps({
12
+ data: Object,
13
+ query: Object,
14
+ onEdge: Function,
15
+ onAction: Object,
16
+ });
17
+ const focused = ref(false);
18
+ const onFocus = () => {
19
+ focused.value = true;
20
+ };
21
+
22
+ const onBlur = () => {
23
+ focused.value = false;
24
+ };
25
+
26
+ const onClick = () => {};
27
+
28
+ props.onAction.register("onFocus", onFocus);
29
+ props.onAction.register("onBlur", onBlur);
30
+ props.onAction.register("onClick", onClick);
31
+ </script>
32
+
33
+ <template>
34
+ <div
35
+ :style="{
36
+ width: props.data.width,
37
+ height: props.data.height,
38
+ fontSize: 30,
39
+ backgroundColor: focused ? '#DD8800' : '#BBBBAA',
40
+ }"
41
+ >
42
+ {{ data.content }}
43
+ </div>
44
+ </template>
@@ -0,0 +1,92 @@
1
+ <script setup>
2
+ import Scroll from "./Scroll.vue";
3
+ import { ref, shallowRef, onMounted } from "vue";
4
+ import { useFocusHub } from "jsview";
5
+
6
+ const props = defineProps({
7
+ step: Number,
8
+ style: Object,
9
+ scrollStyle: Object,
10
+ scrollBlockStyle: Object,
11
+ imageSrc: String,
12
+ });
13
+
14
+ const focusHub = useFocusHub();
15
+ const element = shallowRef(null);
16
+ const scrollY = ref(0);
17
+ const textY = ref(0);
18
+ const onAction = {
19
+ onKeyDown: (ev) => {
20
+ const valid =
21
+ element.value &&
22
+ element.value.clientHeight &&
23
+ element.value.clientHeight > props.style.height;
24
+ // let keyUsed = true;
25
+ if (valid) {
26
+ let text_y;
27
+ switch (ev.keyCode) {
28
+ case 38:
29
+ if (textY.value !== 0) {
30
+ text_y =
31
+ textY.value + props.step >= 0 ? 0 : textY.value + props.step;
32
+ (textY.value = text_y),
33
+ (scrollY.value =
34
+ (-text_y / (element.value.clientHeight - props.style.height)) *
35
+ (props.scrollStyle.height - props.scrollBlockStyle.height));
36
+ }
37
+ break;
38
+ case 40:
39
+ if (textY.value !== props.style.height - element.value.clientHeight) {
40
+ text_y =
41
+ textY.value - props.step <=
42
+ props.style.height - element.value.clientHeight
43
+ ? props.style.height - element.value.clientHeight
44
+ : textY.value - props.step;
45
+ (textY.value = text_y),
46
+ (scrollY.value =
47
+ (-text_y / (element.value.clientHeight - props.style.height)) *
48
+ (props.scrollStyle.height - props.scrollBlockStyle.height));
49
+ } else {
50
+ focusHub.setFocus("button");
51
+ }
52
+ break;
53
+ }
54
+ }
55
+ },
56
+ onFocus: () => {
57
+ console.log("LongImageScroll getFocus");
58
+ },
59
+ onBlur: () => {
60
+ console.log("LongImageScroll loseFocus");
61
+ },
62
+ };
63
+
64
+ const onLoad = () => {
65
+ // 图片加载完成的回调
66
+ console.log("Image loaded!");
67
+ };
68
+
69
+ onMounted(() => {
70
+ focusHub.setFocus("longImageScroll");
71
+ });
72
+ </script>
73
+
74
+
75
+ <template>
76
+ <jsv-focus-block name="longImageScroll" :onAction="onAction">
77
+ <div :style="{ overflow: 'hidden', ...style }">
78
+ <img
79
+ alt=""
80
+ ref="element"
81
+ :src="imageSrc"
82
+ :style="{ top: textY, width: style.width }"
83
+ :onLoad="onLoad"
84
+ />
85
+ </div>
86
+ <Scroll
87
+ :top="scrollY"
88
+ :scrollStyle="scrollStyle"
89
+ :scrollBlockStyle="scrollBlockStyle"
90
+ />
91
+ </jsv-focus-block>
92
+ </template>
@@ -0,0 +1,14 @@
1
+ <script setup>
2
+ defineProps({
3
+ scrollStyle: Object,
4
+ top: Number,
5
+ scrollBlockStyle: Object,
6
+ });
7
+ </script>
8
+ <template>
9
+ <div :style="{ ...scrollStyle }">
10
+ <div :style="{ top: top }">
11
+ <div :style="{ ...scrollBlockStyle }"></div>
12
+ </div>
13
+ </div>
14
+ </template>
Binary file
@@ -0,0 +1,96 @@
1
+ <!--
2
+ * 【界面概述】
3
+ * 协议书的示例
4
+ *
5
+ * 【控件介绍】
6
+ * SimpleWidget:见simpleMetrowidget
7
+ *
8
+ * 【技巧说明】
9
+ * Q: 如何长文字div的高度自适应?
10
+ * A: 描画长文字的div的高度不设置即可
11
+ * 并通过element.clientHeight获取渲染后的自动高度,以决定滚动轴的总高度
12
+ *
13
+ * Q: 长段文字如何换行?
14
+ * A: 若文字内容中需要折行,则需要把要显示内容放入字符串中,并加入'\n'来达到换行效果,例如:
15
+ * <div>{"第一行
16
+ * 第二行"}</div>
17
+ * =======需要改成=======
18
+ * <div>{"第一行\n\
19
+ * 第二行"}</div>
20
+ *
21
+ * Q: 文字首行缩进如何做?
22
+ * A: 目前系统只支持通过空格进行首行缩进,行首加入期望的空格数量即可达到缩进,因为盒子字体库和PC不尽相同,
23
+ * 所以务必在盒子上实际测试缩进效果。
24
+ -->
25
+
26
+ <script setup>
27
+ import LongTextScroll from "./LongTextScroll.vue";
28
+ import Button from "./Button.vue";
29
+ import { jJsvRuntimeBridge } from "jsview";
30
+ import { onMounted, ref, shallowRef } from "vue";
31
+ import { useRouter } from "vue-router";
32
+
33
+ const router = useRouter();
34
+
35
+ const onKeyDown = (ev) => {
36
+ if (ev.keyCode == 8 || ev.keyCode == 27 || ev.keyCode == 10000) {
37
+ router.go(-1); // 有router时,是从DemoHomepage进入,回退
38
+ }
39
+ return true;
40
+ };
41
+
42
+ onMounted(() => {
43
+ jJsvRuntimeBridge.notifyPageLoaded();
44
+ });
45
+ </script>
46
+
47
+ <template>
48
+ <jsv-focus-block
49
+ autoFocus
50
+ :onAction="{
51
+ onKeyDown: onKeyDown,
52
+ }"
53
+ >
54
+ <div>
55
+ <div
56
+ :style="{
57
+ textAlign: 'center',
58
+ fontSize: '30px',
59
+ lineHeight: '50px',
60
+ color: '#ffffff',
61
+ left: 140,
62
+ top: 20,
63
+ width: 1000,
64
+ height: 50,
65
+ backgroundColor: 'rgba(27,38,151,0.8)',
66
+ }"
67
+ >
68
+ 可展示篇幅超过一屏的文字
69
+ </div>
70
+ <div :style="{ left: 140, top: 100 }">
71
+ <LongTextScroll
72
+ :style="{ width: 1000, height: 500, backgroundColor: '#EEEEEE' }"
73
+ :textStyle="{ color: '#000000', fontSize: 20 }"
74
+ :scrollBlockStyle="{
75
+ width: 10,
76
+ height: 30,
77
+ backgroundColor: '#555555',
78
+ }"
79
+ :scrollStyle="{
80
+ left: 1005,
81
+ width: 10,
82
+ height: 500,
83
+ backgroundColor: '#DDDDDD',
84
+ }"
85
+ :step="20"
86
+ >
87
+ </LongTextScroll>
88
+ <div :style="{ left: 400, top: 550 }">
89
+ <Button />
90
+ </div>
91
+ </div>
92
+ </div>
93
+ </jsv-focus-block>
94
+ </template>
95
+
96
+
@@ -0,0 +1,51 @@
1
+ <script setup>
2
+ import { ref, shallowRef } from "vue";
3
+ import { HORIZONTAL, MetroWidget, EdgeDirection, useFocusHub } from "jsview";
4
+ import ButtonItem from "./ButtonItem.vue";
5
+
6
+ const focusHub = useFocusHub();
7
+ const data = [
8
+ {
9
+ width: 100,
10
+ height: 50,
11
+ marginRight: 100,
12
+ content: "同意",
13
+ },
14
+ {
15
+ width: 100,
16
+ height: 50,
17
+ content: "取消",
18
+ },
19
+ ];
20
+
21
+ const measures = (item) => {
22
+ return item;
23
+ };
24
+
25
+ const onEdge = (edgeInfo) => {
26
+ if (edgeInfo.direction == EdgeDirection.top) {
27
+ focusHub.setFocus("longTextScroll");
28
+ }
29
+ };
30
+ </script>
31
+
32
+ <template>
33
+ <metro-widget
34
+ name="button"
35
+ :width="500"
36
+ :height="50"
37
+ :data="data"
38
+ :direction="HORIZONTAL"
39
+ :measures="measures"
40
+ :onEdge="onEdge"
41
+ >
42
+ <template #renderItem="{ data, query, onEdge, onAction }">
43
+ <button-item
44
+ :data="data"
45
+ :query="query"
46
+ :onEdge="onEdge"
47
+ :onAction="onAction"
48
+ />
49
+ </template>
50
+ </metro-widget>
51
+ </template>
@@ -0,0 +1,44 @@
1
+ <!--
2
+ * @Author: ChenChanghua
3
+ * @Date: 2022-07-08 15:05:00
4
+ * @LastEditors: ChenChanghua
5
+ * @LastEditTime: 2022-07-08 17:45:44
6
+ * @Description: file content
7
+ -->
8
+ <script setup>
9
+ import { ref, shallowRef } from "vue";
10
+
11
+ const props = defineProps({
12
+ data: Object,
13
+ query: Object,
14
+ onEdge: Function,
15
+ onAction: Object,
16
+ });
17
+ const focused = ref(false);
18
+ const onFocus = () => {
19
+ focused.value = true;
20
+ };
21
+
22
+ const onBlur = () => {
23
+ focused.value = false;
24
+ };
25
+
26
+ const onClick = () => {};
27
+
28
+ props.onAction.register("onFocus", onFocus);
29
+ props.onAction.register("onBlur", onBlur);
30
+ props.onAction.register("onClick", onClick);
31
+ </script>
32
+
33
+ <template>
34
+ <div
35
+ :style="{
36
+ width: props.data.width,
37
+ height: props.data.height,
38
+ fontSize: 30,
39
+ backgroundColor: focused ? '#DD8800' : '#BBBBAA',
40
+ }"
41
+ >
42
+ {{ data.content }}
43
+ </div>
44
+ </template>