优化主题在页面刷新后重置的问题
This commit is contained in:
@@ -12,6 +12,8 @@
|
||||
<settings />
|
||||
</right-panel>
|
||||
</div>
|
||||
<!-- 防止刷新后主题丢失 -->
|
||||
<Theme v-show="false" ref="theme" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -20,7 +22,8 @@ import RightPanel from '@/components/RightPanel'
|
||||
import { AppMain, Navbar, Settings, Sidebar, TagsView } from './components'
|
||||
import ResizeMixin from './mixin/ResizeHandler'
|
||||
import { mapState } from 'vuex'
|
||||
|
||||
import Theme from '@/components/ThemePicker'
|
||||
import Cookies from 'js-cookie'
|
||||
export default {
|
||||
name: 'Layout',
|
||||
components: {
|
||||
@@ -29,7 +32,8 @@ export default {
|
||||
RightPanel,
|
||||
Settings,
|
||||
Sidebar,
|
||||
TagsView
|
||||
TagsView,
|
||||
Theme
|
||||
},
|
||||
mixins: [ResizeMixin],
|
||||
computed: {
|
||||
@@ -49,6 +53,15 @@ export default {
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
if (Cookies.get('theme')) {
|
||||
this.$refs.theme.theme = Cookies.get('theme')
|
||||
this.$store.dispatch('settings/changeSetting', {
|
||||
key: 'theme',
|
||||
value: Cookies.get('theme')
|
||||
})
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
handleClickOutside() {
|
||||
this.$store.dispatch('app/closeSideBar', { withoutAnimation: false })
|
||||
|
||||
Reference in New Issue
Block a user