@zfqh/uniapp 0.1.1 → 0.1.3

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 (66) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/docs/api/apis/index.md +1 -1
  3. package/docs/api/apis/request.md +9 -9
  4. package/docs/api/configs/index.md +1 -2
  5. package/docs/api/hooks/index.md +4 -4
  6. package/docs/api/index.md +8 -3
  7. package/docs/api/mixins/app.md +1 -2
  8. package/docs/api/modules/app.md +0 -2
  9. package/docs/api/modules/index.md +1 -1
  10. package/docs/api/utils/cos.md +1 -2
  11. package/docs/api/utils/index.md +1 -1
  12. package/docs/api/utils/locale.md +68 -32
  13. package/docs/api/utils/navigate.md +3 -3
  14. package/docs/api/utils/pages.md +1 -1
  15. package/docs/api/utils/request.md +1 -1
  16. package/docs/components/index.md +1 -1
  17. package/docs/components/styles/base-styles.md +239 -367
  18. package/docs/components/usage.md +1 -1
  19. package/docs/faq/index.md +5 -6
  20. package/docs/guide/getting-started.md +3 -4
  21. package/docs/guide/project-frame.md +36 -23
  22. package/docs/index.md +3 -3
  23. package/lib/components/g-back-button/g-back-button.vue +2 -2
  24. package/lib/components/g-checkbox-list/g-checkbox-list.vue +1 -1
  25. package/lib/components/g-float/g-float.vue +1 -1
  26. package/lib/components/g-grid-image/g-grid-image.vue +1 -1
  27. package/lib/components/g-grid-swiper/g-grid-swiper.vue +1 -1
  28. package/lib/components/g-more/g-more.vue +2 -2
  29. package/lib/components/g-page-container/g-page-container.vue +1 -1
  30. package/lib/components/g-popup/g-popup.vue +3 -3
  31. package/lib/components/g-refresh-view/g-refresh-view.vue +1 -1
  32. package/lib/components/g-search/g-search.vue +4 -4
  33. package/lib/components/g-share-photo/g-share-photo.vue +1 -1
  34. package/lib/components/g-share-view/g-share-view.vue +2 -2
  35. package/lib/components/g-share-weixin/g-share-weixin.vue +1 -1
  36. package/lib/components/g-tag-editor/g-tag-editor.vue +2 -2
  37. package/lib/components/g-trtc-room/g-trtc-room.vue +1 -1
  38. package/lib/hooks/useI18n.js +1 -7
  39. package/lib/index.d.ts +1 -0
  40. package/lib/index.js +1 -2
  41. package/lib/styles/bg.scss +1 -22
  42. package/lib/styles/border.scss +1 -158
  43. package/lib/styles/{flex-vue.scss → flex.scss} +15 -12
  44. package/lib/styles/index.scss +5 -17
  45. package/lib/styles/layout.scss +17 -75
  46. package/lib/styles/reset-vue.scss +3 -1
  47. package/lib/styles/text-nvue.scss +1 -10
  48. package/lib/styles/text-vue.scss +0 -55
  49. package/lib/styles/text.scss +1 -43
  50. package/lib/styles/var.module.scss +1 -0
  51. package/lib/utils/locale.d.ts +3 -4
  52. package/lib/utils/locale.js +6 -15
  53. package/package.json +3 -3
  54. package/types/index.d.ts +4 -2
  55. package/lib/styles/animate-vue.scss +0 -3
  56. package/lib/styles/animate.scss +0 -27
  57. package/lib/styles/bg-vue.scss +0 -21
  58. package/lib/styles/flex-nvue.scss +0 -64
  59. package/lib/styles/font.scss +0 -59
  60. package/lib/styles/layout-nvue.scss +0 -24
  61. package/lib/styles/layout-vue.scss +0 -30
  62. package/lib/styles/opacity.scss +0 -10
  63. package/lib/styles/shadow.scss +0 -12
  64. package/lib/styles/sizing-vue.scss +0 -21
  65. package/lib/styles/sizing.scss +0 -21
  66. package/lib/styles/spacing.scss +0 -234
@@ -1,367 +1,239 @@
1
- # 工具样式类
2
-
3
- `@zfqh/uniapp` 内置一套静态 SCSS 工具类系统,命名风格与 UnoCSS / Tailwind CSS 一致。类名覆盖 Flex 布局、间距、尺寸、文字、背景、边框、定位、透明度、阴影和动画,支持 `px` `rpx` 两种单位。
4
-
5
- ## 引入方式
6
-
7
- 在项目全局样式中导入一次即可激活全部工具类。放在 `App.vue` `<style>` 块:
8
-
9
- ```scss
10
- @import '@zfqh/uniapp/lib/styles/index.scss';
11
- ```
12
-
13
- ## 平台差异
14
-
15
- `index.scss` 内部使用 uni-app 条件编译区分平台:
16
-
17
- | 分类 | 全平台 | 仅非 nvue(H5、App-Vue、小程序) |
18
- | --- | --- | --- |
19
- | Flex 布局 | — | `.flex`、`.flex-row/col`、`.items-*`、`.justify-*` 等 |
20
- | 定位 | `.overflow-hidden`、`.top-*`、`.z-*` | `.relative`、`.absolute`、`.fixed`、`.sticky`、`.sticky-top` |
21
- | 尺寸 | `.w-{size}px/rpx`、`.h-{size}px/rpx` | `.w-full`、`.h-full`、`.w-{vw}`、`.h-{vh}` |
22
- | 文字 | `.text-{size}px/rpx`、`.text-{color}` | `.truncate`、`.line-clamp-*`、`.text-{8px..11px}`(zoom 缩小) |
23
- | 背景 | `.bg-{color}` | `.backdrop-blur-*` |
24
- | 动画 | `.origin-*` | `.transition-all-300` |
25
-
26
- nvue 平台提供独立的 flex、layout、text 子集,类名相同但实现适配 Weex。
27
-
28
- ## Flex 布局
29
-
30
- ::: warning 仅非 nvue 平台
31
- 以下类在 H5、App-Vue 和小程序端可用,nvue 端有独立 flex 实现。
32
- :::
33
-
34
- `.flex` 默认设置为 `display: flex; flex-direction: row; align-items: center`。
35
-
36
- | 类名 | 效果 |
37
- | --- | --- |
38
- | `.flex` | flex 行布局,垂直居中 |
39
- | `.flex-inline` | inline-flex 行布局,垂直居中 |
40
- | `.flex-row` / `.flex-row-reverse` | 行方向 |
41
- | `.flex-col` / `.flex-col-reverse` | 列方向 |
42
- | `.flex-wrap` / `.flex-nowrap` / `.flex-wrap-reverse` | 换行控制 |
43
- | `.flex-0` ~ `.flex-5` | `flex: 0` ~ `flex: 5` |
44
- | `.flex-none` | `flex: 0` |
45
- | `.items-start` / `.items-center` / `.items-end` / `.items-stretch` / `.items-baseline` | align-items |
46
- | `.justify-start` / `.justify-center` / `.justify-end` / `.justify-between` / `.justify-around` | justify-content |
47
-
48
- ## 间距(Margin / Padding)
49
-
50
- 所有平台可用。支持 `px` `rpx` 两种单位。
51
-
52
- ### 取值范围
53
-
54
- | 特殊值 | 循环值 |
55
- | --- | --- |
56
- | `0`、`px`(1px) | 2px ~ 160px(步长 2),2rpx ~ 160rpx(步长 2) |
57
-
58
- ### 命名规则
59
-
60
- ```text
61
- .{m|p}{方向}-{值}{单位}
62
- ```
63
-
64
- 方向缩写:
65
-
66
- | 缩写 | 含义 |
67
- | --- | --- |
68
- | (无) | 四边 |
69
- | `x` | 左右 |
70
- | `y` | 上下 |
71
- | `t` | |
72
- | `r` | |
73
- | `b` | |
74
- | `l` | |
75
-
76
- 示例:
77
-
78
- ```text
79
- .m-16px → margin: 16px
80
- .px-24rpx → padding-left: 24rpx; padding-right: 24rpx
81
- .mt-8px → margin-top: 8px
82
- .py-0 → padding-top: 0; padding-bottom: 0
83
- ```
84
-
85
- ### Margin
86
-
87
- margin 支持负值,在值前加 `-` 前缀:
88
-
89
- ```text
90
- .-m-16px → margin: -16px
91
- .-mx-8rpx → margin-left: -8rpx; margin-right: -8rpx
92
- .-mt-4px → margin-top: -4px
93
- ```
94
-
95
- ## 尺寸(Width / Height)
96
-
97
- ### 全平台
98
-
99
- | 类名 | 说明 |
100
- | --- | --- |
101
- | `.w-0` / `.h-0` | 0 宽高 |
102
- | `.w-{2~160}px` / `.h-{2~160}px` | px 单位,步长 2 |
103
- | `.w-{2~160}rpx` / `.h-{2~160}rpx` | rpx 单位,步长 2 |
104
-
105
- ### 仅非 nvue
106
-
107
- | 类名 | 说明 |
108
- | --- | --- |
109
- | `.w-full` / `.h-full` | `100%` |
110
- | `.w-{10~100}vw` / `.h-{10~100}vh` | 视口单位,步长 10 |
111
- | `.box-border` / `.box-content` | box-sizing |
112
-
113
- ## 文字排版
114
-
115
- ### 字号
116
-
117
- | 范围 | 单位 | 说明 |
118
- | --- | --- | --- |
119
- | `.text-{12~100}px` | px | 全平台,步长 2 |
120
- | `.text-{12~100}rpx` | rpx | 全平台,步长 2 |
121
- | `.text-{8px\|9px\|10px\|11px}` | px(zoom 缩放) | 仅非 nvue,用于小字号 |
122
- | `.text-{16rpx\|18rpx\|20rpx\|22rpx}` | rpx(zoom 缩放) | 仅非 nvue |
123
-
124
- ### 语义色
125
-
126
- `.text-{color}` 系列,颜色值跟随主题配置:
127
-
128
- | 色组 | 可用类名 |
129
- | --- | --- |
130
- | primary | `.text-primary`、`.text-primary-dark`、`.text-primary-light`、`.text-primary-disabled` |
131
- | warning | `.text-warning`、`.text-warning-dark`、`.text-warning-light`、`.text-warning-disabled` |
132
- | success | `.text-success`、`.text-success-dark`、`.text-success-light`、`.text-success-disabled` |
133
- | error | `.text-error`、`.text-error-dark`、`.text-error-light`、`.text-error-disabled` |
134
- | info | `.text-info`、`.text-info-dark`、`.text-info-light`、`.text-info-disabled` |
135
- | UI 色 | `.text-main`、`.text-content`、`.text-tips`、`.text-light`、`.text-border`、`.text-disabled` |
136
- | 基础色 | `.text-white`、`.text-black`、`.text-transparent` |
137
-
138
- ### 对齐与装饰
139
-
140
- | 类名 | 效果 |
141
- | --- | --- |
142
- | `.text-left` / `.text-center` / `.text-right` | text-align |
143
- | `.text-ellipsis` / `.text-clip` | text-overflow |
144
- | `.underline` / `.line-through` / `.no-underline` | text-decoration |
145
-
146
- ### 字重与行高
147
-
148
- `.font-{name}` 和 `.font-{weight}`:
149
-
150
- | 类名 | 值 |
151
- | --- | --- |
152
- | `.font-sans` | `system-ui, sans-serif` |
153
- | `.font-thin` ~ `.font-black` | 100 ~ 900 |
154
- | `.font-100` ~ `.font-900` | 数字字重 |
155
- | `.italic` / `.not-italic` | font-style |
156
- | `.leading-none` / `.leading-tight` / `.leading-snug` / `.leading-normal` / `.leading-relaxed` / `.leading-loose` | 1 / 1.25 / 1.375 / 1.5 / 1.625 / 2 |
157
-
158
- ### 文本截断(仅非 nvue)
159
-
160
- | 类名 | 效果 |
161
- | --- | --- |
162
- | `.truncate` | 单行截断(overflow ellipsis + nowrap) |
163
- | `.line-clamp-1` ~ `.line-clamp-5` | 多行截断(-webkit-line-clamp) |
164
-
165
- ### 换行与空白(仅非 nvue)
166
-
167
- | 类名 | 效果 |
168
- | --- | --- |
169
- | `.break-normal` / `.break-all` / `.break-word` / `.break-keep` | word-break |
170
- | `.whitespace-normal` / `.whitespace-nowrap` / `.whitespace-pre` / `.whitespace-pre-line` / `.whitespace-pre-wrap` | white-space |
171
- | `.align-baseline` / `.align-top` / `.align-middle` / `.align-bottom` | vertical-align |
172
-
173
- ## 背景色
174
-
175
- `.bg-{color}` 系列,颜色值跟随主题配置:
176
-
177
- | 类名 | 效果 |
178
- | --- | --- |
179
- | `.bg-transparent` / `.bg-white` / `.bg-black` | 基础背景色 |
180
- | `.bg-primary`、`.bg-primary-dark`、`.bg-primary-light`、`.bg-primary-disabled` | primary 系列 |
181
- | `.bg-warning`、`.bg-warning-dark`、`.bg-warning-light`、`.bg-warning-disabled` | warning 系列 |
182
- | `.bg-success`、`.bg-success-dark`、`.bg-success-light`、`.bg-success-disabled` | success 系列 |
183
- | `.bg-error`、`.bg-error-dark`、`.bg-error-light`、`.bg-error-disabled` | error 系列 |
184
- | `.bg-info`、`.bg-info-dark`、`.bg-info-light`、`.bg-info-disabled` | info 系列 |
185
- | `.bg-main`、`.bg-content`、`.bg-tips`、`.bg-light`、`.bg-border` | UI 语义色 |
186
- | `.bg` | 页面背景色 |
187
- | `.bg-disabled` | 禁用态背景 |
188
-
189
- ### 背景模糊(仅非 nvue)
190
-
191
- | 类名 | 效果 |
192
- | --- | --- |
193
- | `.backdrop-blur-0` | `blur(0)` |
194
- | `.backdrop-blur-{10\|20\|30}px` | px 单位模糊 |
195
- | `.backdrop-blur-{10\|20\|30}rpx` | rpx 单位模糊 |
196
-
197
- ## 边框
198
-
199
- ### 基础边框
200
-
201
- | 类名 | 效果 |
202
- | --- | --- |
203
- | `.border` | 1px solid 边框色 |
204
- | `.border-half` | 0.5px solid 边框色 |
205
- | `.border-0` | 无边框 |
206
- | `.border-t` / `.border-r` / `.border-b` / `.border-l` | 单边 1px solid |
207
- | `.border-x` / `.border-y` | 双轴 1px solid |
208
- | `.border-t-0` / `.border-r-0` / `.border-b-0` / `.border-l-0` | 移除单边边框 |
209
-
210
- ### 边框宽度
211
-
212
- | 范围 | 说明 |
213
- | --- | --- |
214
- | `.border-width-{2\|4\|6\|8}px/rpx` | 四边宽度 |
215
- | `.border-t-width-{size}`、`.border-r-width-{size}`、`.border-b-width-{size}`、`.border-l-width-{size}` | 单边宽度 |
216
- | `.border-x-width-{size}`、`.border-y-width-{size}` | 双轴宽度 |
217
-
218
- ### 边框颜色
219
-
220
- `.border-{color}`:`primary`、`warning`、`success`、`error`、`info`、`main`、`light`、`content`、`transparent`
221
-
222
- ### 边框样式
223
-
224
- `.border-solid`、`.border-dashed`、`.border-dotted`
225
-
226
- ### 圆角
227
-
228
- | 范围 | 说明 |
229
- | --- | --- |
230
- | `.rounded-0` | 无圆角 |
231
- | `.rounded-full` | `9999px`(圆形) |
232
- | `.rounded-{2~100}px/rpx` | 四角圆角,步长 2 |
233
- | `.rounded-t-{size}`、`.rounded-b-{size}`、`.rounded-l-{size}`、`.rounded-r-{size}` | 两边圆角 |
234
- | `.rounded-tl-{size}`、`.rounded-tr-{size}`、`.rounded-bl-{size}`、`.rounded-br-{size}` | 单角圆角 |
235
-
236
- ## 布局与定位
237
-
238
- ### 全平台
239
-
240
- | 类名 | 效果 |
241
- | --- | --- |
242
- | `.overflow-hidden` | overflow: hidden |
243
- | `.inset-0` | top/right/bottom/left 全为 0 |
244
- | `.inset-x-0` / `.inset-y-0` | 双轴归零 |
245
- | `.top-{0~100}px/rpx` | top 定位,步长 2 |
246
- | `.right-{0~100}px/rpx` | right 定位 |
247
- | `.bottom-{0~100}px/rpx` | bottom 定位 |
248
- | `.left-{0~100}px/rpx` | left 定位 |
249
- | `.-top-{2~100}px/rpx` 等 | 负值定位 |
250
- | `.z-0` ~ `.z-10` | z-index |
251
-
252
- ### 仅非 nvue
253
-
254
- | 类名 | 效果 |
255
- | --- | --- |
256
- | `.relative` | position: relative |
257
- | `.absolute` | position: absolute |
258
- | `.fixed` | position: fixed |
259
- | `.sticky` | position: sticky |
260
- | `.sticky-top` | sticky + `top: var(--window-top)` + z-index 9 |
261
- | `.sticky-bottom` | sticky + `bottom: var(--window-bottom)` + z-index 9 |
262
- | `.overflow-auto` / `.overflow-scroll` | overflow |
263
-
264
- ## 透明度
265
-
266
- | 类名 | 值 |
267
- | --- | --- |
268
- | `.opacity-0` | 0 |
269
- | `.opacity-10` ~ `.opacity-100` | 0.1 ~ 1.0,步长 10 |
270
-
271
- ## 阴影
272
-
273
- | 类名 | box-shadow |
274
- | --- | --- |
275
- | `.shadow-sm` | `0 1px 2px 0 rgba(0, 0, 0, 0.05)` |
276
- | `.shadow` | `0 1px 3px 0 rgba(0, 0, 0, 0.1)` |
277
- | `.shadow-md` | `0 4px 6px -1px rgba(0, 0, 0, 0.1)` |
278
- | `.shadow-lg` | `0 10px 15px -3px rgba(0, 0, 0, 0.1)` |
279
-
280
- ## 动画与变换
281
-
282
- ### 变换原点
283
-
284
- `.origin-{position}`:`center`、`top`、`top-right`、`right`、`bottom-right`、`bottom`、`bottom-left`、`left`、`top-left`
285
-
286
- ### 过渡(仅非 nvue)
287
-
288
- | 类名 | 效果 |
289
- | --- | --- |
290
- | `.transition-all-300` | `transition: all 300ms` |
291
-
292
- ## 常用组合示例
293
-
294
- 卡片布局:
295
-
296
- ```html
297
- <view class="flex flex-col p-16px bg-white rounded-8px shadow-sm">
298
- <text class="text-32px font-semibold text-main">标题</text>
299
- <text class="text-24px text-content mt-8px">描述内容</text>
300
- </view>
301
- ```
302
-
303
- 居加载中状态:
304
-
305
- ```html
306
- <view class="flex justify-center items-center h-200px">
307
- <text class="text-28px text-tips">加载中...</text>
308
- </view>
309
- ```
310
-
311
- 列表项(头像 + 文字):
312
-
313
- ```html
314
- <view class="flex items-center px-16px py-12px">
315
- <image class="w-80rpx h-80rpx rounded-full" :src="avatar" />
316
- <view class="flex-1 ml-12px">
317
- <text class="text-28px text-main truncate">用户名</text>
318
- <text class="text-24px text-tips">副标题</text>
319
- </view>
320
- </view>
321
- ```
322
-
323
- 吸顶导航栏:
324
-
325
- ```html
326
- <view class="sticky-top bg-white px-16px py-12px">
327
- <text class="text-32px font-bold text-main">页面标题</text>
328
- </view>
329
- ```
330
-
331
- 表单区域:
332
-
333
- ```html
334
- <view class="flex flex-col px-16px py-12px bg-white mt-8px">
335
- <view class="flex justify-between items-center py-12px border-b">
336
- <text class="text-28px text-main">标签</text>
337
- <text class="text-28px text-content">值</text>
338
- </view>
339
- </view>
340
- ```
341
-
342
- 两列等分布局:
343
-
344
- ```html
345
- <view class="flex flex-wrap">
346
- <view class="w-full flex" v-for="group in groups" :key="group.id">
347
- <view class="flex-1 p-8px" v-for="item in group.items" :key="item.id">
348
- <view class="bg-white rounded-8px p-16px">{{ item.name }}</view>
349
- </view>
350
- </view>
351
- </view>
352
- ```
353
-
354
- 底部固定操作栏:
355
-
356
- ```html
357
- <view class="fixed bottom-0 left-0 right-0 bg-white px-16px py-12px z-5">
358
- <view class="flex">
359
- <view class="flex-1 mr-8px bg-error rounded-8px py-12px text-center">
360
- <text class="text-white text-28px font-medium">取消</text>
361
- </view>
362
- <view class="flex-1 bg-primary rounded-8px py-12px text-center">
363
- <text class="text-white text-28px font-medium">确认</text>
364
- </view>
365
- </view>
366
- </view>
367
- ```
1
+ # 工具样式类
2
+
3
+ `@zfqh/uniapp` 内置一组静态 SCSS 工具类,仅覆盖 **平台差异类** 和 **使用 `$uv-*` SCSS 变量的语义色类**。间距、尺寸、字号、圆角、透明度、阴影等通用原子类需要配合 `@gmcb/vite` 提供的 unocss 插件在构建时动态生成,两者命名风格与 UnoCSS / Tailwind CSS 一致。
4
+
5
+ ## 前置依赖
6
+
7
+ 使用完整原子类能力前,需要在项目的 `vite.config.js` 中注册 unocss 插件,并传入 `blockList` 避免与内置静态类冲突:
8
+
9
+ ```js
10
+ import { defineConfig } from '@gmcb/vite';
11
+ import { unocss } from '@gmcb/vite/lib/plugins';
12
+ import { blockList } from '@gmcb/vite/lib/unocss';
13
+
14
+ export default defineConfig({
15
+ plugins: [
16
+ uni(),
17
+ unocss({
18
+ blockList,
19
+ }),
20
+ ],
21
+ });
22
+ ```
23
+
24
+ `blockList` 已预置全部内置静态类名,unocss 插件不会为这些类名生成重复 CSS。
25
+
26
+ ## 引入方式
27
+
28
+ 在项目全局样式中导入一次即可。放在 `App.vue` 的 `<style>` 块:
29
+
30
+ ```scss
31
+ @import '@zfqh/uniapp/lib/styles/index.scss';
32
+ ```
33
+
34
+ 此入口同时导入 `@gmcb/uv-ui/index.scss`,无需再单独导入 uv-ui 基础样式。
35
+
36
+ ## 内置原子类
37
+
38
+ ### Flex 布局
39
+
40
+ | 类名 | 效果 |
41
+ | --- | --- |
42
+ | `.flex` | flex 行布局 |
43
+ | `.flex-inline` | inline-flex 行布局 |
44
+ | `.flex-row` / `.flex-row-reverse` | 行方向 |
45
+ | `.flex-col` / `.flex-col-reverse` | 列方向 |
46
+ | `.flex-wrap` / `.flex-nowrap` / `.flex-wrap-reverse` | 换行控制 |
47
+ | `.flex-0` ~ `.flex-8` | `flex: 0` ~ `flex: 8` |
48
+ | `.flex-none` | `flex: 0` |
49
+ | `.items-start` / `.items-end` / `.items-center` / `.items-stretch` / `.items-baseline` | align-items |
50
+ | `.justify-start` / `.justify-end` / `.justify-center` / `.justify-between` / `.justify-around` | justify-content |
51
+
52
+ ::: info 平台差异
53
+ - H5 平台下这些类包裹在 `page` 选择器内。
54
+ - `.flex` / `.flex-inline` 的 `display: flex` / `display: inline-flex` 仅在非 APP-NVUE 平台生效,nvue 端省略 display 属性(Weex 默认 flex 布局)。
55
+ :::
56
+
57
+ ### 背景色
58
+
59
+ `.bg-{color}` 系列,颜色值读取 `$uv-*` SCSS 变量,跟随主题配置:
60
+
61
+ | 色组 | 可用类名 |
62
+ | --- | --- |
63
+ | primary | `.bg-primary`、`.bg-primary-dark`、`.bg-primary-light`、`.bg-primary-disabled` |
64
+ | warning | `.bg-warning`、`.bg-warning-dark`、`.bg-warning-light`、`.bg-warning-disabled` |
65
+ | success | `.bg-success`、`.bg-success-dark`、`.bg-success-light`、`.bg-success-disabled` |
66
+ | error | `.bg-error`、`.bg-error-dark`、`.bg-error-light`、`.bg-error-disabled` |
67
+ | info | `.bg-info`、`.bg-info-dark`、`.bg-info-light`、`.bg-info-disabled` |
68
+
69
+ 基础背景:
70
+
71
+ | 类名 | SCSS 变量 | 说明 |
72
+ | --- | --- | --- |
73
+ | `.bg` | `$uv-bg-color` | 页面背景色 |
74
+ | `.bg-light` | `$uv-bg-light-color` | 浅色背景 |
75
+ | `.bg-disabled` | `$uv-disabled-color` | 禁用态背景 |
76
+ | `.bg-border` | `$uv-border-color` | 边框色背景 |
77
+
78
+ ### 文字颜色
79
+
80
+ `.text-{color}` 系列,颜色值读取 `$uv-*` SCSS 变量:
81
+
82
+ | 色组 | 可用类名 |
83
+ | --- | --- |
84
+ | primary | `.text-primary`、`.text-primary-dark`、`.text-primary-light`、`.text-primary-disabled` |
85
+ | warning | `.text-warning`、`.text-warning-dark`、`.text-warning-light`、`.text-warning-disabled` |
86
+ | success | `.text-success`、`.text-success-dark`、`.text-success-light`、`.text-success-disabled` |
87
+ | error | `.text-error`、`.text-error-dark`、`.text-error-light`、`.text-error-disabled` |
88
+ | info | `.text-info`、`.text-info-dark`、`.text-info-light`、`.text-info-disabled` |
89
+
90
+ UI 语义色:
91
+
92
+ | 类名 | SCSS 变量 | 说明 |
93
+ | --- | --- | --- |
94
+ | `.text-main` | `$uv-main-color` | 主要文字 |
95
+ | `.text-content` | `$uv-content-color` | 正文文字 |
96
+ | `.text-tips` | `$uv-tips-color` | 辅助提示 |
97
+ | `.text-light` | `$uv-light-color` | 占位/水印 |
98
+ | `.text-border` | `$uv-border-color` | 边框色文字 |
99
+ | `.text-disabled` | `$uv-disabled-color` | 禁用态文字 |
100
+
101
+ ### 边框
102
+
103
+ | 类名 | 效果 |
104
+ | --- | --- |
105
+ | `.border` | 1px solid 边框色(`$uv-border-color`) |
106
+ | `.border-half` | 0.5px solid 边框色 |
107
+ | `.border-t` / `.border-r` / `.border-b` / `.border-l` | 单边 1px solid 边框色 |
108
+ | `.border-x` / `.border-y` | 双轴 1px solid 边框色 |
109
+
110
+ 语义色边框:
111
+
112
+ | 类名 | SCSS 变量 |
113
+ | --- | --- |
114
+ | `.border-primary` | `$uv-primary` |
115
+ | `.border-warning` | `$uv-warning` |
116
+ | `.border-success` | `$uv-success` |
117
+ | `.border-error` | `$uv-error` |
118
+ | `.border-info` | `$uv-info` |
119
+
120
+ ### 定位
121
+
122
+ | 类名 | 效果 |
123
+ | --- | --- |
124
+ | `.relative` | position: relative |
125
+ | `.absolute` | position: absolute |
126
+ | `.fixed` | position: fixed |
127
+ | `.sticky` | position: sticky |
128
+
129
+ ::: info 平台差异
130
+ H5 平台下这些类包裹在 `page` 选择器内,其他平台直接使用。
131
+ :::
132
+
133
+ ### 文本截断
134
+
135
+ **非 nvue 平台**(`text-vue.scss`):
136
+
137
+ | 类名 | 效果 |
138
+ | --- | --- |
139
+ | `.truncate` | 单行截断(overflow ellipsis + nowrap) |
140
+ | `.line-clamp-1` ~ `.line-clamp-5` | 多行截断(`-webkit-line-clamp`) |
141
+
142
+ **nvue 平台**(`text-nvue.scss`):
143
+
144
+ | 类名 | 效果 |
145
+ | --- | --- |
146
+ | `.truncate` | 单行截断(Weex `lines: 1`) |
147
+ | `.line-clamp-1` ~ `.line-clamp-5` | 多行截断(Weex `lines: n`) |
148
+
149
+ ### 全局重置
150
+
151
+ `reset-vue.scss` 在非 nvue 平台自动生效,不属于原子类,作用:
152
+
153
+ - 设置 `:root` 下的 `--window-bottom`、`--window-top`(非 H5)、`--window-height`、`--window-width` CSS 自定义属性。
154
+ - `page` 元素宽高 100%、`font-family: Microsoft YaHei`、颜色取 `$uv-main-color`、flex 列布局。
155
+ - `view`、`text`、`image` 设置 `box-sizing: border-box`。
156
+ - 修复 `.uni-scroll-view-refresher` 背景透明。
157
+ - 调整 `.ql-editor.ql-blank:before` 占位文字样式。
158
+ - 调整 `.uv-toast` 默认样式。
159
+
160
+ 除上述内置类外,其余原子类(间距、尺寸、字号、字重、行高、对齐、基础背景色、边框宽度/样式、圆角、overflow、top/right/bottom/left/inset/z-index、透明度、阴影、transform-origin、transition 等)均由 `@gmcb/vite` unocss 插件在构建时根据模板扫描动态生成,命名风格与 UnoCSS / Tailwind CSS 一致,支持 `px` 和 `rpx` 两种单位。
161
+
162
+ `blockList` 已预置全部内置静态类名,unocss 插件不会为这些类名生成重复 CSS。
163
+
164
+ ## 常用组合示例
165
+
166
+ 卡片布局:
167
+
168
+ ```html
169
+ <view class="flex flex-col p-16px bg-white rounded-8px shadow-sm">
170
+ <text class="text-32px font-semibold text-main">标题</text>
171
+ <text class="text-24px text-tips mt-8px">描述内容</text>
172
+ </view>
173
+ ```
174
+
175
+ 居加载中状态:
176
+
177
+ ```html
178
+ <view class="flex justify-center items-center h-200px">
179
+ <text class="text-28px text-tips">加载中...</text>
180
+ </view>
181
+ ```
182
+
183
+ 列表项(头像 + 文字):
184
+
185
+ ```html
186
+ <view class="flex items-center px-16px py-12px">
187
+ <image class="w-80rpx h-80rpx rounded-full" :src="avatar" />
188
+ <view class="flex-1 ml-12px">
189
+ <text class="text-28px text-main truncate">用户名</text>
190
+ <text class="text-24px text-tips">副标题</text>
191
+ </view>
192
+ </view>
193
+ ```
194
+
195
+ 吸顶导航栏:
196
+
197
+ ```html
198
+ <view class="sticky top-0 bg-light px-16px py-12px">
199
+ <text class="text-32px font-bold text-main">页面标题</text>
200
+ </view>
201
+ ```
202
+
203
+ 表单区域:
204
+
205
+ ```html
206
+ <view class="flex flex-col px-16px py-12px bg-white mt-8px">
207
+ <view class="flex justify-between items-center py-12px border-b">
208
+ <text class="text-28px text-main">标签</text>
209
+ <text class="text-28px text-content">值</text>
210
+ </view>
211
+ </view>
212
+ ```
213
+
214
+ 两列等分布局:
215
+
216
+ ```html
217
+ <view class="flex flex-wrap">
218
+ <view class="w-full flex" v-for="group in groups" :key="group.id">
219
+ <view class="flex-1 p-8px" v-for="item in group.items" :key="item.id">
220
+ <view class="bg-white rounded-8px p-16px">{{ item.name }}</view>
221
+ </view>
222
+ </view>
223
+ </view>
224
+ ```
225
+
226
+ 底部固定操作栏:
227
+
228
+ ```html
229
+ <view class="fixed bottom-0 left-0 right-0 bg-white px-16px py-12px z-5">
230
+ <view class="flex">
231
+ <view class="flex-1 mr-8px bg-error rounded-8px py-12px text-center">
232
+ <text class="text-white text-28px font-medium">取消</text>
233
+ </view>
234
+ <view class="flex-1 bg-primary rounded-8px py-12px text-center">
235
+ <text class="text-white text-28px font-medium">确认</text>
236
+ </view>
237
+ </view>
238
+ </view>
239
+ ```
@@ -58,7 +58,7 @@ const isLogin = computed(() => store.getters.isLogin);
58
58
  </script>
59
59
  ```
60
60
 
61
- 如果组件仍使用 Options API,可使用 `this.$store`。`uni.$store` 只推荐在脱离组件上下文的普通 TS 模块中使用,例如请求拦截器、导航工具、权限工具和 webview 消息处理。
61
+ 如果组件仍使用 Options API,可使用 `this.$store`。脱离组件上下文的普通 TS 模块中使用 `uni.$store`。
62
62
 
63
63
  ## 页面骨架示例
64
64
 
package/docs/faq/index.md CHANGED
@@ -5,16 +5,15 @@
5
5
  检查:
6
6
 
7
7
  1. 是否先注册 store,再注册 `@zfqh/uniapp`。
8
- 2. 是否设置了 `app.config.globalProperties.$store = store`。
9
- 3. token 是否位于 `uni.$store.state.login.info.token`。
8
+ 2. token 是否位于 `store.state.login.info.token`。
10
9
 
11
- 这里检查 `uni.$store` 是因为请求拦截器属于普通 TS 模块。组件或 hooks 内读取同一份状态时应使用 `useStore()`。
10
+ 请求拦截器属于普通 TS 模块,内部会从 store 中读取状态。组件或 hooks 内读取同一份状态时应使用 `useStore()`。
12
11
 
13
12
  ## 401 后没有退出登录
14
13
 
15
14
  检查:
16
15
 
17
- 1. `uni.$store.state.login.info.token` 是否存在。
16
+ 1. `store.state.login.info.token` 是否存在。
18
17
  2. store 是否实现 `dispatch('logout')`。
19
18
  3. 请求配置是否设置了 `custom.reLogin: false` 或 `custom.needLogin: false`。
20
19
 
@@ -31,12 +30,12 @@
31
30
 
32
31
  检查:
33
32
 
34
- 1. `uni.$store.getters.isLogin` 是否正确。
33
+ 1. `store.getters.isLogin` 是否正确。
35
34
  2. `page.needLoginPages` 是否包含目标页。
36
35
  3. `getPage('login')` 是否能返回登录页路径。
37
36
  4. 当前跳转是否显式传入 `needLogin: false`。
38
37
 
39
- `navigate` 内部读取 `uni.$store.getters.isLogin`。如果页面组件里自己判断登录态,请使用 `import { useStore } from 'vuex'`。
38
+ `navigate` 内部读取 `store.getters.isLogin`。如果页面组件里自己判断登录态,请使用 `import { useStore } from 'vuex'`。
40
39
 
41
40
  ## tabBar 页面 navigateTo 失败
42
41