useAvatarOption.ts 458 字节
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

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

10
  const avatarOption = computed(() => store.history.present)
L
LeoKu 已提交
11 12

  const setAvatarOption = (newOption: AvatarOption) => {
13
    store[SET_AVATAR_OPTION](newOption)
L
LeoKu 已提交
14 15 16 17
  }

  return [avatarOption, setAvatarOption] as const
}