useSider.ts 458 字节
Newer Older
L
LeoKu 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
import { computed } from 'vue'

import { useStore } from '@/store'
import { SET_SIDER_STATUS } from '@/store/mutation-type'

export default function useSider() {
  const store = useStore()

  const isCollapsed = computed(() => store.state.isSiderCollapsed)

  const openSider = () => {
    store.commit(SET_SIDER_STATUS, false)
  }

  const closeSider = () => {
    store.commit(SET_SIDER_STATUS, true)
  }

  return { isCollapsed, openSider, closeSider }
}