2020-01-29 21:37:25 +02:00
|
|
|
<template>
|
2021-11-28 13:07:37 +02:00
|
|
|
<div class="_formRoot">
|
2021-12-25 18:42:50 +02:00
|
|
|
<div v-adaptive-border class="rfqxtzch _panel _formBlock">
|
2021-11-28 13:07:37 +02:00
|
|
|
<div class="toggle">
|
|
|
|
<div class="toggleWrapper">
|
|
|
|
<input id="dn" v-model="darkMode" type="checkbox" class="dn"/>
|
|
|
|
<label for="dn" class="toggle">
|
|
|
|
<span class="before">{{ $ts.light }}</span>
|
|
|
|
<span class="after">{{ $ts.dark }}</span>
|
|
|
|
<span class="toggle__handler">
|
|
|
|
<span class="crater crater--1"></span>
|
|
|
|
<span class="crater crater--2"></span>
|
|
|
|
<span class="crater crater--3"></span>
|
|
|
|
</span>
|
|
|
|
<span class="star star--1"></span>
|
|
|
|
<span class="star star--2"></span>
|
|
|
|
<span class="star star--3"></span>
|
|
|
|
<span class="star star--4"></span>
|
|
|
|
<span class="star star--5"></span>
|
|
|
|
<span class="star star--6"></span>
|
|
|
|
</label>
|
2020-03-22 03:39:12 +02:00
|
|
|
</div>
|
2020-11-14 05:16:28 +02:00
|
|
|
</div>
|
2021-11-28 13:07:37 +02:00
|
|
|
<div class="sync">
|
|
|
|
<FormSwitch v-model="syncDeviceDarkMode">{{ $ts.syncDeviceDarkMode }}</FormSwitch>
|
|
|
|
</div>
|
|
|
|
</div>
|
2020-11-25 14:31:34 +02:00
|
|
|
|
2021-04-12 07:06:00 +03:00
|
|
|
<template v-if="darkMode">
|
2021-11-28 13:07:37 +02:00
|
|
|
<FormSelect v-model="darkThemeId" class="_formBlock">
|
2021-04-12 07:06:00 +03:00
|
|
|
<template #label>{{ $ts.themeForDarkMode }}</template>
|
2021-11-28 13:07:37 +02:00
|
|
|
<template #prefix><i class="fas fa-moon"></i></template>
|
2021-04-12 07:06:00 +03:00
|
|
|
<optgroup :label="$ts.darkThemes">
|
2021-11-19 12:36:12 +02:00
|
|
|
<option v-for="x in darkThemes" :key="x.id" :value="x.id">{{ x.name }}</option>
|
2021-04-12 07:06:00 +03:00
|
|
|
</optgroup>
|
|
|
|
<optgroup :label="$ts.lightThemes">
|
2021-11-19 12:36:12 +02:00
|
|
|
<option v-for="x in lightThemes" :key="x.id" :value="x.id">{{ x.name }}</option>
|
2021-04-12 07:06:00 +03:00
|
|
|
</optgroup>
|
|
|
|
</FormSelect>
|
2021-11-28 13:07:37 +02:00
|
|
|
<FormSelect v-model="lightThemeId" class="_formBlock">
|
2021-04-12 07:06:00 +03:00
|
|
|
<template #label>{{ $ts.themeForLightMode }}</template>
|
2021-11-28 13:07:37 +02:00
|
|
|
<template #prefix><i class="fas fa-sun"></i></template>
|
2021-04-12 07:06:00 +03:00
|
|
|
<optgroup :label="$ts.lightThemes">
|
2021-11-19 12:36:12 +02:00
|
|
|
<option v-for="x in lightThemes" :key="x.id" :value="x.id">{{ x.name }}</option>
|
2021-04-12 07:06:00 +03:00
|
|
|
</optgroup>
|
|
|
|
<optgroup :label="$ts.darkThemes">
|
2021-11-19 12:36:12 +02:00
|
|
|
<option v-for="x in darkThemes" :key="x.id" :value="x.id">{{ x.name }}</option>
|
2021-04-12 07:06:00 +03:00
|
|
|
</optgroup>
|
|
|
|
</FormSelect>
|
|
|
|
</template>
|
|
|
|
<template v-else>
|
2021-11-28 13:07:37 +02:00
|
|
|
<FormSelect v-model="lightThemeId" class="_formBlock">
|
2021-04-12 07:06:00 +03:00
|
|
|
<template #label>{{ $ts.themeForLightMode }}</template>
|
2021-11-28 13:07:37 +02:00
|
|
|
<template #prefix><i class="fas fa-sun"></i></template>
|
2021-04-12 07:06:00 +03:00
|
|
|
<optgroup :label="$ts.lightThemes">
|
2021-11-19 12:36:12 +02:00
|
|
|
<option v-for="x in lightThemes" :key="x.id" :value="x.id">{{ x.name }}</option>
|
2021-04-12 07:06:00 +03:00
|
|
|
</optgroup>
|
|
|
|
<optgroup :label="$ts.darkThemes">
|
2021-11-19 12:36:12 +02:00
|
|
|
<option v-for="x in darkThemes" :key="x.id" :value="x.id">{{ x.name }}</option>
|
2021-04-12 07:06:00 +03:00
|
|
|
</optgroup>
|
|
|
|
</FormSelect>
|
2021-11-28 13:07:37 +02:00
|
|
|
<FormSelect v-model="darkThemeId" class="_formBlock">
|
2021-04-12 07:06:00 +03:00
|
|
|
<template #label>{{ $ts.themeForDarkMode }}</template>
|
2021-11-28 13:07:37 +02:00
|
|
|
<template #prefix><i class="fas fa-moon"></i></template>
|
2021-04-12 07:06:00 +03:00
|
|
|
<optgroup :label="$ts.darkThemes">
|
2021-11-19 12:36:12 +02:00
|
|
|
<option v-for="x in darkThemes" :key="x.id" :value="x.id">{{ x.name }}</option>
|
2021-04-12 07:06:00 +03:00
|
|
|
</optgroup>
|
|
|
|
<optgroup :label="$ts.lightThemes">
|
2021-11-19 12:36:12 +02:00
|
|
|
<option v-for="x in lightThemes" :key="x.id" :value="x.id">{{ x.name }}</option>
|
2021-04-12 07:06:00 +03:00
|
|
|
</optgroup>
|
|
|
|
</FormSelect>
|
|
|
|
</template>
|
|
|
|
|
2021-11-28 13:07:37 +02:00
|
|
|
<FormSection>
|
|
|
|
<div class="_formLinksGrid">
|
|
|
|
<FormLink to="/settings/theme/manage"><template #icon><i class="fas fa-folder-open"></i></template>{{ $ts._theme.manage }}<template #suffix>{{ themesCount }}</template></FormLink>
|
|
|
|
<FormLink to="https://assets.misskey.io/theme/list" external><template #icon><i class="fas fa-globe"></i></template>{{ $ts._theme.explore }}</FormLink>
|
|
|
|
<FormLink to="/settings/theme/install"><template #icon><i class="fas fa-download"></i></template>{{ $ts._theme.install }}</FormLink>
|
|
|
|
<FormLink to="/theme-editor"><template #icon><i class="fas fa-paint-roller"></i></template>{{ $ts._theme.make }}</FormLink>
|
|
|
|
</div>
|
|
|
|
</FormSection>
|
2020-11-25 14:31:34 +02:00
|
|
|
|
2021-11-28 13:07:37 +02:00
|
|
|
<FormButton v-if="wallpaper == null" class="_formBlock" @click="setWallpaper">{{ $ts.setWallpaper }}</FormButton>
|
|
|
|
<FormButton v-else class="_formBlock" @click="wallpaper = null">{{ $ts.removeWallpaper }}</FormButton>
|
|
|
|
</div>
|
2020-01-29 21:37:25 +02:00
|
|
|
</template>
|
|
|
|
|
2022-05-03 14:34:48 +03:00
|
|
|
<script lang="ts" setup>
|
|
|
|
import { computed, onActivated, ref, watch } from 'vue';
|
2022-05-01 16:51:07 +03:00
|
|
|
import JSON5 from 'json5';
|
2021-11-28 13:07:37 +02:00
|
|
|
import FormSwitch from '@/components/form/switch.vue';
|
|
|
|
import FormSelect from '@/components/form/select.vue';
|
|
|
|
import FormSection from '@/components/form/section.vue';
|
|
|
|
import FormLink from '@/components/form/link.vue';
|
|
|
|
import FormButton from '@/components/ui/button.vue';
|
2022-05-28 15:59:23 +03:00
|
|
|
import { getBuiltinThemesRef } from '@/scripts/theme';
|
2021-11-11 19:02:25 +02:00
|
|
|
import { selectFile } from '@/scripts/select-file';
|
|
|
|
import { isDeviceDarkmode } from '@/scripts/is-device-darkmode';
|
|
|
|
import { ColdDeviceStorage } from '@/store';
|
|
|
|
import { i18n } from '@/i18n';
|
|
|
|
import { defaultStore } from '@/store';
|
2022-03-01 16:58:01 +02:00
|
|
|
import { instance } from '@/instance';
|
2022-05-03 14:34:48 +03:00
|
|
|
import { uniqueBy } from '@/scripts/array';
|
2021-11-11 19:02:25 +02:00
|
|
|
import { fetchThemes, getThemes } from '@/theme-store';
|
|
|
|
import * as symbols from '@/symbols';
|
2020-01-29 21:37:25 +02:00
|
|
|
|
2022-05-03 14:34:48 +03:00
|
|
|
const installedThemes = ref(getThemes());
|
2022-05-28 15:59:23 +03:00
|
|
|
const builtinThemes = getBuiltinThemesRef();
|
2022-05-03 14:34:48 +03:00
|
|
|
const instanceThemes = [];
|
|
|
|
|
|
|
|
if (instance.defaultLightTheme != null) instanceThemes.push(JSON5.parse(instance.defaultLightTheme));
|
|
|
|
if (instance.defaultDarkTheme != null) instanceThemes.push(JSON5.parse(instance.defaultDarkTheme));
|
|
|
|
|
2022-05-28 15:59:23 +03:00
|
|
|
const themes = computed(() => uniqueBy([ ...instanceThemes, ...builtinThemes.value, ...installedThemes.value ], theme => theme.id));
|
2022-05-03 14:34:48 +03:00
|
|
|
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 darkTheme = ColdDeviceStorage.ref('darkTheme');
|
|
|
|
const darkThemeId = computed({
|
|
|
|
get() {
|
|
|
|
return darkTheme.value.id;
|
|
|
|
},
|
|
|
|
set(id) {
|
2022-06-10 08:36:55 +03:00
|
|
|
ColdDeviceStorage.set('darkTheme', themes.value.find(x => x.id === id));
|
2022-05-03 14:34:48 +03:00
|
|
|
}
|
|
|
|
});
|
|
|
|
const lightTheme = ColdDeviceStorage.ref('lightTheme');
|
|
|
|
const lightThemeId = computed({
|
|
|
|
get() {
|
|
|
|
return lightTheme.value.id;
|
2020-01-29 21:37:25 +02:00
|
|
|
},
|
2022-05-03 14:34:48 +03:00
|
|
|
set(id) {
|
2022-06-10 08:36:55 +03:00
|
|
|
ColdDeviceStorage.set('lightTheme', themes.value.find(x => x.id === id));
|
2022-05-03 14:34:48 +03:00
|
|
|
}
|
|
|
|
});
|
|
|
|
const darkMode = computed(defaultStore.makeGetterSetter('darkMode'));
|
|
|
|
const syncDeviceDarkMode = computed(ColdDeviceStorage.makeGetterSetter('syncDeviceDarkMode'));
|
|
|
|
const wallpaper = ref(localStorage.getItem('wallpaper'));
|
|
|
|
const themesCount = installedThemes.value.length;
|
|
|
|
|
|
|
|
watch(syncDeviceDarkMode, () => {
|
|
|
|
if (syncDeviceDarkMode.value) {
|
|
|
|
defaultStore.set('darkMode', isDeviceDarkmode());
|
|
|
|
}
|
|
|
|
});
|
2020-10-17 14:12:00 +03:00
|
|
|
|
2022-05-03 14:34:48 +03:00
|
|
|
watch(wallpaper, () => {
|
|
|
|
if (wallpaper.value == null) {
|
|
|
|
localStorage.removeItem('wallpaper');
|
|
|
|
} else {
|
|
|
|
localStorage.setItem('wallpaper', wallpaper.value);
|
|
|
|
}
|
|
|
|
location.reload();
|
|
|
|
});
|
2020-03-22 03:57:58 +02:00
|
|
|
|
2022-05-03 14:34:48 +03:00
|
|
|
onActivated(() => {
|
|
|
|
fetchThemes().then(() => {
|
|
|
|
installedThemes.value = getThemes();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
fetchThemes().then(() => {
|
|
|
|
installedThemes.value = getThemes();
|
|
|
|
});
|
|
|
|
|
|
|
|
function setWallpaper(event) {
|
|
|
|
selectFile(event.currentTarget ?? event.target, null).then(file => {
|
|
|
|
wallpaper.value = file.url;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
defineExpose({
|
|
|
|
[symbols.PAGE_INFO]: {
|
|
|
|
title: i18n.ts.theme,
|
|
|
|
icon: 'fas fa-palette',
|
|
|
|
bg: 'var(--bg)',
|
2020-11-25 14:31:34 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
2020-03-23 12:06:46 +02:00
|
|
|
|
2020-11-25 14:31:34 +02:00
|
|
|
<style lang="scss" scoped>
|
|
|
|
.rfqxtzch {
|
2021-11-28 13:07:37 +02:00
|
|
|
border-radius: 6px;
|
2020-08-08 04:27:37 +03:00
|
|
|
|
2021-11-28 13:07:37 +02:00
|
|
|
> .toggle {
|
2020-11-25 14:31:34 +02:00
|
|
|
position: relative;
|
2021-11-28 13:07:37 +02:00
|
|
|
padding: 26px 0;
|
|
|
|
text-align: center;
|
2020-11-25 14:31:34 +02:00
|
|
|
|
|
|
|
&.disabled {
|
|
|
|
opacity: 0.7;
|
|
|
|
|
|
|
|
&, * {
|
|
|
|
cursor: not-allowed !important;
|
2020-03-23 12:06:46 +02:00
|
|
|
}
|
2020-11-25 14:31:34 +02:00
|
|
|
}
|
|
|
|
|
2021-11-28 13:07:37 +02:00
|
|
|
> .toggleWrapper {
|
|
|
|
display: inline-block;
|
|
|
|
text-align: left;
|
|
|
|
overflow: clip;
|
2020-11-25 14:31:34 +02:00
|
|
|
padding: 0 100px;
|
|
|
|
|
|
|
|
input {
|
|
|
|
position: absolute;
|
|
|
|
left: -99em;
|
2020-03-23 12:06:46 +02:00
|
|
|
}
|
2020-11-25 14:31:34 +02:00
|
|
|
}
|
2020-03-28 08:57:31 +02:00
|
|
|
|
2020-11-25 14:31:34 +02:00
|
|
|
.toggle {
|
|
|
|
cursor: pointer;
|
|
|
|
display: inline-block;
|
|
|
|
position: relative;
|
|
|
|
width: 90px;
|
|
|
|
height: 50px;
|
|
|
|
background-color: #83D8FF;
|
|
|
|
border-radius: 90px - 6;
|
|
|
|
transition: background-color 200ms cubic-bezier(0.445, 0.05, 0.55, 0.95) !important;
|
2020-03-28 08:57:31 +02:00
|
|
|
|
2020-11-25 14:31:34 +02:00
|
|
|
> .before, > .after {
|
|
|
|
position: absolute;
|
|
|
|
top: 15px;
|
|
|
|
transition: color 1s ease;
|
|
|
|
}
|
2020-03-28 08:57:31 +02:00
|
|
|
|
2020-11-25 14:31:34 +02:00
|
|
|
> .before {
|
|
|
|
left: -70px;
|
|
|
|
color: var(--accent);
|
|
|
|
}
|
2020-03-23 12:06:46 +02:00
|
|
|
|
2020-11-25 14:31:34 +02:00
|
|
|
> .after {
|
|
|
|
right: -68px;
|
|
|
|
color: var(--fg);
|
|
|
|
}
|
|
|
|
}
|
2020-03-22 03:39:12 +02:00
|
|
|
|
2020-11-25 14:31:34 +02:00
|
|
|
.toggle__handler {
|
|
|
|
display: inline-block;
|
2020-03-22 03:39:12 +02:00
|
|
|
position: relative;
|
2020-11-25 14:31:34 +02:00
|
|
|
z-index: 1;
|
|
|
|
top: 3px;
|
|
|
|
left: 3px;
|
|
|
|
width: 50px - 6;
|
|
|
|
height: 50px - 6;
|
|
|
|
background-color: #FFCF96;
|
|
|
|
border-radius: 50px;
|
|
|
|
box-shadow: 0 2px 6px rgba(0,0,0,.3);
|
|
|
|
transition: all 400ms cubic-bezier(0.68, -0.55, 0.265, 1.55) !important;
|
|
|
|
transform: rotate(-45deg);
|
|
|
|
|
|
|
|
.crater {
|
|
|
|
position: absolute;
|
|
|
|
background-color: #E8CDA5;
|
|
|
|
opacity: 0;
|
|
|
|
transition: opacity 200ms ease-in-out !important;
|
|
|
|
border-radius: 100%;
|
|
|
|
}
|
2020-03-22 03:39:12 +02:00
|
|
|
|
2020-11-25 14:31:34 +02:00
|
|
|
.crater--1 {
|
|
|
|
top: 18px;
|
|
|
|
left: 10px;
|
|
|
|
width: 4px;
|
|
|
|
height: 4px;
|
|
|
|
}
|
2020-03-22 03:39:12 +02:00
|
|
|
|
2020-11-25 14:31:34 +02:00
|
|
|
.crater--2 {
|
|
|
|
top: 28px;
|
|
|
|
left: 22px;
|
|
|
|
width: 6px;
|
|
|
|
height: 6px;
|
2020-03-22 03:39:12 +02:00
|
|
|
}
|
|
|
|
|
2020-11-25 14:31:34 +02:00
|
|
|
.crater--3 {
|
|
|
|
top: 10px;
|
|
|
|
left: 25px;
|
|
|
|
width: 8px;
|
|
|
|
height: 8px;
|
2020-03-22 03:39:12 +02:00
|
|
|
}
|
2020-11-25 14:31:34 +02:00
|
|
|
}
|
2020-03-22 03:39:12 +02:00
|
|
|
|
2020-11-25 14:31:34 +02:00
|
|
|
.star {
|
|
|
|
position: absolute;
|
|
|
|
background-color: #ffffff;
|
|
|
|
transition: all 300ms cubic-bezier(0.445, 0.05, 0.55, 0.95) !important;
|
|
|
|
border-radius: 50%;
|
|
|
|
}
|
|
|
|
|
|
|
|
.star--1 {
|
|
|
|
top: 10px;
|
|
|
|
left: 35px;
|
|
|
|
z-index: 0;
|
|
|
|
width: 30px;
|
|
|
|
height: 3px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.star--2 {
|
|
|
|
top: 18px;
|
|
|
|
left: 28px;
|
|
|
|
z-index: 1;
|
|
|
|
width: 30px;
|
|
|
|
height: 3px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.star--3 {
|
|
|
|
top: 27px;
|
|
|
|
left: 40px;
|
|
|
|
z-index: 0;
|
|
|
|
width: 30px;
|
|
|
|
height: 3px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.star--4,
|
|
|
|
.star--5,
|
|
|
|
.star--6 {
|
|
|
|
opacity: 0;
|
|
|
|
transition: all 300ms 0 cubic-bezier(0.445, 0.05, 0.55, 0.95) !important;
|
|
|
|
}
|
|
|
|
|
|
|
|
.star--4 {
|
|
|
|
top: 16px;
|
|
|
|
left: 11px;
|
|
|
|
z-index: 0;
|
|
|
|
width: 2px;
|
|
|
|
height: 2px;
|
|
|
|
transform: translate3d(3px,0,0);
|
|
|
|
}
|
|
|
|
|
|
|
|
.star--5 {
|
|
|
|
top: 32px;
|
|
|
|
left: 17px;
|
|
|
|
z-index: 0;
|
|
|
|
width: 3px;
|
|
|
|
height: 3px;
|
|
|
|
transform: translate3d(3px,0,0);
|
|
|
|
}
|
|
|
|
|
|
|
|
.star--6 {
|
|
|
|
top: 36px;
|
|
|
|
left: 28px;
|
|
|
|
z-index: 0;
|
|
|
|
width: 2px;
|
|
|
|
height: 2px;
|
|
|
|
transform: translate3d(3px,0,0);
|
|
|
|
}
|
|
|
|
|
|
|
|
input:checked {
|
|
|
|
+ .toggle {
|
|
|
|
background-color: #749DD6;
|
2020-03-22 03:39:12 +02:00
|
|
|
|
|
|
|
> .before {
|
2020-11-25 14:31:34 +02:00
|
|
|
color: var(--fg);
|
2020-03-22 03:39:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
> .after {
|
2020-11-25 14:31:34 +02:00
|
|
|
color: var(--accent);
|
|
|
|
}
|
|
|
|
|
|
|
|
.toggle__handler {
|
|
|
|
background-color: #FFE5B5;
|
|
|
|
transform: translate3d(40px, 0, 0) rotate(0);
|
|
|
|
|
|
|
|
.crater { opacity: 1; }
|
2020-03-22 03:39:12 +02:00
|
|
|
}
|
|
|
|
|
2020-11-25 14:31:34 +02:00
|
|
|
.star--1 {
|
|
|
|
width: 2px;
|
|
|
|
height: 2px;
|
2020-03-22 03:39:12 +02:00
|
|
|
}
|
|
|
|
|
2020-11-25 14:31:34 +02:00
|
|
|
.star--2 {
|
2020-03-22 03:39:12 +02:00
|
|
|
width: 4px;
|
|
|
|
height: 4px;
|
2020-11-25 14:31:34 +02:00
|
|
|
transform: translate3d(-5px, 0, 0);
|
2020-03-22 03:39:12 +02:00
|
|
|
}
|
|
|
|
|
2020-11-25 14:31:34 +02:00
|
|
|
.star--3 {
|
|
|
|
width: 2px;
|
|
|
|
height: 2px;
|
|
|
|
transform: translate3d(-7px, 0, 0);
|
2020-03-22 03:39:12 +02:00
|
|
|
}
|
|
|
|
|
2020-11-25 14:31:34 +02:00
|
|
|
.star--4,
|
|
|
|
.star--5,
|
|
|
|
.star--6 {
|
|
|
|
opacity: 1;
|
|
|
|
transform: translate3d(0,0,0);
|
2020-03-22 03:39:12 +02:00
|
|
|
}
|
|
|
|
|
2020-11-25 14:31:34 +02:00
|
|
|
.star--4 {
|
|
|
|
transition: all 300ms 200ms cubic-bezier(0.445, 0.05, 0.55, 0.95) !important;
|
|
|
|
}
|
2020-03-22 03:39:12 +02:00
|
|
|
|
2020-11-25 14:31:34 +02:00
|
|
|
.star--5 {
|
|
|
|
transition: all 300ms 300ms cubic-bezier(0.445, 0.05, 0.55, 0.95) !important;
|
|
|
|
}
|
2020-03-22 03:39:12 +02:00
|
|
|
|
2020-11-25 14:31:34 +02:00
|
|
|
.star--6 {
|
|
|
|
transition: all 300ms 400ms cubic-bezier(0.445, 0.05, 0.55, 0.95) !important;
|
2020-03-22 03:39:12 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-11-28 13:07:37 +02:00
|
|
|
|
|
|
|
> .sync {
|
|
|
|
padding: 14px 16px;
|
|
|
|
border-top: solid 0.5px var(--divider);
|
|
|
|
}
|
2020-03-22 03:39:12 +02:00
|
|
|
}
|
|
|
|
</style>
|