mali-applet-ui 0.2.5 → 0.2.6

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 (2) hide show
  1. package/package.json +1 -1
  2. package/utils/applet.js +38 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mali-applet-ui",
3
- "version": "0.2.5",
3
+ "version": "0.2.6",
4
4
  "description": "码里云小程序组件库",
5
5
  "scripts": {
6
6
  "release": "node script/release.js && npm publish"
package/utils/applet.js CHANGED
@@ -1,3 +1,41 @@
1
+ /**
2
+ * 获取当前平台信息
3
+ */
4
+ export function getPlatformInfo () {
5
+ const sysRes = uni.getSystemInfoSync()
6
+ const hostName = sysRes.hostName
7
+ const platform = {
8
+ // H5
9
+ isH5: false,
10
+ isQWH5: false,
11
+ isDDH5: false,
12
+ // 微信
13
+ isWX: false,
14
+ // 企业微信
15
+ isQW: false,
16
+ // 钉钉
17
+ isDD: false,
18
+ // 支付宝
19
+ isZFB: false
20
+ }
21
+ if (/web/.test(sysRes.uniPlatform)) {
22
+ platform.isH5 = true
23
+ platform.isQWH5 = true
24
+ platform.isDDH5 = true
25
+ } else {
26
+ if (/WeChat/i.test(hostName)) {
27
+ platform.isWX = true
28
+ } else if (/wxwork/i.test(hostName)) {
29
+ platform.isQW = true
30
+ } else if (/DingTalk/i.test(hostName)) {
31
+ platform.isDD = true
32
+ } else if (/alipay/i.test(hostName)) {
33
+ platform.isZFB = true
34
+ }
35
+ }
36
+ return platform
37
+ }
38
+
1
39
  /**
2
40
  * 获取 AppId
3
41
  */