fix dashboard config

This commit is contained in:
jxxghp
2024-04-23 10:25:43 +08:00
parent 144992ccec
commit 8e6d3cf30e
2 changed files with 7 additions and 4 deletions

View File

@@ -10,6 +10,7 @@ import MediaServerLatest from '@/views/dashboard/MediaServerLatest.vue'
import MediaServerLibrary from '@/views/dashboard/MediaServerLibrary.vue' import MediaServerLibrary from '@/views/dashboard/MediaServerLibrary.vue'
import MediaServerPlaying from '@/views/dashboard/MediaServerPlaying.vue' import MediaServerPlaying from '@/views/dashboard/MediaServerPlaying.vue'
import api from '@/api' import api from '@/api'
import { isNullOrEmptyObject } from '@/@core/utils'
// 仪表盘配置 // 仪表盘配置
const dashboard_names = { const dashboard_names = {
@@ -41,23 +42,24 @@ const default_config = {
playing: true, playing: true,
latest: true, latest: true,
} }
// 初始化默认值
const config = ref(JSON.parse(localStorage.getItem('MP_DASHBOARD') || '{}')) const config = ref(JSON.parse(localStorage.getItem('MP_DASHBOARD') || '{}'))
if (Object.keys(config.value).length === 0) { if (isNullOrEmptyObject(config.value)) {
config.value = default_config config.value = default_config
localStorage.setItem('MP_DASHBOARD', JSON.stringify(config.value))
} }
// 设置项目 // 设置项目
function setDashboardConfig() { function setDashboardConfig() {
const data = JSON.stringify(config.value) const data = JSON.stringify(config.value)
localStorage.setItem('MP_DASHBOARD', data) localStorage.setItem('MP_DASHBOARD', data)
dialog.value = false
// 保存到服务端 // 保存到服务端
api.post('/user/config/Dashboard', data, { api.post('/user/config/Dashboard', data, {
headers: { headers: {
"Content-Type": "application/json" "Content-Type": "application/json"
} }
}) })
dialog.value = false
} }
</script> </script>

View File

@@ -128,7 +128,8 @@ function login() {
store.dispatch('auth/updateSuperUser', superuser) store.dispatch('auth/updateSuperUser', superuser)
store.dispatch('auth/updateUserName', username) store.dispatch('auth/updateUserName', username)
store.dispatch('auth/updateAvatar', avatar) store.dispatch('auth/updateAvatar', avatar)
// 登录后处理
afterLogin() afterLogin()
}) })
.catch((error: any) => { .catch((error: any) => {