2020-01-29 19:37:25 +00:00
|
|
|
<template>
|
2020-11-25 12:31:34 +00:00
|
|
|
<FormBase>
|
|
|
|
<FormSelect v-model:value="lightTheme" v-if="!darkMode">
|
2020-12-26 01:47:36 +00:00
|
|
|
<template #label>{{ $ts.themeForLightMode }}</template>
|
|
|
|
<optgroup :label="$ts.lightThemes">
|
2020-11-25 12:31:34 +00:00
|
|
|
<option v-for="x in lightThemes" :value="x.id" :key="x.id">{{ x.name }}</option>
|
|
|
|
</optgroup>
|
2020-12-26 01:47:36 +00:00
|
|
|
<optgroup :label="$ts.darkThemes">
|
2020-11-25 12:31:34 +00:00
|
|
|
<option v-for="x in darkThemes" :value="x.id" :key="x.id">{{ x.name }}</option>
|
|
|
|
</optgroup>
|
|
|
|
</FormSelect>
|
|
|
|
<FormSelect v-model:value="darkTheme" v-else>
|
2020-12-26 01:47:36 +00:00
|
|
|
<template #label>{{ $ts.themeForDarkMode }}</template>
|
|
|
|
<optgroup :label="$ts.darkThemes">
|
2020-11-25 12:31:34 +00:00
|
|
|
<option v-for="x in darkThemes" :value="x.id" :key="x.id">{{ x.name }}</option>
|
|
|
|
</optgroup>
|
2020-12-26 01:47:36 +00:00
|
|
|
<optgroup :label="$ts.lightThemes">
|
2020-11-25 12:31:34 +00:00
|
|
|
<option v-for="x in lightThemes" :value="x.id" :key="x.id">{{ x.name }}</option>
|
|
|
|
</optgroup>
|
|
|
|
</FormSelect>
|
|
|
|
|
|
|
|
<FormGroup>
|
|
|
|
<div class="rfqxtzch _formItem _formPanel">
|
2020-12-28 08:00:31 +00:00
|
|
|
<div class="darkMode">
|
2020-10-17 11:12:00 +00:00
|
|
|
<div class="toggleWrapper">
|
2020-12-28 08:00:31 +00:00
|
|
|
<input type="checkbox" class="dn" id="dn" v-model="darkMode"/>
|
2020-10-17 11:12:00 +00:00
|
|
|
<label for="dn" class="toggle">
|
2020-12-26 01:47:36 +00:00
|
|
|
<span class="before">{{ $ts.light }}</span>
|
|
|
|
<span class="after">{{ $ts.dark }}</span>
|
2020-10-17 11:12:00 +00:00
|
|
|
<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>
|
|
|
|
</div>
|
2020-03-22 01:39:12 +00:00
|
|
|
</div>
|
2020-11-14 03:16:28 +00:00
|
|
|
</div>
|
2020-12-26 01:47:36 +00:00
|
|
|
<FormSwitch v-model:value="syncDeviceDarkMode">{{ $ts.syncDeviceDarkMode }}</FormSwitch>
|
2020-11-25 12:31:34 +00:00
|
|
|
</FormGroup>
|
|
|
|
|
2020-12-26 01:47:36 +00:00
|
|
|
<FormButton primary v-if="wallpaper == null" @click="setWallpaper">{{ $ts.setWallpaper }}</FormButton>
|
|
|
|
<FormButton primary v-else @click="wallpaper = null">{{ $ts.removeWallpaper }}</FormButton>
|
2020-11-25 12:31:34 +00:00
|
|
|
|
|
|
|
<FormGroup>
|
2021-01-09 08:18:45 +00:00
|
|
|
<FormLink to="https://assets.msky.cafe/theme/list" external><template #icon><Fa :icon="faGlobe"/></template>{{ $ts._theme.explore }}</FormLink>
|
|
|
|
<FormLink to="/settings/theme/install"><template #icon><Fa :icon="faDownload"/></template>{{ $ts._theme.install }}</FormLink>
|
2020-11-25 12:31:34 +00:00
|
|
|
</FormGroup>
|
|
|
|
|
2021-01-09 08:18:45 +00:00
|
|
|
<FormGroup>
|
|
|
|
<FormLink to="/theme-editor"><template #icon><Fa :icon="faPaintRoller"/></template>{{ $ts._theme.make }}</FormLink>
|
|
|
|
<FormLink to="/advanced-theme-editor"><template #icon><Fa :icon="faPaintRoller"/></template>{{ $ts._theme.make }} ({{ $ts.advanced }})</FormLink>
|
|
|
|
</FormGroup>
|
2020-11-25 12:31:34 +00:00
|
|
|
|
2021-02-07 09:11:56 +00:00
|
|
|
<FormLink to="/settings/theme/manage"><template #icon><Fa :icon="faFolderOpen"/></template>{{ $ts._theme.manage }}<template #suffix>{{ themesCount }}</template></FormLink>
|
2020-11-25 12:31:34 +00:00
|
|
|
</FormBase>
|
2020-01-29 19:37:25 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2020-12-19 01:55:52 +00:00
|
|
|
import { computed, defineComponent, onMounted, ref, watch } from 'vue';
|
2021-01-09 08:18:45 +00:00
|
|
|
import { faPalette, faDownload, faFolderOpen, faCheck, faTrashAlt, faEye, faGlobe, faPaintRoller } from '@fortawesome/free-solid-svg-icons';
|
2021-03-23 08:30:14 +00:00
|
|
|
import FormSwitch from '@client/components/form/switch.vue';
|
|
|
|
import FormSelect from '@client/components/form/select.vue';
|
|
|
|
import FormBase from '@client/components/form/base.vue';
|
|
|
|
import FormGroup from '@client/components/form/group.vue';
|
|
|
|
import FormLink from '@client/components/form/link.vue';
|
|
|
|
import FormButton from '@client/components/form/button.vue';
|
|
|
|
import { builtinThemes, applyTheme } from '@client/scripts/theme';
|
|
|
|
import { selectFile } from '@client/scripts/select-file';
|
|
|
|
import { isDeviceDarkmode } from '@client/scripts/is-device-darkmode';
|
|
|
|
import { ColdDeviceStorage } from '@client/store';
|
|
|
|
import { i18n } from '@client/i18n';
|
|
|
|
import { defaultStore } from '@client/store';
|
|
|
|
import { fetchThemes, getThemes } from '@client/theme-store';
|
2020-01-29 19:37:25 +00:00
|
|
|
|
2020-10-17 11:12:00 +00:00
|
|
|
export default defineComponent({
|
2020-01-29 19:37:25 +00:00
|
|
|
components: {
|
2020-11-25 12:31:34 +00:00
|
|
|
FormSwitch,
|
|
|
|
FormSelect,
|
|
|
|
FormBase,
|
|
|
|
FormGroup,
|
|
|
|
FormLink,
|
|
|
|
FormButton,
|
2020-01-29 19:37:25 +00:00
|
|
|
},
|
2020-10-17 11:12:00 +00:00
|
|
|
|
|
|
|
emits: ['info'],
|
2020-01-29 19:37:25 +00:00
|
|
|
|
2020-12-19 01:55:52 +00:00
|
|
|
setup(props, { emit }) {
|
|
|
|
const INFO = {
|
2020-12-26 01:51:00 +00:00
|
|
|
title: i18n.locale.theme,
|
2020-12-19 01:55:52 +00:00
|
|
|
icon: faPalette
|
|
|
|
};
|
|
|
|
|
2021-01-11 13:31:17 +00:00
|
|
|
const installedThemes = ref(getThemes());
|
2020-12-19 01:55:52 +00:00
|
|
|
const themes = computed(() => builtinThemes.concat(installedThemes.value));
|
|
|
|
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 = computed(ColdDeviceStorage.makeGetterSetter('darkTheme'));
|
|
|
|
const lightTheme = computed(ColdDeviceStorage.makeGetterSetter('lightTheme'));
|
2020-12-28 08:00:31 +00:00
|
|
|
const darkMode = computed(defaultStore.makeGetterSetter('darkMode'));
|
2020-12-19 01:55:52 +00:00
|
|
|
const syncDeviceDarkMode = computed(ColdDeviceStorage.makeGetterSetter('syncDeviceDarkMode'));
|
|
|
|
const wallpaper = ref(localStorage.getItem('wallpaper'));
|
2021-02-07 09:11:56 +00:00
|
|
|
const themesCount = installedThemes.value.length;
|
2020-12-19 01:55:52 +00:00
|
|
|
|
|
|
|
watch(darkTheme, () => {
|
|
|
|
if (defaultStore.state.darkMode) {
|
|
|
|
applyTheme(themes.value.find(x => x.id === darkTheme.value));
|
2020-03-22 01:39:12 +00:00
|
|
|
}
|
2020-12-19 01:55:52 +00:00
|
|
|
});
|
2020-03-22 01:39:12 +00:00
|
|
|
|
2020-12-19 01:55:52 +00:00
|
|
|
watch(lightTheme, () => {
|
|
|
|
if (!defaultStore.state.darkMode) {
|
|
|
|
applyTheme(themes.value.find(x => x.id === lightTheme.value));
|
2020-03-22 01:39:12 +00:00
|
|
|
}
|
2020-12-19 01:55:52 +00:00
|
|
|
});
|
2020-02-16 18:10:51 +00:00
|
|
|
|
2020-12-19 01:55:52 +00:00
|
|
|
watch(syncDeviceDarkMode, () => {
|
|
|
|
if (syncDeviceDarkMode) {
|
|
|
|
defaultStore.set('darkMode', isDeviceDarkmode());
|
2020-03-22 01:57:58 +00:00
|
|
|
}
|
2020-12-19 01:55:52 +00:00
|
|
|
});
|
2020-03-22 01:57:58 +00:00
|
|
|
|
2020-12-19 01:55:52 +00:00
|
|
|
watch(wallpaper, () => {
|
|
|
|
if (wallpaper.value == null) {
|
2020-02-16 18:10:51 +00:00
|
|
|
localStorage.removeItem('wallpaper');
|
|
|
|
} else {
|
2020-12-19 01:55:52 +00:00
|
|
|
localStorage.setItem('wallpaper', wallpaper.value);
|
2020-02-16 18:10:51 +00:00
|
|
|
}
|
|
|
|
location.reload();
|
2020-12-19 01:55:52 +00:00
|
|
|
});
|
2020-01-29 19:37:25 +00:00
|
|
|
|
2020-12-19 01:55:52 +00:00
|
|
|
onMounted(() => {
|
|
|
|
emit('info', INFO);
|
|
|
|
});
|
2020-10-17 11:12:00 +00:00
|
|
|
|
2021-01-11 13:31:17 +00:00
|
|
|
fetchThemes().then(() => {
|
|
|
|
installedThemes.value = getThemes();
|
|
|
|
});
|
|
|
|
|
2020-12-19 01:55:52 +00:00
|
|
|
return {
|
|
|
|
INFO,
|
|
|
|
darkThemes,
|
|
|
|
lightThemes,
|
|
|
|
darkTheme,
|
|
|
|
lightTheme,
|
|
|
|
darkMode,
|
|
|
|
syncDeviceDarkMode,
|
2021-02-07 09:11:56 +00:00
|
|
|
themesCount,
|
2020-12-19 01:55:52 +00:00
|
|
|
wallpaper,
|
|
|
|
setWallpaper(e) {
|
|
|
|
selectFile(e.currentTarget || e.target, null, false).then(file => {
|
|
|
|
wallpaper.value = file.url;
|
|
|
|
});
|
|
|
|
},
|
2021-01-09 08:18:45 +00:00
|
|
|
faPalette, faDownload, faFolderOpen, faCheck, faTrashAlt, faEye, faGlobe, faPaintRoller,
|
2020-12-19 01:55:52 +00:00
|
|
|
};
|
2020-11-25 12:31:34 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
2020-03-23 10:06:46 +00:00
|
|
|
|
2020-11-25 12:31:34 +00:00
|
|
|
<style lang="scss" scoped>
|
|
|
|
.rfqxtzch {
|
|
|
|
padding: 16px;
|
2020-08-08 01:27:37 +00:00
|
|
|
|
2020-11-25 12:31:34 +00:00
|
|
|
> .darkMode {
|
|
|
|
position: relative;
|
|
|
|
padding: 32px 0;
|
|
|
|
|
|
|
|
&.disabled {
|
|
|
|
opacity: 0.7;
|
|
|
|
|
|
|
|
&, * {
|
|
|
|
cursor: not-allowed !important;
|
2020-03-23 10:06:46 +00:00
|
|
|
}
|
2020-11-25 12:31:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.toggleWrapper {
|
|
|
|
position: absolute;
|
|
|
|
top: 50%;
|
|
|
|
left: 50%;
|
2021-03-02 13:57:16 +00:00
|
|
|
overflow: hidden;
|
2020-11-25 12:31:34 +00:00
|
|
|
padding: 0 100px;
|
|
|
|
transform: translate3d(-50%, -50%, 0);
|
|
|
|
|
|
|
|
input {
|
|
|
|
position: absolute;
|
|
|
|
left: -99em;
|
2020-03-23 10:06:46 +00:00
|
|
|
}
|
2020-11-25 12:31:34 +00:00
|
|
|
}
|
2020-03-28 06:57:31 +00:00
|
|
|
|
2020-11-25 12:31:34 +00: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 06:57:31 +00:00
|
|
|
|
2020-11-25 12:31:34 +00:00
|
|
|
> .before, > .after {
|
|
|
|
position: absolute;
|
|
|
|
top: 15px;
|
|
|
|
font-size: 18px;
|
|
|
|
transition: color 1s ease;
|
|
|
|
}
|
2020-03-28 06:57:31 +00:00
|
|
|
|
2020-11-25 12:31:34 +00:00
|
|
|
> .before {
|
|
|
|
left: -70px;
|
|
|
|
color: var(--accent);
|
|
|
|
}
|
2020-03-23 10:06:46 +00:00
|
|
|
|
2020-11-25 12:31:34 +00:00
|
|
|
> .after {
|
|
|
|
right: -68px;
|
|
|
|
color: var(--fg);
|
|
|
|
}
|
|
|
|
}
|
2020-03-22 01:39:12 +00:00
|
|
|
|
2020-11-25 12:31:34 +00:00
|
|
|
.toggle__handler {
|
|
|
|
display: inline-block;
|
2020-03-22 01:39:12 +00:00
|
|
|
position: relative;
|
2020-11-25 12:31:34 +00: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 01:39:12 +00:00
|
|
|
|
2020-11-25 12:31:34 +00:00
|
|
|
.crater--1 {
|
|
|
|
top: 18px;
|
|
|
|
left: 10px;
|
|
|
|
width: 4px;
|
|
|
|
height: 4px;
|
|
|
|
}
|
2020-03-22 01:39:12 +00:00
|
|
|
|
2020-11-25 12:31:34 +00:00
|
|
|
.crater--2 {
|
|
|
|
top: 28px;
|
|
|
|
left: 22px;
|
|
|
|
width: 6px;
|
|
|
|
height: 6px;
|
2020-03-22 01:39:12 +00:00
|
|
|
}
|
|
|
|
|
2020-11-25 12:31:34 +00:00
|
|
|
.crater--3 {
|
|
|
|
top: 10px;
|
|
|
|
left: 25px;
|
|
|
|
width: 8px;
|
|
|
|
height: 8px;
|
2020-03-22 01:39:12 +00:00
|
|
|
}
|
2020-11-25 12:31:34 +00:00
|
|
|
}
|
2020-03-22 01:39:12 +00:00
|
|
|
|
2020-11-25 12:31:34 +00: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 01:39:12 +00:00
|
|
|
|
|
|
|
> .before {
|
2020-11-25 12:31:34 +00:00
|
|
|
color: var(--fg);
|
2020-03-22 01:39:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
> .after {
|
2020-11-25 12:31:34 +00:00
|
|
|
color: var(--accent);
|
|
|
|
}
|
|
|
|
|
|
|
|
.toggle__handler {
|
|
|
|
background-color: #FFE5B5;
|
|
|
|
transform: translate3d(40px, 0, 0) rotate(0);
|
|
|
|
|
|
|
|
.crater { opacity: 1; }
|
2020-03-22 01:39:12 +00:00
|
|
|
}
|
|
|
|
|
2020-11-25 12:31:34 +00:00
|
|
|
.star--1 {
|
|
|
|
width: 2px;
|
|
|
|
height: 2px;
|
2020-03-22 01:39:12 +00:00
|
|
|
}
|
|
|
|
|
2020-11-25 12:31:34 +00:00
|
|
|
.star--2 {
|
2020-03-22 01:39:12 +00:00
|
|
|
width: 4px;
|
|
|
|
height: 4px;
|
2020-11-25 12:31:34 +00:00
|
|
|
transform: translate3d(-5px, 0, 0);
|
2020-03-22 01:39:12 +00:00
|
|
|
}
|
|
|
|
|
2020-11-25 12:31:34 +00:00
|
|
|
.star--3 {
|
|
|
|
width: 2px;
|
|
|
|
height: 2px;
|
|
|
|
transform: translate3d(-7px, 0, 0);
|
2020-03-22 01:39:12 +00:00
|
|
|
}
|
|
|
|
|
2020-11-25 12:31:34 +00:00
|
|
|
.star--4,
|
|
|
|
.star--5,
|
|
|
|
.star--6 {
|
|
|
|
opacity: 1;
|
|
|
|
transform: translate3d(0,0,0);
|
2020-03-22 01:39:12 +00:00
|
|
|
}
|
|
|
|
|
2020-11-25 12:31:34 +00:00
|
|
|
.star--4 {
|
|
|
|
transition: all 300ms 200ms cubic-bezier(0.445, 0.05, 0.55, 0.95) !important;
|
|
|
|
}
|
2020-03-22 01:39:12 +00:00
|
|
|
|
2020-11-25 12:31:34 +00:00
|
|
|
.star--5 {
|
|
|
|
transition: all 300ms 300ms cubic-bezier(0.445, 0.05, 0.55, 0.95) !important;
|
|
|
|
}
|
2020-03-22 01:39:12 +00:00
|
|
|
|
2020-11-25 12:31:34 +00:00
|
|
|
.star--6 {
|
|
|
|
transition: all 300ms 400ms cubic-bezier(0.445, 0.05, 0.55, 0.95) !important;
|
2020-03-22 01:39:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|