mirror of
https://github.com/misskey-dev/misskey.git
synced 2024-12-24 00:39:32 +09:00
refactor(client): refactor settings/theme to use Composition API (#8595)
This commit is contained in:
parent
0e26fae3bb
commit
1f222e6cd1
@ -85,12 +85,11 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts" setup>
|
||||||
import { computed, defineComponent, onActivated, onMounted, ref, watch } from 'vue';
|
import { computed, onActivated, ref, watch } from 'vue';
|
||||||
import JSON5 from 'json5';
|
import JSON5 from 'json5';
|
||||||
import FormSwitch from '@/components/form/switch.vue';
|
import FormSwitch from '@/components/form/switch.vue';
|
||||||
import FormSelect from '@/components/form/select.vue';
|
import FormSelect from '@/components/form/select.vue';
|
||||||
import FormGroup from '@/components/form/group.vue';
|
|
||||||
import FormSection from '@/components/form/section.vue';
|
import FormSection from '@/components/form/section.vue';
|
||||||
import FormLink from '@/components/form/link.vue';
|
import FormLink from '@/components/form/link.vue';
|
||||||
import FormButton from '@/components/ui/button.vue';
|
import FormButton from '@/components/ui/button.vue';
|
||||||
@ -101,33 +100,16 @@ import { ColdDeviceStorage } from '@/store';
|
|||||||
import { i18n } from '@/i18n';
|
import { i18n } from '@/i18n';
|
||||||
import { defaultStore } from '@/store';
|
import { defaultStore } from '@/store';
|
||||||
import { instance } from '@/instance';
|
import { instance } from '@/instance';
|
||||||
import { concat, uniqueBy } from '@/scripts/array';
|
import { uniqueBy } from '@/scripts/array';
|
||||||
import { fetchThemes, getThemes } from '@/theme-store';
|
import { fetchThemes, getThemes } from '@/theme-store';
|
||||||
import * as symbols from '@/symbols';
|
import * as symbols from '@/symbols';
|
||||||
|
|
||||||
export default defineComponent({
|
|
||||||
components: {
|
|
||||||
FormSwitch,
|
|
||||||
FormSelect,
|
|
||||||
FormGroup,
|
|
||||||
FormSection,
|
|
||||||
FormLink,
|
|
||||||
FormButton,
|
|
||||||
},
|
|
||||||
|
|
||||||
emits: ['info'],
|
|
||||||
|
|
||||||
setup(props, { emit }) {
|
|
||||||
const INFO = {
|
|
||||||
title: i18n.ts.theme,
|
|
||||||
icon: 'fas fa-palette',
|
|
||||||
bg: 'var(--bg)',
|
|
||||||
};
|
|
||||||
|
|
||||||
const installedThemes = ref(getThemes());
|
const installedThemes = ref(getThemes());
|
||||||
const instanceThemes = [];
|
const instanceThemes = [];
|
||||||
|
|
||||||
if (instance.defaultLightTheme != null) instanceThemes.push(JSON5.parse(instance.defaultLightTheme));
|
if (instance.defaultLightTheme != null) instanceThemes.push(JSON5.parse(instance.defaultLightTheme));
|
||||||
if (instance.defaultDarkTheme != null) instanceThemes.push(JSON5.parse(instance.defaultDarkTheme));
|
if (instance.defaultDarkTheme != null) instanceThemes.push(JSON5.parse(instance.defaultDarkTheme));
|
||||||
|
|
||||||
const themes = computed(() => uniqueBy(instanceThemes.concat(builtinThemes.concat(installedThemes.value)), theme => theme.id));
|
const themes = computed(() => uniqueBy(instanceThemes.concat(builtinThemes.concat(installedThemes.value)), theme => theme.id));
|
||||||
const darkThemes = computed(() => themes.value.filter(t => t.base === 'dark' || t.kind === 'dark'));
|
const darkThemes = computed(() => themes.value.filter(t => t.base === 'dark' || t.kind === 'dark'));
|
||||||
const lightThemes = computed(() => themes.value.filter(t => t.base === 'light' || t.kind === 'light'));
|
const lightThemes = computed(() => themes.value.filter(t => t.base === 'light' || t.kind === 'light'));
|
||||||
@ -179,22 +161,17 @@ export default defineComponent({
|
|||||||
installedThemes.value = getThemes();
|
installedThemes.value = getThemes();
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
function setWallpaper(event) {
|
||||||
[symbols.PAGE_INFO]: INFO,
|
selectFile(event.currentTarget ?? event.target, null).then(file => {
|
||||||
darkThemes,
|
|
||||||
lightThemes,
|
|
||||||
darkThemeId,
|
|
||||||
lightThemeId,
|
|
||||||
darkMode,
|
|
||||||
syncDeviceDarkMode,
|
|
||||||
themesCount,
|
|
||||||
wallpaper,
|
|
||||||
setWallpaper(e) {
|
|
||||||
selectFile(e.currentTarget ?? e.target, null).then(file => {
|
|
||||||
wallpaper.value = file.url;
|
wallpaper.value = file.url;
|
||||||
});
|
});
|
||||||
},
|
}
|
||||||
};
|
|
||||||
|
defineExpose({
|
||||||
|
[symbols.PAGE_INFO]: {
|
||||||
|
title: i18n.ts.theme,
|
||||||
|
icon: 'fas fa-palette',
|
||||||
|
bg: 'var(--bg)',
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
Reference in New Issue
Block a user