diff --git a/src/store/module/userAnime.ts b/src/store/module/userAnime.ts index 5c97698..6e15cfb 100644 --- a/src/store/module/userAnime.ts +++ b/src/store/module/userAnime.ts @@ -3,36 +3,36 @@ import { RootState } from '@/store' import { BareActionContext, getStoreBuilder } from 'vuex-typex' export interface UserAnimeState { - anime: Meikan.UserAnime[] + userAnime: Meikan.UserAnime[] } const initialState: UserAnimeState = { - anime: [], + userAnime: [], } const builder = getStoreBuilder().module('userAnime', initialState) // Getters const getterUserAnime = builder.read(function anime(state: UserAnimeState) { - return state.anime + return state.userAnime }) // Mutations function setAnime(state: UserAnimeState, animeList: Meikan.UserAnime[]) { - state.anime = animeList + state.userAnime = animeList } // Action async function fetchUserAnime(context: BareActionContext, user: Meikan.User) { const list = await GetUserAnime(user.id) - userAnime.setAnime(list) + userAnimeState.setAnime(list) } function resetUserAnime(context: BareActionContext) { - userAnime.setAnime([]) + userAnimeState.setAnime([]) } -export const userAnime = { +export const userAnimeState = { get anime(): Meikan.UserAnime[] { return getterUserAnime() }, diff --git a/src/types/shims-vue.d.ts b/src/types/shims-vue.d.ts index 0f2f124..8efc84a 100644 --- a/src/types/shims-vue.d.ts +++ b/src/types/shims-vue.d.ts @@ -9,8 +9,27 @@ declare namespace Meikan { name: string } - export interface UserAnime { + export interface Anime { id: number title: string + type: string + episodes: number + state: string + rating: string + start_date: string + end_date: string + genres: string[] + average_duration: number + anidb_id: number + myanimelist_id: number + } + + export interface UserAnime { + anime: Anime + state: string + episode: number + rating?: number + hidden: boolean + recommend: boolean } }