@shijiu/jsview-vue-samples 2.3.151-test.0 → 3.0.0

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 (228) hide show
  1. package/ABImageAlt/App.vue +114 -0
  2. package/ABImageAlt/Item.vue +133 -0
  3. package/{MetroWidgetDemos/SkeletonDiagram/assets/imageList.json → ABImageAlt/assets/imageList.js} +9 -1
  4. package/ABImageAlt/data.js +17 -0
  5. package/AI_Check_Rules.txt +5 -0
  6. package/AnimPicture/App.vue +20 -10
  7. package/ApicSwitch/App.vue +90 -0
  8. package/ApicSwitch/TabItem.vue +65 -0
  9. package/ApicSwitch/WebpShow.vue +24 -0
  10. package/ApicSwitch/data.js +50 -0
  11. package/Basic/AI_skills_update.md +1 -0
  12. package/Basic/components/div/ColorFormatTest.vue +93 -0
  13. package/Basic/components/div/DivRadius.vue +97 -15
  14. package/Basic/components/div/DivTag3Group.vue +30 -0
  15. package/Basic/components/img/ImageType.vue +65 -0
  16. package/Basic/components/panel/Panel2.vue +13 -1
  17. package/Basic/components/text/TextAlign.vue +7 -1
  18. package/BlobLoadTest/App.vue +201 -0
  19. package/BreakLinesApi/App.vue +82 -0
  20. package/CanvasDrawChart/App.vue +11 -0
  21. package/CanvasDrawChart/Graph1.vue +104 -0
  22. package/CanvasDrawChart/Graph2.vue +115 -0
  23. package/CssPreprocessor/Scss/PanelData.js +1 -1
  24. package/CssPreprocessor/Scss/components/scss-group4/ScssMaps.vue +4 -3
  25. package/CssPreprocessor/Scss/components/scss-group5/ScssImporting.vue +2 -2
  26. package/DemoForOperator/Bounce/FreeMoveBuilder.js +1 -1
  27. package/DemoForOperator/Firework1/App.vue +12 -1
  28. package/DemoForOperator/Firework1/Fireworks.vue +18 -0
  29. package/DemoForOperator/FlipPage/FlipPage/FlipPage.vue +1 -0
  30. package/DemoForOperator/Focus/Alpha/Item.vue +1 -0
  31. package/DemoForOperator/Focus/Light/Item.vue +1 -0
  32. package/DemoForOperator/Focus/Normal/Item.vue +1 -0
  33. package/DemoForOperator/FrameShadow/FrameShadow.vue +1 -1
  34. package/DemoForOperator/Genie/App.vue +20 -6
  35. package/DemoForOperator/Genie/App2.vue +61 -0
  36. package/DemoForOperator/Genie/geniePakcer/GenieImage.vue +298 -0
  37. package/DemoForOperator/Genie/geniePakcer/GenieSlot.vue +292 -0
  38. package/DemoForOperator/Genie/geniePakcer/GenieTools.ts +463 -0
  39. package/DemoForOperator/Jigsaw/JigsawFull.vue +12 -7
  40. package/DemoForOperator/Jigsaw/JigsawSingle.vue +13 -7
  41. package/DemoForOperator/LongChatBox/App.vue +13 -13
  42. package/DemoForOperator/LongChatBox/Bubble.vue +78 -66
  43. package/DemoForOperator/LongChatBox/LongChat.vue +68 -36
  44. package/DemoForOperator/LongChatBox/testData.js +7 -44
  45. package/DemoForOperator/Sound/Bounce/FreeMoveBuilder.js +1 -1
  46. package/DemoForOperator/routeList.js +8 -2
  47. package/DemoHomepage/App.vue +74 -1
  48. package/DemoHomepage/components/BodyFrame.vue +1 -0
  49. package/DemoHomepage/components/TabFrame.vue +1 -1
  50. package/DemoHomepage/router.js +723 -160
  51. package/DemoHomepage/views/Homepage.vue +60 -2
  52. package/DemoHomepage/watchTest.vue +50 -0
  53. package/FilterDemo/AnimatePic.vue +63 -17
  54. package/FilterDemo/App.vue +3 -3
  55. package/FlexCellDemo/AI_skills_update.md +4 -0
  56. package/FlexCellDemo/TestFrame1.vue +12 -2
  57. package/FlexCellDemo/TestFrame2.vue +10 -1
  58. package/FlexCellDemo/TestFrame3.vue +114 -59
  59. package/FpsLimit/App.vue +102 -0
  60. package/FreeMoveChildAttract/App.vue +18 -8
  61. package/FreeMoveLink/App.vue +49 -20
  62. package/Hover/App.vue +144 -0
  63. package/HttpRequestSSE/SSEReader.js +200 -0
  64. package/ImpactStop/App.vue +2 -2
  65. package/Input/FullKeyboard.vue +3 -3
  66. package/Input/InputPanel.vue +63 -3
  67. package/JsvLine/App.vue +53 -38
  68. package/LatexDemo/App.vue +3 -1
  69. package/LatexFormula/App.vue +196 -0
  70. package/LongImage/App.vue +1 -1
  71. package/LongImage/LongImageScroll.vue +100 -47
  72. package/LongImage/Scroll.vue +28 -9
  73. package/LongText/LongTextScroll.vue +1 -0
  74. package/Markdown/App.vue +36 -0
  75. package/Markdown/Bubble.vue +109 -0
  76. package/Markdown/LongChat.vue +206 -0
  77. package/Markdown/Markdown/Markdown.vue +156 -0
  78. package/Markdown/Markdown/index.ts +1 -0
  79. package/Markdown/Markdown/marked/LICENSE.md +45 -0
  80. package/Markdown/Markdown/marked/index.ts +2 -0
  81. package/Markdown/Markdown/marked/marked.d.ts +756 -0
  82. package/Markdown/Markdown/marked/marked.js +71 -0
  83. package/Markdown/Markdown/parser.ts +1365 -0
  84. package/Markdown/data.js +581 -0
  85. package/MetroWidgetDemos/AI_skills_update.md +2 -0
  86. package/MetroWidgetDemos/ListExpand/ChildItem.vue +130 -0
  87. package/MetroWidgetDemos/ListExpand/ExpandItem.vue +375 -0
  88. package/MetroWidgetDemos/ListExpand/ExpandItem1.vue +403 -0
  89. package/MetroWidgetDemos/ListExpand/assets/arrow-down.png +0 -0
  90. package/MetroWidgetDemos/ListExpand/assets/up-arrow.png +0 -0
  91. package/MetroWidgetDemos/ListExpand/components/WidgetListHandler.vue +150 -0
  92. package/MetroWidgetDemos/ListExpand/index.vue +88 -0
  93. package/MetroWidgetDemos/ListExpand/list.js +2421 -0
  94. package/MetroWidgetDemos/RefreshDemo/App.vue +14 -1
  95. package/MetroWidgetDemos/RenderAccelerate/App.vue +142 -0
  96. package/MetroWidgetDemos/RenderAccelerate/AppPage.vue +78 -0
  97. package/MetroWidgetDemos/RenderAccelerate/AppTab.vue +62 -0
  98. package/MetroWidgetDemos/RenderAccelerate/ContentItem.vue +409 -0
  99. package/MetroWidgetDemos/RenderAccelerate/Item.vue +67 -0
  100. package/MetroWidgetDemos/RenderAccelerate/TabItem.vue +100 -0
  101. package/MetroWidgetDemos/RenderAccelerate/ViewSwiper.vue +215 -0
  102. package/MetroWidgetDemos/RenderAccelerate/WidgetItem.vue +107 -0
  103. package/MetroWidgetDemos/SkeletonDiagram/App.vue +35 -8
  104. package/MetroWidgetDemos/SkeletonDiagram/Item.vue +11 -2
  105. package/MetroWidgetDemos/SkeletonDiagram/assets/imageList.js +245 -0
  106. package/MetroWidgetDemos/SkeletonDiagram/data.js +3 -3
  107. package/MetroWidgetDemos/SpatialNav/App.vue +177 -0
  108. package/MetroWidgetDemos/SpatialNav/Buttons.vue +83 -0
  109. package/MetroWidgetDemos/SpatialNav/CustomFocus.vue +57 -0
  110. package/MetroWidgetDemos/{TripleWidget → SpatialNav}/Item.vue +1 -8
  111. package/MetroWidgetDemos/{TripleWidget/WidgetItem.vue → SpatialNav/SimpleFloor.vue} +14 -45
  112. package/MetroWidgetDemos/SpatialNav/StepMw.vue +113 -0
  113. package/MetroWidgetDemos/SpatialNav/TabContent/TabContent.vue +185 -0
  114. package/MetroWidgetDemos/SpatialNav/TripleSection/TripleSection.vue +69 -0
  115. package/MetroWidgetDemos/SpatialNav/TripleSection/WidgetItem.vue +100 -0
  116. package/MetroWidgetDemos/SpatialNav/TvSection/List.vue +75 -0
  117. package/MetroWidgetDemos/SpatialNav/TvSection/TvSection.vue +91 -0
  118. package/MetroWidgetDemos/basic2/App.vue +407 -0
  119. package/MetroWidgetDemos/basic2/Item.vue +68 -0
  120. package/MetroWidgetDemos/direction/App.vue +22 -0
  121. package/MetroWidgetDemos/gazeFocusDiff/App.vue +126 -0
  122. package/MetroWidgetDemos/gazeFocusDiff/Item.vue +87 -0
  123. package/MetroWidgetDemos/minimalUsage/App.vue +66 -0
  124. package/MetroWidgetDemos/minimalUsage/Item.vue +54 -0
  125. package/MetroWidgetDemos/ninePatchFocusPage/App.vue +22 -7
  126. package/MetroWidgetDemos/ninePatchFocusPage/Item.vue +7 -5
  127. package/MetroWidgetDemos/ninePatchFocusPage/focusConstants.js +2 -0
  128. package/MetroWidgetDemos/routeList.js +203 -12
  129. package/MetroWidgetDemos/slideSetting/App.vue +288 -99
  130. package/MetroWidgetDemos/zIndex/App.vue +117 -0
  131. package/MetroWidgetDemos/zIndex/Item.vue +61 -0
  132. package/NinePatchTester/App.vue +24 -31
  133. package/PreDecode/App.vue +140 -0
  134. package/ReactiveTest/App.vue +115 -0
  135. package/ReactiveTest/Item.vue +92 -0
  136. package/ReactiveTest/assets/imageList.js +245 -0
  137. package/ReactiveTest/component/TestSmartDiv.vue +50 -0
  138. package/ReactiveTest/component/TestSmartDivSrcList.vue +74 -0
  139. package/ReactiveTest/component/TestSmartImage.vue +46 -0
  140. package/ReactiveTest/component/TestSmartImageSrcList.vue +90 -0
  141. package/ReactiveTest/component/TestSmartImageStyle.vue +41 -0
  142. package/ReactiveTest/data.js +49 -0
  143. package/ScreenToBlob/App.vue +250 -0
  144. package/SecTorTest/App.vue +9 -3
  145. package/SpringFestival/SpringFestivalScene/FreeMoveBuilder.js +3 -3
  146. package/SyncDecode/App.vue +137 -0
  147. package/TextSizeLimit/App.vue +211 -0
  148. package/TransitPage/App.vue +2 -0
  149. package/assets/logo.png +0 -0
  150. package/package.json +5 -5
  151. package/DemoForOperator/Genie/geniePakcer/Genie.vue +0 -741
  152. package/DemoForOperator/LongChatBox/TextManager.ts +0 -147
  153. package/DemoForOperator/LongChatBox/VirtualList.vue +0 -298
  154. package/DemoForOperator/LongChatBox/utile.js +0 -331
  155. package/DivMetroPerformance/App.vue +0 -157
  156. package/DivMetroPerformance/Item.vue +0 -58
  157. package/DivMetroPerformance/assets/bg.jpg +0 -0
  158. package/DivMetroPerformance/assets/coupon_content.png +0 -0
  159. package/DivMetroPerformance/assets/coupon_left.png +0 -0
  160. package/DivMetroPerformance/assets/coupon_mid.png +0 -0
  161. package/DivMetroPerformance/assets/coupon_right.png +0 -0
  162. package/DivMetroPerformance/assets/focus_border.png +0 -0
  163. package/DivMetroPerformance/assets/holder_logo.png +0 -0
  164. package/DivMetroPerformance/assets/jrbm.png +0 -0
  165. package/DivMetroPerformance/assets/line_left.png +0 -0
  166. package/DivMetroPerformance/assets/line_mid.png +0 -0
  167. package/DivMetroPerformance/assets/line_right.png +0 -0
  168. package/DivMetroPerformance/assets/loading.png +0 -0
  169. package/DivMetroPerformance/assets/logo.png +0 -0
  170. package/DivMetroPerformance/assets/mcjx.png +0 -0
  171. package/DivMetroPerformance/assets/tao.png +0 -0
  172. package/DivMetroPerformance/assets/tmall.png +0 -0
  173. package/DivMetroPerformance/border.png +0 -0
  174. package/DivMetroPerformance/components/ContentItem.vue +0 -384
  175. package/DivMetroPerformance/components/MyTab.vue +0 -129
  176. package/DivMetroPerformance/data.js +0 -124
  177. package/DivMetroPerformance/utils/GridItem.vue +0 -28
  178. package/DivMetroPerformance/utils/GridPlate.vue +0 -85
  179. package/MediaDemo/App.vue +0 -127
  180. package/MediaDemo/assets/audio-poster.png +0 -0
  181. package/MediaDemo/components/Button.vue +0 -69
  182. package/MediaDemo/components/Controllor.vue +0 -286
  183. package/MediaDemo/components/StatusBar.vue +0 -100
  184. package/MediaDemo/components/frames/AudioFrame.vue +0 -39
  185. package/MediaDemo/components/frames/AudioPoster.vue +0 -48
  186. package/MediaDemo/components/frames/MediaFrame.vue +0 -153
  187. package/MediaDemo/components/frames/VideoFrame.vue +0 -39
  188. package/MetroWidgetDemos/TripleWidget/App.vue +0 -87
  189. package/MetroWidgetDemos/TripleWidget/SWidgetItem.vue +0 -99
  190. package/Parkour/App.vue +0 -13
  191. package/Parkour/Common/Context.js +0 -21
  192. package/Parkour/Common/MatchmanInfo.js +0 -62
  193. package/Parkour/Common/Random.js +0 -61
  194. package/Parkour/Common/Sound.js +0 -50
  195. package/Parkour/appConfig/HOW_TO_CONFIG.md +0 -20
  196. package/Parkour/appConfig/app.config.mjs +0 -5
  197. package/Parkour/appConfig/app_sign_private_key_sample.crt +0 -28
  198. package/Parkour/appConfig/app_sign_public_key_sample.pem +0 -9
  199. package/Parkour/appConfig/jsview.config.mjs +0 -39
  200. package/Parkour/assets/Bgimages/bg1.png +0 -0
  201. package/Parkour/assets/Bgimages/bg2.png +0 -0
  202. package/Parkour/assets/Bgimages/bg3.png +0 -0
  203. package/Parkour/assets/Bgimages/bg4.png +0 -0
  204. package/Parkour/assets/Bgimages/bg5.png +0 -0
  205. package/Parkour/assets/audio/jump.mp3 +0 -0
  206. package/Parkour/assets/audio/lose.mp3 +0 -0
  207. package/Parkour/assets/role_skin1/fail.json +0 -44
  208. package/Parkour/assets/role_skin1/fail.png +0 -0
  209. package/Parkour/assets/role_skin1/jump_down.json +0 -20
  210. package/Parkour/assets/role_skin1/jump_down.png +0 -0
  211. package/Parkour/assets/role_skin1/jump_up.json +0 -44
  212. package/Parkour/assets/role_skin1/jump_up.png +0 -0
  213. package/Parkour/assets/role_skin1/roll.json +0 -44
  214. package/Parkour/assets/role_skin1/roll.png +0 -0
  215. package/Parkour/assets/role_skin1/run.json +0 -52
  216. package/Parkour/assets/role_skin1/run.png +0 -0
  217. package/Parkour/components/Backdrop.vue +0 -61
  218. package/Parkour/components/GameSence.vue +0 -602
  219. package/Parkour/components/Matchman.vue +0 -85
  220. package/ThrowMoveDemo/AccelerateDemo.vue +0 -85
  221. package/ThrowMoveDemo/App.vue +0 -104
  222. package/ThrowMoveDemo/LRParabolicDemo.vue +0 -101
  223. package/ThrowMoveDemo/TargetDemo.vue +0 -87
  224. package/ThrowMoveDemo/UDParabolicDemo.vue +0 -92
  225. /package/{AnimPicture/assets → assets}/animated_webp.webp +0 -0
  226. /package/{AnimPicture/assets → assets}/ball_3.webp +0 -0
  227. /package/{AnimPicture/assets → assets}/girl_run.gif +0 -0
  228. /package/{AnimPicture/assets → assets}/quan.webp +0 -0
@@ -0,0 +1,298 @@
1
+ <script setup>
2
+ import buildGenieAnimation from "./GenieTools.ts";
3
+ import {
4
+ shallowRef,
5
+ onMounted,
6
+ onUnmounted,
7
+ onBeforeUnmount,
8
+ } from "vue";
9
+ import {
10
+ JsvFragShaderView,
11
+ getKeyFramesGroup,
12
+ } from "jsview";
13
+ const props = defineProps({
14
+ /**
15
+ * 组件宽度(必填),且不支持响应式
16
+ * @type {Number}
17
+ */
18
+ width: { type: Number, require: true },
19
+
20
+ /**
21
+ * 组件高度(必填),且不支持响应式
22
+ * @type {Number}
23
+ */
24
+ height: { type: Number, require: true },
25
+
26
+ /**
27
+ * 左侧定位位置,且不支持响应式
28
+ * @type {Number}
29
+ * @default 0
30
+ */
31
+ left: { type: Number, default: 0 },
32
+
33
+ /**
34
+ * 顶部定位位置,且不支持响应式
35
+ * @type {Number}
36
+ * @default 0
37
+ */
38
+ top: { type: Number, default: 0 },
39
+
40
+ /**
41
+ * 动画持续时间(秒),且不支持响应式
42
+ * @type {Number}
43
+ * @default 2
44
+ */
45
+ time: { type: Number, default: 2 },
46
+
47
+ /**
48
+ * 动画中心点坐标(必填),且不支持响应式
49
+ * @type {Object}
50
+ * @property {Number} x - X轴坐标
51
+ * @property {Number} y - Y轴坐标
52
+ */
53
+ position: { type: Object, require: true },
54
+
55
+ /**
56
+ * 缩放比例,且不支持响应式
57
+ * @type {Number}
58
+ * @default 1
59
+ */
60
+ size: { type: Number, default: 1 },
61
+
62
+ /**
63
+ * 动画方向(必填),且不支持响应式
64
+ * @type {'horizontal'|'vertical'}
65
+ */
66
+ direction: { type: String, require: true },
67
+
68
+ /**
69
+ * 动画结束回调函数
70
+ * @type {Function}
71
+ * @default () => {}
72
+ */
73
+ onAnimEnd: { type: Function, default: () => {} },
74
+
75
+ /**
76
+ * 初始显示状态(必填),且不支持响应式
77
+ * @type {Boolean}
78
+ */
79
+ initShow: { type: Boolean, require: true },
80
+
81
+ /**
82
+ * 截屏后的纹理名称
83
+ * @type {String}
84
+ */
85
+ textureName: { type: String, default: null },
86
+
87
+ /**
88
+ * 图片url, 与截屏二选一
89
+ * @type {String}
90
+ */
91
+ imageUrl: { type: String, default: null },
92
+ });
93
+
94
+
95
+ let rSlotShowOnDone = shallowRef(false);
96
+
97
+ let vUnmounted = false; // 当前组件是否已经卸载, 用于控制Timer回调后的有效性
98
+
99
+ // 初始状态slot显示状态
100
+ const STAGE_DONE = 1;
101
+ // 截屏回调执行了doAnim后, 此动作会v-if加载JsvFragShaderView, 并隐藏slot
102
+ const STAGE_STARTING_ANIMATION = 3;
103
+ // JsvFragShaderView加载完成(onRef回调), 设置动画属性来开始动画
104
+ const STAGE_ANIMATING = 4;
105
+ // 动画结束的onAllAnimEnd回调后, 至此, setTimeout(1)后, 设置为STAGE_DONE, 并进行props.onAnimEnd回调
106
+ const STAGE_CLOSING_ANIMATION = 5;
107
+
108
+ let rStageMachine = shallowRef(STAGE_DONE);
109
+
110
+ //动画
111
+ const cStyleShell = getKeyFramesGroup();
112
+ //动画字符串
113
+ let vAniStr = shallowRef(null);
114
+
115
+ const {
116
+ vRelease,
117
+ vContract,
118
+ vShader,
119
+ vTransformDirection, //位移动画中心点方向
120
+ KeyFrameReleaseName,
121
+ KeyFrameContractName,
122
+ } = buildGenieAnimation(props.position, props.width, props.height, props.direction);
123
+
124
+ // Shader配置, 因为组件在动画时都是重新创建的, 所以不用做成响应式
125
+ const cShaderInfo = {
126
+ shader: "",
127
+ uniforms: [],
128
+ textures: [
129
+ {
130
+ name: "iChannel0",
131
+ resource: null,
132
+ },
133
+ ],
134
+ duration: props.time * 1000,
135
+ };
136
+
137
+ // 制作基础版shader
138
+ const cLocalizationShader = vShader;
139
+
140
+ //根据初始状态展示
141
+ if (props.initShow) {
142
+ rSlotShowOnDone.value = true;
143
+ } else {
144
+ rSlotShowOnDone.value = false;
145
+ }
146
+
147
+ const onAllAnimEnd = () => {
148
+ rStageMachine.value = STAGE_CLOSING_ANIMATION;
149
+
150
+ setTimeout(() => {
151
+ rStageMachine.value = STAGE_DONE;
152
+ if (!vUnmounted) {
153
+ if (props.onAnimEnd) {
154
+ props.onAnimEnd();
155
+ }
156
+ }
157
+ }, 1);
158
+ }
159
+
160
+ const onShaderViewNewRef = (widgetRef) => {
161
+ if (widgetRef != null) {
162
+ rStageMachine.value = STAGE_ANIMATING;
163
+
164
+ widgetRef.startAnim();
165
+ } else {
166
+ // 动画结束后的组件消失回调, 不需要做任何事情
167
+ }
168
+ }
169
+
170
+ cStyleShell.insertRule(vContract);
171
+ cStyleShell.insertRule(vRelease);
172
+
173
+ function doAnim() {
174
+ rStageMachine.value = STAGE_STARTING_ANIMATION;
175
+
176
+ if (rSlotShowOnDone.value) {
177
+ vAniStr = KeyFrameReleaseName;
178
+ cShaderInfo.shader = cLocalizationShader.replace(/\$\{myTime\}/g, "(iDuration - iTime) / iDuration");
179
+ } else {
180
+ vAniStr = KeyFrameContractName;
181
+ cShaderInfo.shader = cLocalizationShader.replace(/\$\{myTime\}/g, "iTime / iDuration");
182
+ }
183
+ }
184
+
185
+ let vWaitingImageLoadResolveFunc = null;
186
+ let vImageLoaded = false;
187
+
188
+ const onImageLoad = () => {
189
+ if (vUnmounted) {
190
+ return;
191
+ }
192
+
193
+ vImageLoaded = true;
194
+
195
+ if (vWaitingImageLoadResolveFunc) {
196
+ vWaitingImageLoadResolveFunc();
197
+ }
198
+ }
199
+
200
+ const switcher = async () => {
201
+ if (rStageMachine.value != STAGE_DONE) {
202
+ // 动画还没结束, 不能切换
203
+ // 结束后因为slot显示资源可能要重新加载, 所以也不适宜做switcher指令堆积处理
204
+ return;
205
+ }
206
+
207
+ if (props.imageUrl && !vImageLoaded) {
208
+ // 等待图片加载完成
209
+ await new Promise((resolve) => {
210
+ vWaitingImageLoadResolveFunc = resolve;
211
+ });
212
+ }
213
+
214
+ if (props.textureName) {
215
+ cShaderInfo.textures[0].resource = `jsvtexturestore://${props.textureName}`;
216
+ } else {
217
+ cShaderInfo.textures[0].resource = props.imageUrl;
218
+ }
219
+
220
+ // 反转显示目标
221
+ rSlotShowOnDone.value = !rSlotShowOnDone.value;
222
+
223
+ doAnim();
224
+ };
225
+
226
+ onMounted(() => {
227
+ window.JsvCoreApi.enableFpsDisplay(true);
228
+ });
229
+
230
+ onUnmounted(() => {
231
+ vUnmounted = true;
232
+ window.JsvCoreApi.enableFpsDisplay(false);
233
+ });
234
+
235
+ onBeforeUnmount(() => {
236
+ cStyleShell.removeRule(KeyFrameContractName);
237
+ cStyleShell.removeRule(KeyFrameReleaseName);
238
+ });
239
+
240
+ defineExpose({
241
+ /**
242
+ * 触发精灵动画切换
243
+ * 执行截屏并启动收缩/展开动画
244
+ */
245
+ switcher,
246
+ });
247
+
248
+ </script>
249
+ <template>
250
+ <div
251
+ :style="{
252
+ left: props.left,
253
+ top: props.top,
254
+ }"
255
+ >
256
+ <div
257
+ v-if="rStageMachine == STAGE_ANIMATING || rStageMachine == STAGE_STARTING_ANIMATION"
258
+ :style="{
259
+ width: props.width,
260
+ height: props.height,
261
+ animation: `${vAniStr} ${props.time}s`,
262
+ transformOrigin: vTransformDirection,
263
+ }"
264
+ @animationend="onAllAnimEnd"
265
+ >
266
+ <jsv-frag-shader-view
267
+ :ref="onShaderViewNewRef"
268
+ :style="{
269
+ width: props.width,
270
+ height: props.height,
271
+ }"
272
+ :duration="cShaderInfo.duration"
273
+ :shaderStr="cShaderInfo.shader"
274
+ :autoplay="false"
275
+ :textures="cShaderInfo.textures"
276
+ :loadComfirmed="true"
277
+ >
278
+ </jsv-frag-shader-view>
279
+ </div>
280
+ <div
281
+ v-show="rStageMachine == STAGE_DONE || rStageMachine == STAGE_CLOSING_ANIMATION"
282
+ >
283
+ <div
284
+ v-if="props.textureName"
285
+ :style="{
286
+ width: rSlotShowOnDone ? props.width : 1,
287
+ height: rSlotShowOnDone ? props.height : 1,
288
+ backgroundImage: `url(jsvtexturestore://${props.textureName})`,
289
+ }"/>
290
+ <img v-else :src="props.imageUrl" :style="{
291
+ width: rSlotShowOnDone ? props.width : 1,
292
+ height: rSlotShowOnDone ? props.height : 1,
293
+ }"
294
+ @load="onImageLoad"
295
+ />
296
+ </div>
297
+ </div>
298
+ </template>
@@ -0,0 +1,292 @@
1
+ <script setup>
2
+ import buildGenieAnimation from "./GenieTools.ts";
3
+ import {
4
+ shallowRef,
5
+ onMounted,
6
+ onUnmounted,
7
+ onBeforeUnmount,
8
+ } from "vue";
9
+ import {
10
+ JsvFragShaderView,
11
+ getKeyFramesGroup,
12
+ JsvTextureStoreApi,
13
+ } from "jsview";
14
+ const props = defineProps({
15
+ /**
16
+ * 组件宽度(必填),且不支持响应式
17
+ * @type {Number}
18
+ */
19
+ width: { type: Number, require: true },
20
+
21
+ /**
22
+ * 组件高度(必填),且不支持响应式
23
+ * @type {Number}
24
+ */
25
+ height: { type: Number, require: true },
26
+
27
+ /**
28
+ * 左侧定位位置,且不支持响应式
29
+ * @type {Number}
30
+ * @default 0
31
+ */
32
+ left: { type: Number, default: 0 },
33
+
34
+ /**
35
+ * 顶部定位位置,且不支持响应式
36
+ * @type {Number}
37
+ * @default 0
38
+ */
39
+ top: { type: Number, default: 0 },
40
+
41
+ /**
42
+ * 动画持续时间(秒),且不支持响应式
43
+ * @type {Number}
44
+ * @default 2
45
+ */
46
+ time: { type: Number, default: 2 },
47
+
48
+ /**
49
+ * 动画中心点坐标(必填),且不支持响应式
50
+ * @type {Object}
51
+ * @property {Number} x - X轴坐标
52
+ * @property {Number} y - Y轴坐标
53
+ */
54
+ position: { type: Object, require: true },
55
+
56
+ /**
57
+ * 缩放比例,且不支持响应式
58
+ * @type {Number}
59
+ * @default 1
60
+ */
61
+ size: { type: Number, default: 1 },
62
+
63
+ /**
64
+ * 动画方向(必填),且不支持响应式
65
+ * @type {'horizontal'|'vertical'}
66
+ */
67
+ direction: { type: String, require: true },
68
+
69
+ /**
70
+ * 动画结束回调函数
71
+ * @type {Function}
72
+ * @default () => {}
73
+ */
74
+ onAnimEnd: { type: Function, default: () => {} },
75
+
76
+ /**
77
+ * 初始显示状态(必填),且不支持响应式
78
+ * @type {Boolean}
79
+ */
80
+ initShow: { type: Boolean, require: true },
81
+ });
82
+
83
+
84
+ let rSlotShowOnDone = shallowRef(false);
85
+
86
+ let vUnmounted = false; // 当前组件是否已经卸载, 用于控制Timer回调后的有效性
87
+
88
+ // 初始状态slot显示状态
89
+ const STAGE_DONE = 1;
90
+ // 对slot进行截屏
91
+ const STAGE_CAPTURE = 2;
92
+ // 截屏回调执行了doAnim后, 此动作会v-if加载JsvFragShaderView, 并隐藏slot
93
+ const STAGE_STARTING_ANIMATION = 3;
94
+ // JsvFragShaderView加载完成(onRef回调), 设置动画属性来开始动画
95
+ const STAGE_ANIMATING = 4;
96
+ // 动画结束的onAllAnimEnd回调后, 至此, setTimeout(1)后, 设置为STAGE_DONE, 并进行props.onAnimEnd回调
97
+ const STAGE_CLOSING_ANIMATION = 5;
98
+
99
+ let rStageMachine = shallowRef(STAGE_DONE);
100
+
101
+ //动画
102
+ const cStyleShell = getKeyFramesGroup();
103
+ //动画字符串
104
+ let vAniStr = shallowRef(null);
105
+
106
+ const {
107
+ vRelease,
108
+ vContract,
109
+ vShader,
110
+ vTransformDirection, //位移动画中心点方向
111
+ KeyFrameReleaseName,
112
+ KeyFrameContractName,
113
+ } = buildGenieAnimation(props.position, props.width, props.height, props.direction);
114
+
115
+ // Shader配置, 因为组件在动画时都是重新创建的, 所以不用做成响应式
116
+ const cShaderInfo = {
117
+ shader: "",
118
+ uniforms: [],
119
+ textures: [
120
+ {
121
+ name: "iChannel0",
122
+ resource: null,
123
+ },
124
+ ],
125
+ duration: props.time * 1000,
126
+ };
127
+
128
+ // 制作基础版shader
129
+ const cLocalizationShader = vShader;
130
+
131
+ //根据初始状态展示
132
+ if (props.initShow) {
133
+ rSlotShowOnDone.value = true;
134
+ } else {
135
+ rSlotShowOnDone.value = false;
136
+ }
137
+
138
+ const onAllAnimEnd = () => {
139
+ rStageMachine.value = STAGE_CLOSING_ANIMATION;
140
+
141
+ setTimeout(() => {
142
+ rStageMachine.value = STAGE_DONE;
143
+ if (!vUnmounted) {
144
+ if (props.onAnimEnd) {
145
+ props.onAnimEnd();
146
+ }
147
+ }
148
+ }, 1);
149
+ }
150
+
151
+ const onShaderViewNewRef = (widgetRef) => {
152
+ if (widgetRef != null) {
153
+ rStageMachine.value = STAGE_ANIMATING;
154
+
155
+ widgetRef.startAnim();
156
+ } else {
157
+ // 动画结束后的组件消失回调, 不需要做任何事情
158
+ }
159
+ }
160
+
161
+ cStyleShell.insertRule(vContract);
162
+ cStyleShell.insertRule(vRelease);
163
+
164
+ function doAnim() {
165
+ rStageMachine.value = STAGE_STARTING_ANIMATION;
166
+
167
+ if (rSlotShowOnDone.value) {
168
+ vAniStr = KeyFrameReleaseName;
169
+ cShaderInfo.shader = cLocalizationShader.replace(/\$\{myTime\}/g, "(iDuration - iTime) / iDuration");
170
+ } else {
171
+ vAniStr = KeyFrameContractName;
172
+ cShaderInfo.shader = cLocalizationShader.replace(/\$\{myTime\}/g, "iTime / iDuration");
173
+ }
174
+ }
175
+
176
+ let rSlotRootRef = shallowRef(null);
177
+
178
+ let rDebugCaptureResult = shallowRef(null);
179
+
180
+ const switcher = () => {
181
+ if (rStageMachine.value != STAGE_DONE) {
182
+ // 动画还没结束, 不能切换
183
+ // 结束后因为slot显示资源可能要重新加载, 所以也不适宜做switcher指令堆积处理
184
+ return;
185
+ }
186
+
187
+
188
+ rStageMachine.value = STAGE_CAPTURE;
189
+ JsvTextureStoreApi.capture2Texture(
190
+ rSlotRootRef.value,
191
+ (textureName, autoRecycle, w, h) => {
192
+ if (vUnmounted) {
193
+ return;
194
+ }
195
+
196
+ cShaderInfo.textures[0].resource = `jsvtexturestore://${textureName}`;
197
+ rDebugCaptureResult.value = `jsvtexturestore://${textureName}`;
198
+
199
+ if (autoRecycle) {
200
+ // 已经是设置了texture的自动回收,所以不再需要主动调用 JsvTextureStoreApi.deleteTexture 来释放内存
201
+ }
202
+
203
+ // 截图后反转状态
204
+ rSlotShowOnDone.value = !rSlotShowOnDone.value;
205
+
206
+ doAnim();
207
+ },
208
+ true // 自动回收, 不填也行,默认为true
209
+ );
210
+ };
211
+
212
+ onMounted(() => {
213
+ window.JsvCoreApi.enableFpsDisplay(true);
214
+ });
215
+
216
+ onUnmounted(() => {
217
+ vUnmounted = true;
218
+ window.JsvCoreApi.enableFpsDisplay(false);
219
+ });
220
+
221
+ onBeforeUnmount(() => {
222
+ cStyleShell.removeRule(KeyFrameContractName);
223
+ cStyleShell.removeRule(KeyFrameReleaseName);
224
+ });
225
+
226
+ defineExpose({
227
+ /**
228
+ * 触发精灵动画切换
229
+ * 执行截屏并启动收缩/展开动画
230
+ */
231
+ switcher,
232
+ });
233
+
234
+ </script>
235
+ <template>
236
+ <div
237
+ :style="{
238
+ left: props.left,
239
+ top: props.top,
240
+ }"
241
+ >
242
+ <div
243
+ v-if="rStageMachine == STAGE_ANIMATING || rStageMachine == STAGE_STARTING_ANIMATION"
244
+ :style="{
245
+ width: props.width,
246
+ height: props.height,
247
+ animation: `${vAniStr} ${props.time}s`,
248
+ transformOrigin: vTransformDirection,
249
+ }"
250
+ @animationend="onAllAnimEnd"
251
+ >
252
+ <jsv-frag-shader-view
253
+ :ref="onShaderViewNewRef"
254
+ :style="{
255
+ width: props.width,
256
+ height: props.height,
257
+ }"
258
+ :duration="cShaderInfo.duration"
259
+ :shaderStr="cShaderInfo.shader"
260
+ :autoplay="false"
261
+ :textures="cShaderInfo.textures"
262
+ >
263
+ </jsv-frag-shader-view>
264
+ </div>
265
+ <div
266
+ v-show="rStageMachine == STAGE_CAPTURE || rStageMachine == STAGE_DONE || rStageMachine == STAGE_CLOSING_ANIMATION"
267
+ :style="{
268
+ width: rSlotShowOnDone ? props.width : 1,
269
+ height: rSlotShowOnDone ? props.height : 1,
270
+ overflow: rSlotShowOnDone ? null : 'hidden',
271
+ // width: props.width,
272
+ // height: props.height,
273
+ }"
274
+ >
275
+ <div
276
+ ref="rSlotRootRef"
277
+ :style="{
278
+ width: props.width,
279
+ height: props.height,
280
+ }"
281
+ >
282
+ <slot></slot>
283
+ </div>
284
+ </div>
285
+ <!-- <div :style="{
286
+ width: 320,
287
+ height: 160,
288
+ backgroundImage: rDebugCaptureResult ? `url(${rDebugCaptureResult})` : '',
289
+ }"/> -->
290
+
291
+ </div>
292
+ </template>