Skip to content

Commit

Permalink
chore: store debug parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
imzbf committed Mar 1, 2023
1 parent bfab8a1 commit f805d6e
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions dev/App.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { defineComponent, ref } from 'vue';
import { defineComponent, ref, watch } from 'vue';
import Header from './Header';
import Preview from './Preview';
import PreviewOnly from './PreviewOnly';
Expand All @@ -11,10 +11,17 @@ export type Theme = 'dark' | 'light';

export default defineComponent({
setup() {
const theme = ref<Theme>('light');
const previewTheme = ref<string>('default');
const codeTheme = ref<string>('atom');
const lang = ref<string>('zh-CN');
const theme = ref<Theme>((localStorage.getItem('theme') as Theme) || 'light');
const previewTheme = ref<string>(localStorage.getItem('previewTheme') || 'default');
const codeTheme = ref<string>(localStorage.getItem('codeTheme') || 'atom');
const lang = ref<string>(localStorage.getItem('lang') || 'zh-CN');

watch([theme, previewTheme, codeTheme, lang], () => {
localStorage.setItem('theme', theme.value);
localStorage.setItem('previewTheme', previewTheme.value);
localStorage.setItem('codeTheme', codeTheme.value);
localStorage.setItem('lang', lang.value);
});

return () => (
<div class={['app', theme.value === 'dark' && 'theme-dark']}>
Expand Down

0 comments on commit f805d6e

Please sign in to comment.