@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
@@ -0,0 +1,17 @@
1
+ export declare const loading: (title?: string | UniNamespace.ShowLoadingOptions, options?: UniNamespace.ShowLoadingOptions) => void;
2
+ export declare const message: (title?: string | UniNamespace.ShowToastOptions, options?: UniNamespace.ShowToastOptions) => Promise<void>;
3
+ export declare const close: () => void;
4
+ export declare const hideToast: () => void;
5
+ export declare const hideLoading: () => void;
6
+ declare const toast: {
7
+ loading: (title?: string | UniNamespace.ShowLoadingOptions, options?: UniNamespace.ShowLoadingOptions) => void;
8
+ message: (title?: string | UniNamespace.ShowToastOptions, options?: UniNamespace.ShowToastOptions) => Promise<void>;
9
+ success: (title?: string | UniNamespace.ShowToastOptions, options?: UniNamespace.ShowToastOptions) => Promise<void>;
10
+ error: (title?: string | UniNamespace.ShowToastOptions, options?: UniNamespace.ShowToastOptions) => Promise<void>;
11
+ fail: (title?: string | UniNamespace.ShowToastOptions, options?: UniNamespace.ShowToastOptions) => Promise<void>;
12
+ exception: (title?: string | UniNamespace.ShowToastOptions, options?: UniNamespace.ShowToastOptions) => Promise<void>;
13
+ close: () => void;
14
+ hideToast: () => void;
15
+ hideLoading: () => void;
16
+ };
17
+ export default toast;
@@ -0,0 +1,66 @@
1
+ import toastConfig from '../configs/toast';
2
+ export const loading = (title = '', options = {}) => {
3
+ if (typeof title === 'object') {
4
+ options = title;
5
+ title = options.title || '';
6
+ }
7
+ uni.showLoading(Object.assign({
8
+ title: title || '',
9
+ }, options));
10
+ };
11
+ export const message = (title = '', options = {}) => {
12
+ if (typeof title === 'object') {
13
+ options = title;
14
+ title = options.title || '';
15
+ }
16
+ options = Object.assign({
17
+ title: title || '',
18
+ icon: 'none',
19
+ duration: 2000,
20
+ }, options);
21
+ return new Promise((res) => {
22
+ if (options.title) {
23
+ setTimeout(() => {
24
+ if (toastConfig.custom === true) {
25
+ if (toastConfig.show(options) !== false) {
26
+ return;
27
+ }
28
+ }
29
+ uni.showToast(options);
30
+ });
31
+ setTimeout(() => {
32
+ res();
33
+ }, options.duration || 2000);
34
+ }
35
+ else {
36
+ res();
37
+ }
38
+ });
39
+ };
40
+ export const close = () => {
41
+ if (toastConfig.custom === true) {
42
+ if (toastConfig.hide() !== false) {
43
+ return;
44
+ }
45
+ }
46
+ uni.hideToast();
47
+ };
48
+ export const hideToast = close;
49
+ export const hideLoading = () => uni.hideLoading();
50
+ const toast = {
51
+ loading,
52
+ message,
53
+ success: message,
54
+ error: message,
55
+ fail: message,
56
+ exception: message,
57
+ close,
58
+ hideToast,
59
+ hideLoading,
60
+ };
61
+ ['success', 'error', 'fail', 'exception'].forEach((icon) => {
62
+ toast[icon] = (title, options = {}) => {
63
+ return message(title, { ...options, icon });
64
+ };
65
+ });
66
+ export default toast;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,147 @@
1
+ // #ifdef H5
2
+ import { colorGradient } from '@gmcb/uv-ui/libs/function/colorGradient';
3
+ // #endif
4
+ import { app } from '../configs/app';
5
+ import { brand } from '../configs/brand';
6
+ import mp from '../configs/mp';
7
+ import color from '../configs/color';
8
+ import { IS_WEBVIEW_ENV, SYSTEM_INFO } from './consts';
9
+ import { getPage } from './pages';
10
+ import query from './query';
11
+ // #ifndef H5
12
+ uni.webView = uni;
13
+ if (!uni.webView.postMessage) {
14
+ uni.webView.postMessage = () => { };
15
+ }
16
+ // #endif
17
+ // #ifdef H5
18
+ // H5下没有该方法,做兼容处理
19
+ uni.hideShareMenu = () => { };
20
+ uni.showShareMenu = () => { };
21
+ // 解决Tree Shaking导致程序报错
22
+ const scanCode = uni.scanCode;
23
+ const chooseImage = uni.chooseImage;
24
+ const chooseVideo = uni.chooseVideo;
25
+ const chooseFile = uni.chooseFile;
26
+ const navigateTo = uni.navigateTo;
27
+ const redirectTo = uni.redirectTo;
28
+ const switchTab = uni.switchTab;
29
+ const reLaunch = uni.reLaunch;
30
+ uni.scanCode = scanCode;
31
+ uni.chooseImage = chooseImage;
32
+ uni.chooseVideo = chooseVideo;
33
+ uni.chooseFile = chooseFile;
34
+ uni.navigateTo = navigateTo;
35
+ uni.redirectTo = redirectTo;
36
+ uni.switchTab = switchTab;
37
+ uni.reLaunch = reLaunch;
38
+ // #endif
39
+ const navigateBack = uni.navigateBack;
40
+ const navigateToMiniProgram = uni.navigateToMiniProgram;
41
+ const openEmbeddedMiniProgram = uni.openEmbeddedMiniProgram;
42
+ uni.navigateBack = (options = {}) => {
43
+ let { delta = 1 } = options;
44
+ if (delta < 1) {
45
+ delta = 1;
46
+ }
47
+ const pages = getCurrentPages();
48
+ const length = pages.length;
49
+ if (IS_WEBVIEW_ENV && length === 1) {
50
+ // webview内没有上页,则触发原生返回
51
+ uni.webView?.navigateBack(options);
52
+ }
53
+ else if (!IS_WEBVIEW_ENV &&
54
+ ((length > 1 && delta >= length) || (length === 1 && !getPage('index')?.includes(pages[0].route)))) {
55
+ // 非首页返回则跳转到首页
56
+ uni.reLaunch({
57
+ url: getPage('index'),
58
+ });
59
+ }
60
+ else {
61
+ navigateBack(options);
62
+ }
63
+ };
64
+ uni.navigateToMiniProgram = (options) => {
65
+ // #ifdef MP
66
+ navigateToMiniProgram({
67
+ envVersion: mp.envVersion,
68
+ ...options,
69
+ });
70
+ // #endif
71
+ };
72
+ uni.openEmbeddedMiniProgram = (options) => {
73
+ // #ifdef MP
74
+ openEmbeddedMiniProgram({
75
+ envVersion: mp.envVersion,
76
+ allowFullScreen: true,
77
+ ...options,
78
+ });
79
+ // #endif
80
+ };
81
+ // 应用是否从后台唤起,在App.onShow中建议使用if (uni.showAppFromBackground) { /* do something */ }
82
+ uni.showAppFromBackground = true;
83
+ // 调用API将appShowFromBackground设置为false,防止App.vue非必要的执行onShow
84
+ [
85
+ // #ifdef MP
86
+ 'previewImage',
87
+ 'openLocation',
88
+ 'chooseLocation',
89
+ 'chooseAddress',
90
+ 'chooseMessageFile',
91
+ 'openSetting',
92
+ // #endif
93
+ // #ifndef APP
94
+ 'scanCode',
95
+ // #endif
96
+ 'chooseImage',
97
+ 'chooseVideo',
98
+ 'chooseFile',
99
+ ].forEach((key) => {
100
+ const func = uni[key];
101
+ uni[key] = (options = {}) => {
102
+ uni.showAppFromBackground = false;
103
+ return func(options);
104
+ };
105
+ });
106
+ // #ifdef H5
107
+ if (query) {
108
+ // 给H5添加安全区域,需再url地址参数中添加safeBottom
109
+ if (Number(query.safeBottom) > 0) {
110
+ SYSTEM_INFO.safeAreaInsets.bottom = Number(query.safeBottom);
111
+ const node = document.createElement('style');
112
+ node.type = 'text/css';
113
+ node.innerText = `
114
+ .uv-safe-area-inset-bottom { padding-bottom: ${query.safeBottom}px; }
115
+ `.trim();
116
+ document.body.append(node);
117
+ }
118
+ // 隐藏子应用tabbar,不传或者为空字符表示显式子应用tabbar
119
+ if (query.tabbar != null && query.tabbar !== '') {
120
+ const node = document.createElement('style');
121
+ node.type = 'text/css';
122
+ node.innerText = `
123
+ .uni-tabbar-bottom { display: none }
124
+ `.trim();
125
+ document.body.append(node);
126
+ window.addEventListener('load', () => {
127
+ document.documentElement.style.setProperty('--window-bottom', '0px');
128
+ });
129
+ }
130
+ // 更新主题色
131
+ const primary = String(query.primary ? `#${query.primary}`.replace(/^#+/, '#') : '') ||
132
+ app[query.app]?.primary ||
133
+ brand[query.brand]?.primary;
134
+ if (primary) {
135
+ const colors = colorGradient(primary, '#fff', 10);
136
+ document.documentElement.style.setProperty('--primary', (color.primary = colors[0]));
137
+ document.documentElement.style.setProperty('--primary-light', (color.primaryLight = colors[9]));
138
+ document.documentElement.style.setProperty('--primary-disabled', (color.primaryDisabled = colors[6]));
139
+ document.documentElement.style.setProperty('--primary-dark', (color.primaryDark = colors[4]));
140
+ }
141
+ }
142
+ // const resizeCallback = () => {
143
+ // document.documentElement.style.setProperty('--window-height', `${window.innerHeight}px`);
144
+ // };
145
+ // resizeCallback();
146
+ // window.addEventListener('resize', resizeCallback);
147
+ // #endif
@@ -0,0 +1,9 @@
1
+ /**
2
+ * 检测更新
3
+ * @param immediate 是否立即更新,不显示确认框
4
+ */
5
+ declare function check(immediate?: boolean): Promise<void>;
6
+ declare const _default: {
7
+ check: typeof check;
8
+ };
9
+ export default _default;
@@ -0,0 +1,376 @@
1
+ import color from '../configs/color';
2
+ import update from '../configs/update';
3
+ import ver from '../configs/ver';
4
+ import app from '../configs/app';
5
+ import { SYSTEM_INFO } from './consts';
6
+ // 防止弹窗多次弹出
7
+ let visibleModal = false;
8
+ function showModal(options) {
9
+ uni.showModal({
10
+ title: '更新提示',
11
+ content: options?.content || '检测到新版本,下载并重启应用?',
12
+ confirmColor: color.primary,
13
+ showCancel: options?.showCancel,
14
+ fail() {
15
+ visibleModal = false;
16
+ },
17
+ success(res) {
18
+ if (res.confirm) {
19
+ options?.confirm && options.confirm();
20
+ }
21
+ else {
22
+ visibleModal = false;
23
+ }
24
+ },
25
+ });
26
+ }
27
+ // #ifdef APP
28
+ function appFileDownload(url, restart = true) {
29
+ let downloaded = false;
30
+ const showWaiting = plus.nativeUI.showWaiting('下载中...');
31
+ const downloadTask = uni.downloadFile({
32
+ url,
33
+ success(downloadResult) {
34
+ if (downloadResult.statusCode === 200) {
35
+ showWaiting.setTitle('安装中...');
36
+ setTimeout(() => {
37
+ plus.runtime.install(downloadResult.tempFilePath, {
38
+ force: true,
39
+ }, () => {
40
+ plus.nativeUI.closeWaiting();
41
+ if (restart) {
42
+ visibleModal = false;
43
+ uni.showModal({
44
+ title: '提示',
45
+ content: '应用更新完成',
46
+ showCancel: false,
47
+ confirmText: '重启应用',
48
+ confirmColor: color.primary,
49
+ success() {
50
+ plus.runtime.restart();
51
+ },
52
+ });
53
+ }
54
+ });
55
+ }, 500);
56
+ }
57
+ else {
58
+ visibleModal = false;
59
+ plus.nativeUI.alert('更新失败');
60
+ plus.nativeUI.closeWaiting();
61
+ }
62
+ },
63
+ fail() {
64
+ visibleModal = false;
65
+ plus.nativeUI.closeWaiting();
66
+ },
67
+ });
68
+ downloadTask.onProgressUpdate(({ progress }) => {
69
+ if (!downloaded) {
70
+ showWaiting.setTitle('下载中...' + progress + '%');
71
+ if (progress === 100) {
72
+ downloaded = true;
73
+ }
74
+ }
75
+ });
76
+ }
77
+ function checkAppUpdate(immediate = false) {
78
+ return new Promise((resolve, reject) => {
79
+ plus.runtime.getProperty(plus.runtime.appid, async ({ versionCode, version: versionName }) => {
80
+ try {
81
+ const { platform, appName, appId, appVersion: appVersionName, appVersionCode } = SYSTEM_INFO;
82
+ const params = {
83
+ appId: app.appId || appId,
84
+ appName: app.name || appName,
85
+ versionCode: Number(ver.code || versionCode),
86
+ versionName: ver.name || versionName,
87
+ appVersionCode: Number(appVersionCode),
88
+ appVersionName,
89
+ platform,
90
+ };
91
+ const data = await update.request(params);
92
+ if (data) {
93
+ let url = '';
94
+ if (data.hot_update == 1) {
95
+ url = data.wgt_url;
96
+ }
97
+ else {
98
+ if (platform === 'android') {
99
+ url = data.apk_url;
100
+ }
101
+ else if (platform === 'ios') {
102
+ url = data.ipa_url;
103
+ }
104
+ }
105
+ if (url) {
106
+ resolve();
107
+ if (!visibleModal) {
108
+ visibleModal = true;
109
+ if (data.hot_update == 1) {
110
+ // 热更新
111
+ if (immediate) {
112
+ appFileDownload(url);
113
+ }
114
+ else {
115
+ showModal({
116
+ showCancel: !data.force_update,
117
+ confirm() {
118
+ appFileDownload(url);
119
+ },
120
+ });
121
+ }
122
+ }
123
+ else {
124
+ // 整包更新
125
+ if (params.platform == 'android') {
126
+ if (immediate) {
127
+ if (data.external_install) {
128
+ plus.runtime.openURL(url);
129
+ }
130
+ else {
131
+ appFileDownload(url, false);
132
+ }
133
+ }
134
+ else {
135
+ showModal({
136
+ showCancel: !data.force_update,
137
+ confirm() {
138
+ if (data.external_install) {
139
+ plus.runtime.openURL(url);
140
+ }
141
+ else {
142
+ appFileDownload(url, false);
143
+ }
144
+ },
145
+ });
146
+ }
147
+ }
148
+ else if (params.platform == 'ios') {
149
+ showModal({
150
+ content: '检测到新版本,前往应用市场更新?',
151
+ confirm() {
152
+ plus.runtime.openURL(url);
153
+ },
154
+ });
155
+ }
156
+ }
157
+ }
158
+ }
159
+ else {
160
+ reject();
161
+ }
162
+ }
163
+ else {
164
+ reject();
165
+ }
166
+ }
167
+ catch (e) {
168
+ reject(e);
169
+ }
170
+ });
171
+ });
172
+ }
173
+ // #endif
174
+ // #ifdef H5
175
+ function fileDownload(url, restart = true) {
176
+ const ipcRenderer = window['electron'].ipcRenderer;
177
+ ipcRenderer.send('update', url);
178
+ function updateDownload() {
179
+ uni.showLoading({
180
+ title: '下载中...',
181
+ mask: true,
182
+ });
183
+ }
184
+ function uploadProgress(e, progress) {
185
+ uni.showLoading({
186
+ title: `下载中...${progress}%`,
187
+ mask: true,
188
+ });
189
+ }
190
+ function updateSuccess() {
191
+ if (restart) {
192
+ uni.showModal({
193
+ title: '提示',
194
+ content: '应用更新完成',
195
+ showCancel: false,
196
+ confirmText: '重启应用',
197
+ confirmColor: color.primary,
198
+ success() {
199
+ ipcRenderer.send('relaunch');
200
+ },
201
+ });
202
+ }
203
+ }
204
+ function updateFail() {
205
+ setTimeout(() => {
206
+ uni.showToast({
207
+ title: '更新失败',
208
+ icon: 'error',
209
+ duration: 2000,
210
+ });
211
+ }, 300);
212
+ }
213
+ function updateComplete() {
214
+ visibleModal = false;
215
+ uni.hideLoading();
216
+ ipcRenderer.removeListener('update-download', updateDownload);
217
+ ipcRenderer.removeListener('update-progress', uploadProgress);
218
+ ipcRenderer.removeListener('update-success', updateSuccess);
219
+ ipcRenderer.removeListener('update-fail', updateFail);
220
+ }
221
+ ipcRenderer.on('update-download', updateDownload);
222
+ ipcRenderer.on('update-progress', uploadProgress);
223
+ ipcRenderer.on('update-success', updateSuccess);
224
+ ipcRenderer.on('update-fail', updateFail);
225
+ ipcRenderer.once('update-complete', updateComplete);
226
+ }
227
+ async function checkUpdate(immediate = false) {
228
+ return new Promise((resolve, reject) => {
229
+ const { platform, appName, appId, appVersion: versionName, versionCode } = SYSTEM_INFO;
230
+ const params = {
231
+ appId: app.appId || appId,
232
+ appName: app.name || appName,
233
+ versionCode: Number(ver.code || versionCode),
234
+ versionName: ver.name || versionName,
235
+ appVersionCode: Number(window['versionCode'] || versionCode),
236
+ appVersionName: window['versionName'] || versionName,
237
+ platform: window['platform'] || platform,
238
+ };
239
+ update
240
+ .request(params)
241
+ .then((data) => {
242
+ if (data) {
243
+ let url = '';
244
+ if (data.hot_update == 1) {
245
+ url = data.zip_url;
246
+ }
247
+ else {
248
+ if (params.platform === 'windows') {
249
+ url = data.exe_url;
250
+ }
251
+ else if (params.platform === 'macos') {
252
+ url = data.dmg_url;
253
+ }
254
+ }
255
+ if (url) {
256
+ resolve();
257
+ if (!visibleModal) {
258
+ visibleModal = true;
259
+ if (data.hot_update == 1) {
260
+ // 热更新
261
+ if (immediate) {
262
+ fileDownload(url);
263
+ }
264
+ else {
265
+ showModal({
266
+ showCancel: !data.force_update,
267
+ confirm() {
268
+ fileDownload(url);
269
+ },
270
+ });
271
+ }
272
+ }
273
+ else {
274
+ // 整包更新
275
+ if (immediate) {
276
+ fileDownload(url, false);
277
+ }
278
+ else {
279
+ showModal({
280
+ showCancel: !data.force_update,
281
+ confirm() {
282
+ fileDownload(url, false);
283
+ },
284
+ });
285
+ }
286
+ }
287
+ }
288
+ }
289
+ else {
290
+ reject();
291
+ }
292
+ }
293
+ else {
294
+ reject();
295
+ }
296
+ })
297
+ .catch((e) => {
298
+ reject(e);
299
+ });
300
+ });
301
+ }
302
+ // #endif
303
+ // #ifdef MP
304
+ function mpDownload(updateManager) {
305
+ uni.showLoading({ title: '更新中...' });
306
+ updateManager.onUpdateReady(() => {
307
+ uni.hideLoading();
308
+ setTimeout(() => {
309
+ visibleModal = false;
310
+ updateManager.applyUpdate();
311
+ }, 300);
312
+ });
313
+ updateManager.onUpdateFailed(() => {
314
+ visibleModal = false;
315
+ uni.hideLoading();
316
+ uni.showModal({
317
+ title: '更新失败',
318
+ content: `请您删除当前小程序,并搜索“${app.name || SYSTEM_INFO.appName}”重新打开应用`,
319
+ confirmColor: color.primary,
320
+ });
321
+ });
322
+ }
323
+ function checkMpUpdate(immediate = false) {
324
+ return new Promise((resolve, reject) => {
325
+ if (uni.canIUse('getUpdateManager')) {
326
+ const updateManager = uni.getUpdateManager();
327
+ updateManager.onCheckForUpdate((e) => {
328
+ if (e.hasUpdate) {
329
+ visibleModal = true;
330
+ resolve();
331
+ if (immediate) {
332
+ mpDownload(updateManager);
333
+ }
334
+ else {
335
+ showModal({
336
+ confirm() {
337
+ mpDownload(updateManager);
338
+ },
339
+ });
340
+ }
341
+ }
342
+ else {
343
+ reject();
344
+ }
345
+ });
346
+ }
347
+ else {
348
+ reject();
349
+ }
350
+ });
351
+ }
352
+ // #endif
353
+ /**
354
+ * 检测更新
355
+ * @param immediate 是否立即更新,不显示确认框
356
+ */
357
+ function check(immediate = false) {
358
+ let res = Promise.resolve();
359
+ if (!visibleModal) {
360
+ // #ifdef H5
361
+ if (typeof window['electron'] === 'object') {
362
+ res = checkUpdate(immediate);
363
+ }
364
+ // #endif
365
+ // #ifdef APP
366
+ res = checkAppUpdate(immediate);
367
+ // #endif
368
+ // #ifdef MP
369
+ res = checkMpUpdate(immediate);
370
+ // #endif
371
+ }
372
+ return res;
373
+ }
374
+ export default {
375
+ check,
376
+ };
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@zfqh/uniapp",
3
+ "version": "0.1.1",
4
+ "description": "uniapp公共模块",
5
+ "author": "yinjiazeng@163.com",
6
+ "license": "MIT",
7
+ "main": "lib/index.js",
8
+ "types": "lib/index.d.ts",
9
+ "homepage": "https://git.keeprisk.cn/zfqh/front-end/tree/master/packages/uniapp-zfqh",
10
+ "publishConfig": {
11
+ "access": "public"
12
+ },
13
+ "scripts": {
14
+ "tsc": "vue-tsc",
15
+ "tsc:dev": "vue-tsc --watch",
16
+ "docs:dev": "vitepress dev . --config .vitepress/config.mts",
17
+ "docs:build": "vitepress build . --config .vitepress/config.mts"
18
+ },
19
+ "keywords": [
20
+ "uniapp"
21
+ ],
22
+ "files": [
23
+ "docs",
24
+ "lib",
25
+ "types",
26
+ "CHANGELOG.md",
27
+ "README.md"
28
+ ],
29
+ "dependencies": {
30
+ "@gmcb/uv-ui": "0.3.1",
31
+ "@tencentcloud/chat-uikit-engine": "^2.3.2",
32
+ "@tencentcloud/tui-core": "^2.3.2",
33
+ "crypto-js": "^4.2.0",
34
+ "html2canvas": "^1.4.1",
35
+ "qs": "^6.13.0",
36
+ "trtc-wx-sdk": "^1.1.12",
37
+ "url-parse": "^1.5.10",
38
+ "vue": "3.4.21",
39
+ "vue-i18n": "9.1.9",
40
+ "vuex": "4.1.0"
41
+ },
42
+ "devDependencies": {
43
+ "@dcloudio/types": "^3.4.19",
44
+ "@types/crypto-js": "^4.2.2",
45
+ "@types/qs": "^6.9.16",
46
+ "@types/url-parse": "^1.4.11"
47
+ },
48
+ "gitHead": "29f2e4284d8c7e3585410f8800f2b89a39a37cf1"
49
+ }
@@ -0,0 +1,25 @@
1
+ /// <reference path="./virtual.d.ts" />
2
+
3
+ import type { Uni as UniTypes } from '@dcloudio/types';
4
+ import color from '../lib/configs/color';
5
+
6
+ declare global {
7
+ interface Uni extends UniTypes {
8
+ $store: any;
9
+ $messages: any;
10
+ $uv: any;
11
+ webView: any;
12
+ showAppFromBackground: boolean;
13
+ getLocationCallback: {
14
+ [key: string]: (data: any) => void;
15
+ };
16
+ openLocationCallback: {
17
+ [key: string]: (data: any) => void;
18
+ };
19
+ requestPermission: (permission: 'location' | 'storage') => Promise<any>;
20
+ }
21
+
22
+ interface Window {
23
+ __wxjs_environment: string;
24
+ }
25
+ }
@@ -0,0 +1 @@
1
+ declare module 'virtual:*';