@@ -159,16 +159,24 @@ export default class WebView {
159159 this . show ( ) ;
160160 }
161161
162+ restoreZoomLevel ( ) : void {
163+ const savedZoom = this . getSavedZoomLevel ( ) ;
164+ this . getWebContents ( ) . zoomLevel = savedZoom ;
165+ }
166+
162167 zoomIn ( ) : void {
163168 this . getWebContents ( ) . zoomLevel += 0.5 ;
169+ this . saveZoomLevel ( this . getWebContents ( ) . zoomLevel ) ;
164170 }
165171
166172 zoomOut ( ) : void {
167173 this . getWebContents ( ) . zoomLevel -= 0.5 ;
174+ this . saveZoomLevel ( this . getWebContents ( ) . zoomLevel ) ;
168175 }
169176
170177 zoomActualSize ( ) : void {
171178 this . getWebContents ( ) . zoomLevel = 0 ;
179+ this . saveZoomLevel ( 0 ) ;
172180 }
173181
174182 logOut ( ) : void {
@@ -229,6 +237,32 @@ export default class WebView {
229237 ipcRenderer . send ( "forward-to" , this . webContentsId , channel , ...arguments_ ) ;
230238 }
231239
240+ private getZoomStorageKey ( ) : string {
241+ // Use single device-wide zoom level
242+ return "zoom_level" ;
243+ }
244+
245+ private getSavedZoomLevel ( ) : number {
246+ try {
247+ const key = this . getZoomStorageKey ( ) ;
248+ const saved = localStorage . getItem ( key ) ;
249+ if ( ! saved ) return 0 ;
250+ const parsed = Number ( saved ) ;
251+ return Number . isNaN ( parsed ) ? 0 : parsed ;
252+ } catch {
253+ return 0 ;
254+ }
255+ }
256+
257+ private saveZoomLevel ( level : number ) : void {
258+ try {
259+ const key = this . getZoomStorageKey ( ) ;
260+ localStorage . setItem ( key , String ( level ) ) ;
261+ } catch ( error ) {
262+ console . error ( "Failed to save zoom level to localStorage:" , error ) ;
263+ }
264+ }
265+
232266 private registerListeners ( ) : void {
233267 const webContents = this . getWebContents ( ) ;
234268
@@ -269,6 +303,7 @@ export default class WebView {
269303 this . $webview . addEventListener ( "dom-ready" , ( ) => {
270304 this . loading = false ;
271305 this . properties . switchLoading ( false , this . properties . url ) ;
306+ this . restoreZoomLevel ( ) ;
272307 this . show ( ) ;
273308 } ) ;
274309
0 commit comments