装备控制界面

This commit is contained in:
mmc
2026-05-09 16:44:39 +08:00
parent a7aa27242f
commit 48c6d1d4bc
9 changed files with 725 additions and 441 deletions

View File

@@ -61,3 +61,37 @@ export const buildPermTree = (treeData) => {
};
return loop(treeData);
};
export async function getWeatherData(options = {}) {
// 默认参数配置
const defaultPayload = {
city: "苏州",
adcode: "",
extended: false,
forecast: false,
hourly: false,
minutely: false,
indices: false,
lang: "zh"
};
// 合并用户传入参数与默认参数
const payload = { ...defaultPayload, ...options };
try {
// 动态导入 UapiClient SDK
// @ts-ignore
const { UapiClient } = await import('https://cdn.jsdelivr.net/npm/uapi-browser-sdk@latest/dist/index.js');
// 初始化客户端(注意:需替换为真实有效的 API_KEY)
const client = new UapiClient('https://uapis.cn', 'uapi-qy9ybtxlQ3Pp0JsHl7gXTAX45v0QpIeOoRbOnymq');
// 调用天气接口并返回数据
const weatherData = await client.misc.getMiscWeather(payload);
return weatherData;
} catch (error) {
console.error('[WeatherAPI] 获取天气数据失败:', error);
throw new Error(`天气接口调用失败:${error.message}`);
}
}