uni-auth 1.0.5 → 1.0.7
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.
- package/package.json +1 -1
- package/src/common/index.js +13 -0
- package/src/components/AuthPop.vue +12 -8
- package/src/index.js +1 -1
package/package.json
CHANGED
package/src/common/index.js
CHANGED
|
@@ -32,3 +32,16 @@ export function hintOpenAuth(params = {}) {
|
|
|
32
32
|
})
|
|
33
33
|
})
|
|
34
34
|
}
|
|
35
|
+
|
|
36
|
+
export const safeHeight = () => {
|
|
37
|
+
const obj = {
|
|
38
|
+
statusBarHeight: uni.getWindowInfo().statusBarHeight,
|
|
39
|
+
menuButtonHeight: 0,
|
|
40
|
+
}
|
|
41
|
+
if (uni.getMenuButtonBoundingClientRect) {
|
|
42
|
+
console.log(uni.getMenuButtonBoundingClientRect())
|
|
43
|
+
obj.menuButtonHeight = uni.getMenuButtonBoundingClientRect().height
|
|
44
|
+
obj.statusBarHeight = uni.getMenuButtonBoundingClientRect().top
|
|
45
|
+
}
|
|
46
|
+
return obj
|
|
47
|
+
}
|
|
@@ -1,28 +1,31 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<view class="auth-pop" v-if="isPermissionAlertShow">
|
|
2
|
+
<view class="auth-pop" :style="{ marginTop: safeH }" v-if="isPermissionAlertShow">
|
|
3
3
|
<view class="title">{{ type }}权限使用说明</view>
|
|
4
4
|
<view class="msg">{{ contentEnum['android'][type] }}</view>
|
|
5
5
|
</view>
|
|
6
6
|
</template>
|
|
7
7
|
|
|
8
8
|
<script setup>
|
|
9
|
-
import { onMounted, onUnmounted, ref } from 'vue'
|
|
10
|
-
import { contentEnum } from '../common/index.js'
|
|
9
|
+
import { onMounted, onUnmounted, computed, ref } from 'vue'
|
|
10
|
+
import { contentEnum, safeHeight } from '../common/index.js'
|
|
11
11
|
const type = ref('')
|
|
12
12
|
const permissionListener = ref(null)
|
|
13
13
|
const isPermissionAlertShow = ref(false)
|
|
14
14
|
onMounted(() => {
|
|
15
|
-
type.value = uni.getStorageSync('authCode') || ''
|
|
16
|
-
uni.removeStorageSync('authCode')
|
|
17
|
-
if (!type.value) return
|
|
18
15
|
permissionListener.value = uni.createRequestPermissionListener()
|
|
19
16
|
permissionListener.value.onConfirm((e) => {
|
|
20
|
-
|
|
17
|
+
type.value = uni.getStorageSync('authCode') || ''
|
|
18
|
+
uni.removeStorageSync('authCode')
|
|
19
|
+
if (type.value) isPermissionAlertShow.value = true
|
|
21
20
|
})
|
|
22
21
|
permissionListener.value.onComplete((e) => {
|
|
23
22
|
isPermissionAlertShow.value = false
|
|
24
23
|
})
|
|
25
24
|
})
|
|
25
|
+
const safeH = computed(() => {
|
|
26
|
+
const { statusBarHeight, menuButtonHeight } = safeHeight()
|
|
27
|
+
return (statusBarHeight + menuButtonHeight || 70) + 20 + 'px'
|
|
28
|
+
})
|
|
26
29
|
onUnmounted(() => {
|
|
27
30
|
permissionListener.value.stop()
|
|
28
31
|
})
|
|
@@ -39,7 +42,8 @@ onUnmounted(() => {
|
|
|
39
42
|
box-shadow: 0 0 10rpx rgba(0, 0, 0, 0.1);
|
|
40
43
|
z-index: 999;
|
|
41
44
|
border-radius: 14rpx;
|
|
42
|
-
margin:
|
|
45
|
+
margin-left: 5%;
|
|
46
|
+
margin-right: 5%;
|
|
43
47
|
animation: identifier 1s ease-in-out;
|
|
44
48
|
padding: 20rpx 30rpx;
|
|
45
49
|
box-sizing: border-box;
|
package/src/index.js
CHANGED