@zfqh/uniapp 0.1.1

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 (310) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/LICENSE +21 -0
  3. package/README.md +39 -0
  4. package/docs/api/apis/core.md +189 -0
  5. package/docs/api/apis/index.md +82 -0
  6. package/docs/api/apis/request.md +369 -0
  7. package/docs/api/configs/api.md +32 -0
  8. package/docs/api/configs/app.md +43 -0
  9. package/docs/api/configs/brand.md +43 -0
  10. package/docs/api/configs/cdn.md +35 -0
  11. package/docs/api/configs/color.md +144 -0
  12. package/docs/api/configs/env.md +120 -0
  13. package/docs/api/configs/index.md +394 -0
  14. package/docs/api/configs/link.md +33 -0
  15. package/docs/api/configs/log.md +27 -0
  16. package/docs/api/configs/mp.md +34 -0
  17. package/docs/api/configs/navigate.md +27 -0
  18. package/docs/api/configs/page.md +32 -0
  19. package/docs/api/configs/path.md +27 -0
  20. package/docs/api/configs/storage.md +24 -0
  21. package/docs/api/configs/tabbar.md +29 -0
  22. package/docs/api/configs/toast.md +35 -0
  23. package/docs/api/configs/update.md +25 -0
  24. package/docs/api/configs/upload.md +45 -0
  25. package/docs/api/configs/ver.md +32 -0
  26. package/docs/api/configs/web.md +28 -0
  27. package/docs/api/hooks/index.md +182 -0
  28. package/docs/api/hooks/useI18n.md +27 -0
  29. package/docs/api/hooks/useOverlay.md +37 -0
  30. package/docs/api/hooks/usePopup.md +35 -0
  31. package/docs/api/hooks/useVersion.md +23 -0
  32. package/docs/api/index.md +269 -0
  33. package/docs/api/mixins/app.md +29 -0
  34. package/docs/api/mixins/badge.md +23 -0
  35. package/docs/api/mixins/debounce.md +32 -0
  36. package/docs/api/mixins/deep.md +29 -0
  37. package/docs/api/mixins/index.md +23 -0
  38. package/docs/api/mixins/login.md +22 -0
  39. package/docs/api/mixins/model.md +26 -0
  40. package/docs/api/mixins/redirect.md +26 -0
  41. package/docs/api/mixins/share.md +29 -0
  42. package/docs/api/mixins/show.md +27 -0
  43. package/docs/api/mixins/webview.md +27 -0
  44. package/docs/api/modules/app.md +30 -0
  45. package/docs/api/modules/dict.md +28 -0
  46. package/docs/api/modules/im.md +22 -0
  47. package/docs/api/modules/index.md +44 -0
  48. package/docs/api/modules/launch.md +26 -0
  49. package/docs/api/modules/location.md +25 -0
  50. package/docs/api/modules/login.md +35 -0
  51. package/docs/api/modules/network.md +26 -0
  52. package/docs/api/modules/system.md +29 -0
  53. package/docs/api/utils/audio.md +84 -0
  54. package/docs/api/utils/consts.md +201 -0
  55. package/docs/api/utils/cos.md +269 -0
  56. package/docs/api/utils/debounce.md +89 -0
  57. package/docs/api/utils/file.md +78 -0
  58. package/docs/api/utils/index.md +547 -0
  59. package/docs/api/utils/locale.md +32 -0
  60. package/docs/api/utils/message.md +81 -0
  61. package/docs/api/utils/navigate.md +267 -0
  62. package/docs/api/utils/pages.md +205 -0
  63. package/docs/api/utils/permission.md +28 -0
  64. package/docs/api/utils/permit.md +62 -0
  65. package/docs/api/utils/query.md +89 -0
  66. package/docs/api/utils/request.md +34 -0
  67. package/docs/api/utils/storage.md +145 -0
  68. package/docs/api/utils/subscribe.md +77 -0
  69. package/docs/api/utils/throttle.md +101 -0
  70. package/docs/api/utils/toast.md +164 -0
  71. package/docs/api/utils/uni.md +28 -0
  72. package/docs/api/utils/update.md +165 -0
  73. package/docs/components/g-back-button.md +76 -0
  74. package/docs/components/g-checkbox-list.md +101 -0
  75. package/docs/components/g-container.md +93 -0
  76. package/docs/components/g-data-list.md +106 -0
  77. package/docs/components/g-dot-text.md +79 -0
  78. package/docs/components/g-env.md +75 -0
  79. package/docs/components/g-float.md +83 -0
  80. package/docs/components/g-grid-image.md +91 -0
  81. package/docs/components/g-grid-swiper.md +99 -0
  82. package/docs/components/g-icon.md +106 -0
  83. package/docs/components/g-mask.md +82 -0
  84. package/docs/components/g-money.md +90 -0
  85. package/docs/components/g-more.md +78 -0
  86. package/docs/components/g-page-container.md +170 -0
  87. package/docs/components/g-permission-popup.md +117 -0
  88. package/docs/components/g-polyline-chat.md +102 -0
  89. package/docs/components/g-polyline-view.md +67 -0
  90. package/docs/components/g-popup.md +144 -0
  91. package/docs/components/g-refresh-view.md +118 -0
  92. package/docs/components/g-render-image.md +83 -0
  93. package/docs/components/g-search.md +120 -0
  94. package/docs/components/g-share-photo.md +77 -0
  95. package/docs/components/g-share-view.md +83 -0
  96. package/docs/components/g-share-weixin.md +81 -0
  97. package/docs/components/g-skeleton-view.md +71 -0
  98. package/docs/components/g-skeleton.md +64 -0
  99. package/docs/components/g-tag-editor.md +134 -0
  100. package/docs/components/g-timer.md +72 -0
  101. package/docs/components/g-trtc-room.md +116 -0
  102. package/docs/components/g-trtc-tui.md +84 -0
  103. package/docs/components/g-trtc.md +124 -0
  104. package/docs/components/g-upload.md +117 -0
  105. package/docs/components/g-waterfall.md +84 -0
  106. package/docs/components/index.md +109 -0
  107. package/docs/components/styles/base-styles.md +367 -0
  108. package/docs/components/styles/global-vars.md +150 -0
  109. package/docs/components/usage.md +112 -0
  110. package/docs/faq/index.md +78 -0
  111. package/docs/guide/getting-started.md +195 -0
  112. package/docs/guide/project-frame.md +297 -0
  113. package/docs/index.md +80 -0
  114. package/lib/apis/core.d.ts +12 -0
  115. package/lib/apis/core.js +13 -0
  116. package/lib/apis/index.d.ts +2 -0
  117. package/lib/apis/index.js +2 -0
  118. package/lib/apis/request.d.ts +4 -0
  119. package/lib/apis/request.js +27 -0
  120. package/lib/components/g-back-button/g-back-button.vue +141 -0
  121. package/lib/components/g-checkbox-list/g-checkbox-list.vue +156 -0
  122. package/lib/components/g-container/g-container.vue +159 -0
  123. package/lib/components/g-data-list/g-data-list.vue +192 -0
  124. package/lib/components/g-dot-text/g-dot-text.vue +114 -0
  125. package/lib/components/g-env/g-env.vue +123 -0
  126. package/lib/components/g-float/g-float.vue +131 -0
  127. package/lib/components/g-grid-image/g-grid-image.vue +84 -0
  128. package/lib/components/g-grid-swiper/g-grid-swiper.vue +224 -0
  129. package/lib/components/g-icon/g-icon.vue +72 -0
  130. package/lib/components/g-mask/g-mask.vue +126 -0
  131. package/lib/components/g-money/g-money.vue +174 -0
  132. package/lib/components/g-more/g-more.vue +68 -0
  133. package/lib/components/g-page-container/g-page-container.vue +470 -0
  134. package/lib/components/g-permission-popup/g-permission-popup.vue +80 -0
  135. package/lib/components/g-polyline-chat/g-polyline-chat.vue +255 -0
  136. package/lib/components/g-polyline-view/g-polyline-view.vue +104 -0
  137. package/lib/components/g-popup/g-popup.vue +449 -0
  138. package/lib/components/g-refresh-view/g-refresh-view.vue +213 -0
  139. package/lib/components/g-render-image/g-render-image.vue +222 -0
  140. package/lib/components/g-search/g-search.vue +274 -0
  141. package/lib/components/g-share-photo/g-share-photo.vue +75 -0
  142. package/lib/components/g-share-view/g-share-view.vue +157 -0
  143. package/lib/components/g-share-weixin/g-share-weixin.vue +106 -0
  144. package/lib/components/g-skeleton/g-skeleton.vue +55 -0
  145. package/lib/components/g-skeleton-view/g-skeleton-view.vue +78 -0
  146. package/lib/components/g-tag-editor/g-tag-editor.vue +482 -0
  147. package/lib/components/g-timer/g-timer.vue +61 -0
  148. package/lib/components/g-trtc/g-trtc.vue +347 -0
  149. package/lib/components/g-trtc-room/g-trtc-room.vue +524 -0
  150. package/lib/components/g-trtc-room/iconfont.scss +59 -0
  151. package/lib/components/g-trtc-tui/g-trtc-tui.vue +245 -0
  152. package/lib/components/g-upload/g-upload.vue +294 -0
  153. package/lib/components/g-waterfall/g-waterfall.vue +101 -0
  154. package/lib/configs/api.d.ts +7 -0
  155. package/lib/configs/api.js +6 -0
  156. package/lib/configs/app.d.ts +26 -0
  157. package/lib/configs/app.js +50 -0
  158. package/lib/configs/brand.d.ts +22 -0
  159. package/lib/configs/brand.js +26 -0
  160. package/lib/configs/cdn.d.ts +13 -0
  161. package/lib/configs/cdn.js +12 -0
  162. package/lib/configs/color.d.ts +62 -0
  163. package/lib/configs/color.js +66 -0
  164. package/lib/configs/env.d.ts +37 -0
  165. package/lib/configs/env.js +71 -0
  166. package/lib/configs/index.d.ts +170 -0
  167. package/lib/configs/index.js +82 -0
  168. package/lib/configs/link.d.ts +11 -0
  169. package/lib/configs/link.js +3 -0
  170. package/lib/configs/log.d.ts +9 -0
  171. package/lib/configs/log.js +8 -0
  172. package/lib/configs/mp.d.ts +15 -0
  173. package/lib/configs/mp.js +9 -0
  174. package/lib/configs/navigate.d.ts +17 -0
  175. package/lib/configs/navigate.js +5 -0
  176. package/lib/configs/page.d.ts +18 -0
  177. package/lib/configs/page.js +14 -0
  178. package/lib/configs/path.d.ts +11 -0
  179. package/lib/configs/path.js +10 -0
  180. package/lib/configs/storage.d.ts +7 -0
  181. package/lib/configs/storage.js +6 -0
  182. package/lib/configs/tabbar.d.ts +7 -0
  183. package/lib/configs/tabbar.js +6 -0
  184. package/lib/configs/toast.d.ts +18 -0
  185. package/lib/configs/toast.js +29 -0
  186. package/lib/configs/update.d.ts +45 -0
  187. package/lib/configs/update.js +6 -0
  188. package/lib/configs/upload.d.ts +30 -0
  189. package/lib/configs/upload.js +7 -0
  190. package/lib/configs/ver.d.ts +8 -0
  191. package/lib/configs/ver.js +28 -0
  192. package/lib/configs/web.d.ts +5 -0
  193. package/lib/configs/web.js +2 -0
  194. package/lib/hooks/index.d.ts +4 -0
  195. package/lib/hooks/index.js +4 -0
  196. package/lib/hooks/useI18n.d.ts +2 -0
  197. package/lib/hooks/useI18n.js +19 -0
  198. package/lib/hooks/useOverlay.d.ts +1 -0
  199. package/lib/hooks/useOverlay.js +17 -0
  200. package/lib/hooks/usePopup.d.ts +1 -0
  201. package/lib/hooks/usePopup.js +14 -0
  202. package/lib/hooks/useVersion.d.ts +6 -0
  203. package/lib/hooks/useVersion.js +21 -0
  204. package/lib/index.d.ts +26 -0
  205. package/lib/index.js +33 -0
  206. package/lib/mixins/app.d.ts +14 -0
  207. package/lib/mixins/app.js +105 -0
  208. package/lib/mixins/badge.d.ts +24 -0
  209. package/lib/mixins/badge.js +44 -0
  210. package/lib/mixins/debounce.d.ts +6 -0
  211. package/lib/mixins/debounce.js +11 -0
  212. package/lib/mixins/deep.d.ts +6 -0
  213. package/lib/mixins/deep.js +8 -0
  214. package/lib/mixins/index.d.ts +8 -0
  215. package/lib/mixins/index.js +8 -0
  216. package/lib/mixins/login.d.ts +4 -0
  217. package/lib/mixins/login.js +25 -0
  218. package/lib/mixins/model.d.ts +22 -0
  219. package/lib/mixins/model.js +29 -0
  220. package/lib/mixins/redirect.d.ts +8 -0
  221. package/lib/mixins/redirect.js +94 -0
  222. package/lib/mixins/share.d.ts +15 -0
  223. package/lib/mixins/share.js +55 -0
  224. package/lib/mixins/show.d.ts +9 -0
  225. package/lib/mixins/show.js +16 -0
  226. package/lib/mixins/webview.d.ts +26 -0
  227. package/lib/mixins/webview.js +225 -0
  228. package/lib/modules/app.d.ts +5 -0
  229. package/lib/modules/app.js +19 -0
  230. package/lib/modules/dict.d.ts +8 -0
  231. package/lib/modules/dict.js +43 -0
  232. package/lib/modules/im.d.ts +6 -0
  233. package/lib/modules/im.js +105 -0
  234. package/lib/modules/index.d.ts +8 -0
  235. package/lib/modules/index.js +8 -0
  236. package/lib/modules/launch.d.ts +5 -0
  237. package/lib/modules/launch.js +32 -0
  238. package/lib/modules/location.d.ts +5 -0
  239. package/lib/modules/location.js +57 -0
  240. package/lib/modules/login.d.ts +5 -0
  241. package/lib/modules/login.js +72 -0
  242. package/lib/modules/network.d.ts +5 -0
  243. package/lib/modules/network.js +39 -0
  244. package/lib/modules/system.d.ts +5 -0
  245. package/lib/modules/system.js +65 -0
  246. package/lib/styles/animate-vue.scss +3 -0
  247. package/lib/styles/animate.scss +27 -0
  248. package/lib/styles/bg-vue.scss +21 -0
  249. package/lib/styles/bg.scss +93 -0
  250. package/lib/styles/border.scss +218 -0
  251. package/lib/styles/flex-nvue.scss +64 -0
  252. package/lib/styles/flex-vue.scss +75 -0
  253. package/lib/styles/font.scss +59 -0
  254. package/lib/styles/index.scss +25 -0
  255. package/lib/styles/layout-nvue.scss +24 -0
  256. package/lib/styles/layout-vue.scss +30 -0
  257. package/lib/styles/layout.scss +76 -0
  258. package/lib/styles/opacity.scss +10 -0
  259. package/lib/styles/reset-vue.scss +46 -0
  260. package/lib/styles/shadow.scss +12 -0
  261. package/lib/styles/sizing-vue.scss +21 -0
  262. package/lib/styles/sizing.scss +21 -0
  263. package/lib/styles/spacing.scss +234 -0
  264. package/lib/styles/text-nvue.scss +21 -0
  265. package/lib/styles/text-vue.scss +70 -0
  266. package/lib/styles/text.scss +122 -0
  267. package/lib/styles/var.module.scss +29 -0
  268. package/lib/utils/audio.d.ts +14 -0
  269. package/lib/utils/audio.js +43 -0
  270. package/lib/utils/consts.d.ts +30 -0
  271. package/lib/utils/consts.js +52 -0
  272. package/lib/utils/cos.d.ts +15 -0
  273. package/lib/utils/cos.js +140 -0
  274. package/lib/utils/debounce.d.ts +2 -0
  275. package/lib/utils/debounce.js +30 -0
  276. package/lib/utils/file.d.ts +28 -0
  277. package/lib/utils/file.js +292 -0
  278. package/lib/utils/index.d.ts +166 -0
  279. package/lib/utils/index.js +485 -0
  280. package/lib/utils/locale.d.ts +6 -0
  281. package/lib/utils/locale.js +19 -0
  282. package/lib/utils/message.d.ts +9 -0
  283. package/lib/utils/message.js +63 -0
  284. package/lib/utils/navigate.d.ts +27 -0
  285. package/lib/utils/navigate.js +183 -0
  286. package/lib/utils/pages.d.ts +21 -0
  287. package/lib/utils/pages.js +79 -0
  288. package/lib/utils/permission.d.ts +16 -0
  289. package/lib/utils/permission.js +291 -0
  290. package/lib/utils/permit.d.ts +30 -0
  291. package/lib/utils/permit.js +181 -0
  292. package/lib/utils/query.d.ts +13 -0
  293. package/lib/utils/query.js +14 -0
  294. package/lib/utils/request.d.ts +8 -0
  295. package/lib/utils/request.js +126 -0
  296. package/lib/utils/storage.d.ts +53 -0
  297. package/lib/utils/storage.js +145 -0
  298. package/lib/utils/subscribe.d.ts +7 -0
  299. package/lib/utils/subscribe.js +94 -0
  300. package/lib/utils/throttle.d.ts +2 -0
  301. package/lib/utils/throttle.js +32 -0
  302. package/lib/utils/toast.d.ts +17 -0
  303. package/lib/utils/toast.js +66 -0
  304. package/lib/utils/uni.d.ts +1 -0
  305. package/lib/utils/uni.js +147 -0
  306. package/lib/utils/update.d.ts +9 -0
  307. package/lib/utils/update.js +376 -0
  308. package/package.json +49 -0
  309. package/types/index.d.ts +25 -0
  310. package/types/virtual.d.ts +1 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,16 @@
1
+ # Change Log
2
+
3
+ All notable changes to this project will be documented in this file.
4
+ See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
+
6
+ ## 0.1.1 (2026-05-31)
7
+
8
+ **Note:** Version bump only for package @zfqh/uniapp
9
+
10
+
11
+
12
+
13
+
14
+ ## [0.1.0](http://10.10.200.92:8090/gmcb/front-end/compare/@zfqh/uniapp@0.1.0) (2026-05-31)
15
+
16
+ **Note:** Version bump only for package @zfqh/uniapp
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 aniu
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # @zfqh/uniapp
2
+
3
+ uni-app 公共能力包,面向 Vue 3 项目提供统一配置、请求封装、导航、Toast、COS 上传、常用工具、组合式 hooks 和 `g-*` 公共组件。
4
+
5
+ ## 安装
6
+
7
+ ```bash
8
+ npm i @zfqh/uniapp
9
+ ```
10
+
11
+ 本包依赖 `@gmcb/uv-ui`、Vue 3、Vuex、Vue I18n、腾讯云 IM/TRTC 相关 SDK 等能力,适合在已有 uni-app 业务项目中复用。
12
+
13
+ ## 注册插件
14
+
15
+ ```ts
16
+ import { createSSRApp } from 'vue';
17
+ import uniapp from '@zfqh/uniapp';
18
+ import App from './App.vue';
19
+
20
+ export function createApp() {
21
+ const app = createSSRApp(App);
22
+ app.use(uniapp);
23
+ return { app };
24
+ }
25
+ ```
26
+
27
+ ## 公共组件
28
+
29
+ ```json
30
+ {
31
+ "easycom": {
32
+ "autoscan": true,
33
+ "custom": {
34
+ "^g-(.*)": "@zfqh/uniapp/lib/components/g-$1/g-$1.vue",
35
+ "^uv-(.*)": "@gmcb/uv-ui/components/uv-$1/uv-$1.vue"
36
+ }
37
+ }
38
+ }
39
+ ```
@@ -0,0 +1,189 @@
1
+ # core
2
+
3
+ 公共接口集合。发布路径:`@zfqh/uniapp/lib/apis/core`
4
+
5
+ | 方法 | HTTP | 路径 | 说明 |
6
+ | --- | --- | --- | --- |
7
+ | `sendSmsCode` | `POST` | `/admin-api/system/auth/send-checkCode` | 发送短信验证码。 |
8
+ | `getTencentToken` | `GET` | `/app-api/infra/file/getTencentToken` | 获取腾讯上传临时 Token。 |
9
+ | `getLastVersion` | `POST` | `/app-api/system/app/version/get-last-version` | 获取最新版本。 |
10
+ | `getCosUrls` | `POST` | `/app-api/infra/cos/getUrls` | 获取 COS 签名后的地址。 |
11
+ | `postRefreshToken` | `POST` | `/app-api/robot/store/auth/refreshToken?refreshToken=:refreshToken` | 刷新 token。 |
12
+ | `getDictData` | `GET` | `/app-api/system/dict-data/type` | 获取字典数据。 |
13
+
14
+ ## 基本使用
15
+
16
+ 上传配置、字典下拉和 token 刷新都可以直接复用公共接口。
17
+
18
+ ```ts
19
+ import { getTencentToken, postRefreshToken, getDictData, getLastVersion } from '@zfqh/uniapp/lib/apis';
20
+
21
+ export async function loadUploadToken() {
22
+ const { data } = await getTencentToken();
23
+ return {
24
+ secret_id: data.tmpSecretId,
25
+ secret_key: data.tmpSecretKey,
26
+ session_token: data.sessionToken,
27
+ };
28
+ }
29
+
30
+ export const getCardTypeOptions = () => getDictData({ type: 'system_user_id_type' });
31
+
32
+ export const refreshLoginToken = (refreshToken: string) => postRefreshToken({ refreshToken });
33
+
34
+ export const checkAppVersion = () => getLastVersion({ appCode: 'merchant' });
35
+ ```
36
+
37
+ ## 接口用法
38
+
39
+ ### sendSmsCode
40
+
41
+ 发送短信验证码。
42
+
43
+ ```ts
44
+ import { sendSmsCode } from '@zfqh/uniapp/lib/apis';
45
+
46
+ await sendSmsCode({
47
+ phone: '13800138000',
48
+ });
49
+ ```
50
+
51
+ | 参数 | 类型 | 必填 | 说明 |
52
+ | --- | --- | --- | --- |
53
+ | `data` | `Record<string, any>` | 是 | 请求体。常用字段为手机号,例如 `phone` 或后端约定的手机号字段。 |
54
+
55
+ | 返回值 | 说明 |
56
+ | --- | --- |
57
+ | `Promise<ApiResponse>` | 成功时 resolve 后端响应对象;失败、非 `code == 0` 或网络异常时 reject 统一错误响应。 |
58
+
59
+ ### getTencentToken
60
+
61
+ 获取腾讯云上传临时 Token,常用于 COS 直传。
62
+
63
+ ```ts
64
+ import { getTencentToken } from '@zfqh/uniapp/lib/apis';
65
+
66
+ const { data } = await getTencentToken();
67
+ const credentials = {
68
+ secretId: data.tmpSecretId,
69
+ secretKey: data.tmpSecretKey,
70
+ sessionToken: data.sessionToken,
71
+ };
72
+ ```
73
+
74
+ | 参数 | 类型 | 必填 | 说明 |
75
+ | --- | --- | --- | --- |
76
+ | `data` | `Record<string, any>` | 否 | 查询参数;通常不需要传。 |
77
+
78
+ | 返回值 | 说明 |
79
+ | --- | --- |
80
+ | `Promise<ApiResponse<TencentToken>>` | 成功时 `data` 为后端返回的临时密钥信息。 |
81
+
82
+ ### getLastVersion
83
+
84
+ 获取 App 最新版本信息,常用于更新弹窗。
85
+
86
+ ```ts
87
+ import { getLastVersion } from '@zfqh/uniapp/lib/apis';
88
+
89
+ const { data } = await getLastVersion({
90
+ version: '1.0.0',
91
+ packageName: 'uni.UNI07DD08D',
92
+ type: 2,
93
+ platform: 1,
94
+ });
95
+ ```
96
+
97
+ | 参数 | 类型 | 必填 | 说明 |
98
+ | --- | --- | --- | --- |
99
+ | `data.version` | `string \| number` | 否 | 当前版本号。 |
100
+ | `data.packageName` | `string` | 否 | 应用包名。 |
101
+ | `data.type` | `number` | 否 | 应用类型,按后端约定传值。 |
102
+ | `data.platform` | `number` | 否 | 平台,常见约定为 Android `1`、iOS `2`。 |
103
+ | `data.appCode` | `string` | 否 | 应用编码,业务按后端约定传。 |
104
+
105
+ | 返回值 | 说明 |
106
+ | --- | --- |
107
+ | `Promise<ApiResponse<AppVersion>>` | 成功时 `data` 为版本信息,例如版本号、状态、整包地址、热更新地址等后端字段。 |
108
+
109
+ ### getCosUrls
110
+
111
+ 获取 COS 私有资源签名访问地址。
112
+
113
+ ```ts
114
+ import { getCosUrls } from '@zfqh/uniapp/lib/apis';
115
+
116
+ const { data: urls } = await getCosUrls({
117
+ urls: ['/report/2026/05/demo.pdf'],
118
+ });
119
+
120
+ const firstUrl = urls[0];
121
+ ```
122
+
123
+ | 参数 | 类型 | 必填 | 说明 |
124
+ | --- | --- | --- | --- |
125
+ | `data.urls` | `string[]` | 是 | 需要签名的 COS 路径数组,通常传去掉域名后的路径。 |
126
+
127
+ | 返回值 | 说明 |
128
+ | --- | --- |
129
+ | `Promise<ApiResponse<string[]>>` | 成功时 `data` 为签名后的 URL 数组。 |
130
+
131
+ ### postRefreshToken
132
+
133
+ 刷新登录 token。
134
+
135
+ ```ts
136
+ import { postRefreshToken } from '@zfqh/uniapp/lib/apis';
137
+
138
+ const { data } = await postRefreshToken({
139
+ refreshToken: loginInfo.refreshToken,
140
+ });
141
+ ```
142
+
143
+ | 参数 | 类型 | 必填 | 说明 |
144
+ | --- | --- | --- | --- |
145
+ | `data.refreshToken` | `string` | 是 | 刷新 token。该字段会替换 URL 中的 `:refreshToken`。 |
146
+
147
+ | 返回值 | 说明 |
148
+ | --- | --- |
149
+ | `Promise<ApiResponse<LoginToken>>` | 成功时 `data` 为后端返回的新登录凭证。 |
150
+
151
+ ### getDictData
152
+
153
+ 按字典类型获取字典数据。
154
+
155
+ ```ts
156
+ import { getDictData } from '@zfqh/uniapp/lib/apis';
157
+
158
+ const { data } = await getDictData({
159
+ type: 'group_relation',
160
+ });
161
+
162
+ const options = data.map((item) => ({
163
+ label: item.label,
164
+ value: item.value,
165
+ }));
166
+ ```
167
+
168
+ | 参数 | 类型 | 必填 | 说明 |
169
+ | --- | --- | --- | --- |
170
+ | `data.type` | `string` | 是 | 字典类型。 |
171
+
172
+ | 返回值 | 说明 |
173
+ | --- | --- |
174
+ | `Promise<ApiResponse<DictItem[]>>` | 成功时 `data` 为字典项数组,字段以当前后端返回为准。 |
175
+
176
+ ## 返回值约定
177
+
178
+ 以上接口都基于 `GET`、`POST` 封装,成功时返回后端响应对象,常见结构如下:
179
+
180
+ ```ts
181
+ type ApiResponse<T = any> = {
182
+ code: number;
183
+ data: T;
184
+ msg?: string;
185
+ message?: string;
186
+ };
187
+ ```
188
+
189
+ 当响应 `code != 0`、HTTP 状态异常或网络异常时,请求会进入 `catch`,错误对象会被规范为包含 `status`、`data.code`、`data.msg` 和 `config` 的响应结构。
@@ -0,0 +1,82 @@
1
+ # 接口
2
+
3
+ 业务 API 发布路径为 `@zfqh/uniapp/lib/apis`。当前只保留通用请求入口和少量公共接口,已删除原先按业务域拆分的 `login`、`user`、`order`、`consult`、`im`、`message`、`search`、`member`、`prescribe`、`constitution`、`home`、 `goods`、`doctor`、`cos` 等模块。
4
+
5
+ ## 基本使用
6
+
7
+ 推荐从聚合入口引入,并在业务项目的 `apis/*.ts` 中按领域封装请求函数:
8
+
9
+ ```ts
10
+ import { GET, POST } from '@zfqh/uniapp/lib/apis';
11
+
12
+ export const getFamilyList = (data) => GET('/app-api/robot/user-family/getUserFamily', data);
13
+
14
+ export const submitConsult = (data) => POST('/app-api/robot/api/medical/inquirySubmitV2', data);
15
+
16
+ export const getReportByNo = (no: string) => GET('/app-api/constitution/new/getReportByNo?no=:no', { no });
17
+ ```
18
+
19
+ 也可以按文件深度引入:
20
+
21
+ ```ts
22
+ import request, { GET, POST, PUT, DELETE } from '@zfqh/uniapp/lib/apis/request';
23
+ import { getTencentToken, getDictData } from '@zfqh/uniapp/lib/apis/core';
24
+ ```
25
+
26
+ ## 调用契约
27
+
28
+ - `GET` 会把 data 作为 query params。
29
+ - `POST`、`PUT`、`DELETE` 会把 data 作为请求体或方法参数传给底层请求实例。
30
+ - URL 中的 `:id`、`/:id` 会由 `formatURL` 使用 data 同名字段替换,并从 data 中删除该字段。
31
+ - 响应拦截器要求后端成功码为 `code == 0`;失败时会按配置弹 toast,并在 401 时触发 `uni.$store.dispatch('logout')`。
32
+
33
+ ## 接口清单
34
+
35
+ ### 请求方法
36
+
37
+ | 接口 | 参数 | 返回值 | 说明 |
38
+ | --- | --- | --- | --- |
39
+ | `GET(url, data?, options?)` | `url: string`、`data?: Record<string, any>`、`options?: Record<string, any>` | `Promise<ApiResponse<T>>` | 发起 GET 请求,`data` 作为 query。 |
40
+ | `POST(url, data?, options?)` | `url: string`、`data?: Record<string, any>`、`options?: Record<string, any>` | `Promise<ApiResponse<T>>` | 发起 POST 请求,`data` 作为请求体。 |
41
+ | `PUT(url, data?, options?)` | `url: string`、`data?: Record<string, any>`、`options?: Record<string, any>` | `Promise<ApiResponse<T>>` | 发起 PUT 请求,`data` 作为请求体。 |
42
+ | `DELETE(url, data?, options?)` | `url: string`、`data?: Record<string, any>`、`options?: Record<string, any>` | `Promise<ApiResponse<T>>` | 发起 DELETE 请求。 |
43
+
44
+ ```ts
45
+ import { GET, POST, PUT, DELETE } from '@zfqh/uniapp/lib/apis';
46
+
47
+ export const getDetail = (id: number) => GET('/app-api/demo/detail?id=:id', { id });
48
+ export const createItem = (data) => POST('/app-api/demo/create', data);
49
+ export const updateItem = (data) => PUT('/app-api/demo/update', data);
50
+ export const removeItem = (id: number) => DELETE('/app-api/demo/delete?id=:id', { id });
51
+ ```
52
+
53
+ ### 公共接口
54
+
55
+ | 接口 | 参数 | 返回值 | 说明 |
56
+ | --- | --- | --- | --- |
57
+ | `sendSmsCode(data)` | `data: Record<string, any>` | `Promise<ApiResponse>` | 发送短信验证码。 |
58
+ | `getTencentToken(data?)` | `data?: Record<string, any>` | `Promise<ApiResponse<TencentToken>>` | 获取腾讯云上传临时 Token。 |
59
+ | `getLastVersion(data?)` | `data?: Record<string, any>` | `Promise<ApiResponse<AppVersion>>` | 获取最新版本。 |
60
+ | `getCosUrls(data)` | `data: { urls: string[] }` | `Promise<ApiResponse<string[]>>` | 获取 COS 签名后的访问地址。 |
61
+ | `postRefreshToken(data)` | `data: { refreshToken: string }` | `Promise<ApiResponse<LoginToken>>` | 刷新登录 token。 |
62
+ | `getDictData(data)` | `data: { type: string }` | `Promise<ApiResponse<DictItem[]>>` | 按字典类型获取字典数据。 |
63
+
64
+ ```ts
65
+ import {
66
+ sendSmsCode,
67
+ getTencentToken,
68
+ getLastVersion,
69
+ getCosUrls,
70
+ postRefreshToken,
71
+ getDictData,
72
+ } from '@zfqh/uniapp/lib/apis';
73
+
74
+ await sendSmsCode({ phone: '13800138000' });
75
+ await getTencentToken();
76
+ await getLastVersion({ version: '1.0.0', packageName: 'uni.UNI07DD08D', type: 2, platform: 1 });
77
+ await getCosUrls({ urls: ['/report/demo.pdf'] });
78
+ await postRefreshToken({ refreshToken: 'refresh-token' });
79
+ await getDictData({ type: 'group_relation' });
80
+ ```
81
+
82
+ 更细的参数说明和单接口用法见 [request](./request.md) 与 [core](./core.md)。