mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-09-08 09:16:58 +08:00
refactor: Update saveDashboardConfig function to use stringified JSON for enableConfig and orderObj
This commit is contained in:
+10
-14
@@ -192,25 +192,21 @@ function sortDashboardConfigs() {
|
|||||||
// 设置项目
|
// 设置项目
|
||||||
async function saveDashboardConfig() {
|
async function saveDashboardConfig() {
|
||||||
// 启用配置
|
// 启用配置
|
||||||
const data = JSON.stringify(enableConfig.value)
|
const enableString = JSON.stringify(enableConfig.value)
|
||||||
localStorage.setItem('MP_DASHBOARD', data)
|
localStorage.setItem('MP_DASHBOARD', enableString)
|
||||||
|
|
||||||
// 顺序配置,从dashboardConfigs中提取
|
// 顺序配置,从dashboardConfigs中提取
|
||||||
const order = JSON.stringify(dashboardConfigs.value.map(item => ({ id: item.id, key: item.key })))
|
const orderObj = dashboardConfigs.value.map(item => ({ id: item.id, key: item.key }))
|
||||||
localStorage.setItem('MP_DASHBOARD_ORDER', order)
|
const orderString = JSON.stringify(orderObj)
|
||||||
|
localStorage.setItem('MP_DASHBOARD_ORDER', orderString)
|
||||||
|
|
||||||
// 是否拉升高度
|
// 是否拉升高度
|
||||||
localStorage.setItem('MP_DASHBOARD_ELEVATED', isElevated.value.toString())
|
localStorage.setItem('MP_DASHBOARD_ELEVATED', isElevated.value.toString())
|
||||||
|
|
||||||
// 保存到服务端
|
// 保存到服务端
|
||||||
try {
|
try {
|
||||||
await api.post('/user/config/Dashboard', data, {
|
await api.post('/user/config/Dashboard', enableConfig.value)
|
||||||
headers: {
|
await api.post('/user/config/DashboardOrder', orderObj)
|
||||||
'Content-Type': 'application/json',
|
|
||||||
},
|
|
||||||
})
|
|
||||||
await api.post('/user/config/DashboardOrder', order, {
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
},
|
|
||||||
})
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user