12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- import { defineStore } from "pinia";
- import axios from "axios";
- import { nanoid } from "nanoid";
- import { reactive } from "vue";
- // export const useTalkStore = defineStore('talk1',{
- // state(){
- // return {
- // // list:[
- // // { id: "01", title: "今天你有点怪,哪里怪?怪好看的!" },
- // // { id: "02", title: "草莓、蓝莓、蔓越莓,今天想我了没?" },
- // // { id: "03", title: "心里给你留了一块地,我的死心塌地" },
- // // ]
- // list:JSON.parse(localStorage.getItem("talkList") as string) || []
- // }
- // },
- // actions:{
- // async getMain() {
- // let {data:{content:title}} = await axios.get("https://api.uomg.com/api/rand.qinghua?format=json");
- // console.log(title);
- // let obj = {
- // id:nanoid(),
- // title
- // }
- // this.list.push(obj);
- // // TalkStore.list.push(obj);
- // }
- // }
- // })
- export const useTalkStore = defineStore("talk1", () => {
- let list = JSON.parse(localStorage.getItem("talkList") as string) || [];
- async function getMain() {
- let {
- data: { content: title },
- } = await axios.get("https://api.uomg.com/api/rand.qinghua?format=json");
- console.log(title);
- let obj = {
- id: nanoid(),
- title,
- };
- list.push(obj);
- console.log(list,'最新')
- }
- return {
- list,
- getMain,
- };
- });
|