From 49d82959e70f1f42e846f789dda6b026a4a6a814 Mon Sep 17 00:00:00 2001 From: shutao Date: Tue, 2 Jul 2024 18:38:07 +0800 Subject: [PATCH] =?UTF-8?q?update=20theme-change.uvue=20=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E5=8E=9F=E5=A7=8B=E4=B8=BB=E9=A2=98=E7=94=A8=E4=BA=8E=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E8=BF=98=E5=8E=9F=E4=B8=BB=E9=A2=98=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/API/theme-change/theme-change.test.js | 4 +++- pages/API/theme-change/theme-change.uvue | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/pages/API/theme-change/theme-change.test.js b/pages/API/theme-change/theme-change.test.js index f9c72455..150e8d44 100644 --- a/pages/API/theme-change/theme-change.test.js +++ b/pages/API/theme-change/theme-change.test.js @@ -27,11 +27,13 @@ describe('API-theme-change', () => { it("check-set-app-theme", async () => { + const originalTheme = await page.data('originalTheme') + console.log("originalTheme是", originalTheme) await page.callMethod('setAppTheme', "dark") await page.waitFor(300) expect(await page.data('appTheme')).toBe("dark") //还原主题为light - await page.callMethod('setAppTheme', "light") + await page.callMethod('setAppTheme', originalTheme) await page.waitFor(600) }) }); diff --git a/pages/API/theme-change/theme-change.uvue b/pages/API/theme-change/theme-change.uvue index 04de30cd..acdc7e21 100644 --- a/pages/API/theme-change/theme-change.uvue +++ b/pages/API/theme-change/theme-change.uvue @@ -35,6 +35,7 @@ appThemeChangeId: 0, osTheme: "light" as string, appTheme: "light" as string, + originalTheme: "light" as string, current: 0, items: [ "light", @@ -80,6 +81,7 @@ uni.getSystemInfo({ success: (res:GetSystemInfoResult) => { this.osTheme = res.osTheme! + this.originalTheme = res.appTheme! this.appTheme = res.appTheme == "auto" ? res.osTheme! : res.appTheme! this.current = this.items.indexOf(res.appTheme!) } -- GitLab