mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-09-04 23:18:44 +08:00
优化dashboard配置功能
This commit is contained in:
+9
-1
@@ -53,11 +53,19 @@ async function loadDashboardConfig() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 尝试加载用户监控面板配置(本地无配置时才加载)
|
||||||
|
async function tryLoadDashboardConfig() {
|
||||||
|
if (localStorage.getItem("MP_DASHBOARD")) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
await loadDashboardConfig()
|
||||||
|
}
|
||||||
|
|
||||||
// 页面加载时,加载当前用户数据
|
// 页面加载时,加载当前用户数据
|
||||||
onBeforeMount(async () => {
|
onBeforeMount(async () => {
|
||||||
setTheme()
|
setTheme()
|
||||||
startSSEMessager()
|
startSSEMessager()
|
||||||
await loadDashboardConfig()
|
await tryLoadDashboardConfig()
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -50,15 +50,13 @@ if (Object.keys(config.value).length === 0) {
|
|||||||
// 设置项目
|
// 设置项目
|
||||||
function setDashboardConfig() {
|
function setDashboardConfig() {
|
||||||
const data = JSON.stringify(config.value)
|
const data = JSON.stringify(config.value)
|
||||||
|
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"
|
||||||
}
|
}
|
||||||
}).then((response: any) => {
|
|
||||||
if (response && response.success) {
|
|
||||||
localStorage.setItem('MP_DASHBOARD', data)
|
|
||||||
dialog.value = false
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
+10
-2
@@ -77,9 +77,17 @@ async function loadDashboardConfig() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function afterLogin() {
|
// 尝试加载用户监控面板配置(本地无配置时才加载)
|
||||||
// 加载用户监控面板配置
|
async function tryLoadDashboardConfig() {
|
||||||
|
if (localStorage.getItem("MP_DASHBOARD")) {
|
||||||
|
return
|
||||||
|
}
|
||||||
await loadDashboardConfig()
|
await loadDashboardConfig()
|
||||||
|
}
|
||||||
|
|
||||||
|
async function afterLogin() {
|
||||||
|
// 尝试加载用户监控面板配置(本地无配置时才加载)
|
||||||
|
await tryLoadDashboardConfig()
|
||||||
// 跳转到首页或回原始页面
|
// 跳转到首页或回原始页面
|
||||||
router.push(store.state.auth.originalPath ?? '/')
|
router.push(store.state.auth.originalPath ?? '/')
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user