feat: 初始化智能物联网设备管理系统前后端基础项目

完成项目整体结构搭建,包含:
1. 前端Vue3+TS+Vite+Antd项目基础配置与核心依赖
2. 后端MidwayJS+TypeORM+JWT权限认证框架
3. 完整的用户、角色、权限、日志数据库表结构
4. 核心业务模块API与基础服务实现
5. 全局样式、路由、状态管理配置
This commit is contained in:
andyesfly committed 2026-05-28 16:23:15 +08:00
commit 3d7eb12103
89 files changed
+16085

No files matched your search

+40
View File
@@ -0,0 +1,40 @@
import { ref, watchEffect, onMounted, computed } from 'vue'
type Theme = 'light' | 'dark'
export function useTheme() {
const theme = ref<Theme>('light')
const getPreferredTheme = (): Theme => {
const saved = localStorage.getItem('theme') as Theme | null
if (saved === 'light' || saved === 'dark') return saved
return window.matchMedia('(prefers-color-scheme: dark)').matches
? 'dark'
: 'light'
}
const applyTheme = (t: Theme) => {
document.documentElement.classList.remove('light', 'dark')
document.documentElement.classList.add(t)
localStorage.setItem('theme', t)
}
const toggleTheme = () => {
theme.value = theme.value === 'light' ? 'dark' : 'light'
}
onMounted(() => {
theme.value = getPreferredTheme()
applyTheme(theme.value)
})
watchEffect(() => {
applyTheme(theme.value)
})
return {
theme,
toggleTheme,
isDark: computed(() => theme.value === 'dark'),
}
}