-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
240 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,13 @@ | ||
import { DepOptimizationOptions } from 'vite' | ||
import { DepOptimizationOptions } from 'vite'; | ||
|
||
export function createViteOptimizeDeps(): DepOptimizationOptions { | ||
const viteOptimizeDeps: DepOptimizationOptions = { | ||
// 默认情况下,不在 node_modules 中的,链接的包不会被预构建。使用此选项可强制预构建链接的包。 | ||
include: [ | ||
'element-plus/es/locale/lang/zh-tw', | ||
'element-plus/es/locale/lang/en', | ||
], | ||
// 默认情况下,Vite 会抓取你的 index.html 来检测需要预构建的依赖项。如果指定了 build.rollupOptions.input,Vite 将转而去抓取这些入口点。 | ||
entries: [], | ||
// 在预构建中强制排除的依赖项。 | ||
exclude: ['@zougt/vite-plugin-theme-preprocessor/dist/browser-utils'], | ||
} | ||
return viteOptimizeDeps | ||
const viteOptimizeDeps: DepOptimizationOptions = { | ||
// 默认情况下,不在 node_modules 中的,链接的包不会被预构建。使用此选项可强制预构建链接的包。 | ||
include: ['element-plus/es/locale/lang/zh-tw', 'element-plus/es/locale/lang/en'], | ||
// 默认情况下,Vite 会抓取你的 index.html 来检测需要预构建的依赖项。如果指定了 build.rollupOptions.input,Vite 将转而去抓取这些入口点。 | ||
entries: [], | ||
// 在预构建中强制排除的依赖项。 | ||
exclude: ['@zougt/vite-plugin-theme-preprocessor/dist/browser-utils'], | ||
}; | ||
return viteOptimizeDeps; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,7 @@ | |
|
||
<style lang="scss" scoped> | ||
.icon { | ||
color: #{$textColor}; | ||
font-size: 1em; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<template> | ||
<div class="theme" :class="{ 'theme-dark': isDark }" @click="toggleDarkMode"> | ||
<div class="theme-inner"></div> | ||
<SvgIcon name="sun"></SvgIcon> | ||
<SvgIcon name="moon"></SvgIcon> | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { ref } from 'vue'; | ||
import SvgIcon from '../SvgIcon/index.vue'; | ||
import { toggleTheme } from '@zougt/vite-plugin-theme-preprocessor/dist/browser-utils'; | ||
// const toggleTheme = (scopeName = 'theme-default') => { | ||
// document.documentElement.className = scopeName | ||
// } | ||
const isDark = ref<boolean>(false); | ||
const toggleDarkMode = () => { | ||
isDark.value = !isDark.value; | ||
console.log(isDark.value); | ||
let scopeName = 'variables-theme-day'; | ||
if (isDark.value) scopeName = 'variables-theme-dark'; | ||
else scopeName = 'variables-theme-day'; | ||
console.log(scopeName); | ||
toggleTheme({ | ||
scopeName, | ||
}); | ||
}; | ||
</script> | ||
|
||
<style lang="scss" scoped> | ||
.theme { | ||
position: relative; | ||
width: 50px; | ||
height: 26px; | ||
display: flex; | ||
justify-content: space-between; | ||
align-items: center; | ||
background-color: 151515; | ||
border: 1px solid #{$textColor}; | ||
padding: 0 6px; | ||
font-size: 1em; | ||
border-radius: 30px; | ||
.theme-inner { | ||
position: absolute; | ||
z-index: 1; | ||
width: 18px; | ||
height: 18px; | ||
background-color: #{$textColor}; | ||
border-radius: 50%; | ||
transition: transform 0.5s, background-color 0.5s; | ||
will-change: transform; | ||
} | ||
} | ||
.theme-dark { | ||
.theme-inner { | ||
transform: translateX(calc(100% + 2px)); | ||
} | ||
} | ||
.icon { | ||
font-size: 1em; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
import { withInstall } from '@/utils'; | ||
import appLocale from './AppLocale.vue'; | ||
import appTheme from './AppTheme.vue'; | ||
|
||
export const AppLocale = withInstall(appLocale); | ||
export const AppTheme = withInstall(appTheme); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.