diff --git a/pages/API/theme-change/theme-change.test.js b/pages/API/theme-change/theme-change.test.js index 779e9ef4313b24220628060fe74adb2015108170..765ce63b3d0ef11fdbe3fc34e7c5be9756764284 100644 --- a/pages/API/theme-change/theme-change.test.js +++ b/pages/API/theme-change/theme-change.test.js @@ -20,11 +20,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 392d9173dd86dacc6f3fbc1c9731d35f769f6c00..253a7413cd68bc9807563f0fa9058da5250a40a8 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!) }