@shijiu/jsview-vue-samples 2.2.201 → 2.2.426-test.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 (103) hide show
  1. package/BakeViewDemo/App.vue +6 -1
  2. package/Basic/components/anim/AnimEasingCubicBezier.vue +56 -0
  3. package/Basic/components/anim/AnimGroup2.vue +33 -0
  4. package/Basic/components/panel/Panel2.vue +8 -3
  5. package/Basic/components/text/TextDirection.vue +0 -1
  6. package/ColorSpace/App.vue +2 -2
  7. package/CoupletsTest/widget/Banger/Maroon.vue +0 -1
  8. package/CoupletsTest/widget/Fireworks/Fireworks.vue +0 -2
  9. package/CssPreprocessor/Stylus/components/stylus-group1/StylusOperations.vue +0 -1
  10. package/CssPreprocessor/utils/ContentBlock.vue +3 -3
  11. package/CssPreprocessor/utils/{FontStyle.css → FontConfig.css} +3 -3
  12. package/CssPreprocessor/utils/TitleBar.vue +2 -2
  13. package/CustomShader/App.vue +32 -15
  14. package/CustomShader/pageFlip.glsl +3 -2
  15. package/DemoHomepage/App.vue +14 -5
  16. package/DemoHomepage/components/Item.vue +23 -12
  17. package/DemoHomepage/index.d.ts +5 -2
  18. package/DemoHomepage/router.js +97 -74
  19. package/DemoHomepage/views/Homepage.vue +0 -4
  20. package/DispersedFocusControl/App.vue +67 -0
  21. package/DispersedFocusControl/Button.vue +76 -0
  22. package/DispersedFocusControl/data.js +44 -0
  23. package/DivMetroPerformance/components/ContentItem.vue +0 -1
  24. package/DragBox/App.vue +148 -0
  25. package/FlexCellDemo/App.vue +47 -223
  26. package/FlexCellDemo/TestFrame1.vue +84 -0
  27. package/FlexCellDemo/TestFrame2.vue +100 -0
  28. package/FlexCellDemo/TestFrame3.vue +97 -0
  29. package/FlexCellDemo/TestFrame4.vue +60 -0
  30. package/FlexCellDemo/TestFrame5.vue +60 -0
  31. package/FlexCellDemo/images/6.jpg +0 -0
  32. package/FocusMoveStyle/App.vue +1 -0
  33. package/FocusMoveStyle/CreepFocus.vue +11 -1
  34. package/FocusMoveStyle/FoldableItem.vue +1 -1
  35. package/FullScreenFlex/App.vue +42 -0
  36. package/FullScreenFlex/TestFrame2.vue +107 -0
  37. package/FullScreenFlex/images/1.png +0 -0
  38. package/GiftRain/App.vue +0 -3
  39. package/HashHistory/App.vue +8 -4
  40. package/HashParams/App.vue +0 -1
  41. package/Input/App.vue +184 -97
  42. package/Input/InputPanel.vue +98 -82
  43. package/JsvPreDownloader/App.vue +0 -2
  44. package/LatexFormula/App.vue +97 -10
  45. package/Marquee/App.vue +2 -2
  46. package/MetroWidgetDemos/MassiveItems/ContentItem.vue +0 -1
  47. package/MetroWidgetDemos/PerformanceTest/components/ContentItem.vue +0 -1
  48. package/MetroWidgetDemos/PerformanceTest/components/MyTab.vue +18 -17
  49. package/MetroWidgetDemos/itemSizeUpdate/backward/Item.vue +1 -1
  50. package/MetroWidgetDemos/routeList.js +17 -17
  51. package/MindMap/App.vue +10 -1
  52. package/MindMap/data.js +34 -8
  53. package/Parkour/appConfig/jsview.config.mjs +0 -4
  54. package/PosterPacker/App.vue +207 -0
  55. package/PosterPacker/images/bg.jpg +0 -0
  56. package/PosterPacker/images/blue.png +0 -0
  57. package/PosterPacker/images/darkGreen.png +0 -0
  58. package/PosterPacker/images/left.png +0 -0
  59. package/PosterPacker/images/orange.png +0 -0
  60. package/PosterPacker/images/pink.png +0 -0
  61. package/PosterPacker/images/purple.png +0 -0
  62. package/PosterPacker/images/red.png +0 -0
  63. package/PosterPacker/images/right.png +0 -0
  64. package/PosterPacker/images/yellowGreen.png +0 -0
  65. package/PosterPacker/tools/geniePakcer/Genie.vue +686 -0
  66. package/PosterPacker/tools/geniePakcer/genieBottom.glsl +49 -0
  67. package/PosterPacker/tools/geniePakcer/genieLeft.glsl +50 -0
  68. package/PosterPacker/tools/geniePakcer/genieRight.glsl +57 -0
  69. package/PosterPacker/tools/geniePakcer/genieTop.glsl +50 -0
  70. package/PosterPacker/tools/particlePacker/Particle.vue +71 -0
  71. package/PosterPacker/tools/vortexPacker/Vortex.vue +135 -0
  72. package/PosterPacker/tools/vortexPacker/vortex.glsl +37 -0
  73. package/Preload/App.vue +1 -1
  74. package/ScaleDownNeon/App.vue +13 -10
  75. package/SceneTransition/App.vue +5 -4
  76. package/ScrollBoxTest/ClipBar.vue +1 -0
  77. package/ScrollBoxTest/NinePatchBar.vue +1 -0
  78. package/ScrollBoxTest/SizeDivBar.vue +1 -0
  79. package/SprayMove/App.vue +75 -0
  80. package/SprayMove/SprayMove.vue +173 -0
  81. package/SprayView/App.vue +8 -9
  82. package/TestNativeSharedView/App.vue +6 -4
  83. package/TextShadowDemo/App.vue +3 -3
  84. package/TextureAnimation/App.vue +237 -151
  85. package/TextureAnimation/App2.vue +66 -14
  86. package/TextureAnimation/assets/blackWhiteTurntable.png +0 -0
  87. package/TextureAnimation/assets/circleHaloMask.png +0 -0
  88. package/TextureSize/App.vue +5 -6
  89. package/TouchWidget/App.vue +79 -40
  90. package/TouchWidget/Item.vue +15 -3
  91. package/ViewOpacity/App.vue +4 -5
  92. package/index.d.ts +1 -1
  93. package/package.json +1 -1
  94. package/TextureAnimation/assets/mask.png +0 -0
  95. package/TextureAnimation/assets/php.jpg +0 -0
  96. package/TouchSample/App.vue +0 -136
  97. package/TouchSample/Item.vue +0 -102
  98. package/TouchSample/MetroWidgetHorizontal.vue +0 -144
  99. package/TouchSample/MetroWidgetVertical.vue +0 -144
  100. package/TouchSample/TouchContainerHorizontal.vue +0 -160
  101. package/TouchSample/TouchContainerVertical.vue +0 -160
  102. package/TouchSample/data.js +0 -81
  103. /package/TextureAnimation/assets/{php2.png → borderOpacity.png} +0 -0
@@ -37,7 +37,12 @@ onMounted(() => {
37
37
  (textureName, autoRecycle, w, h) => {
38
38
  vCapturedTexture.value = textureName;
39
39
  console.log(`capture done id=${textureName} w=${w} h=${h}`);
40
- }
40
+
41
+ if (autoRecycle) {
42
+ // 已经是设置了texture的自动回收,所以不再需要主动调用 JsvTextureStoreApi.deleteTexture 来释放内存
43
+ }
44
+ },
45
+ true // 自动回收, 不填也行,默认为true
41
46
  );
42
47
  }, 2200);
43
48
  });
@@ -0,0 +1,56 @@
1
+ <script setup>
2
+ import { getKeyFramesGroup } from "jsview";
3
+ import { onBeforeUnmount } from "vue";
4
+
5
+ const itemStyle = {
6
+ top: 20,
7
+ left: 20,
8
+ width: 60,
9
+ height: 60,
10
+ fontSize: 15,
11
+ color: "rgba(255, 255, 0, 1)",
12
+ backgroundColor: "rgba(255, 0, 0, 1)",
13
+ };
14
+
15
+ // 单纯的放大动画使用贝塞尔的timingFunction成为心跳效果
16
+ const cP1 = [0.42, 3.96];
17
+ const cP2 = [0.62, 0];
18
+ const sScaleUpTs = `BasicAnim_PumpUp 0.8s cubic-bezier(${cP1[0]}, ${cP1[1]}, ${cP2[0]}, ${cP2[1]}) infinite`;
19
+
20
+ // 暂时不暴露fill-mode = forwards接口
21
+ // const sScaleUpOnce = `BasicAnim_PumpUp 0.8s cubic-bezier(${cP1[0]}, ${cP1[1]}, ${cP2[0]}, ${cP2[1]}) 3 forwards`;
22
+
23
+ // 拿取group句柄
24
+ const styleShell = getKeyFramesGroup();
25
+
26
+ // 动态注入规则, 注意 keyFrame 名称是全局的, 不要重名
27
+ styleShell.insertRule(
28
+ "@keyframes BasicAnim_PumpUp \
29
+ {from {transform: scale3d(1, 1, 1);} \
30
+ to {transform: scale3d(1.2, 1.2, 1);}}"
31
+ );
32
+
33
+ // keyFrame 注意unmount时的销毁
34
+ onBeforeUnmount(() => {
35
+ styleShell.removeRule("BasicAnim_PumpUp");
36
+ });
37
+ </script>
38
+
39
+ <template>
40
+ <div id="layout-root">
41
+ <div :style="{ ...itemStyle, animation: sScaleUpTs }">
42
+ {{ "心跳\n效果" }}
43
+ </div>
44
+ <!-- <div
45
+ :style="{
46
+ ...itemStyle,
47
+ left: 100,
48
+ animation: sScaleUpOnce,
49
+ }"
50
+ >
51
+ {{ "心跳\n效果2" }}
52
+ </div> -->
53
+ </div>
54
+ </template>
55
+
56
+ <style></style>
@@ -0,0 +1,33 @@
1
+ <script setup>
2
+ import { reactive, onMounted, onBeforeUnmount } from "vue";
3
+ import ContentBlock from "../ContentBlock.vue";
4
+ import AnimEasingCubicBezier from "./AnimEasingCubicBezier.vue";
5
+
6
+ const props = defineProps({
7
+ contentClass: String,
8
+ itemSides: Object,
9
+ });
10
+
11
+ const contentBlockProps = {
12
+ colIndex: 0,
13
+ itemSides: props.itemSides,
14
+ };
15
+
16
+ onMounted(() => {});
17
+
18
+ onBeforeUnmount(() => {});
19
+ </script>
20
+
21
+ <template>
22
+ <div id="item-root">
23
+ <ContentBlock
24
+ :class="contentClass"
25
+ :style="{ top: itemSides.height * 0 }"
26
+ :="contentBlockProps"
27
+ :index="1"
28
+ title="贝塞尔动画"
29
+ >
30
+ <AnimEasingCubicBezier />
31
+ </ContentBlock>
32
+ </div>
33
+ </template>
@@ -1,13 +1,14 @@
1
1
  <script setup>
2
2
  import TitleBar from "./TitleBar.vue";
3
3
  import ImageGroup from "../img/ImageGroup.vue";
4
+ import AnimGroup2 from "../anim/AnimGroup2.vue";
4
5
 
5
6
  const props = defineProps({
6
7
  panelClass: String,
7
8
  itemSides: Object,
8
9
  });
9
10
 
10
- const titleData = ["img标签"];
11
+ const titleData = ["img标签", "div动画2"];
11
12
  </script>
12
13
 
13
14
  <template>
@@ -23,9 +24,13 @@ const titleData = ["img标签"];
23
24
  :contentClass="panelClass"
24
25
  :itemSides="itemSides"
25
26
  />
27
+ <AnimGroup2
28
+ :style="{ left: itemSides.width * 1 }"
29
+ :contentClass="panelClass"
30
+ :itemSides="itemSides"
31
+ />
26
32
  </div>
27
33
  </div>
28
34
  </template>
29
35
 
30
- <style>
31
- </style>
36
+ <style></style>
@@ -91,7 +91,6 @@ const rtlText = "شلؤيثبلاهتنمةىخحضقسفعررصءغئا";
91
91
  font-size: 25;
92
92
  white-space: nowrap;
93
93
  text-overflow: ellipsis;
94
- overflow: hidden;
95
94
  }
96
95
 
97
96
  .explain {
@@ -10,7 +10,7 @@ const router = useRouter();
10
10
  const onKeyDown = (ev) => {
11
11
  // 8:Backspace, 27:Escape, 10000:盒子返回键
12
12
  if (ev.keyCode == 8 || ev.keyCode == 27 || ev.keyCode == 10000) {
13
- window.JsView?.setGlobalConfig({
13
+ window.JsvCoreApi?.setRenderGlobalConfig({
14
14
  texCache: -1,
15
15
  });
16
16
 
@@ -123,4 +123,4 @@ const onKeyDown = (ev) => {
123
123
  color: #ffffff;
124
124
  font-size: 20;
125
125
  }
126
- </style>
126
+ </style>
@@ -110,7 +110,6 @@ const sprayOk = {
110
110
  lifeMax: 2000,
111
111
  accelerateX: 0,
112
112
  accelerateY: 0,
113
- addNumSpeed: 0.001,
114
113
  enableFade: true,
115
114
  enableShrink: true,
116
115
  };
@@ -270,7 +270,6 @@ const sprayOk = {
270
270
  lifeMax: 800,
271
271
  accelerateX: 0,
272
272
  accelerateY: 0,
273
- addNumSpeed: 0.001,
274
273
  enableFade: false,
275
274
  enableShrink: true,
276
275
  };
@@ -288,7 +287,6 @@ const sprayOk1 = {
288
287
  lifeMax: 2000,
289
288
  accelerateX: 0,
290
289
  accelerateY: -40,
291
- addNumSpeed: 0.001,
292
290
  enableFade: false,
293
291
  enableShrink: false,
294
292
  };
@@ -19,7 +19,6 @@ export default {
19
19
 
20
20
  <style scoped lang="stylus">
21
21
  .stylus-op {
22
- color: #001100 * 16;
23
22
  font-size: 20 - 6;
24
23
 
25
24
  left: 10;
@@ -44,10 +44,10 @@ const titleStyle = {
44
44
 
45
45
  <template>
46
46
  <div :style=props.style>
47
- <div class="container-font" :style=titleStyle>
47
+ <div class="container-config" :style=titleStyle>
48
48
  {{ title }}
49
49
  </div>
50
- <div class="content-font" :style="{
50
+ <div class="content-config" :style="{
51
51
  top: titleStyle.lineHeight,
52
52
  width: props.style.width, height: props.style.height - 18,
53
53
  backgroundColor: 'rgba(0,0,0,' + blockOpacity + ')'
@@ -59,5 +59,5 @@ const titleStyle = {
59
59
 
60
60
  <style>
61
61
  /* css文件要单独放到没有scoped设置的style标签中,规避css属性redefine的warning */
62
- @import "./FontStyle.css";
62
+ @import "./FontConfig.css";
63
63
  </style>
@@ -1,18 +1,18 @@
1
1
 
2
- .title-font {
2
+ .title-config {
3
3
  color:#877c4a;
4
4
  font-family: 黑体;
5
5
  font-size: 16;
6
6
  text-align: center;
7
7
  }
8
8
 
9
- .container-font {
9
+ .container-config {
10
10
  color: #FFFFFF;
11
11
  font-family: 黑体;
12
12
  font-size: 16;
13
13
  }
14
14
 
15
- .content-font {
15
+ .content-config {
16
16
  color: #000000;
17
17
  font-family: 黑体;
18
18
  font-size: 10;
@@ -8,7 +8,7 @@ const props = defineProps({
8
8
  <template>
9
9
  <div>
10
10
  <template v-for="(title, index) in props.titleData" :key="index">
11
- <div class='title-font title-range' :style="{ left: props.style.width * index }">
11
+ <div class='title-config title-range' :style="{ left: props.style.width * index }">
12
12
  {{ title }}
13
13
  </div>
14
14
  </template>
@@ -25,5 +25,5 @@ const props = defineProps({
25
25
  </style>
26
26
  <style>
27
27
  /* css文件要单独放到没有scoped设置的style标签中,规避css属性redefine的warning */
28
- @import "./FontStyle.css";
28
+ @import "./FontConfig.css";
29
29
  </style>
@@ -24,6 +24,7 @@ const cShaderSettings = [
24
24
  resource: ImageOwl,
25
25
  },
26
26
  ],
27
+ duration: 100000,
27
28
  },
28
29
  {
29
30
  name: "pageFlip",
@@ -35,6 +36,16 @@ const cShaderSettings = [
35
36
  resource: ImageOwl,
36
37
  },
37
38
  ],
39
+ duration: 500,
40
+ onEnd: (id, status) => {
41
+ if (status) {
42
+ // 动画正常结束,而非cancel打断
43
+ console.log("flip anim end");
44
+ rShowShaderView.value = false;
45
+ } else {
46
+ console.log("flip anim cancel");
47
+ }
48
+ },
38
49
  },
39
50
  {
40
51
  name: "sdf",
@@ -46,7 +57,9 @@ const cShaderSettings = [
46
57
  resource: ImageOwl,
47
58
  },
48
59
  ],
60
+ duration: 100000,
49
61
  },
62
+ // 高斯模糊性能太差,先不做推广
50
63
  {
51
64
  name: "gaussianBlur",
52
65
  shader: gaussianBlurShader,
@@ -57,27 +70,31 @@ const cShaderSettings = [
57
70
  resource: ImageOwl,
58
71
  },
59
72
  ],
73
+ duration: 0,
60
74
  },
61
75
  ];
62
76
 
77
+ const rShowShaderView = ref(true);
63
78
  const rKeyCount = ref(0);
64
79
  const rShaderInfo = computed(() => {
65
80
  return cShaderSettings[rKeyCount.value];
66
81
  });
67
82
 
68
83
  const rAutoplay = computed(() => {
69
- return rKeyCount.value != 3;
84
+ return true;
70
85
  });
71
86
 
72
87
  const rWidgetRef = ref();
73
88
  const onKeyDown = (ev) => {
74
89
  switch (ev.keyCode) {
75
90
  case 37: {
91
+ rShowShaderView.value = true;
76
92
  rKeyCount.value =
77
93
  rKeyCount.value > 0 ? rKeyCount.value - 1 : rKeyCount.value;
78
94
  return true;
79
95
  }
80
96
  case 39: {
97
+ rShowShaderView.value = true;
81
98
  rKeyCount.value =
82
99
  rKeyCount.value < cShaderSettings.length - 1
83
100
  ? rKeyCount.value + 1
@@ -85,9 +102,8 @@ const onKeyDown = (ev) => {
85
102
  return true;
86
103
  }
87
104
  case 13: {
88
- if (rKeyCount.value != 3) {
89
- rWidgetRef.value?.startAnim();
90
- }
105
+ rShowShaderView.value = true;
106
+ rWidgetRef.value?.startAnim();
91
107
  return true;
92
108
  }
93
109
  default:
@@ -96,11 +112,11 @@ const onKeyDown = (ev) => {
96
112
  };
97
113
 
98
114
  onMounted(() => {
99
- window.JsView?.enableFpsDisplay(true);
115
+ window.JsvCoreApi.enableFpsDisplay(true);
100
116
  });
101
117
 
102
118
  onUnmounted(() => {
103
- window.JsView?.enableFpsDisplay(false);
119
+ window.JsvCoreApi.enableFpsDisplay(false);
104
120
  });
105
121
  </script>
106
122
 
@@ -111,30 +127,31 @@ onUnmounted(() => {
111
127
  onKeyDown,
112
128
  }"
113
129
  :style="{
114
- width: 1920,
115
- height: 1080,
130
+ width: 1280,
131
+ height: 720,
116
132
  backgroundImage: `url(${ImageChinChilla})`,
117
133
  }"
118
134
  ></jsv-focus-block>
119
135
 
120
136
  <jsv-frag-shader-view
137
+ v-if="rShowShaderView"
121
138
  :key="rKeyCount"
122
139
  ref="rWidgetRef"
123
- :style="{ left: 0, top: 0, width: 1920, height: 1080 }"
124
- :duration="100000"
140
+ :style="{ left: 0, top: 0, width: 1280, height: 720 }"
141
+ :duration="rShaderInfo.duration"
125
142
  :shaderStr="rShaderInfo.shader"
126
143
  :autoplay="rAutoplay"
127
144
  :textures="rShaderInfo.textures"
145
+ :onEnd="rShaderInfo.onEnd"
128
146
  ></jsv-frag-shader-view>
129
147
  <div
130
148
  :key="rKeyCount"
131
149
  :style="{
132
- top: 20,
133
- left: 500,
150
+ top: 100,
151
+ left: 20,
134
152
  width: 500,
135
153
  height: 50,
136
154
  fontSize: 30,
137
- textAlign: 'center',
138
155
  backgroundColor: '#00000055',
139
156
  color: '#ffffff',
140
157
  }"
@@ -143,8 +160,8 @@ onUnmounted(() => {
143
160
  </div>
144
161
  <div
145
162
  :style="{
146
- top: 20,
147
- left: 1400,
163
+ top: 150,
164
+ left: 20,
148
165
  width: 500,
149
166
  height: 50,
150
167
  fontSize: 30,
@@ -1,3 +1,4 @@
1
+ //https://andrewhungblog.wordpress.com/2018/04/29/page-curl-shader-breakdown/
1
2
  #define pi 3.14159265359
2
3
  #define radius .1
3
4
 
@@ -13,7 +14,7 @@ void mainImage(out vec4 fragColor, in vec2 fragCoord) {
13
14
  vec2 aspect = iResolution.xy / iResolution.y;
14
15
  vec2 uv = fragCoord * aspect / iResolution.xy;
15
16
  vec2 anchor = aspect;
16
- vec2 mouse = anchor - abs(sin(iTime / 2.)) * anchor;
17
+ vec2 mouse = anchor - abs(iTime / iDuration) * anchor;
17
18
  vec2 mouseDir = normalize(anchor - mouse);
18
19
  vec2 origin = mouse - mouseDir * mouse.x / abs(mouseDir.x);
19
20
  float mouseDist = length(mouse - origin);
@@ -22,7 +23,7 @@ void mainImage(out vec4 fragColor, in vec2 fragCoord) {
22
23
  float dist = proj - mouseDist;
23
24
  vec2 linePoint = uv - dist * mouseDir;
24
25
  if(dist > radius) {
25
- fragColor = vec4(0.0, 0.5, 0.6, 1.0);
26
+ fragColor = vec4(0.0, 0.0, 0.0, 0.0);
26
27
  fragColor.rgb *= pow(clamp(dist - radius, 0., 1.) * 1.5, .2);
27
28
  } else if(dist >= 0.) {
28
29
  // map to cylinder point
@@ -6,13 +6,14 @@
6
6
  * @Description: file content
7
7
  -->
8
8
  <script setup>
9
- import { shallowRef, onMounted, onUnmounted } from "vue";
9
+ import { shallowRef, onMounted, onUnmounted, provide } from "vue";
10
10
  import {
11
11
  JsvPreload,
12
12
  buildPreloadInfo,
13
13
  jJsvRuntimeBridge,
14
14
  JsvFocusBlock,
15
15
  useFocusHub,
16
+ JsvTouchModeSwitcher,
16
17
  } from "jsview";
17
18
  import { useRouter } from "vue-router";
18
19
  import { setDataUrl, getDataUrl } from "../CommonUtils/ResourceData.js";
@@ -20,7 +21,8 @@ import { getSearchQuery } from "../CommonUtils/getSearchQuery.js";
20
21
 
21
22
  let DemoResourceBase = shallowRef("");
22
23
  let backgroundImageUrl = shallowRef(null);
23
-
24
+ const touchModeSwitcherRef = shallowRef();
25
+ provide("touchModeSwitcherRef", touchModeSwitcherRef);
24
26
  // let preloadInfo = shallowRef([]);
25
27
 
26
28
  window.DebugFocusHub = useFocusHub();
@@ -54,6 +56,9 @@ if (query.DemoResourceBase) {
54
56
  DemoResourceBase.value = getDataUrl();
55
57
  }
56
58
  onMounted(() => {
59
+ touchModeSwitcherRef.value?.registerCallback((mode) => {
60
+ console.log("change mode to", mode == 1 ? "key" : "touch");
61
+ });
57
62
  console.log("simulate async get background url");
58
63
  setTimeout(() => {
59
64
  console.log("simulate background url got");
@@ -79,7 +84,11 @@ onUnmounted(() => {
79
84
  </script>
80
85
 
81
86
  <template>
82
- <div>
87
+ <jsv-touch-mode-switcher
88
+ ref="touchModeSwitcherRef"
89
+ :width="1280"
90
+ :height="720"
91
+ >
83
92
  <!-- <jsv-preload :key="backgroundImageUrl" :preloadList="preloadInfo" :onPreloadDone="_onPreloadDone" /> -->
84
93
  <img
85
94
  :src="backgroundImageUrl"
@@ -90,7 +99,7 @@ onUnmounted(() => {
90
99
  @load="_onPreloadDone"
91
100
  />
92
101
  <div class="TestKeepAliveDiv">
93
- {{ "刷新:" + testKeepAliveModeText }}
102
+ {{ "更新页面计数:" + testKeepAliveModeText }}
94
103
  </div>
95
104
  <jsv-focus-block
96
105
  :onAction="{
@@ -104,7 +113,7 @@ onUnmounted(() => {
104
113
  <component v-if="!route.meta.keepAlive" :is="Component" />
105
114
  </router-view>
106
115
  </jsv-focus-block>
107
- </div>
116
+ </jsv-touch-mode-switcher>
108
117
  </template>
109
118
 
110
119
  <style scoped>
@@ -1,5 +1,5 @@
1
1
  <script setup>
2
- import { shallowRef, computed } from "vue"
2
+ import { shallowRef, computed, inject } from "vue";
3
3
  const props = defineProps({
4
4
  style: Object,
5
5
  itemClick: Function,
@@ -7,16 +7,17 @@ const props = defineProps({
7
7
  data: Object,
8
8
  query: Object,
9
9
  onAction: Object,
10
- })
10
+ });
11
11
 
12
- let focused = shallowRef(false)
12
+ let focused = shallowRef(false);
13
+ const touchModeSwitcherRef = inject("touchModeSwitcherRef");
13
14
 
14
15
  const foucsStyle = computed(() => {
15
16
  return {
16
17
  width: props.style.width,
17
18
  height: props.style.height,
18
19
  };
19
- })
20
+ });
20
21
 
21
22
  const itemStyle = computed(() => {
22
23
  return {
@@ -25,31 +26,41 @@ const itemStyle = computed(() => {
25
26
  backgroundColor: props.style.backgroundColor,
26
27
  color: props.style.color,
27
28
  };
29
+ });
28
30
 
29
- })
31
+ const modeChangeCallback = (mode) => {
32
+ if (mode == 2) {
33
+ focused.value = false;
34
+ } else {
35
+ focused.value = true;
36
+ }
37
+ };
30
38
 
31
39
  const onFocus = () => {
32
- focused.value = true;
40
+ //为了避免每个item都注册回调, 这里onFocus时注册, onBlur时注销
41
+ touchModeSwitcherRef.value.registerCallback(modeChangeCallback);
42
+ if (touchModeSwitcherRef.value.getInteractiveMode() == 1) {
43
+ focused.value = true;
44
+ }
33
45
  if (props.itemFocus) {
34
46
  props.itemFocus(props.data);
35
47
  }
36
- }
48
+ };
37
49
 
38
50
  const onBlur = () => {
51
+ touchModeSwitcherRef.value.unregisterCallback(modeChangeCallback);
39
52
  focused.value = false;
40
- }
53
+ };
41
54
 
42
55
  const onClick = () => {
43
- console.log("testtest", "onclick ", props.data.name)
44
56
  if (props.itemClick) {
45
57
  props?.itemClick(props.query.id, props.data);
46
58
  }
47
- }
59
+ };
48
60
 
49
61
  props.onAction.register("onFocus", onFocus);
50
62
  props.onAction.register("onBlur", onBlur);
51
63
  props.onAction.register("onClick", onClick);
52
-
53
64
  </script>
54
65
 
55
66
  <template>
@@ -72,4 +83,4 @@ props.onAction.register("onClick", onClick);
72
83
  text-align: center;
73
84
  font-size: 30;
74
85
  }
75
- </style>
86
+ </style>
@@ -1,5 +1,8 @@
1
1
  import App from './App.vue'
2
2
 
3
- export * from "./router.js"
3
+ import { router } from "./router.js"
4
4
 
5
- export default App
5
+ export default App
6
+ export {
7
+ router
8
+ }