useAvatarOption.ts 471 字节
Newer Older
L
LeoKu 已提交
1 2 3 4
import { computed } from 'vue'

import { useStore } from '@/store'
import { SET_AVATAR_OPTION } from '@/store/mutation-type'
L
LeoKu 已提交
5
import type { AvatarOption } from '@/types'
L
LeoKu 已提交
6 7 8 9 10 11 12 13 14 15 16 17

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
}