| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- <template>
- <a-dropdown trigger="hover" @select="handleSelect">
- <div class="header-right-theme-item">
- <img class="icon-theme-img" src="../../../assets/theme.png" />
- </div>
- <template #content>
- <a-doption value="light">浅色主题</a-doption>
- <a-doption value="dark">深色主题</a-doption>
- </template>
- </a-dropdown>
- </template>
- <script setup>
- import { setThemeDark, setThemeLight } from '../../../base/theme';
- const props = defineProps({
- label: String
- });
- /**
- * 设置系统主题
- * @param {string} theme - 主题 dark/theme
- */
- const handleThemeChange = (theme) => {
- if (theme === 'dark') {
- setThemeDark();
- }
- if (theme === 'light') {
- setThemeLight();
- }
- };
- const handleSelect = (value) => {
- handleThemeChange(value);
- };
- </script>
- <style lang="css" scoped>
- .header-right-theme-item {
- color: var(--color-text-2);
- width: 30px;
- height: 30px;
- border-radius: 20px;
- border: solid 1px #e5e6eb;
- display: flex;
- justify-content: center;
- align-items: center;
- cursor: pointer;
- }
- .icon-theme-img {
- width: 16px;
- }
- </style>
|