主题配置保存到服务端,使各端主题一致

This commit is contained in:
Allen
2024-04-28 16:18:12 +08:00
parent 89353c1f7e
commit 0268df0e24
3 changed files with 48 additions and 6 deletions
+7
View File
@@ -2,6 +2,7 @@
import { ref } from 'vue'
import { useTheme } from 'vuetify'
import type { ThemeSwitcherTheme } from '@layouts/types'
import api from '@/api'
const props = defineProps<{
themes: ThemeSwitcherTheme[]
@@ -42,6 +43,12 @@ function changeTheme() {
const nextTheme = getNextThemeName()
currentThemeName.value = nextTheme
localStorage.setItem('theme', nextTheme)
// 保存主题到服务端
api.post('/user/config/theme', nextTheme, {
headers: {
'Content-Type': 'text/plain',
},
})
}
// Apply saved theme on page load