@@ -25,6 +25,7 @@ declare global {
25
25
_windvane_backControl : Function | null ;
26
26
__megability_bridge__ : {
27
27
syncCall : Function ;
28
+ asyncCall : Function ;
28
29
} ;
29
30
}
30
31
}
@@ -74,7 +75,7 @@ export const CacheCanvas = forwardRef((props: CacheCanvasProps, ref) => {
74
75
}
75
76
// Cache base64 string when canvas rendered.
76
77
if ( renderedCanvas && strBase64 ) {
77
- Storage . setItem ( cacheKey , strBase64 , {
78
+ return Storage . setItem ( cacheKey , strBase64 , {
78
79
bizID,
79
80
} ) ;
80
81
}
@@ -88,27 +89,6 @@ export const CacheCanvas = forwardRef((props: CacheCanvasProps, ref) => {
88
89
setMounted ( true ) ;
89
90
} , [ ] ) ;
90
91
91
- useEffect ( ( ) => {
92
- if ( window . WindVane ) {
93
- window . WindVane . call ( 'WebAppInterface' , 'enableHookNativeBack' , { } ) ;
94
- window . _windvane_backControl = ( ) => {
95
- cacheCanvasFunc ( ) ;
96
- // Windvane must return a string value of true for it to work properly.
97
- return 'false' ;
98
- } ;
99
- }
100
- document . addEventListener ( 'wvBackClickEvent' , cacheCanvasFunc , false ) ;
101
- window . addEventListener ( 'beforeunload' , cacheCanvasFunc ) ;
102
-
103
- return ( ) => {
104
- window . removeEventListener ( 'beforeunload' , cacheCanvasFunc ) ;
105
- window . removeEventListener ( 'wvBackClickEvent' , cacheCanvasFunc ) ;
106
- if ( window . _windvane_backControl ) {
107
- window . _windvane_backControl = null ;
108
- }
109
- } ;
110
- } , [ cacheCanvasFunc ] ) ;
111
-
112
92
useEffect ( ( ) => {
113
93
if ( mounted && typeof init === 'function' ) {
114
94
const res = init ( ) ;
@@ -139,10 +119,9 @@ export const CacheCanvas = forwardRef((props: CacheCanvasProps, ref) => {
139
119
{
140
120
( typeof fallback === 'function' ) && ( < div
141
121
id = { `fallback-${ id } ` }
142
- style = { isNode || Storage . getItem ( cacheKey , { bizID } ) ? { display : 'none' } : { display : 'block' } }
143
122
>
144
123
{
145
- fallback ( )
124
+ ( isNode || ! Storage . getItem ( cacheKey , { bizID } ) ) && fallback ( )
146
125
}
147
126
</ div > )
148
127
}
@@ -175,9 +154,9 @@ export const CacheCanvas = forwardRef((props: CacheCanvasProps, ref) => {
175
154
if (base64Data) {
176
155
const img = document.getElementById('canvas-img-${ id } ');
177
156
img && (img.src = base64Data);
178
- fallback && ( fallback.style.display = 'none');
179
- } else {
180
- fallback && (fallback.style.display = 'block');
157
+ if ( fallback && fallback.childNodes[0]) {
158
+ fallback.removeChild(fallback.childNodes[0]);
159
+ }
181
160
}
182
161
` ,
183
162
} }
0 commit comments