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

import { useStore } from '@/store'
import { SET_AVATAR_OPTION } from '@/store/mutation-type'
import type { AvatarOption } from '@/types'

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

  const avatarOption = computed(() => store.state.history.present)

  const setAvatarOption = (newOption: AvatarOption) => {
    store.commit(SET_AVATAR_OPTION, newOption)
  }

  return [avatarOption, setAvatarOption] as const
}