mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-05-18 04:07:36 +08:00
dashboard配置支持保存入库
This commit is contained in:
13
src/App.vue
13
src/App.vue
@@ -1,6 +1,7 @@
|
||||
<script lang="ts" setup>
|
||||
import { useToast } from 'vue-toast-notification'
|
||||
import { useTheme } from 'vuetify'
|
||||
import api from '@/api'
|
||||
|
||||
import store from './store'
|
||||
|
||||
@@ -41,10 +42,22 @@ function startSSEMessager() {
|
||||
}
|
||||
}
|
||||
|
||||
// 加载用户监控面板配置
|
||||
async function loadDashboardConfig() {
|
||||
const response = await api.get('/user/config/Dashboard')
|
||||
if (response && response.data && response.data.value) {
|
||||
const data = JSON.stringify(response.data.value)
|
||||
if (data != localStorage.getItem("MP_DASHBOARD")) {
|
||||
localStorage.setItem("MP_DASHBOARD", data)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 页面加载时,加载当前用户数据
|
||||
onBeforeMount(async () => {
|
||||
setTheme()
|
||||
startSSEMessager()
|
||||
await loadDashboardConfig()
|
||||
})
|
||||
</script>
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import AnalyticsMemory from '@/views/dashboard/AnalyticsMemory.vue'
|
||||
import MediaServerLatest from '@/views/dashboard/MediaServerLatest.vue'
|
||||
import MediaServerLibrary from '@/views/dashboard/MediaServerLibrary.vue'
|
||||
import MediaServerPlaying from '@/views/dashboard/MediaServerPlaying.vue'
|
||||
import api from '@/api'
|
||||
|
||||
// 仪表盘配置
|
||||
const dashboard_names = {
|
||||
@@ -48,8 +49,17 @@ if (Object.keys(config.value).length === 0) {
|
||||
|
||||
// 设置项目
|
||||
function setDashboardConfig() {
|
||||
localStorage.setItem('MP_DASHBOARD', JSON.stringify(config.value))
|
||||
dialog.value = false
|
||||
const data = JSON.stringify(config.value)
|
||||
api.post('/user/config/Dashboard', data, {
|
||||
headers: {
|
||||
"Content-Type": "text/plain"
|
||||
}
|
||||
}).then((response: any) => {
|
||||
if (response && response.success) {
|
||||
localStorage.setItem('MP_DASHBOARD', data)
|
||||
dialog.value = false
|
||||
}
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -66,6 +66,24 @@ async function fetchOTP() {
|
||||
})
|
||||
}
|
||||
|
||||
// 加载用户监控面板配置
|
||||
async function loadDashboardConfig() {
|
||||
const response = await api.get('/user/config/Dashboard')
|
||||
if (response && response.data && response.data.value) {
|
||||
const data = JSON.stringify(response.data.value)
|
||||
if (data != localStorage.getItem("MP_DASHBOARD")) {
|
||||
localStorage.setItem("MP_DASHBOARD", data)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function afterLogin() {
|
||||
// 加载用户监控面板配置
|
||||
await loadDashboardConfig()
|
||||
// 跳转到首页或回原始页面
|
||||
router.push(store.state.auth.originalPath ?? '/')
|
||||
}
|
||||
|
||||
// 登录获取token事件
|
||||
function login() {
|
||||
errorMessage.value = ''
|
||||
@@ -103,8 +121,7 @@ function login() {
|
||||
store.dispatch('auth/updateUserName', username)
|
||||
store.dispatch('auth/updateAvatar', avatar)
|
||||
|
||||
// 跳转到首页或回原始页面
|
||||
router.push(store.state.auth.originalPath ?? '/')
|
||||
afterLogin()
|
||||
})
|
||||
.catch((error: any) => {
|
||||
// 登录失败,显示错误提示
|
||||
|
||||
Reference in New Issue
Block a user