mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-10-14 05:00:10 +00:00
1、后端优化多环境动态管理:python3 main.py run --env=dev(dev、test、prod,可以不加--env,默认dev)
2、前端加入切换主题功能(布局页面头部背景未生效,待优化)
This commit is contained in:
+27
-2
@@ -2,8 +2,9 @@
|
||||
<ConfigProvider
|
||||
:locale="zhCN"
|
||||
:theme="{
|
||||
algorithm: theme.defaultAlgorithm,
|
||||
}">
|
||||
algorithm: isDarkMode ? theme.darkAlgorithm : theme.defaultAlgorithm,
|
||||
}"
|
||||
>
|
||||
<div id="app">
|
||||
<router-view />
|
||||
</div>
|
||||
@@ -15,10 +16,34 @@ import { ConfigProvider, theme } from 'ant-design-vue'
|
||||
import zhCN from 'ant-design-vue/es/locale/zh_CN'
|
||||
import dayjs from 'dayjs'
|
||||
import 'dayjs/locale/zh-cn'
|
||||
import { ref, provide } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
|
||||
dayjs.locale('zh-cn')
|
||||
|
||||
// 主题状态
|
||||
const isDarkMode = ref(localStorage.getItem('theme') === 'dark')
|
||||
|
||||
// 提供主题状态和切换方法给所有子组件
|
||||
provide('isDarkMode', isDarkMode)
|
||||
|
||||
// 全局切换主题方法
|
||||
const toggleTheme = (darkMode: boolean) => {
|
||||
isDarkMode.value = darkMode
|
||||
if (darkMode) {
|
||||
document.documentElement.classList.add('dark')
|
||||
} else {
|
||||
document.documentElement.classList.remove('dark')
|
||||
}
|
||||
}
|
||||
|
||||
provide('toggleTheme', toggleTheme)
|
||||
|
||||
// 初始化主题
|
||||
if (isDarkMode.value) {
|
||||
document.documentElement.classList.add('dark')
|
||||
}
|
||||
|
||||
// 禁用Promise reject输出控制台
|
||||
window.addEventListener('unhandledrejection', function browserRejectionHandler(event) {
|
||||
event && event.preventDefault()
|
||||
|
||||
Reference in New Issue
Block a user