mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-09-05 07:28:37 +08:00
dashboard配置支持保存入库
This commit is contained in:
+13
@@ -1,6 +1,7 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { useToast } from 'vue-toast-notification'
|
import { useToast } from 'vue-toast-notification'
|
||||||
import { useTheme } from 'vuetify'
|
import { useTheme } from 'vuetify'
|
||||||
|
import api from '@/api'
|
||||||
|
|
||||||
import store from './store'
|
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 () => {
|
onBeforeMount(async () => {
|
||||||
setTheme()
|
setTheme()
|
||||||
startSSEMessager()
|
startSSEMessager()
|
||||||
|
await loadDashboardConfig()
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
+12
-2
@@ -9,6 +9,7 @@ import AnalyticsMemory from '@/views/dashboard/AnalyticsMemory.vue'
|
|||||||
import MediaServerLatest from '@/views/dashboard/MediaServerLatest.vue'
|
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'
|
||||||
|
|
||||||
// 仪表盘配置
|
// 仪表盘配置
|
||||||
const dashboard_names = {
|
const dashboard_names = {
|
||||||
@@ -48,8 +49,17 @@ if (Object.keys(config.value).length === 0) {
|
|||||||
|
|
||||||
// 设置项目
|
// 设置项目
|
||||||
function setDashboardConfig() {
|
function setDashboardConfig() {
|
||||||
localStorage.setItem('MP_DASHBOARD', JSON.stringify(config.value))
|
const data = JSON.stringify(config.value)
|
||||||
dialog.value = false
|
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>
|
</script>
|
||||||
|
|
||||||
|
|||||||
+19
-2
@@ -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事件
|
// 登录获取token事件
|
||||||
function login() {
|
function login() {
|
||||||
errorMessage.value = ''
|
errorMessage.value = ''
|
||||||
@@ -103,8 +121,7 @@ function login() {
|
|||||||
store.dispatch('auth/updateUserName', username)
|
store.dispatch('auth/updateUserName', username)
|
||||||
store.dispatch('auth/updateAvatar', avatar)
|
store.dispatch('auth/updateAvatar', avatar)
|
||||||
|
|
||||||
// 跳转到首页或回原始页面
|
afterLogin()
|
||||||
router.push(store.state.auth.originalPath ?? '/')
|
|
||||||
})
|
})
|
||||||
.catch((error: any) => {
|
.catch((error: any) => {
|
||||||
// 登录失败,显示错误提示
|
// 登录失败,显示错误提示
|
||||||
|
|||||||
Reference in New Issue
Block a user