mirror of
https://github.com/youzan/vant.git
synced 2025-10-20 02:31:21 +00:00
feat(@vant/cli): mobile site support dark mode
This commit is contained in:
@@ -10,10 +10,31 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { watch } from 'vue';
|
||||
import DemoNav from './components/DemoNav.vue';
|
||||
import { useCurrentTheme } from '../common/iframe-sync';
|
||||
import { config } from 'site-mobile-shared';
|
||||
|
||||
export default {
|
||||
components: { DemoNav },
|
||||
|
||||
setup() {
|
||||
const theme = useCurrentTheme();
|
||||
|
||||
watch(
|
||||
theme,
|
||||
(newVal, oldVal) => {
|
||||
document.body.classList.remove(`van-doc-theme-${oldVal}`);
|
||||
document.body.classList.add(`van-doc-theme-${newVal}`);
|
||||
|
||||
const { darkModeClass } = config.site;
|
||||
if (darkModeClass) {
|
||||
document.body.classList.toggle(darkModeClass, newVal === 'dark');
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -24,6 +45,10 @@ body {
|
||||
min-width: 100vw;
|
||||
}
|
||||
|
||||
.van-doc-theme-dark {
|
||||
background-color: var(--van-doc-background);
|
||||
}
|
||||
|
||||
::-webkit-scrollbar {
|
||||
width: 0;
|
||||
background: transparent;
|
||||
|
Reference in New Issue
Block a user