import { reactive } from "vue";
import axios from "axios";

export default function () {
  // eslint-disable-next-line prefer-const
let dogList = reactive<string[]>([
  'https://images.dog.ceo/breeds/pembroke/n02113023_8021.jpg'
]);

// 加载随机狗图片
async function loadRandomDog() {
  try {
    const response = await axios.get('https://dog.ceo/api/breed/pembroke/images/random');
    const imageUrl = response.data.message; // 获取图片 URL
    dogList.push(imageUrl); // 将图片 URL 添加到 dogList
  } catch (error) {
    console.error("加载狗图片失败:", error);
  }
}
//向外部提供东西
return{dogList,loadRandomDog}
}
