@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
package/CHANGELOG.md CHANGED
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [0.1.2](http://10.10.10.16/caoben/front-end/compare/@zfqh/uniapp@0.1.1...@zfqh/uniapp@0.1.2) (2026-06-01)
7
+
8
+ **Note:** Version bump only for package @zfqh/uniapp
9
+
10
+
11
+
12
+
13
+
6
14
  ## 0.1.1 (2026-05-31)
7
15
 
8
16
  **Note:** Version bump only for package @zfqh/uniapp
@@ -28,7 +28,7 @@ import { getTencentToken, getDictData } from '@zfqh/uniapp/lib/apis/core';
28
28
  - `GET` 会把 data 作为 query params。
29
29
  - `POST`、`PUT`、`DELETE` 会把 data 作为请求体或方法参数传给底层请求实例。
30
30
  - URL 中的 `:id`、`/:id` 会由 `formatURL` 使用 data 同名字段替换,并从 data 中删除该字段。
31
- - 响应拦截器要求后端成功码为 `code == 0`;失败时会按配置弹 toast,并在 401 时触发 `uni.$store.dispatch('logout')`。
31
+ - 响应拦截器要求后端成功码为 `code == 0`;失败时会按配置弹 toast,并在 401 时触发 `store.dispatch('logout')`。
32
32
 
33
33
  ## 接口清单
34
34
 
@@ -26,9 +26,9 @@ const request = uni.$uv.http;
26
26
 
27
27
  | Header | 来源 | 默认值 |
28
28
  | --- | --- | --- |
29
- | `Authorization` | `uni.$store.state.login.info.token` | 无 |
30
- | `Tenant-Id` | `uni.$store.state.login.info.tenantId` | `1` |
31
- | `X-Language` | `uni.$store.state.system.info.appLanguage` 映射到 `LANGUAGE` | 无 |
29
+ | `Authorization` | `store.state.login.info.token` | 无 |
30
+ | `Tenant-Id` | `store.state.login.info.tenantId` | `1` |
31
+ | `X-Language` | `store.state.system.info.appLanguage` 映射到 `LANGUAGE` | 无 |
32
32
  | `Channel` | `query.channel` 或 `config.app.channel` | `config.app.channel` |
33
33
 
34
34
  业务请求的 `baseURL` 来自 `config.api.baseUrl`。
@@ -274,7 +274,7 @@ GET('/app-api/demo/check', {}, {
274
274
  | 阶段 | 行为 |
275
275
  | --- | --- |
276
276
  | request | 当 `log.request` 为 true 时打印请求 URL 和配置。 |
277
- | request | 如果存在 `uni.$store.state.login.info.token`,注入 `Authorization: Bearer <token>`。 |
277
+ | request | 如果存在 `store.state.login.info.token`,注入 `Authorization: Bearer <token>`。 |
278
278
  | response | 当 `log.response` 为 true 时打印响应数据。 |
279
279
  | response | 当 `data.code != 0` 时将其作为错误响应处理。 |
280
280
  | error | 补齐非标准错误的 `response`、`status`、`data.msg`。 |
@@ -283,11 +283,11 @@ GET('/app-api/demo/check', {}, {
283
283
  `401` 处理依赖:
284
284
 
285
285
  ```ts
286
- uni.$store.state.login.info.token
287
- uni.$store.dispatch('logout')
286
+ store.state.login.info.token
287
+ store.dispatch('logout')
288
288
  ```
289
289
 
290
- 请求拦截器属于普通 TS 模块,不在 Vue 组件 setup 上下文中,因此这里使用 `uni.$store`。如果是在组件或 hooks 中读取同一份登录态,请使用:
290
+ 请求拦截器属于普通 TS 模块,不在 Vue 组件 setup 上下文中,因此直接引入 store 实例。如果是在组件或 hooks 中读取同一份登录态,请使用:
291
291
 
292
292
  ```ts
293
293
  import { useStore } from 'vuex';
@@ -322,8 +322,8 @@ const request = uni.$uv.http;
322
322
 
323
323
  | Header | 来源 |
324
324
  | --- | --- |
325
- | `Tenant-Id` | `uni.$store.state.login.info.tenantId`,默认 `1`。 |
326
- | `X-Language` | `uni.$store.state.system.info.appLanguage` 映射到 `LANGUAGE`。 |
325
+ | `Tenant-Id` | `store.state.login.info.tenantId`,默认 `1`。 |
326
+ | `X-Language` | `store.state.system.info.appLanguage` 映射到 `LANGUAGE`。 |
327
327
  | `Channel` | `query.channel`,没有 query 渠道时回退到 `config.app.channel`。 |
328
328
 
329
329
  业务请求的 `baseURL` 来自:
@@ -283,7 +283,6 @@ defineConfig({
283
283
 
284
284
  ```ts
285
285
  import { getTencentToken } from '@zfqh/uniapp/lib/apis';
286
- import store from '@/store';
287
286
 
288
287
  defineConfig({
289
288
  upload: {
@@ -296,7 +295,7 @@ defineConfig({
296
295
  create_time: data.createTime,
297
296
  expire_time: data.expirationTime,
298
297
  bucket: data.bucket,
299
- region: store.state.storeConfig.isGlobalAccelerate ? 'accelerate' : data.region,
298
+ region: uni.$store.state.storeConfig.isGlobalAccelerate ? 'accelerate' : data.region,
300
299
  };
301
300
  },
302
301
  },
@@ -10,7 +10,7 @@ import { useStore } from 'vuex';
10
10
  const store = useStore();
11
11
  ```
12
12
 
13
- `uni.$store` 主要用于请求、导航、权限、webview 消息等普通模块。
13
+ 普通 TS 模块中使用 `uni.$store`。
14
14
 
15
15
  | Hook | 说明 |
16
16
  | --- | --- |
@@ -44,7 +44,7 @@ import { useOverlay, usePopup, useVersion, useI18n } from '@zfqh/uniapp';
44
44
 
45
45
  ## Store 用法
46
46
 
47
- Hooks 运行在组件 setup 上下文中,需要读取 Vuex 时请使用 `useStore()`,不要直接读取 `uni.$store`:
47
+ Hooks 运行在组件 setup 上下文中,需要读取 Vuex 时请使用 `useStore()`:
48
48
 
49
49
  ```ts
50
50
  import { computed } from 'vue';
@@ -57,7 +57,7 @@ export function useUserName() {
57
57
  }
58
58
  ```
59
59
 
60
- `uni.$store` 主要给请求、导航、权限、webview 消息等非组件上下文的普通模块使用。完整约定见 [Store 使用位置](./../../guide/project-frame#store-使用位置)。
60
+ 普通 TS 模块中使用 `uni.$store`。完整约定见 [Store 使用位置](./../../guide/project-frame#store-使用位置)。
61
61
 
62
62
  ## useOverlay
63
63
 
@@ -172,7 +172,7 @@ const { t, locale } = useI18n();
172
172
 
173
173
  | 平台 | 行为 |
174
174
  | --- | --- |
175
- | APP-NVUE | 使用内部 `inject('t')` 和 `showLocale`。 |
175
+ | APP-NVUE | 使用内部 `inject('t')` 和 `getLocaleMessage`。 |
176
176
  | 其他平台 | 透传 `vue-i18n` 的 `useI18n`。 |
177
177
 
178
178
  ```vue
package/docs/api/index.md CHANGED
@@ -21,14 +21,19 @@ app.use(uniapp);
21
21
  安装逻辑:
22
22
 
23
23
  - 小程序端混入 `deep`。
24
- - 将 `app.config.globalProperties.$store` 挂到 `uni.$store`。
25
24
 
26
- `uni.$store` 用于请求、导航、权限、webview 消息等非组件上下文的普通模块。组件的 Composition API 和 hooks 中请使用 Vuex 官方入口:
25
+ Store 使用入口请按上下文区分:
27
26
 
28
27
  ```ts
28
+ // Composition API / <script setup>
29
29
  import { useStore } from 'vuex';
30
-
31
30
  const store = useStore();
31
+
32
+ // Options API 组件
33
+ this.$store
34
+
35
+ // 普通 TS 模块
36
+ uni.$store
32
37
  ```
33
38
 
34
39
  ## Hooks
@@ -16,13 +16,12 @@ App.vue 全局生命周期 mixin。发布路径:`@zfqh/uniapp/lib/mixins/app`
16
16
 
17
17
  ```ts
18
18
  import app from '@zfqh/uniapp/lib/mixins/app';
19
- import store from '@/store';
20
19
 
21
20
  export default {
22
21
  mixins: [app],
23
22
  onLaunch() {
24
23
  if (store.getters.isLogin) {
25
- store.dispatch('getInfo');
24
+ this.$store.dispatch('getInfo');
26
25
  }
27
26
  },
28
27
  };
@@ -20,8 +20,6 @@ const store = createStore({
20
20
  app,
21
21
  },
22
22
  });
23
-
24
- uni.$store = store;
25
23
  ```
26
24
 
27
25
  ```ts
@@ -2,7 +2,7 @@
2
2
 
3
3
  模块发布路径为 `@zfqh/uniapp/lib/modules`。根入口没有直接导出这些模块;如果业务项目要复用,请深度引入 `@zfqh/uniapp/lib/modules/&lt;name&gt;` 或从 `@zfqh/uniapp/lib/modules` 取具名导出。
4
4
 
5
- 这些模块默认假设项目使用 Vuex 4,并且插件安装后会把 Vuex store 暴露到 `uni.$store`,请求、导航、webview 消息等普通模块会读取它。组件和 hooks 中读取 Vuex 时仍应使用 `useStore()` 或 `this.$store`。
5
+ 这些模块默认假设项目使用 Vuex 4。请求、导航、webview 消息等普通模块会从 store 中读取状态。组件和 hooks 中读取 Vuex 时仍应使用 `useStore()` 或 `this.$store`。
6
6
 
7
7
  ## 基本使用
8
8
 
@@ -205,7 +205,6 @@ defineConfig({
205
205
 
206
206
  ```ts
207
207
  import { getTencentToken } from '@zfqh/uniapp/lib/apis';
208
- import store from '@/store';
209
208
 
210
209
  defineConfig({
211
210
  upload: {
@@ -218,7 +217,7 @@ defineConfig({
218
217
  create_time: data.createTime,
219
218
  expire_time: data.expirationTime,
220
219
  bucket: data.bucket,
221
- region: store.state.storeConfig.isGlobalAccelerate ? 'accelerate' : data.region,
220
+ region: uni.$store.state.storeConfig.isGlobalAccelerate ? 'accelerate' : data.region,
222
221
  };
223
222
  },
224
223
  },
@@ -12,7 +12,7 @@
12
12
  | [cos](./cos) | 腾讯云 COS 上传与图片压缩 URL。 |
13
13
  | [debounce](./debounce) | 防抖类和默认实例。 |
14
14
  | [file](./file) | URL、dataURL、base64、File、本地路径互转。 |
15
- | [locale](./locale) | 当前语言、回退语言和 nvue 文案读取。 |
15
+ | [locale](./locale) | 当前语言、回退语言、vue-i18n 实例创建和 nvue 文案读取。 |
16
16
  | [message](./message) | webview 与宿主环境通信的消息类型常量。 |
17
17
  | [navigate](./navigate) | 页面跳转、登录拦截、tabBar、webview、自定义协议。 |
18
18
  | [pages](./pages) | 根据页面配置生成页面集合。 |
@@ -1,32 +1,68 @@
1
- # 多语言辅助
2
-
3
- ::: tip 工具模块
4
- `@zfqh/uniapp/lib/utils/locale`
5
- :::
6
-
7
- 提供当前语言、回退语言和 nvue 可用的简易文案读取方法。
8
-
9
- ## 平台兼容性
10
-
11
- | App | H5 | 微信小程序 | 其他小程序 | WebView |
12
- | --- | --- | --- | --- | --- |
13
- | √ | √ | √ | 视平台 API 而定 | 视运行容器而定 |
14
-
15
- ## 基本使用
16
-
17
- ```ts
18
- import { defaultLocale, fallbackLocale, showLocale } from '@zfqh/uniapp';
19
- ```
20
-
21
- 具体方法、参数语义和返回值以发布包类型为准;下方表格按 `@zfqh/uniapp/lib/utils/locale` 的导出整理。
22
-
23
- ## API
24
-
25
- 发布路径:`@zfqh/uniapp/lib/utils/locale`
26
-
27
- | 名称 | 签名/声明 | 说明 |
28
- | --- | --- | --- |
29
- | `defaultLocale` | `export const defaultLocale = uni.getLocale();` | 默认语言。 |
30
- | `fallbackLocale` | `export const fallbackLocale = 'zh-Hans';` | 回退语言。 |
31
- | `showLocale` | `export function showLocale(key, values) {` | nvue 场景下的简易 i18n 文案获取函数。 |
32
-
1
+ # 多语言辅助
2
+
3
+ ::: tip 工具模块
4
+ `@zfqh/uniapp/lib/utils/locale`
5
+ :::
6
+
7
+ 提供当前语言、回退语言、vue-i18n 实例创建和 nvue 可用的简易文案读取方法。
8
+
9
+ ## 平台兼容性
10
+
11
+ | App | H5 | 微信小程序 | 其他小程序 | WebView |
12
+ | --- | --- | --- | --- | --- |
13
+ | √ | √ | √ | 视平台 API 而定 | 视运行容器而定 |
14
+
15
+ ## 基本使用
16
+
17
+ ```ts
18
+ import { defaultLocale, fallbackLocale, createI18n, getLocaleMessage } from '@zfqh/uniapp';
19
+ ```
20
+
21
+ 具体方法、参数语义和返回值以发布包类型为准;下方表格按 `@zfqh/uniapp/lib/utils/locale` 的导出整理。
22
+
23
+ ## 创建 vue-i18n 实例
24
+
25
+ 在 `locale/index.js` 中调用 `createI18n` 创建实例并导出:
26
+
27
+ ```js
28
+ import { createI18n, defaultLocale, fallbackLocale } from '@zfqh/uniapp';
29
+ import messages from './messages';
30
+
31
+ export const i18n = createI18n({
32
+ locale: defaultLocale,
33
+ fallbackLocale,
34
+ messages,
35
+ });
36
+ ```
37
+
38
+ `messages.js` 按语言键组织翻译文件:
39
+
40
+ ```js
41
+ import zhHans from './zh-Hans.json';
42
+ import en from './en.json';
43
+
44
+ export default {
45
+ 'zh-Hans': zhHans,
46
+ en,
47
+ };
48
+ ```
49
+
50
+ 实例创建后可在 App 启动时注册:
51
+
52
+ ```js
53
+ import { i18n } from './locale';
54
+
55
+ const app = createApp(App);
56
+ app.use(i18n);
57
+ ```
58
+
59
+ ## API
60
+
61
+ 发布路径:`@zfqh/uniapp/lib/utils/locale`
62
+
63
+ | 名称 | 签名/声明 | 说明 |
64
+ | --- | --- | --- |
65
+ | `defaultLocale` | `export const defaultLocale = uni.getLocale();` | 默认语言。 |
66
+ | `fallbackLocale` | `export const fallbackLocale = 'zh-Hans';` | 回退语言。 |
67
+ | `createI18n` | `export function createI18n(opts: I18nOptions)` | 创建 vue-i18n 实例,返回实例。 |
68
+ | `getLocaleMessage` | `export function getLocaleMessage(key: string): string` | 通过 key 获取当前语言文案,nvue 场景下的简易 i18n 文案读取。未匹配时返回 key 本身。 |
@@ -18,7 +18,7 @@
18
18
  import { navigate } from '@zfqh/uniapp';
19
19
  ```
20
20
 
21
- 导航工具脱离组件 setup 上下文,内部会通过 `uni.$store.getters.isLogin` 判断登录态。组件或 hooks 中判断登录态时请使用 `useStore()`。
21
+ 导航工具脱离组件 setup 上下文,内部会通过 `store.getters.isLogin` 判断登录态。组件或 hooks 中判断登录态时请使用 `useStore()`。
22
22
 
23
23
  ## 常用跳转
24
24
 
@@ -192,10 +192,10 @@ navigate.navigateTo({
192
192
  登录判断依赖:
193
193
 
194
194
  ```ts
195
- uni.$store.getters.isLogin
195
+ store.getters.isLogin
196
196
  ```
197
197
 
198
- `navigate` 是普通工具模块,脱离组件 setup 上下文,所以读取 `uni.$store`。如果是在组件或 hooks 中判断登录态,请使用:
198
+ `navigate` 是普通工具模块,脱离组件 setup 上下文,所以直接引入 store 实例。如果是在组件或 hooks 中判断登录态,请使用:
199
199
 
200
200
  ```ts
201
201
  import { computed } from 'vue';
@@ -124,7 +124,7 @@ defineConfig({
124
124
 
125
125
  `needLogin` 字段控制页面是否需要登录才能访问,默认为 `false`。
126
126
 
127
- 当 `needLogin: true` 时,`navigate` 会检查 `uni.$store.getters.isLogin`,如果未登录则自动跳转到 `getPage('login')` 返回的登录页路径。
127
+ 当 `needLogin: true` 时,`navigate` 会检查 `store.getters.isLogin`,如果未登录则自动跳转到 `getPage('login')` 返回的登录页路径。
128
128
 
129
129
  ```json
130
130
  {
@@ -18,7 +18,7 @@
18
18
  import { formatURL, createInterceptors, createRequest } from '@zfqh/uniapp';
19
19
  ```
20
20
 
21
- 请求工具脱离组件 setup 上下文,拦截器内部会通过 `uni.$store` 读取 token 并处理 `401`。组件或 hooks 中读取 store 时请使用 `useStore()`。
21
+ 请求工具脱离组件 setup 上下文,拦截器内部会从 store 中读取 token 并处理 `401`。组件或 hooks 中读取 store 时请使用 `useStore()`。
22
22
 
23
23
  具体方法、参数语义和返回值以发布包类型为准;下方表格按 `@zfqh/uniapp/lib/utils/request` 的导出整理。
24
24
 
@@ -41,7 +41,7 @@ import { useStore } from 'vuex';
41
41
  const store = useStore();
42
42
  ```
43
43
 
44
- Options API 组件可使用 `this.$store`。`uni.$store` 主要给请求、导航、权限、webview 消息等普通 TS 模块使用,不建议作为组件 setup 或 hooks 的首选入口。
44
+ Options API 组件可使用 `this.$store`。普通 TS 模块中使用 `uni.$store`。
45
45
 
46
46
  ## 组件分类
47
47