diff --git a/pages/API/theme-change/theme-change.test.js b/pages/API/theme-change/theme-change.test.js index f9c7245532af4aae3afaa124f107b236ceacc1ec..150e8d44f2dd3f571879332ad1afcc7bb1a74577 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 04de30cd65421546ea1c09a79794308e4a269b3d..acdc7e21433398d8186dbbd59efbc7d66419ccbe 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!) }