Browse Source

bug fix: storage更新时更新无障碍主题色的逻辑

任一存 2 năm trước cách đây
mục cha
commit
67c945dbf8
1 tập tin đã thay đổi với 8 bổ sung2 xóa
  1. 8 2
      web/src/views/accessibilityMixin.js

+ 8 - 2
web/src/views/accessibilityMixin.js

@@ -14,17 +14,23 @@ export default {
       } else {
         this.themeIdx = idx
       }
+    },
+    updateColorThemeByStorage() {
+      const settings = localStorage.getItem('ariaSettings')
+      if (settings) {
+        this.themeIdx = JSON.parse(settings).themeIdx
+      }
     }
   },
   created() {
     this.updateColorTheme()
-    window.addEventListener('storage', this.updateColorTheme, {
+    window.addEventListener('storage', this.updateColorThemeByStorage, {
       passive: true,
     })
     this.$eventBus.$on('color-modification', this.updateColorTheme)
   },
   destroyed() {
-    window.removeEventListener('storage', this.updateColorTheme, {
+    window.removeEventListener('storage', this.updateColorThemeByStorage, {
       passive: true,
     })
     this.$eventBus.$off('color-modification', this.updateColorTheme)