From 81578b2585eefc1349a397993a0551f9b864c156 Mon Sep 17 00:00:00 2001
From: Li1304553726 <1304553726@qq.com>
Date: Mon, 17 Nov 2025 17:55:01 +0800
Subject: [PATCH 1/7] 1
---
app/components/WeatherDetailsGird.tsx | 52 +++++++++++++++++++++++++++
package.json | 44 -----------------------
2 files changed, 52 insertions(+), 44 deletions(-)
diff --git a/app/components/WeatherDetailsGird.tsx b/app/components/WeatherDetailsGird.tsx
index 2287c34..6765d7e 100644
--- a/app/components/WeatherDetailsGird.tsx
+++ b/app/components/WeatherDetailsGird.tsx
@@ -1,3 +1,5 @@
+import { Cloud, Droplets, Gauge, ThermometerSun, Wind } from "lucide-react";
+
interface WeatherDetailsGridProps {
icon: React.ReactNode;
label: string;
@@ -5,3 +7,53 @@ interface WeatherDetailsGridProps {
subtitle?: string;
}
+function WeatherInfoItem({ icon, label, value, subtitle }: WeatherDetailsGridProps) {
+ return(
+
+
+
+ {icon}
+
+
+
{label}
+
{value}
+ {subtitle &&
{subtitle}
}
+
+
+
+ )
+}
+
+export function WeatherDetailsGrid(){
+ const currentWeather = useWeatherState();
+ if(!currentWeather) return null;
+ return(
+
+
+ } label="湿度" value={`${currentWeather.current.humidity}%`} />
+ } label="风速" value={`${currentWeather.current.wind_speed} m/s`} />
+ } label="气压" value={`${currentWeather.current.pressure} hPa`} />
+ } label="云量" value={`${currentWeather.current.cloudcover}%`} />
+ } label="紫外线" value={`${currentWeather.current.uv_index} UV`} />
+
+
+
+
+
+ 降水量:\
+
+ {currentWeather.current.precipitation} mm
+
+
+
+
+ {currentWeather.current.is_day === "yes" ? "白天" : "夜晚"}
+
+
+
+ 观测时间: {currentWeather.current.observation_time}
+
+
+
+ )
+}
\ No newline at end of file
diff --git a/package.json b/package.json
index b6e384f..653642a 100644
--- a/package.json
+++ b/package.json
@@ -8,37 +8,6 @@
"start": "react-router-serve ./build/server/index.js",
"typecheck": "react-router typegen && tsc"
},
- "dependencies": {
- "@radix-ui/react-dialog": "^1.1.15",
- "@radix-ui/react-label": "^2.1.8",
- "@radix-ui/react-select": "^2.2.6",
- "@radix-ui/react-slot": "^1.2.4",
- "@react-router/node": "^7.9.2",
- "@react-router/serve": "^7.9.2",
- "class-variance-authority": "^0.7.1",
- "clsx": "^2.1.1",
- "isbot": "^5.1.31",
- "lucide-react": "^0.554.0",
- "next-themes": "^0.4.6",
- "react": "^19.1.1",
- "react-dom": "^19.1.1",
-<<<<<<< HEAD
- "react-router": "^7.9.2",
- "sonner": "^2.0.7",
- "tailwind-merge": "^3.4.0"
-=======
- "react-router": "^7.9.2"
- },{
- "name": "1114",
- "private": true,
- "type": "module",
- "scripts": {
- "build": "react-router build",
- "dev": "react-router dev",
- "start": "react-router-serve ./build/server/index.js",
- "typecheck": "react-router typegen && tsc"
->>>>>>> 9b018e3e43a44ed8f5b9d08e22c09de35b4ce874
- },
"dependencies": {
"@radix-ui/react-dialog": "^1.1.15",
"@radix-ui/react-label": "^2.1.8",
@@ -75,16 +44,3 @@
"vite-tsconfig-paths": "^5.1.4"
}
}
- "devDependencies": {
- "@react-router/dev": "^7.9.2",
- "@tailwindcss/vite": "^4.1.13",
- "@types/node": "^22",
- "@types/react": "^19.1.13",
- "@types/react-dom": "^19.1.9",
- "tailwindcss": "^4.1.13",
- "tw-animate-css": "^1.4.0",
- "typescript": "^5.9.2",
- "vite": "^7.1.7",
- "vite-tsconfig-paths": "^5.1.4"
- }
-}
\ No newline at end of file
From 374f5b7672e3dd2409cbf6762de9c6b5ea501d0f Mon Sep 17 00:00:00 2001
From: qiuchenfan <2035024011@qq.com>
Date: Mon, 17 Nov 2025 18:57:40 +0800
Subject: [PATCH 2/7] qiu4
---
app/lib/utils.ts | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/app/lib/utils.ts b/app/lib/utils.ts
index bd0c391..96a51f4 100644
--- a/app/lib/utils.ts
+++ b/app/lib/utils.ts
@@ -4,3 +4,12 @@ import { twMerge } from "tailwind-merge"
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs))
}
+
+export const formatTemperature = (
+ temp: number,
+ unit: 'celsius' | 'fahrenheit' = 'celsius'
+): string => {
+ const value = unit === 'fahrenheit' ? (temp * 9) / 5 + 32 : temp;
+ const symbol = unit === 'fahrenheit' ? '°F' : '°C';
+ return `${Math.round(value)}${symbol}`;
+};
\ No newline at end of file
From 053631c64dba4094ab317b6a58b0cf82c14a37f2 Mon Sep 17 00:00:00 2001
From: qiuchenfan <2035024011@qq.com>
Date: Mon, 17 Nov 2025 19:05:11 +0800
Subject: [PATCH 3/7] 111
---
app/routes.ts | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/routes.ts b/app/routes.ts
index 102b402..39a1749 100644
--- a/app/routes.ts
+++ b/app/routes.ts
@@ -1,3 +1,3 @@
-import { type RouteConfig, index } from "@react-router/dev/routes";
+import { type RouteConfig, index,route } from "@react-router/dev/routes";
-export default [index("routes/home.tsx")] satisfies RouteConfig;
+export default [index("routes/home.tsx"),route('weather',"routes/weather.tsx")] satisfies RouteConfig;
From 109e83857381fe98f89e32a979874967c435e1af Mon Sep 17 00:00:00 2001
From: jinsir <874871581@qq.com>
Date: Mon, 17 Nov 2025 19:07:04 +0800
Subject: [PATCH 4/7] =?UTF-8?q?Form=20api=E6=9B=B4=E6=96=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/components/WeatherSearchForm.tsx | 102 ++++++++++++++
app/services/weatherApi.ts | 46 +++++++
package.json | 45 +-----
pnpm-lock.yaml | 198 ++++++++++++++++++++++++++-
4 files changed, 341 insertions(+), 50 deletions(-)
create mode 100644 app/components/WeatherSearchForm.tsx
create mode 100644 app/services/weatherApi.ts
diff --git a/app/components/WeatherSearchForm.tsx b/app/components/WeatherSearchForm.tsx
new file mode 100644
index 0000000..04dff4f
--- /dev/null
+++ b/app/components/WeatherSearchForm.tsx
@@ -0,0 +1,102 @@
+import React, { useState, type FormEvent, type ChangeEvent } from 'react';
+import { Search, Loader2, AlertCircle, RefreshCw } from 'lucide-react';
+import { Button } from '@/ui/button';
+import { Input } from '@/ui/input';
+import { cn } from '@/lib/utils';
+import { useWeatherStore } from '@/store/weatherStore';
+
+
+export function WeatherSearchForm() {
+ const [isLoading, currentWeather, searchWeather, refreshWeather] = useWeatherStore();
+
+ const [city, setCity] = useState('');
+ const [inputError, setInputError] = useState('');
+
+ const handleInputChange = (e: ChangeEvent) => {
+ setCity(e.target.value);
+ if (inputError) {
+ setInputError('');
+ }
+
+ const handleFormSubmit = async (e: FormEvent) => {
+ e.preventDefault();
+ const trimmedCity = city.trim();
+ if (!trimmedCity) {
+ setInputError('请输入城市名称');
+ return;
+ }
+ if (!trimmedCity) {
+ setInputError('请输入有效的城市名称');
+ return;
+ }
+
+ if (trimmedCity.length < 2) {
+ setInputError('请输入至少2个字符');
+ return;
+ }
+
+ if (!/^[a-zA-Z\s]+$/.test(trimmedCity)) {
+ setInputError('请输入字母和空格');
+ return;
+ }
+ await searchWeather(trimmedCity);
+ }
+
+ return (
+
+
+
+
+ )
+ }
+
+}
\ No newline at end of file
diff --git a/app/services/weatherApi.ts b/app/services/weatherApi.ts
new file mode 100644
index 0000000..bd7b4d5
--- /dev/null
+++ b/app/services/weatherApi.ts
@@ -0,0 +1,46 @@
+import axios,{type AxiosInstance,AxiosError} from 'axios';
+import { type WeatherData } from '@/store/weatherStore';
+
+const API_KEY = '0c4679ac2decfe6a756aa09e61f42dc1';
+const BASE_URL = 'http://api.weatherstack.com';
+
+const apiClient: AxiosInstance = axios.create({
+ baseURL: BASE_URL,
+ timeout: 10000,
+ headers: {
+ 'Content-Type': 'application/json'
+ }
+});
+
+
+apiClient.interceptors.request.use(
+ (config) => {
+ config.params = {...config.params, access_key: API_KEY };
+ if (process.env.NODE_ENV === 'development'){
+ console.log('API Request:', config.method ?.toUpperCase(), config.url);
+ }
+ return config;
+ },
+ (error) => {
+ console.error('Request Error:' ,error);
+ return Promise.reject(error);
+ }
+);
+
+apiClient.interceptors.response.use(
+ (response) => {
+ if (response.data && response.data.error){
+ const error = response.data.error;
+ console.error('API Error:', error);
+ throw new Error(error.info || '请求失效');
+ }
+ if (process.env.NODE_ENV === 'development'){
+ console.log('API Response:', response.config.url,response.data);
+ }
+ return response;
+ },
+ (error :AxiosError)=>{
+ }
+
+
+);
\ No newline at end of file
diff --git a/package.json b/package.json
index b6e384f..84ef151 100644
--- a/package.json
+++ b/package.json
@@ -8,37 +8,7 @@
"start": "react-router-serve ./build/server/index.js",
"typecheck": "react-router typegen && tsc"
},
- "dependencies": {
- "@radix-ui/react-dialog": "^1.1.15",
- "@radix-ui/react-label": "^2.1.8",
- "@radix-ui/react-select": "^2.2.6",
- "@radix-ui/react-slot": "^1.2.4",
- "@react-router/node": "^7.9.2",
- "@react-router/serve": "^7.9.2",
- "class-variance-authority": "^0.7.1",
- "clsx": "^2.1.1",
- "isbot": "^5.1.31",
- "lucide-react": "^0.554.0",
- "next-themes": "^0.4.6",
- "react": "^19.1.1",
- "react-dom": "^19.1.1",
-<<<<<<< HEAD
- "react-router": "^7.9.2",
- "sonner": "^2.0.7",
- "tailwind-merge": "^3.4.0"
-=======
- "react-router": "^7.9.2"
- },{
- "name": "1114",
- "private": true,
- "type": "module",
- "scripts": {
- "build": "react-router build",
- "dev": "react-router dev",
- "start": "react-router-serve ./build/server/index.js",
- "typecheck": "react-router typegen && tsc"
->>>>>>> 9b018e3e43a44ed8f5b9d08e22c09de35b4ce874
- },
+
"dependencies": {
"@radix-ui/react-dialog": "^1.1.15",
"@radix-ui/react-label": "^2.1.8",
@@ -75,16 +45,3 @@
"vite-tsconfig-paths": "^5.1.4"
}
}
- "devDependencies": {
- "@react-router/dev": "^7.9.2",
- "@tailwindcss/vite": "^4.1.13",
- "@types/node": "^22",
- "@types/react": "^19.1.13",
- "@types/react-dom": "^19.1.9",
- "tailwindcss": "^4.1.13",
- "tw-animate-css": "^1.4.0",
- "typescript": "^5.9.2",
- "vite": "^7.1.7",
- "vite-tsconfig-paths": "^5.1.4"
- }
-}
\ No newline at end of file
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 495b4eb..c8e3572 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -20,24 +20,36 @@ importers:
'@radix-ui/react-slot':
specifier: ^1.2.4
version: 1.2.4(@types/react@19.2.5)(react@19.2.0)
+ '@radix-ui/react-toast':
+ specifier: ^1.2.2
+ version: 1.2.15(@types/react-dom@19.2.3(@types/react@19.2.5))(@types/react@19.2.5)(react-dom@19.2.0(react@19.2.0))(react@19.2.0)
'@react-router/node':
specifier: ^7.9.2
version: 7.9.6(react-router@7.9.6(react-dom@19.2.0(react@19.2.0))(react@19.2.0))(typescript@5.9.3)
'@react-router/serve':
specifier: ^7.9.2
version: 7.9.6(react-router@7.9.6(react-dom@19.2.0(react@19.2.0))(react@19.2.0))(typescript@5.9.3)
+ axios:
+ specifier: ^1.13.2
+ version: 1.13.2
class-variance-authority:
specifier: ^0.7.1
version: 0.7.1
clsx:
specifier: ^2.1.1
version: 2.1.1
+ dayjs:
+ specifier: ^1.11.19
+ version: 1.11.19
+ immer:
+ specifier: ^10.2.0
+ version: 10.2.0
isbot:
specifier: ^5.1.31
version: 5.1.32
lucide-react:
- specifier: ^0.554.0
- version: 0.554.0(react@19.2.0)
+ specifier: ^0.553.0
+ version: 0.553.0(react@19.2.0)
next-themes:
specifier: ^0.4.6
version: 0.4.6(react-dom@19.2.0(react@19.2.0))(react@19.2.0)
@@ -56,6 +68,9 @@ importers:
tailwind-merge:
specifier: ^3.4.0
version: 3.4.0
+ zustand:
+ specifier: ^4.4.7
+ version: 4.5.7(@types/react@19.2.5)(immer@10.2.0)(react@19.2.0)
devDependencies:
'@react-router/dev':
specifier: ^7.9.2
@@ -64,7 +79,7 @@ importers:
specifier: ^4.1.13
version: 4.1.17(vite@7.2.2(@types/node@22.19.1)(jiti@2.6.1)(lightningcss@1.30.2))
'@types/node':
- specifier: ^22
+ specifier: ^22.19.0
version: 22.19.1
'@types/react':
specifier: ^19.1.13
@@ -654,6 +669,19 @@ packages:
'@types/react':
optional: true
+ '@radix-ui/react-toast@1.2.15':
+ resolution: {integrity: sha512-3OSz3TacUWy4WtOXV38DggwxoqJK4+eDkNMl5Z/MJZaoUPaP4/9lf81xXMe1I2ReTAptverZUpbPY4wWwWyL5g==}
+ peerDependencies:
+ '@types/react': '*'
+ '@types/react-dom': '*'
+ react: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc
+ react-dom: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc
+ peerDependenciesMeta:
+ '@types/react':
+ optional: true
+ '@types/react-dom':
+ optional: true
+
'@radix-ui/react-use-callback-ref@1.1.1':
resolution: {integrity: sha512-FkBMwD+qbGQeMu1cOHnuGB6x4yzPjho8ap5WtbEJ26umhgqVXbhekKUQO+hZEL1vU92a3wHwdp0HAcqAUF5iDg==}
peerDependencies:
@@ -828,56 +856,67 @@ packages:
resolution: {integrity: sha512-EPlb95nUsz6Dd9Qy13fI5kUPXNSljaG9FiJ4YUGU1O/Q77i5DYFW5KR8g1OzTcdZUqQQ1KdDqsTohdFVwCwjqg==}
cpu: [arm]
os: [linux]
+ libc: [glibc]
'@rollup/rollup-linux-arm-musleabihf@4.53.2':
resolution: {integrity: sha512-BOmnVW+khAUX+YZvNfa0tGTEMVVEerOxN0pDk2E6N6DsEIa2Ctj48FOMfNDdrwinocKaC7YXUZ1pHlKpnkja/Q==}
cpu: [arm]
os: [linux]
+ libc: [musl]
'@rollup/rollup-linux-arm64-gnu@4.53.2':
resolution: {integrity: sha512-Xt2byDZ+6OVNuREgBXr4+CZDJtrVso5woFtpKdGPhpTPHcNG7D8YXeQzpNbFRxzTVqJf7kvPMCub/pcGUWgBjA==}
cpu: [arm64]
os: [linux]
+ libc: [glibc]
'@rollup/rollup-linux-arm64-musl@4.53.2':
resolution: {integrity: sha512-+LdZSldy/I9N8+klim/Y1HsKbJ3BbInHav5qE9Iy77dtHC/pibw1SR/fXlWyAk0ThnpRKoODwnAuSjqxFRDHUQ==}
cpu: [arm64]
os: [linux]
+ libc: [musl]
'@rollup/rollup-linux-loong64-gnu@4.53.2':
resolution: {integrity: sha512-8ms8sjmyc1jWJS6WdNSA23rEfdjWB30LH8Wqj0Cqvv7qSHnvw6kgMMXRdop6hkmGPlyYBdRPkjJnj3KCUHV/uQ==}
cpu: [loong64]
os: [linux]
+ libc: [glibc]
'@rollup/rollup-linux-ppc64-gnu@4.53.2':
resolution: {integrity: sha512-3HRQLUQbpBDMmzoxPJYd3W6vrVHOo2cVW8RUo87Xz0JPJcBLBr5kZ1pGcQAhdZgX9VV7NbGNipah1omKKe23/g==}
cpu: [ppc64]
os: [linux]
+ libc: [glibc]
'@rollup/rollup-linux-riscv64-gnu@4.53.2':
resolution: {integrity: sha512-fMjKi+ojnmIvhk34gZP94vjogXNNUKMEYs+EDaB/5TG/wUkoeua7p7VCHnE6T2Tx+iaghAqQX8teQzcvrYpaQA==}
cpu: [riscv64]
os: [linux]
+ libc: [glibc]
'@rollup/rollup-linux-riscv64-musl@4.53.2':
resolution: {integrity: sha512-XuGFGU+VwUUV5kLvoAdi0Wz5Xbh2SrjIxCtZj6Wq8MDp4bflb/+ThZsVxokM7n0pcbkEr2h5/pzqzDYI7cCgLQ==}
cpu: [riscv64]
os: [linux]
+ libc: [musl]
'@rollup/rollup-linux-s390x-gnu@4.53.2':
resolution: {integrity: sha512-w6yjZF0P+NGzWR3AXWX9zc0DNEGdtvykB03uhonSHMRa+oWA6novflo2WaJr6JZakG2ucsyb+rvhrKac6NIy+w==}
cpu: [s390x]
os: [linux]
+ libc: [glibc]
'@rollup/rollup-linux-x64-gnu@4.53.2':
resolution: {integrity: sha512-yo8d6tdfdeBArzC7T/PnHd7OypfI9cbuZzPnzLJIyKYFhAQ8SvlkKtKBMbXDxe1h03Rcr7u++nFS7tqXz87Gtw==}
cpu: [x64]
os: [linux]
+ libc: [glibc]
'@rollup/rollup-linux-x64-musl@4.53.2':
resolution: {integrity: sha512-ah59c1YkCxKExPP8O9PwOvs+XRLKwh/mV+3YdKqQ5AMQ0r4M4ZDuOrpWkUaqO7fzAHdINzV9tEVu8vNw48z0lA==}
cpu: [x64]
os: [linux]
+ libc: [musl]
'@rollup/rollup-openharmony-arm64@4.53.2':
resolution: {integrity: sha512-4VEd19Wmhr+Zy7hbUsFZ6YXEiP48hE//KPLCSVNY5RMGX2/7HZ+QkN55a3atM1C/BZCGIgqN+xrVgtdak2S9+A==}
@@ -942,24 +981,28 @@ packages:
engines: {node: '>= 10'}
cpu: [arm64]
os: [linux]
+ libc: [glibc]
'@tailwindcss/oxide-linux-arm64-musl@4.1.17':
resolution: {integrity: sha512-HvZLfGr42i5anKtIeQzxdkw/wPqIbpeZqe7vd3V9vI3RQxe3xU1fLjss0TjyhxWcBaipk7NYwSrwTwK1hJARMg==}
engines: {node: '>= 10'}
cpu: [arm64]
os: [linux]
+ libc: [musl]
'@tailwindcss/oxide-linux-x64-gnu@4.1.17':
resolution: {integrity: sha512-M3XZuORCGB7VPOEDH+nzpJ21XPvK5PyjlkSFkFziNHGLc5d6g3di2McAAblmaSUNl8IOmzYwLx9NsE7bplNkwQ==}
engines: {node: '>= 10'}
cpu: [x64]
os: [linux]
+ libc: [glibc]
'@tailwindcss/oxide-linux-x64-musl@4.1.17':
resolution: {integrity: sha512-k7f+pf9eXLEey4pBlw+8dgfJHY4PZ5qOUFDyNf7SI6lHjQ9Zt7+NcscjpwdCEbYi6FI5c2KDTDWyf2iHcCSyyQ==}
engines: {node: '>= 10'}
cpu: [x64]
os: [linux]
+ libc: [musl]
'@tailwindcss/oxide-wasm32-wasi@4.1.17':
resolution: {integrity: sha512-cEytGqSSoy7zK4JRWiTCx43FsKP/zGr0CsuMawhH67ONlH+T79VteQeJQRO/X7L0juEUA8ZyuYikcRBf0vsxhg==}
@@ -1038,6 +1081,12 @@ packages:
array-flatten@1.1.1:
resolution: {integrity: sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==}
+ asynckit@0.4.0:
+ resolution: {integrity: sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==}
+
+ axios@1.13.2:
+ resolution: {integrity: sha512-VPk9ebNqPcy5lRGuSlKx752IlDatOjT9paPlm8A7yOuW2Fbvp4X3JznJtT4f0GzGLLiWE9W8onz51SqLYwzGaA==}
+
babel-dead-code-elimination@1.0.10:
resolution: {integrity: sha512-DV5bdJZTzZ0zn0DC24v3jD7Mnidh6xhKa4GfKCbq3sfW8kaWhDdZjP3i81geA8T33tdYqWKw4D3fVv0CwEgKVA==}
@@ -1104,6 +1153,10 @@ packages:
color-name@1.1.4:
resolution: {integrity: sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==}
+ combined-stream@1.0.8:
+ resolution: {integrity: sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==}
+ engines: {node: '>= 0.8'}
+
compressible@2.0.18:
resolution: {integrity: sha512-AF3r7P5dWxL8MxyITRMlORQNaOA2IkAFaTr4k7BUumjPtRpGDTZpl0Pb1XCO6JeDCBdp126Cgs9sMxqSjgYyRg==}
engines: {node: '>= 0.6'}
@@ -1141,6 +1194,9 @@ packages:
csstype@3.2.2:
resolution: {integrity: sha512-D80T+tiqkd/8B0xNlbstWDG4x6aqVfO52+OlSUNIdkTvmNw0uQpJLeos2J/2XvpyidAFuTPmpad+tUxLndwj6g==}
+ dayjs@1.11.19:
+ resolution: {integrity: sha512-t5EcLVS6QPBNqM2z8fakk/NKel+Xzshgt8FFKAn+qwlD1pzZWxh0nVCrvFK7ZDb6XucZeF9z8C7CBWTRIVApAw==}
+
debug@2.6.9:
resolution: {integrity: sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==}
peerDependencies:
@@ -1166,6 +1222,10 @@ packages:
babel-plugin-macros:
optional: true
+ delayed-stream@1.0.0:
+ resolution: {integrity: sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==}
+ engines: {node: '>=0.4.0'}
+
depd@2.0.0:
resolution: {integrity: sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==}
engines: {node: '>= 0.8'}
@@ -1230,6 +1290,10 @@ packages:
resolution: {integrity: sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==}
engines: {node: '>= 0.4'}
+ es-set-tostringtag@2.1.0:
+ resolution: {integrity: sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA==}
+ engines: {node: '>= 0.4'}
+
esbuild@0.25.12:
resolution: {integrity: sha512-bbPBYYrtZbkt6Os6FiTLCTFxvq4tt3JKall1vRwshA3fdVztsLAatFaZobhkBC8/BrPetoa0oksYoKXoG4ryJg==}
engines: {node: '>=18'}
@@ -1267,10 +1331,23 @@ packages:
resolution: {integrity: sha512-6BN9trH7bp3qvnrRyzsBz+g3lZxTNZTbVO2EV1CS0WIcDbawYVdYvGflME/9QP0h0pYlCDBCTjYa9nZzMDpyxQ==}
engines: {node: '>= 0.8'}
+ follow-redirects@1.15.11:
+ resolution: {integrity: sha512-deG2P0JfjrTxl50XGCDyfI97ZGVCxIpfKYmfyrQ54n5FO/0gfIES8C/Psl6kWVDolizcaaxZJnTS0QSMxvnsBQ==}
+ engines: {node: '>=4.0'}
+ peerDependencies:
+ debug: '*'
+ peerDependenciesMeta:
+ debug:
+ optional: true
+
foreground-child@3.3.1:
resolution: {integrity: sha512-gIXjKqtFuWEgzFRJA9WCQeSJLZDjgJUOMCMzxtvFq/37KojM1BFGufqsCy0r4qSQmYLsZYMeyRqzIWOMup03sw==}
engines: {node: '>=14'}
+ form-data@4.0.5:
+ resolution: {integrity: sha512-8RipRLol37bNs2bhoV67fiTEvdTrbMUYcFTiy3+wuuOnUog2QBHCZWXDRijWQfAkhBj2Uf5UnVaiWwA5vdd82w==}
+ engines: {node: '>= 6'}
+
forwarded@0.2.0:
resolution: {integrity: sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==}
engines: {node: '>= 0.6'}
@@ -1325,6 +1402,10 @@ packages:
resolution: {integrity: sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==}
engines: {node: '>= 0.4'}
+ has-tostringtag@1.0.2:
+ resolution: {integrity: sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==}
+ engines: {node: '>= 0.4'}
+
hasown@2.0.2:
resolution: {integrity: sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==}
engines: {node: '>= 0.4'}
@@ -1341,6 +1422,9 @@ packages:
resolution: {integrity: sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==}
engines: {node: '>=0.10.0'}
+ immer@10.2.0:
+ resolution: {integrity: sha512-d/+XTN3zfODyjr89gM3mPq1WNX2B8pYsu7eORitdwyA2sBubnTl3laYlBk4sXY5FUa5qTZGBDPJICVbvqzjlbw==}
+
inherits@2.0.4:
resolution: {integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==}
@@ -1422,24 +1506,28 @@ packages:
engines: {node: '>= 12.0.0'}
cpu: [arm64]
os: [linux]
+ libc: [glibc]
lightningcss-linux-arm64-musl@1.30.2:
resolution: {integrity: sha512-5Vh9dGeblpTxWHpOx8iauV02popZDsCYMPIgiuw97OJ5uaDsL86cnqSFs5LZkG3ghHoX5isLgWzMs+eD1YzrnA==}
engines: {node: '>= 12.0.0'}
cpu: [arm64]
os: [linux]
+ libc: [musl]
lightningcss-linux-x64-gnu@1.30.2:
resolution: {integrity: sha512-Cfd46gdmj1vQ+lR6VRTTadNHu6ALuw2pKR9lYq4FnhvgBc4zWY1EtZcAc6EffShbb1MFrIPfLDXD6Xprbnni4w==}
engines: {node: '>= 12.0.0'}
cpu: [x64]
os: [linux]
+ libc: [glibc]
lightningcss-linux-x64-musl@1.30.2:
resolution: {integrity: sha512-XJaLUUFXb6/QG2lGIW6aIk6jKdtjtcffUT0NKvIqhSBY3hh9Ch+1LCeH80dR9q9LBjG3ewbDjnumefsLsP6aiA==}
engines: {node: '>= 12.0.0'}
cpu: [x64]
os: [linux]
+ libc: [musl]
lightningcss-win32-arm64-msvc@1.30.2:
resolution: {integrity: sha512-FZn+vaj7zLv//D/192WFFVA0RgHawIcHqLX9xuWiQt7P0PtdFEVaxgF9rjM/IRYHQXNnk61/H/gb2Ei+kUQ4xQ==}
@@ -1470,8 +1558,8 @@ packages:
resolution: {integrity: sha512-jumlc0BIUrS3qJGgIkWZsyfAM7NCWiBcCDhnd+3NNM5KbBmLTgHVfWBcg6W+rLUsIpzpERPsvwUP7CckAQSOoA==}
engines: {node: '>=12'}
- lucide-react@0.554.0:
- resolution: {integrity: sha512-St+z29uthEJVx0Is7ellNkgTEhaeSoA42I7JjOCBCrc5X6LYMGSv0P/2uS5HDLTExP5tpiqRD2PyUEOS6s9UXA==}
+ lucide-react@0.553.0:
+ resolution: {integrity: sha512-BRgX5zrWmNy/lkVAe0dXBgd7XQdZ3HTf+Hwe3c9WK6dqgnj9h+hxV+MDncM88xDWlCq27+TKvHGE70ViODNILw==}
peerDependencies:
react: ^16.5.1 || ^17.0.0 || ^18.0.0 || ^19.0.0
@@ -1650,6 +1738,9 @@ packages:
resolution: {integrity: sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==}
engines: {node: '>= 0.10'}
+ proxy-from-env@1.1.0:
+ resolution: {integrity: sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==}
+
qs@6.13.0:
resolution: {integrity: sha512-+38qI9SOr8tfZ4QmJNplMUxqjbe7LKvvZgWdExBOmd+egZTtjLB67Gu0HRX3u/XOq7UU2Nx6nsjvS16Z9uwfpg==}
engines: {node: '>=0.6'}
@@ -1916,6 +2007,11 @@ packages:
'@types/react':
optional: true
+ use-sync-external-store@1.6.0:
+ resolution: {integrity: sha512-Pp6GSwGP/NrPIrxVFAIkOQeyw8lFenOHijQWkUTrDvrF4ALqylP2C/KCkeS9dpUM3KvYRQhna5vt7IL95+ZQ9w==}
+ peerDependencies:
+ react: ^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0
+
utils-merge@1.0.1:
resolution: {integrity: sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==}
engines: {node: '>= 0.4.0'}
@@ -2013,6 +2109,21 @@ packages:
yallist@3.1.1:
resolution: {integrity: sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==}
+ zustand@4.5.7:
+ resolution: {integrity: sha512-CHOUy7mu3lbD6o6LJLfllpjkzhHXSBlX8B9+qPddUsIfeF5S/UZ5q0kmCsnRqT1UHFQZchNFDDzMbQsuesHWlw==}
+ engines: {node: '>=12.7.0'}
+ peerDependencies:
+ '@types/react': '>=16.8'
+ immer: '>=9.0.6'
+ react: '>=16.8'
+ peerDependenciesMeta:
+ '@types/react':
+ optional: true
+ immer:
+ optional: true
+ react:
+ optional: true
+
snapshots:
'@babel/code-frame@7.27.1':
@@ -2568,6 +2679,26 @@ snapshots:
optionalDependencies:
'@types/react': 19.2.5
+ '@radix-ui/react-toast@1.2.15(@types/react-dom@19.2.3(@types/react@19.2.5))(@types/react@19.2.5)(react-dom@19.2.0(react@19.2.0))(react@19.2.0)':
+ dependencies:
+ '@radix-ui/primitive': 1.1.3
+ '@radix-ui/react-collection': 1.1.7(@types/react-dom@19.2.3(@types/react@19.2.5))(@types/react@19.2.5)(react-dom@19.2.0(react@19.2.0))(react@19.2.0)
+ '@radix-ui/react-compose-refs': 1.1.2(@types/react@19.2.5)(react@19.2.0)
+ '@radix-ui/react-context': 1.1.2(@types/react@19.2.5)(react@19.2.0)
+ '@radix-ui/react-dismissable-layer': 1.1.11(@types/react-dom@19.2.3(@types/react@19.2.5))(@types/react@19.2.5)(react-dom@19.2.0(react@19.2.0))(react@19.2.0)
+ '@radix-ui/react-portal': 1.1.9(@types/react-dom@19.2.3(@types/react@19.2.5))(@types/react@19.2.5)(react-dom@19.2.0(react@19.2.0))(react@19.2.0)
+ '@radix-ui/react-presence': 1.1.5(@types/react-dom@19.2.3(@types/react@19.2.5))(@types/react@19.2.5)(react-dom@19.2.0(react@19.2.0))(react@19.2.0)
+ '@radix-ui/react-primitive': 2.1.3(@types/react-dom@19.2.3(@types/react@19.2.5))(@types/react@19.2.5)(react-dom@19.2.0(react@19.2.0))(react@19.2.0)
+ '@radix-ui/react-use-callback-ref': 1.1.1(@types/react@19.2.5)(react@19.2.0)
+ '@radix-ui/react-use-controllable-state': 1.2.2(@types/react@19.2.5)(react@19.2.0)
+ '@radix-ui/react-use-layout-effect': 1.1.1(@types/react@19.2.5)(react@19.2.0)
+ '@radix-ui/react-visually-hidden': 1.2.3(@types/react-dom@19.2.3(@types/react@19.2.5))(@types/react@19.2.5)(react-dom@19.2.0(react@19.2.0))(react@19.2.0)
+ react: 19.2.0
+ react-dom: 19.2.0(react@19.2.0)
+ optionalDependencies:
+ '@types/react': 19.2.5
+ '@types/react-dom': 19.2.3(@types/react@19.2.5)
+
'@radix-ui/react-use-callback-ref@1.1.1(@types/react@19.2.5)(react@19.2.0)':
dependencies:
react: 19.2.0
@@ -2887,6 +3018,16 @@ snapshots:
array-flatten@1.1.1: {}
+ asynckit@0.4.0: {}
+
+ axios@1.13.2:
+ dependencies:
+ follow-redirects: 1.15.11
+ form-data: 4.0.5
+ proxy-from-env: 1.1.0
+ transitivePeerDependencies:
+ - debug
+
babel-dead-code-elimination@1.0.10:
dependencies:
'@babel/core': 7.28.5
@@ -2967,6 +3108,10 @@ snapshots:
color-name@1.1.4: {}
+ combined-stream@1.0.8:
+ dependencies:
+ delayed-stream: 1.0.0
+
compressible@2.0.18:
dependencies:
mime-db: 1.54.0
@@ -3005,6 +3150,8 @@ snapshots:
csstype@3.2.2: {}
+ dayjs@1.11.19: {}
+
debug@2.6.9:
dependencies:
ms: 2.0.0
@@ -3015,6 +3162,8 @@ snapshots:
dedent@1.7.0: {}
+ delayed-stream@1.0.0: {}
+
depd@2.0.0: {}
destroy@1.2.0: {}
@@ -3060,6 +3209,13 @@ snapshots:
dependencies:
es-errors: 1.3.0
+ es-set-tostringtag@2.1.0:
+ dependencies:
+ es-errors: 1.3.0
+ get-intrinsic: 1.3.0
+ has-tostringtag: 1.0.2
+ hasown: 2.0.2
+
esbuild@0.25.12:
optionalDependencies:
'@esbuild/aix-ppc64': 0.25.12
@@ -3149,11 +3305,21 @@ snapshots:
transitivePeerDependencies:
- supports-color
+ follow-redirects@1.15.11: {}
+
foreground-child@3.3.1:
dependencies:
cross-spawn: 7.0.6
signal-exit: 4.1.0
+ form-data@4.0.5:
+ dependencies:
+ asynckit: 0.4.0
+ combined-stream: 1.0.8
+ es-set-tostringtag: 2.1.0
+ hasown: 2.0.2
+ mime-types: 2.1.35
+
forwarded@0.2.0: {}
fresh@0.5.2: {}
@@ -3204,6 +3370,10 @@ snapshots:
has-symbols@1.1.0: {}
+ has-tostringtag@1.0.2:
+ dependencies:
+ has-symbols: 1.1.0
+
hasown@2.0.2:
dependencies:
function-bind: 1.1.2
@@ -3224,6 +3394,8 @@ snapshots:
dependencies:
safer-buffer: 2.1.2
+ immer@10.2.0: {}
+
inherits@2.0.4: {}
ipaddr.js@1.9.1: {}
@@ -3313,7 +3485,7 @@ snapshots:
lru-cache@7.18.3: {}
- lucide-react@0.554.0(react@19.2.0):
+ lucide-react@0.553.0(react@19.2.0):
dependencies:
react: 19.2.0
@@ -3456,6 +3628,8 @@ snapshots:
forwarded: 0.2.0
ipaddr.js: 1.9.1
+ proxy-from-env@1.1.0: {}
+
qs@6.13.0:
dependencies:
side-channel: 1.1.0
@@ -3727,6 +3901,10 @@ snapshots:
optionalDependencies:
'@types/react': 19.2.5
+ use-sync-external-store@1.6.0(react@19.2.0):
+ dependencies:
+ react: 19.2.0
+
utils-merge@1.0.1: {}
valibot@1.1.0(typescript@5.9.3):
@@ -3809,3 +3987,11 @@ snapshots:
strip-ansi: 7.1.2
yallist@3.1.1: {}
+
+ zustand@4.5.7(@types/react@19.2.5)(immer@10.2.0)(react@19.2.0):
+ dependencies:
+ use-sync-external-store: 1.6.0(react@19.2.0)
+ optionalDependencies:
+ '@types/react': 19.2.5
+ immer: 10.2.0
+ react: 19.2.0
From e4542ac7cfe7b53428224edb379d0c8dc9f7896f Mon Sep 17 00:00:00 2001
From: Li1304553726 <1304553726@qq.com>
Date: Mon, 17 Nov 2025 19:08:01 +0800
Subject: [PATCH 5/7] 1
---
app/store/weatherStore.ts | 81 ++++++++++++++++++++++++++++++---------
package.json | 10 +----
2 files changed, 64 insertions(+), 27 deletions(-)
diff --git a/app/store/weatherStore.ts b/app/store/weatherStore.ts
index 5c9f8a1..8754ff9 100644
--- a/app/store/weatherStore.ts
+++ b/app/store/weatherStore.ts
@@ -1,5 +1,5 @@
import { create } from 'zustand'
-import {persist} from 'zustand/middleware'
+import {persist,createJSONStorage} from 'zustand/middleware'
const CACHE_EXPIRY = 10 * 60 * 1000;
export interface Location {
@@ -71,23 +71,68 @@ export interface WeatherStore {
}
-export const useWeatherStore = create()(persist((set,get)=>({currentWeather:null,weatherCache:new Map(),isLoading:false,error:null,
- setCurrentWeather:(weather)=>set({currentWeather:weather}),
- getWeatherFromCache:(city)=>{
- const cashe = get().weatherCache.get(city.toLowerCase());
- if(!cashe)return null;
- const isExpired = Date.now()-cashe.timestamp>CACHE_EXPIRY;
- return isExpired?null:cashe.data;
- },
- cacheWeather:(city,weather)=>set((state)=>{
- const newCache = new Map(state.weatherCache);
- newCache.set(city.toLowerCase(),{data:weather,timestamp:Date.now()});
- return{weatherCache:newCache}
- }),
- setLoading:(loading)=>set({error})
-})
-
-))
+export const useWeatherStore = create()(
+ persist(
+ (set,get)=>({
+ currentWeather:null,weatherCache:new Map(),isLoading:false,error:null,
+ setCurrentWeather:(weather)=>set({currentWeather:weather}),
+ getWeatherFromCache:(city)=>{
+ const cashe = get().weatherCache.get(city.toLowerCase());
+ if(!cashe)return null;
+ const isExpired = Date.now()-cashe.timestamp>CACHE_EXPIRY;
+ return isExpired?null:cashe.data;
+ },
+ cacheWeather:(city,weather)=>set((state)=>{
+ const newCache = new Map(state.weatherCache);
+ newCache.set(city.toLowerCase(),{data:weather,timestamp:Date.now()});
+ return{weatherCache:newCache}
+ }),
+ setLoading:(loading)=>set({isLoading:loading}),
+ setError:(error)=>set({error}),
+ reset:()=>set({currentWeather:null,weatherCache:new Map(),isLoading:false,error:null}),
+ searchWeather:async(city:string)=>{
+ try{
+ set({isLoading:true,error:null});
+ const cachedWeather = get().getWeatherFromCache(city);
+ if(cachedWeather){
+ set({currentWeather:cachedWeather,isLoading:false});
+ return;
+ }
+ const WeatherData = await WeatherAPI.getcurrentWeather(city);
+ set({currentWeather:WeatherData,isLoading:false});
+ get().cacheWeather(city,WeatherData);
+ }catch(error){
+ set({error:'获取失败',isLoading:false});
+ }
+ },
+ refreshWeather:async()=>{
+ const currentWeather = get().currentWeather;
+ if(!currentWeather)return;
+ try{
+ set({isLoading:true,error:null});
+ const city = currentWeather.location.name;
+ const WeatherData = await WeatherAPI.getcurrentWeather(city);
+ set({currentWeather:WeatherData,isLoading:false});
+ get().cacheWeather(city,WeatherData);
+ }catch(error){
+ set({error:'刷新失败',isLoading:false});
+ }
+ }
+ }),
+ {
+ name:'weather-strorage',
+ storage:createJSONStorage(()=>localStorage),
+ partialize:(state)=>({
+ weatherCache:Array.from(state.weatherCache.entries())
+ }),
+ onRehydrateStorage:(state)=>{
+ if(state && Array.isArray(state.weatherCache)){
+ state.weatherCache = new Map(state.weatherCache as any);
+ }
+ }
+ }
+ )
+)
diff --git a/package.json b/package.json
index c7da746..dd4f6e7 100644
--- a/package.json
+++ b/package.json
@@ -43,12 +43,4 @@
"vite": "^7.1.7",
"vite-tsconfig-paths": "^5.1.4"
}
-<<<<<<< HEAD
-<<<<<<< HEAD
-}
-=======
-}
->>>>>>> 34ee14ecd423bb649a4c45f54ab6e3f37ad0f35f
-=======
-}
->>>>>>> 12e66397d84bd55cde0c1b209d3e943e5e20bcb9
+}
\ No newline at end of file
From 23d0bedd82d0503af7d7625739f59bbc2a9e214d Mon Sep 17 00:00:00 2001
From: qiuchenfan <2035024011@qq.com>
Date: Mon, 17 Nov 2025 19:10:41 +0800
Subject: [PATCH 6/7] 1112
---
app/components/WeatherDetailsGird.tsx | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/app/components/WeatherDetailsGird.tsx b/app/components/WeatherDetailsGird.tsx
index 6765d7e..30bf498 100644
--- a/app/components/WeatherDetailsGird.tsx
+++ b/app/components/WeatherDetailsGird.tsx
@@ -1,4 +1,5 @@
import { Cloud, Droplets, Gauge, ThermometerSun, Wind } from "lucide-react";
+import { useWeatherStore } from "@/store/weatherStore";
interface WeatherDetailsGridProps {
icon: React.ReactNode;
@@ -25,7 +26,7 @@ function WeatherInfoItem({ icon, label, value, subtitle }: WeatherDetailsGridPro
}
export function WeatherDetailsGrid(){
- const currentWeather = useWeatherState();
+ const {currentWeather} = useWeatherStore();
if(!currentWeather) return null;
return(
@@ -42,7 +43,7 @@ export function WeatherDetailsGrid(){
降水量:\
- {currentWeather.current.precipitation} mm
+ {currentWeather.current.precip} mm
From df117304d739b4322ea380bf5eb8bad389002bda Mon Sep 17 00:00:00 2001
From: jinsir <874871581@qq.com>
Date: Mon, 17 Nov 2025 19:13:23 +0800
Subject: [PATCH 7/7] =?UTF-8?q?api=E6=9B=B4=E6=96=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/services/weatherApi.ts | 40 +++++++++++++++++++++++++++++++++++---
1 file changed, 37 insertions(+), 3 deletions(-)
diff --git a/app/services/weatherApi.ts b/app/services/weatherApi.ts
index bd7b4d5..d5b9477 100644
--- a/app/services/weatherApi.ts
+++ b/app/services/weatherApi.ts
@@ -1,6 +1,7 @@
import axios,{type AxiosInstance,AxiosError} from 'axios';
import { type WeatherData } from '@/store/weatherStore';
+
const API_KEY = '0c4679ac2decfe6a756aa09e61f42dc1';
const BASE_URL = 'http://api.weatherstack.com';
@@ -40,7 +41,40 @@ apiClient.interceptors.response.use(
return response;
},
(error :AxiosError)=>{
- }
-
-);
\ No newline at end of file
+ console.error('Response Error:',error.message);
+ if (error.response) {
+ const status = error.response.status;
+ if (status === 404) {
+ throw new Error('未找到该城市的天气信息');
+ } else if (status === 401) {
+ throw new Error('API认证失败,请检查API');
+ } else if (status === 403) {
+ throw new Error('请检查API密钥是否正确');
+ }
+ }
+ else if (error.request) {
+ throw new Error('网络连接失败');
+ }
+ else {
+ return (('配置错误'))
+ }
+ }
+
+
+);
+
+export class WeatherApi {
+static async getCurrentWeather(city: string): Promise {
+ try {
+ const response = await apiClient.get('/current',{
+ params:{query :city} ,
+ });
+ return response.data;
+}catch (error){
+ throw error;
+}
+}
+
+}
+export default WeatherApi;
\ No newline at end of file