cos-design 3.2.0 → 3.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +27 -0
- package/README.md +18 -17
- package/dist/components/index.d.ts +4 -0
- package/dist/components/weatherBackground/index.d.ts +24 -0
- package/dist/components/weatherBackground/live-weather.d.ts +32 -0
- package/dist/index.cjs +1 -1
- package/dist/index.css +1 -1
- package/dist/index.js +1087 -305
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,33 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [3.4.0] - 2026-07-21
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- `WeatherBackground` 接入 Open-Meteo 实况:支持 `live`、可选 `latitude` / `longitude`(未配置则用浏览器定位)
|
|
13
|
+
- 日夜效果:手动 `night`,实况模式按当地 `is_day` 自动切换月亮、星空与夜间色调
|
|
14
|
+
- 实况请求中在当前画面上叠加 loading 遮罩,切换城市时不再闪回默认天气
|
|
15
|
+
- 导出 `useLiveWeather`、`mapWmoCodeToWeatherType` 及坐标相关类型
|
|
16
|
+
|
|
17
|
+
### Fixed
|
|
18
|
+
|
|
19
|
+
- WMO 码 1(mainly clear)映射为 `sunny`,与官方晴 / 多云 / 阴三档对齐
|
|
20
|
+
- Playground 示例去掉并列多根 JSX,修复「编辑代码」语法错误
|
|
21
|
+
|
|
22
|
+
## [3.3.0] - 2026-07-21
|
|
23
|
+
|
|
24
|
+
### Added
|
|
25
|
+
|
|
26
|
+
- 新增 `WeatherBackground` 天气背景组件,支持 15 种天气:大晴天 / 多云 / 阴天 / 小中大雨 / 雷阵雨 / 雾 / 小中大雪 / 雨夹雪 / 冰雹 / 霾 / 大风
|
|
27
|
+
- 雪天使用程序化六重对称冰晶贴图,每片雪花形态各不相同
|
|
28
|
+
- Props 提取脚本自动展开字符串联合类型别名(如 `WeatherType` → `'sunny' | ...`)
|
|
29
|
+
|
|
30
|
+
### Changed
|
|
31
|
+
|
|
32
|
+
- 配置参数表将长字符串联合类型拆分为可换行标签,默认值列不再强制断词换行
|
|
33
|
+
- `WeatherBackground` 置于背景动效分类首位
|
|
34
|
+
|
|
8
35
|
## [3.2.0] - 2026-06-23
|
|
9
36
|
|
|
10
37
|
### Added
|
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# cos-design
|
|
4
4
|
|
|
5
|
-
**
|
|
5
|
+
**56 个 React 视觉特效组件 · 活动页 / 品牌页 / 创意展示开箱即用**
|
|
6
6
|
|
|
7
7
|
[](https://github.com/jiaxiantao/cos-design/actions/workflows/ci.yml)
|
|
8
8
|
[](https://www.npmjs.com/package/cos-design)
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
| 数据大屏 | 翻牌器、仪表盘、液体进度环 |
|
|
30
30
|
| 创意作品集 | 牛顿摆、DNA 螺旋、迷宫生成 |
|
|
31
31
|
|
|
32
|
-
> 15 个组件太单薄,
|
|
32
|
+
> 15 个组件太单薄,56 个刚好组成一套完整的「视觉工具箱」。
|
|
33
33
|
|
|
34
34
|
---
|
|
35
35
|
|
|
@@ -73,24 +73,25 @@ export default function Page() {
|
|
|
73
73
|
|
|
74
74
|
---
|
|
75
75
|
|
|
76
|
-
## 组件一览(
|
|
76
|
+
## 组件一览(56 个 · 6 大分类)
|
|
77
77
|
|
|
78
78
|
<details open>
|
|
79
|
-
<summary><strong>背景动效</strong> —
|
|
79
|
+
<summary><strong>背景动效</strong> — 10 个 · 动态场景与粒子背景</summary>
|
|
80
80
|
|
|
81
81
|
<br>
|
|
82
82
|
|
|
83
|
-
| 组件
|
|
84
|
-
|
|
|
85
|
-
| `MatrixRain`
|
|
86
|
-
| `MeteorRain`
|
|
87
|
-
| `ParticleNetwork`
|
|
88
|
-
| `Aurora`
|
|
89
|
-
| `RippleWater`
|
|
90
|
-
| `SmokeFog`
|
|
91
|
-
| `CyberGrid`
|
|
92
|
-
| `Snowfall`
|
|
93
|
-
| `Starfield`
|
|
83
|
+
| 组件 | 说明 |
|
|
84
|
+
| ------------------- | ---------------------------------------------- |
|
|
85
|
+
| `MatrixRain` | 黑客帝国数字雨 |
|
|
86
|
+
| `MeteorRain` | 流星雨穿越 |
|
|
87
|
+
| `ParticleNetwork` | 粒子连线网络(支持触摸) |
|
|
88
|
+
| `Aurora` | 极光渐变光带 |
|
|
89
|
+
| `RippleWater` | 点击水波纹 |
|
|
90
|
+
| `SmokeFog` | 烟雾雾气飘动 |
|
|
91
|
+
| `CyberGrid` | 赛博透视地面 |
|
|
92
|
+
| `Snowfall` | 雪花 / 樱花飘落 |
|
|
93
|
+
| `Starfield` | 3D 纵深星空 |
|
|
94
|
+
| `WeatherBackground` | 天气背景(15 种场景 · Open-Meteo 实况 · 日夜) |
|
|
94
95
|
|
|
95
96
|
</details>
|
|
96
97
|
|
|
@@ -194,7 +195,7 @@ export default function Page() {
|
|
|
194
195
|
|
|
195
196
|
## 特性
|
|
196
197
|
|
|
197
|
-
- **
|
|
198
|
+
- **56 个组件**,覆盖背景、文字、交互、营销、数据、物理六大场景
|
|
198
199
|
- **React 19** + **Vite 8** + **TypeScript 5** 现代技术栈
|
|
199
200
|
- **ESM / CJS** 双格式,完整 `.d.ts` 类型
|
|
200
201
|
- **样式自动注入**,无需 `import 'cos-design/dist/index.css'`
|
|
@@ -215,7 +216,7 @@ npm run setup # 安装依赖(绕过 corepack 问题)
|
|
|
215
216
|
npx --yes pnpm@9 dev # 启动 Playground
|
|
216
217
|
```
|
|
217
218
|
|
|
218
|
-
访问 **http://localhost:4000** — 按分类浏览全部
|
|
219
|
+
访问 **http://localhost:4000** — 按分类浏览全部 56 个组件,右侧可查看与复制示例代码。
|
|
219
220
|
|
|
220
221
|
---
|
|
221
222
|
|
|
@@ -106,5 +106,9 @@ export { default as Typewriter } from './typewriter';
|
|
|
106
106
|
export type { TypewriterProps } from './typewriter';
|
|
107
107
|
export { default as WaveButton } from './waveButton';
|
|
108
108
|
export type { WaveButtonProps } from './waveButton';
|
|
109
|
+
export { default as WeatherBackground } from './weatherBackground';
|
|
110
|
+
export type { WeatherBackgroundProps, WeatherType } from './weatherBackground';
|
|
111
|
+
export { mapWmoCodeToWeatherType, useLiveWeather } from './weatherBackground/live-weather';
|
|
112
|
+
export type { LiveWeatherCoords, LiveWeatherState, LiveWeatherStatus, OpenMeteoCurrent } from './weatherBackground/live-weather';
|
|
109
113
|
export { default as WaveText } from './waveText';
|
|
110
114
|
export type { WaveTextProps } from './waveText';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
export type WeatherType = 'sunny' | 'partlyCloudy' | 'overcast' | 'lightRain' | 'moderateRain' | 'heavyRain' | 'thunderstorm' | 'fog' | 'lightSnow' | 'moderateSnow' | 'heavySnow' | 'sleet' | 'hail' | 'smog' | 'gale'
|
|
3
|
+
/** @deprecated 请使用 moderateSnow */
|
|
4
|
+
| 'snow';
|
|
5
|
+
export interface WeatherBackgroundProps {
|
|
6
|
+
width?: number;
|
|
7
|
+
height?: number;
|
|
8
|
+
/** 天气类型:sunny 大晴天 / partlyCloudy 多云 / overcast 阴天 / lightRain 小雨 / moderateRain 中雨 / heavyRain 大雨 / thunderstorm 雷阵雨 / fog 雾 / lightSnow 小雪 / moderateSnow 中雪 / heavySnow 大雪 / sleet 雨夹雪 / hail 冰雹 / smog 霾 / gale 大风 */
|
|
9
|
+
weather?: WeatherType;
|
|
10
|
+
/** 夜间模式:渲染深夜天空、月亮与星空;live 模式下自动按当地实际日夜覆盖此值 */
|
|
11
|
+
night?: boolean;
|
|
12
|
+
/** 接入 Open-Meteo 实况:自动定位并按真实天气渲染,定位或请求失败时回退到 weather */
|
|
13
|
+
live?: boolean;
|
|
14
|
+
/** live 模式查询纬度(-90 ~ 90),与 longitude 同时配置时跳过浏览器定位 */
|
|
15
|
+
latitude?: number;
|
|
16
|
+
/** live 模式查询经度(-180 ~ 180),与 latitude 同时配置时跳过浏览器定位 */
|
|
17
|
+
longitude?: number;
|
|
18
|
+
/** live 模式解析出真实天气后回调 */
|
|
19
|
+
onLiveWeather?: (weather: WeatherType) => void;
|
|
20
|
+
/** 外部受控 loading:在当前画面上叠加加载遮罩(live 模式定位/请求期间会自动显示,无需传入) */
|
|
21
|
+
loading?: boolean;
|
|
22
|
+
}
|
|
23
|
+
declare const WeatherBackground: React.FC<WeatherBackgroundProps>;
|
|
24
|
+
export default WeatherBackground;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { WeatherType } from './index';
|
|
2
|
+
export interface OpenMeteoCurrent {
|
|
3
|
+
/** WMO 天气码 */
|
|
4
|
+
weatherCode: number;
|
|
5
|
+
/** 10 米风速(km/h) */
|
|
6
|
+
windSpeed: number;
|
|
7
|
+
/** 是否白天 */
|
|
8
|
+
isDay: boolean;
|
|
9
|
+
latitude: number;
|
|
10
|
+
longitude: number;
|
|
11
|
+
}
|
|
12
|
+
export type LiveWeatherStatus = 'idle' | 'locating' | 'fetching' | 'success' | 'error';
|
|
13
|
+
export interface LiveWeatherState {
|
|
14
|
+
/** 映射后的组件天气类型,成功前为 null */
|
|
15
|
+
weather: WeatherType | null;
|
|
16
|
+
status: LiveWeatherStatus;
|
|
17
|
+
error: string | null;
|
|
18
|
+
/** Open-Meteo 原始实况数据 */
|
|
19
|
+
current: OpenMeteoCurrent | null;
|
|
20
|
+
}
|
|
21
|
+
/** WMO 天气码 → WeatherType;无降水且风速达强风时映射为大风 */
|
|
22
|
+
export declare const mapWmoCodeToWeatherType: (code: number, windSpeedKmh?: number) => WeatherType;
|
|
23
|
+
export interface LiveWeatherCoords {
|
|
24
|
+
latitude: number;
|
|
25
|
+
longitude: number;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Open-Meteo 实况天气。
|
|
29
|
+
* 传入 coords 时直接按该经纬度查询;未传时使用浏览器定位(需 HTTPS 与用户授权)。
|
|
30
|
+
* 失败时 status 为 error,调用方自行回退。
|
|
31
|
+
*/
|
|
32
|
+
export declare const useLiveWeather: (enabled?: boolean, coords?: LiveWeatherCoords) => LiveWeatherState;
|