31 lines
621 B
TypeScript
31 lines
621 B
TypeScript
import { defineStore } from 'pinia'
|
|
import { ref } from 'vue'
|
|
|
|
export const useAppStore = defineStore('admin-app', () => {
|
|
// 侧边栏折叠状态
|
|
const sidebarCollapsed = ref(false)
|
|
|
|
// 设备类型
|
|
const device = ref<'desktop' | 'mobile'>('desktop')
|
|
|
|
// 切换侧边栏
|
|
function toggleSidebar() {
|
|
sidebarCollapsed.value = !sidebarCollapsed.value
|
|
}
|
|
|
|
// 设置设备类型
|
|
function setDevice(d: 'desktop' | 'mobile') {
|
|
device.value = d
|
|
if (d === 'mobile') {
|
|
sidebarCollapsed.value = true
|
|
}
|
|
}
|
|
|
|
return {
|
|
sidebarCollapsed,
|
|
device,
|
|
toggleSidebar,
|
|
setDevice
|
|
}
|
|
})
|