@rxdrag/website-lib-core 0.0.127 → 0.0.129

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.
Files changed (138) hide show
  1. package/README.md +1 -1
  2. package/index.ts +1 -1
  3. package/package.json +4 -4
  4. package/src/astro/animation.ts +146 -146
  5. package/src/astro/background.ts +82 -86
  6. package/src/astro/base.ts +7 -0
  7. package/src/astro/business.ts +13 -0
  8. package/src/astro/grid/consts.ts +80 -80
  9. package/src/astro/grid/index.ts +2 -2
  10. package/src/astro/grid/types.ts +35 -35
  11. package/src/astro/image.ts +239 -239
  12. package/src/astro/index.ts +12 -10
  13. package/src/astro/link.ts +20 -21
  14. package/src/astro/media.ts +123 -123
  15. package/src/astro/nav.ts +13 -13
  16. package/src/astro/section/index.ts +7 -12
  17. package/src/component-logic/index.ts +1 -1
  18. package/src/component-logic/link-client.ts +32 -32
  19. package/src/component-logic/link.ts +61 -61
  20. package/src/design-tokens.ts +160 -160
  21. package/src/entify/Entify.ts +111 -101
  22. package/src/entify/IEntify.ts +157 -177
  23. package/src/entify/index.ts +4 -4
  24. package/src/entify/lib/collectCategoryIds.ts +20 -20
  25. package/src/entify/lib/fulltextSearch.ts +63 -62
  26. package/src/entify/lib/langFields.ts +14 -14
  27. package/src/entify/lib/listToTree.ts +23 -23
  28. package/src/entify/lib/newAvatarQueryOptions.ts +4 -4
  29. package/src/entify/lib/newOgImageQueryOptions.ts +5 -5
  30. package/src/entify/lib/newQueryPostOptions.ts +42 -45
  31. package/src/entify/lib/newQueryProductOptions.ts +96 -98
  32. package/src/entify/lib/newQueryProductsMediaOptions.ts +28 -28
  33. package/src/entify/lib/queryAllProducts.ts +40 -40
  34. package/src/entify/lib/queryBulletin.ts +28 -16
  35. package/src/entify/lib/queryEntityList.ts +41 -41
  36. package/src/entify/lib/queryFeaturedProducts.ts +69 -68
  37. package/src/entify/lib/queryLangs.ts +36 -60
  38. package/src/entify/lib/queryLatestPosts.ts +92 -91
  39. package/src/entify/lib/queryOneEntity.ts +63 -63
  40. package/src/entify/lib/queryOneMedia.ts +27 -27
  41. package/src/entify/lib/queryOnePostById.ts +21 -21
  42. package/src/entify/lib/queryOnePostBySlug.ts +40 -39
  43. package/src/entify/lib/queryOnePostCategoryBySlug.ts +35 -35
  44. package/src/entify/lib/queryOneProductById.ts +20 -20
  45. package/src/entify/lib/queryOneProductBySlug.ts +53 -52
  46. package/src/entify/lib/queryOneProductCategoryBySlug.ts +50 -49
  47. package/src/entify/lib/queryOneTheme.ts +54 -72
  48. package/src/entify/lib/queryOneUser.ts +38 -38
  49. package/src/entify/lib/queryPostCategories.ts +67 -67
  50. package/src/entify/lib/queryPostSlugs.ts +37 -37
  51. package/src/entify/lib/queryPosts.ts +175 -174
  52. package/src/entify/lib/queryProductCategories.ts +59 -59
  53. package/src/entify/lib/queryProducts.ts +145 -144
  54. package/src/entify/lib/queryProductsInMenu.ts +45 -45
  55. package/src/entify/lib/queryTagCategories.ts +58 -58
  56. package/src/entify/lib/queryTags.ts +57 -57
  57. package/src/entify/lib/queryUserIds.ts +24 -24
  58. package/src/entify/lib/queryUserPosts.ts +80 -79
  59. package/src/entify/lib/queryWebSiteSettings.ts +28 -28
  60. package/src/entify/lib/queryWebsite.ts +43 -43
  61. package/src/entify/lib/sendEmail.ts +7 -7
  62. package/src/entify/lib/toQueryOptions.ts +19 -19
  63. package/src/entify/lib/upsertEntity.ts +8 -8
  64. package/src/entify/types/index.ts +1 -1
  65. package/src/entify/types/utils.ts +11 -6
  66. package/src/entify/types/variables.ts +0 -1
  67. package/src/entify/view-model/funcs.ts +230 -230
  68. package/src/entify/view-model/index.ts +1 -1
  69. package/src/entify/view-model/models.ts +135 -135
  70. package/src/global.d.ts +7 -7
  71. package/src/index.ts +8 -8
  72. package/src/lib/formatDate.ts +15 -15
  73. package/src/lib/index.ts +3 -3
  74. package/src/lib/pagination.ts +114 -114
  75. package/src/lib/utils.ts +135 -135
  76. package/src/react/components/Analytics/eventHandlers.ts +173 -173
  77. package/src/react/components/Analytics/index.tsx +21 -21
  78. package/src/react/components/Analytics/singleton.ts +214 -214
  79. package/src/react/components/Analytics/tracking.ts +221 -221
  80. package/src/react/components/Analytics/types.ts +60 -60
  81. package/src/react/components/Analytics/utils.ts +95 -95
  82. package/src/react/components/AttachmentIcon/index.tsx +53 -53
  83. package/src/react/components/BackgroundHlsVideoPlayer.tsx +97 -97
  84. package/src/react/components/BackgroundVideoPlayer.tsx +32 -32
  85. package/src/react/components/Bulletin.tsx +30 -30
  86. package/src/react/components/ContactForm/ContactForm.tsx +289 -289
  87. package/src/react/components/ContactForm/Input.tsx +48 -48
  88. package/src/react/components/ContactForm/Input2.tsx +59 -59
  89. package/src/react/components/ContactForm/Submit.tsx +48 -48
  90. package/src/react/components/ContactForm/TelInput.tsx +215 -215
  91. package/src/react/components/ContactForm/Textarea.tsx +48 -48
  92. package/src/react/components/ContactForm/Textarea2.tsx +89 -89
  93. package/src/react/components/ContactForm/funcs.ts +64 -64
  94. package/src/react/components/ContactForm/index.ts +7 -7
  95. package/src/react/components/ContactForm/types.ts +68 -68
  96. package/src/react/components/GoogleConsent/CookieItemPanel.tsx +80 -80
  97. package/src/react/components/GoogleConsent/CumtomizedModal.tsx +148 -148
  98. package/src/react/components/GoogleConsent/GoogleConsent.tsx +100 -100
  99. package/src/react/components/GoogleConsent/gtags.ts +67 -67
  100. package/src/react/components/GoogleConsent/index.ts +2 -2
  101. package/src/react/components/GoogleConsent/types.ts +18 -18
  102. package/src/react/components/GoogleConsent//345/217/202/350/200/203.md +4 -4
  103. package/src/react/components/Icon/index.tsx +19 -19
  104. package/src/react/components/Medias/MainMedia.tsx +257 -257
  105. package/src/react/components/Medias/Thumbnail.tsx +62 -62
  106. package/src/react/components/Medias/VideoPlayer.tsx +114 -114
  107. package/src/react/components/Medias/index.tsx +271 -271
  108. package/src/react/components/ProductCard/ProductCard.tsx +24 -24
  109. package/src/react/components/ProductCard/ProductCta/index.tsx +28 -28
  110. package/src/react/components/ProductCard/ProductCta/style.css +3 -3
  111. package/src/react/components/ProductCard/ProductDescription/index.tsx +12 -12
  112. package/src/react/components/ProductCard/ProductDescription/style.css +5 -5
  113. package/src/react/components/ProductCard/ProductMedia/index.tsx +35 -35
  114. package/src/react/components/ProductCard/ProductMedia/style.css +5 -5
  115. package/src/react/components/ProductCard/ProductTitle/index.tsx +7 -7
  116. package/src/react/components/ProductCard/ProductTitle/style.css +3 -3
  117. package/src/react/components/ProductCard/ProductView.tsx +36 -36
  118. package/src/react/components/ProductCard/index.ts +4 -4
  119. package/src/react/components/ProductCard/useQueryProduct.ts +32 -32
  120. package/src/react/components/ReactModalTrigger.tsx +28 -28
  121. package/src/react/components/ReactVideoPlayer.tsx +29 -52
  122. package/src/react/components/RichTextOutline/index.tsx +75 -75
  123. package/src/react/components/RichTextOutline/useAnchorScroll.ts +23 -23
  124. package/src/react/components/Scroller.tsx +39 -39
  125. package/src/react/components/SearchInput.tsx +21 -21
  126. package/src/react/components/Share/index.tsx +86 -86
  127. package/src/react/components/Share/socials.tsx +79 -77
  128. package/src/react/components/Share//350/265/204/346/226/231.md +7 -7
  129. package/src/react/components/ToTop.tsx +72 -72
  130. package/src/react/components/VideoPlayIcon.tsx +43 -0
  131. package/src/react/components/all.ts +38 -38
  132. package/src/react/components/index.ts +16 -16
  133. package/src/robots.ts +4 -4
  134. package/src/entify/lib/newPageMetaOptions.ts +0 -18
  135. package/src/entify/lib/newQueryPageOptions.ts +0 -14
  136. package/src/entify/lib/queryOneIcon.ts +0 -27
  137. package/src/entify/lib/queryPageBySlug.ts +0 -43
  138. package/src/entify/lib/queryPageByType.ts +0 -44
@@ -1,239 +1,239 @@
1
- import type { HTMLAttributes } from "astro/types";
2
- import type { ImageLayout } from "astro/dist/assets/types";
3
- export type ImageMetadata = import("astro").ImageMetadata;
4
-
5
- export type { ImageLayout };
6
-
7
- /**
8
- * 图片输出格式
9
- */
10
- export type ImageFormat = "webp" | "avif" | "png" | "jpg" | "gif" | "svg";
11
-
12
- /**
13
- * 图片在页面中的布局位置(用于优化下载尺寸)
14
- */
15
- export type ImageSizePreset =
16
- | "auto" // 自动处理(让 layout 决定)
17
- | "full" // 全宽内容
18
- | "half" // 两栏布局(约 50%)
19
- | "third" // 三栏布局(约 33%)
20
- | "quarter" // 四栏布局(约 25%)
21
- | "sidebar"; // 侧边栏内图片
22
-
23
-
24
- /**
25
- * ============================================================
26
- * 图片组件属性
27
- * ============================================================
28
- *
29
- * 设计原则:
30
- * 1. Props 只处理图片核心功能(来源、加载、优化)
31
- * 2. 样式相关属性通过 Tailwind class 设置
32
- *
33
- * ============================================================
34
- * 样式设置指南(通过 class 属性使用 Tailwind)
35
- * ============================================================
36
- *
37
- * 【尺寸】
38
- * - 宽度:w-full, w-1/2, w-64, w-[300px]
39
- * - 高度:h-auto, h-64, h-screen, h-[200px]
40
- * - 最大宽度:max-w-md, max-w-lg, max-w-full
41
- *
42
- * 【宽高比】
43
- * - 正方形:aspect-square
44
- * - 视频:aspect-video (16:9)
45
- * - 自定义:aspect-[4/3], aspect-[3/2]
46
- *
47
- * 【填充模式】
48
- * - 裁剪填满:object-cover(推荐用于背景图、卡片图)
49
- * - 完整显示:object-contain(推荐用于 logo)
50
- * - 拉伸填满:object-fill
51
- * - 原始尺寸:object-none
52
- *
53
- * 【位置(配合 object-cover/contain 使用)】
54
- * - 居中:object-center(默认)
55
- * - 顶部:object-top
56
- * - 底部:object-bottom
57
- * - 左右:object-left, object-right
58
- *
59
- * 【圆角】
60
- * - 小:rounded-sm
61
- * - 中:rounded-md, rounded-lg
62
- * - 大:rounded-xl, rounded-2xl
63
- * - 圆形:rounded-full
64
- *
65
- * 【阴影】
66
- * - 小:shadow-sm
67
- * - 中:shadow, shadow-md
68
- * - 大:shadow-lg, shadow-xl
69
- *
70
- * 【边框】
71
- * - 细边框:border
72
- * - 边框颜色:border-gray-200, border-white
73
- *
74
- * 【滤镜效果】
75
- * - 灰度:grayscale
76
- * - 模糊:blur-sm, blur-md
77
- * - 亮度:brightness-50, brightness-150
78
- * - 悬停效果:hover:scale-105, hover:brightness-110
79
- *
80
- * 使用示例:
81
- * ```astro
82
- * <Image
83
- * src="/hero.jpg"
84
- * alt="英雄图"
85
- * class="w-full aspect-video object-cover rounded-lg shadow-lg"
86
- * />
87
- * ```
88
- */
89
- export interface ImageProps extends Omit<HTMLAttributes<"img">, "src" | "width" | "height"> {
90
- /**
91
- * 图片来源
92
- * - 本地图片:使用 import 导入
93
- * - 远程图片:使用完整 URL
94
- * - CMS 图片:使用媒体库路径
95
- */
96
- src: string | ImageMetadata;
97
-
98
- /**
99
- * 图片宽度
100
- * - 本地图片可自动推断,可不填
101
- * - 本地图片使用 layout="fixed" 时必须填写
102
- * - 远程图片不需要填写,用 Tailwind 样式代替
103
- */
104
- width?: number;
105
-
106
- /**
107
- * 图片宽度列表
108
- * - Astro Image/Picture 的 widths 参数
109
- */
110
- widths?: number[];
111
-
112
- /**
113
- * 图片高度
114
- * - 本地图片可自动推断,可不填
115
- * - 本地图片使用 layout="fixed" 时必须填写
116
- * - 远程图片不需要填写,用 Tailwind 样式代替
117
- */
118
- height?: number;
119
-
120
- /**
121
- * 图片描述(用于无障碍访问和 SEO)
122
- * - 内容图片:填写描述文字
123
- * - 装饰性图片:设为空字符串 alt="",屏幕阅读器会忽略
124
- */
125
- alt?: string;
126
-
127
- /**
128
- * 响应式布局模式(Astro 原生值)
129
- * - responsive: 跟随容器宽度,最大不超过原图尺寸(推荐)
130
- * - full-width: 填满父容器(100% 宽度)
131
- * - fixed: 固定尺寸,不响应屏幕变化
132
- * - none: 不使用 Astro 响应式处理
133
- */
134
- layout?: ImageLayout;
135
-
136
- /**
137
- * 输出格式(用于 Picture 组件)
138
- * - 浏览器会自动选择最优格式
139
- * - 推荐:['avif', 'webp'] 获得最佳压缩
140
- * @example ['avif', 'webp']
141
- */
142
- formats?: ImageFormat[];
143
-
144
- /**
145
- * 加载策略
146
- * - lazy: 延迟加载,首屏外的图片使用
147
- * - eager: 立即加载,首屏图片使用
148
- * @default "lazy"
149
- */
150
- loading?: "lazy" | "eager";
151
-
152
- /**
153
- * 是否为重要图片(LCP 优化,Astro 原生支持)
154
- * - 设为 true 会自动设置 loading="eager" 和 fetchpriority="high"
155
- * - 仅对首屏最大的图片使用
156
- */
157
- priority?: boolean;
158
-
159
- /**
160
- * 图片质量(1-100)
161
- * - 数值越高质量越好,文件越大
162
- * - 推荐 80-90 平衡质量和大小
163
- * 备注:这个可以先不提供可视化支持,小白理解不了
164
- * @default 80
165
- */
166
- quality?: number;
167
-
168
- /**
169
- * sizes 属性(兼容 Astro Image 原生)
170
- * - 用于响应式图片选择
171
- * - 传递原生 CSS sizes 字符串
172
- * @example "(max-width: 768px) 100vw, 50vw"
173
- */
174
- sizes?: string;
175
-
176
- /**
177
- * 图片在页面中的布局位置预设(用于优化下载尺寸)
178
- * - auto: 自动处理(推荐,让 layout 决定)
179
- * - full: 全宽内容
180
- * - half: 两栏布局
181
- * - third: 三栏布局
182
- * - quarter: 四栏布局
183
- * - sidebar: 侧边栏内图片
184
- * 会自动映射为 sizes 属性值
185
- * @default "auto"
186
- */
187
- sizeHint?: ImageSizePreset;
188
-
189
- /**
190
- * 样式类(使用 Tailwind)
191
- *
192
- * 【避免布局偏移】
193
- * 设置宽高比可预留空间,防止图片加载时页面跳动:
194
- * - aspect-square(1:1)
195
- * - aspect-video(16:9)
196
- * - aspect-[4/3]、aspect-[3/2] 等自定义比例
197
- *
198
- * 【常用宽高比】
199
- * - 1:1 - 正方形,电商产品、头像、社交卡片
200
- * - 4:3 - 传统屏幕,博客卡片、新闻缩略图
201
- * - 3:2 - 单反照片,摄影作品、画廊
202
- * - 16:9 - 宽屏视频,英雄图、视频封面
203
- * - 21:9 - 超宽屏,电影海报、横幅广告
204
- * - 4:5 - 竖版,Instagram、社交媒体
205
- * - 9:16 - 竖屏视频,Stories、短视频封面
206
- *
207
- * 【快捷模板】
208
- * - 英雄图:w-full aspect-video object-cover
209
- * - 博客卡片:w-full aspect-[16/9] object-cover rounded-lg
210
- * - 新闻卡片:w-full aspect-[4/3] object-cover rounded-lg
211
- * - 电商卡片:w-full aspect-square object-cover rounded-lg
212
- * - 社交卡片:w-full aspect-[4/5] object-cover rounded-lg
213
- * - 缩略图:w-32 aspect-square object-cover rounded
214
- * - 头像(小):w-8 h-8 object-cover rounded-full
215
- * - 头像(中):w-12 h-12 object-cover rounded-full
216
- * - 头像(大):w-16 h-16 object-cover rounded-full
217
- * - Logo:h-8 w-auto object-contain
218
- * - 产品图:w-full aspect-square object-contain bg-white
219
- * - 背景图:w-full h-full object-cover absolute inset-0
220
- * - 画廊图:w-full aspect-[3/2] object-cover hover:scale-105 transition
221
- * - 横幅广告:w-full aspect-[21/9] object-cover
222
- *
223
- * 【常用样式】
224
- * - 尺寸:w-full, w-1/2, w-32, h-64, max-w-lg, max-w-screen-xl
225
- * - 填充:object-cover(裁剪填满), object-contain(完整显示), object-fill(拉伸)
226
- * - 位置:object-center, object-top, object-bottom, object-left, object-right
227
- * - 圆角:rounded-sm, rounded, rounded-md, rounded-lg, rounded-xl, rounded-full
228
- * - 阴影:shadow-sm, shadow, shadow-md, shadow-lg, shadow-xl
229
- * - 边框:border, border-2, border-white, border-gray-200
230
- * - 滤镜:grayscale, blur-sm, brightness-75, contrast-125
231
- * - 过渡:transition, hover:scale-105, hover:brightness-110, hover:shadow-xl
232
- *
233
- * @example "w-full aspect-video object-cover rounded-lg"
234
- */
235
- class?: string;
236
- //兼容react组件
237
- className?: string;
238
- }
239
-
1
+ import type { HTMLAttributes } from "astro/types";
2
+ import type { ImageLayout } from "astro/dist/assets/types";
3
+ export type ImageMetadata = import("astro").ImageMetadata;
4
+
5
+ export type { ImageLayout };
6
+
7
+ /**
8
+ * 图片输出格式
9
+ */
10
+ export type ImageFormat = "webp" | "avif" | "png" | "jpg" | "gif" | "svg";
11
+
12
+ /**
13
+ * 图片在页面中的布局位置(用于优化下载尺寸)
14
+ */
15
+ export type ImageSizePreset =
16
+ | "auto" // 自动处理(让 layout 决定)
17
+ | "full" // 全宽内容
18
+ | "half" // 两栏布局(约 50%)
19
+ | "third" // 三栏布局(约 33%)
20
+ | "quarter" // 四栏布局(约 25%)
21
+ | "sidebar"; // 侧边栏内图片
22
+
23
+
24
+ /**
25
+ * ============================================================
26
+ * 图片组件属性
27
+ * ============================================================
28
+ *
29
+ * 设计原则:
30
+ * 1. Props 只处理图片核心功能(来源、加载、优化)
31
+ * 2. 样式相关属性通过 Tailwind class 设置
32
+ *
33
+ * ============================================================
34
+ * 样式设置指南(通过 class 属性使用 Tailwind)
35
+ * ============================================================
36
+ *
37
+ * 【尺寸】
38
+ * - 宽度:w-full, w-1/2, w-64, w-[300px]
39
+ * - 高度:h-auto, h-64, h-screen, h-[200px]
40
+ * - 最大宽度:max-w-md, max-w-lg, max-w-full
41
+ *
42
+ * 【宽高比】
43
+ * - 正方形:aspect-square
44
+ * - 视频:aspect-video (16:9)
45
+ * - 自定义:aspect-[4/3], aspect-[3/2]
46
+ *
47
+ * 【填充模式】
48
+ * - 裁剪填满:object-cover(推荐用于背景图、卡片图)
49
+ * - 完整显示:object-contain(推荐用于 logo)
50
+ * - 拉伸填满:object-fill
51
+ * - 原始尺寸:object-none
52
+ *
53
+ * 【位置(配合 object-cover/contain 使用)】
54
+ * - 居中:object-center(默认)
55
+ * - 顶部:object-top
56
+ * - 底部:object-bottom
57
+ * - 左右:object-left, object-right
58
+ *
59
+ * 【圆角】
60
+ * - 小:rounded-sm
61
+ * - 中:rounded-md, rounded-lg
62
+ * - 大:rounded-xl, rounded-2xl
63
+ * - 圆形:rounded-full
64
+ *
65
+ * 【阴影】
66
+ * - 小:shadow-sm
67
+ * - 中:shadow, shadow-md
68
+ * - 大:shadow-lg, shadow-xl
69
+ *
70
+ * 【边框】
71
+ * - 细边框:border
72
+ * - 边框颜色:border-gray-200, border-white
73
+ *
74
+ * 【滤镜效果】
75
+ * - 灰度:grayscale
76
+ * - 模糊:blur-sm, blur-md
77
+ * - 亮度:brightness-50, brightness-150
78
+ * - 悬停效果:hover:scale-105, hover:brightness-110
79
+ *
80
+ * 使用示例:
81
+ * ```astro
82
+ * <Image
83
+ * src="/hero.jpg"
84
+ * alt="英雄图"
85
+ * class="w-full aspect-video object-cover rounded-lg shadow-lg"
86
+ * />
87
+ * ```
88
+ */
89
+ export interface ImageProps extends Omit<HTMLAttributes<"img">, "src" | "width" | "height"> {
90
+ /**
91
+ * 图片来源
92
+ * - 本地图片:使用 import 导入
93
+ * - 远程图片:使用完整 URL
94
+ * - CMS 图片:使用媒体库路径
95
+ */
96
+ src: string | ImageMetadata;
97
+
98
+ /**
99
+ * 图片宽度
100
+ * - 本地图片可自动推断,可不填
101
+ * - 本地图片使用 layout="fixed" 时必须填写
102
+ * - 远程图片不需要填写,用 Tailwind 样式代替
103
+ */
104
+ width?: number;
105
+
106
+ /**
107
+ * 图片宽度列表
108
+ * - Astro Image/Picture 的 widths 参数
109
+ */
110
+ widths?: number[];
111
+
112
+ /**
113
+ * 图片高度
114
+ * - 本地图片可自动推断,可不填
115
+ * - 本地图片使用 layout="fixed" 时必须填写
116
+ * - 远程图片不需要填写,用 Tailwind 样式代替
117
+ */
118
+ height?: number;
119
+
120
+ /**
121
+ * 图片描述(用于无障碍访问和 SEO)
122
+ * - 内容图片:填写描述文字
123
+ * - 装饰性图片:设为空字符串 alt="",屏幕阅读器会忽略
124
+ */
125
+ alt?: string;
126
+
127
+ /**
128
+ * 响应式布局模式(Astro 原生值)
129
+ * - responsive: 跟随容器宽度,最大不超过原图尺寸(推荐)
130
+ * - full-width: 填满父容器(100% 宽度)
131
+ * - fixed: 固定尺寸,不响应屏幕变化
132
+ * - none: 不使用 Astro 响应式处理
133
+ */
134
+ layout?: ImageLayout;
135
+
136
+ /**
137
+ * 输出格式(用于 Picture 组件)
138
+ * - 浏览器会自动选择最优格式
139
+ * - 推荐:['avif', 'webp'] 获得最佳压缩
140
+ * @example ['avif', 'webp']
141
+ */
142
+ formats?: ImageFormat[];
143
+
144
+ /**
145
+ * 加载策略
146
+ * - lazy: 延迟加载,首屏外的图片使用
147
+ * - eager: 立即加载,首屏图片使用
148
+ * @default "lazy"
149
+ */
150
+ loading?: "lazy" | "eager";
151
+
152
+ /**
153
+ * 是否为重要图片(LCP 优化,Astro 原生支持)
154
+ * - 设为 true 会自动设置 loading="eager" 和 fetchpriority="high"
155
+ * - 仅对首屏最大的图片使用
156
+ */
157
+ priority?: boolean;
158
+
159
+ /**
160
+ * 图片质量(1-100)
161
+ * - 数值越高质量越好,文件越大
162
+ * - 推荐 80-90 平衡质量和大小
163
+ * 备注:这个可以先不提供可视化支持,小白理解不了
164
+ * @default 80
165
+ */
166
+ quality?: number;
167
+
168
+ /**
169
+ * sizes 属性(兼容 Astro Image 原生)
170
+ * - 用于响应式图片选择
171
+ * - 传递原生 CSS sizes 字符串
172
+ * @example "(max-width: 768px) 100vw, 50vw"
173
+ */
174
+ sizes?: string;
175
+
176
+ /**
177
+ * 图片在页面中的布局位置预设(用于优化下载尺寸)
178
+ * - auto: 自动处理(推荐,让 layout 决定)
179
+ * - full: 全宽内容
180
+ * - half: 两栏布局
181
+ * - third: 三栏布局
182
+ * - quarter: 四栏布局
183
+ * - sidebar: 侧边栏内图片
184
+ * 会自动映射为 sizes 属性值
185
+ * @default "auto"
186
+ */
187
+ sizeHint?: ImageSizePreset;
188
+
189
+ /**
190
+ * 样式类(使用 Tailwind)
191
+ *
192
+ * 【避免布局偏移】
193
+ * 设置宽高比可预留空间,防止图片加载时页面跳动:
194
+ * - aspect-square(1:1)
195
+ * - aspect-video(16:9)
196
+ * - aspect-[4/3]、aspect-[3/2] 等自定义比例
197
+ *
198
+ * 【常用宽高比】
199
+ * - 1:1 - 正方形,电商产品、头像、社交卡片
200
+ * - 4:3 - 传统屏幕,博客卡片、新闻缩略图
201
+ * - 3:2 - 单反照片,摄影作品、画廊
202
+ * - 16:9 - 宽屏视频,英雄图、视频封面
203
+ * - 21:9 - 超宽屏,电影海报、横幅广告
204
+ * - 4:5 - 竖版,Instagram、社交媒体
205
+ * - 9:16 - 竖屏视频,Stories、短视频封面
206
+ *
207
+ * 【快捷模板】
208
+ * - 英雄图:w-full aspect-video object-cover
209
+ * - 博客卡片:w-full aspect-[16/9] object-cover rounded-lg
210
+ * - 新闻卡片:w-full aspect-[4/3] object-cover rounded-lg
211
+ * - 电商卡片:w-full aspect-square object-cover rounded-lg
212
+ * - 社交卡片:w-full aspect-[4/5] object-cover rounded-lg
213
+ * - 缩略图:w-32 aspect-square object-cover rounded
214
+ * - 头像(小):w-8 h-8 object-cover rounded-full
215
+ * - 头像(中):w-12 h-12 object-cover rounded-full
216
+ * - 头像(大):w-16 h-16 object-cover rounded-full
217
+ * - Logo:h-8 w-auto object-contain
218
+ * - 产品图:w-full aspect-square object-contain bg-white
219
+ * - 背景图:w-full h-full object-cover absolute inset-0
220
+ * - 画廊图:w-full aspect-[3/2] object-cover hover:scale-105 transition
221
+ * - 横幅广告:w-full aspect-[21/9] object-cover
222
+ *
223
+ * 【常用样式】
224
+ * - 尺寸:w-full, w-1/2, w-32, h-64, max-w-lg, max-w-screen-xl
225
+ * - 填充:object-cover(裁剪填满), object-contain(完整显示), object-fill(拉伸)
226
+ * - 位置:object-center, object-top, object-bottom, object-left, object-right
227
+ * - 圆角:rounded-sm, rounded, rounded-md, rounded-lg, rounded-xl, rounded-full
228
+ * - 阴影:shadow-sm, shadow, shadow-md, shadow-lg, shadow-xl
229
+ * - 边框:border, border-2, border-white, border-gray-200
230
+ * - 滤镜:grayscale, blur-sm, brightness-75, contrast-125
231
+ * - 过渡:transition, hover:scale-105, hover:brightness-110, hover:shadow-xl
232
+ *
233
+ * @example "w-full aspect-video object-cover rounded-lg"
234
+ */
235
+ class?: string;
236
+ //兼容react组件
237
+ className?: string;
238
+ }
239
+
@@ -1,10 +1,12 @@
1
- export * from "./animation";
2
- export * from "./grid";
3
- export * from "./section";
4
- export * from "./background";
5
- export * from "./link";
6
- export * from "./media";
7
- export * from "./nav";
8
- export * from "./image";
9
-
10
-
1
+ export * from "./animation";
2
+ export * from "./grid";
3
+ export * from "./section";
4
+ export * from "./background";
5
+ export * from "./base";
6
+ export * from "./business";
7
+ export * from "./link";
8
+ export * from "./media";
9
+ export * from "./nav";
10
+ export * from "./image";
11
+
12
+
package/src/astro/link.ts CHANGED
@@ -1,21 +1,20 @@
1
- import { HTMLAttributes } from "astro/types";
2
- import { LinkType } from "../component-logic";
3
-
4
- export interface LinkProps extends HTMLAttributes<"a"> {
5
- type?: LinkType | string;
6
- to?: string;
7
- className?: string;
8
- //用于active类名的传递
9
- activeWhen?: string | true;
10
-
11
- // 链接生成配置:用于 toHref 计算最终 href 的路径前缀
12
- // - productsSlug:产品详情页路径前缀(如 "products")
13
- // - postsSlug:文章详情页路径前缀(如 "posts")
14
- options?: {
15
- productsSlug?: string;
16
- postsSlug?: string;
17
- };
18
-
19
- // 允许外部传入以便兼容旧用法,但运行时会被忽略(href 统一由 type/to/options 生成)
20
- href?: string;
21
- }
1
+ import { HTMLAttributes } from "astro/types";
2
+ import { LinkType } from "../component-logic";
3
+
4
+ export interface LinkProps extends HTMLAttributes<"a"> {
5
+ type?: LinkType | string;
6
+ to?: string;
7
+ className?: string;
8
+ //用于active类名的传递
9
+ activeWhen?: string | true;
10
+
11
+ // 链接生成配置:用于 toHref 计算最终 href 的路径前缀
12
+ // - productsSlug:产品详情页路径前缀(如 "products")
13
+ // - postsSlug:文章详情页路径前缀(如 "posts")
14
+ options?: {
15
+ productsSlug?: string;
16
+ postsSlug?: string;
17
+ };
18
+
19
+ target?: "_blank" | "_self" | "_parent" | "_top";
20
+ }