// weatherService.js
import axios from "axios";

export async function getWeather() {
    try {
        const response = await axios.get("http://monjack.cn/weatherInfo.php");
        const weatherData = response.data.lives[0];
        return weatherData;
        // 将 API 数据更新到 Pinia Store
    } catch (error) {
        console.error("Failed to fetch weather data:", error);
        throw error; // 确保将错误抛出，以便调用者可以捕获
    }
}

export async function getIPInfo() {
    try {
        const response = await axios.get("https://restapi.amap.com/v3/ip?key=12085a54026b8e80ed3f69ec9c328e3e");
        return response.data;
        // 将 API 数据更新到 Pinia Store
    } catch (error) {
        console.error("Failed to fetch IP info:", error);
    }
}

export async function getLocalData() {
    try {
        const response = await axios.get("http://localhost/getLocalData.php");
        return response.data;
        // 将 API 数据更新到 Pinia Store
    }    catch (error) {
        console.error("Failed to fetch local data:", error);
        }
}

