From daf44a7523c8fec9c5a00fecd88ba1d1f009fa89 Mon Sep 17 00:00:00 2001 From: piaoyidage Date: Sun, 30 Oct 2022 10:06:08 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96zoom=E9=87=8D=E5=A4=8D?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src-tauri/src/pake.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src-tauri/src/pake.js b/src-tauri/src/pake.js index c2132f3..b0834ff 100644 --- a/src-tauri/src/pake.js +++ b/src-tauri/src/pake.js @@ -113,18 +113,18 @@ function setDefaultZoom() { } } +function zoomCommon(callback) { + const htmlZoom = window.localStorage.getItem('htmlZoom') || '100%'; + const html = document.getElementsByTagName('html')[0]; + const zoom = callback(htmlZoom); + html.style.zoom = zoom; + window.localStorage.setItem('htmlZoom', zoom); +} + function zoomIn() { - const htmlZoom = window.localStorage.getItem('htmlZoom') || '100%'; - const html = document.getElementsByTagName('html')[0]; - const zoom = parseInt(htmlZoom) < 200 ? (parseInt(htmlZoom) + 10 +'%') : '200%'; - html.style.zoom = zoom; - window.localStorage.setItem('htmlZoom', zoom); + zoomCommon(htmlZoom => parseInt(htmlZoom) < 200 ? (parseInt(htmlZoom) + 10 +'%') : '200%'); } function zoomOut() { - const htmlZoom = window.localStorage.getItem('htmlZoom') || '100%'; - const html = document.getElementsByTagName('html')[0]; - const zoom = parseInt(htmlZoom) > 30 ? (parseInt(htmlZoom) - 10 +'%') : '30%'; - html.style.zoom = zoom; - window.localStorage.setItem('htmlZoom', zoom); -} \ No newline at end of file + zoomCommon(htmlZoom => parseInt(htmlZoom) > 30 ? (parseInt(htmlZoom) - 10 +'%') : '30%'); +}