import {defineStore} from "pinia";

export const useListStore = defineStore('List', {
    state: () => ({
        infos: [
            {
                "title": "红楼梦",
                "author": "曹雪芹",
                "publisher": "人民文学出版社",
                "year": 1791,
                "isbn": "9787020002207",
                "genre": "古典文学",
                "available_copies": 10
            },
            // {
            //     "title": "三国演义",
            //     "author": "罗贯中",
            //     "publisher": "中华书局",
            //     "year": 1522,
            //     "isbn": "9787101003048",
            //     "genre": "历史小说",
            //     "available_copies": 8
            // },
            {
                "title": "西游记",
                "author": "吴承恩",
                "publisher": "人民文学出版社",
                "year": 1592,
                "isbn": "9787020002208",
                "genre": "古典文学",
                "available_copies": 12
            },
            {
                "title": "水浒传",
                "author": "施耐庵",
                "publisher": "人民文学出版社",
                "year": 1589,
                "isbn": "9787020002209",
                "genre": "古典文学",
                "available_copies": 7
            },
            {
                "title": "围城",
                "author": "钱钟书",
                "publisher": "人民文学出版社",
                "year": 1947,
                "isbn": "9787020002210",
                "genre": "现代文学",
                "available_copies": 15
            },
            {
                "title": "小王子",
                "author": "安托万·德·圣-埃克苏佩里",
                "publisher": "译林出版社",
                "year": 1943,
                "isbn": "9787544752311",
                "genre": "童话",
                "available_copies": 9
            },
            {
                "title": "平凡的世界",
                "author": "路遥",
                "publisher": "人民文学出版社",
                "year": 1986,
                "isbn": "9787020024755",
                "genre": "现代文学",
                "available_copies": 5
            },
            {
                "title": "活着",
                "author": "余华",
                "publisher": "作家出版社",
                "year": 1993,
                "isbn": "9787506365437",
                "genre": "现代文学",
                "available_copies": 8
            },
            {
                "title": "百年孤独",
                "author": "加西亚·马尔克斯",
                "publisher": "南海出版公司",
                "year": 1967,
                "isbn": "9787544253993",
                "genre": "魔幻现实主义",
                "available_copies": 12
            },
            {
                "title": "白夜行",
                "author": "东野圭吾",
                "publisher": "南海出版公司",
                "year": 1999,
                "isbn": "9787544258608",
                "genre": "悬疑",
                "available_copies": 7
            }
        ],
        currentDataIndex: 0,
        drawerVisible: false,
    }),
    actions: {
        getCurrentData(){
            return this.infos[this.currentDataIndex];
        }
    }
})