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