Add dark mode support (#16)
This commit is contained in:
1 parent
ddef4cec2a
commit
b8970e1373
46 files changed
+247
-166
No files matched your search
@@ -32,7 +32,7 @@ export default defineComponent({
|
||||
border-radius: 50%;
|
||||
padding: 5px 6px;
|
||||
cursor: pointer;
|
||||
color: var(--el-color-black);
|
||||
background: var(--el-color-white);
|
||||
background-color: inherit;
|
||||
color: var(--el-text-color-primary);
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,57 @@
|
||||
<template>
|
||||
<dark-switch class="switch" dark-background="#333" light-background="#fff" />
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { Switch as DarkSwitch, toggleDark, isDark } from 'vue-dark-switch';
|
||||
|
||||
export default defineComponent({
|
||||
components: {
|
||||
DarkSwitch
|
||||
},
|
||||
emits: ['update:dark'],
|
||||
computed: {
|
||||
dark() {
|
||||
return this.$store.getters.dark;
|
||||
},
|
||||
switchValue() {
|
||||
return isDark.value;
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
switchValue(val) {
|
||||
console.log('switchValue', val);
|
||||
this.$store.dispatch('setDark', val);
|
||||
},
|
||||
dark(val) {
|
||||
document.documentElement.classList.toggle('dark', val);
|
||||
this.$store.dispatch('setDark', this.dark);
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
if (this.dark) {
|
||||
toggleDark(true);
|
||||
document.documentElement.classList.add('dark');
|
||||
} else {
|
||||
toggleDark(false);
|
||||
document.documentElement.classList.remove('dark');
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.switch {
|
||||
margin-top: 2px;
|
||||
--n-rail-color-active: var(--el-color-primary) !important;
|
||||
--n-loading-color: var(--el-color-primary) !important;
|
||||
border-radius: 10px !important;
|
||||
border: 1px solid var(--el-border-color);
|
||||
overflow: hidden;
|
||||
.n-switch__button {
|
||||
border-radius: 50% !important;
|
||||
box-shadow: none !important;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,29 +0,0 @@
|
||||
<template>
|
||||
<el-tooltip
|
||||
effect="dark"
|
||||
:content="`<p>${$t('common.message.helpWechat')}: yuxingzou</p><p>${$t(
|
||||
'common.message.helpWechat2'
|
||||
)}: sunbitty</p>`"
|
||||
placement="top-start"
|
||||
raw-content
|
||||
>
|
||||
<el-button type="primary" circle size="large">
|
||||
<font-awesome-icon icon="fa-solid fa-question" />
|
||||
</el-button>
|
||||
</el-tooltip>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElTooltip, ElButton } from 'element-plus';
|
||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'HelpEntry',
|
||||
components: {
|
||||
ElTooltip,
|
||||
ElButton,
|
||||
FontAwesomeIcon
|
||||
}
|
||||
});
|
||||
</script>
|
||||
@@ -1,45 +0,0 @@
|
||||
<template>
|
||||
<el-tooltip
|
||||
effect="dark"
|
||||
:content="`<p>${$t('common.message.helpWechat')}: yuxingzou</p><p>${$t(
|
||||
'common.message.helpWechat2'
|
||||
)}: sunbitty</p>`"
|
||||
placement="top-start"
|
||||
raw-content
|
||||
>
|
||||
<el-button class="button">
|
||||
<font-awesome-icon icon="fa-solid fa-question" />
|
||||
</el-button>
|
||||
</el-tooltip>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElTooltip, ElButton } from 'element-plus';
|
||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'HelpEntry',
|
||||
components: {
|
||||
ElTooltip,
|
||||
ElButton,
|
||||
FontAwesomeIcon
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.button {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
border-radius: 10px;
|
||||
border: none;
|
||||
background-color: var(--el-bg-color-page);
|
||||
&.active,
|
||||
&:hover,
|
||||
&:focus {
|
||||
background-color: var(--el-button-hover-bg-color);
|
||||
color: var(--el-button-active-text-color);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,25 @@
|
||||
<template>
|
||||
<img :src="url" class="logo" @click="$emit('click')" />
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
|
||||
export default defineComponent({
|
||||
emits: ['click'],
|
||||
data() {
|
||||
return {
|
||||
url1: 'https://cdn.acedata.cloud/logo.png/thumb_450x_',
|
||||
url2: 'https://cdn.acedata.cloud/logo2.png/thumb_450x_'
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
dark() {
|
||||
return this.$store.getters.dark;
|
||||
},
|
||||
url() {
|
||||
return this.dark ? this.url2 : this.url1;
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
@@ -4,7 +4,8 @@
|
||||
<chevron v-else class="chevron" direction="left" @click="onCollapseMenu"></chevron>
|
||||
<div class="top">
|
||||
<div v-if="!collapsed">
|
||||
<img src="@/assets/images/logo.png" class="logo" @click="onHome" />
|
||||
<logo @click="onHome" />
|
||||
<dark-selector v-show="false" />
|
||||
</div>
|
||||
<el-menu v-if="!collapsed" :default-active="activeIndex">
|
||||
<el-menu-item
|
||||
@@ -97,11 +98,15 @@ import {
|
||||
ROUTE_MIDJOURNEY_INDEX
|
||||
} from '@/router/constants';
|
||||
import Chevron from './Chevron.vue';
|
||||
import DarkSelector from './DarkSelector.vue';
|
||||
import Logo from './Logo.vue';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'Navigator',
|
||||
components: {
|
||||
ElButton,
|
||||
Logo,
|
||||
DarkSelector,
|
||||
ElTooltip,
|
||||
LocaleSelector,
|
||||
FontAwesomeIcon,
|
||||
@@ -213,8 +218,16 @@ export default defineComponent({
|
||||
.el-menu {
|
||||
width: 180px;
|
||||
border-right: none;
|
||||
background: none;
|
||||
.el-menu-item {
|
||||
height: 50px;
|
||||
color: var(--el-text-color-primary);
|
||||
&.active,
|
||||
&:hover,
|
||||
&:focus {
|
||||
background-color: var(--el-button-hover-bg-color);
|
||||
color: var(--el-color-primary);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -248,11 +261,11 @@ export default defineComponent({
|
||||
height: 40px;
|
||||
border-radius: 10px;
|
||||
border: none;
|
||||
background-color: var(--el-bg-color-page);
|
||||
color: var(--el-text-color-primary);
|
||||
background-color: var(--el-bg-color-overlay);
|
||||
&.active,
|
||||
&:hover,
|
||||
&:focus {
|
||||
background-color: var(--el-button-hover-bg-color);
|
||||
color: var(--el-button-active-text-color);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user