perf: 优化通知

This commit is contained in:
kuaifan 2022-09-09 15:56:06 +08:00
parent e4b38e4121
commit ec73c3c785
6 changed files with 43 additions and 3 deletions

View File

@ -76,7 +76,7 @@ export default {
}, },
computed: { computed: {
...mapState(['ws', 'windowActive', 'themeMode']), ...mapState(['ws', 'themeMode']),
isSoftware() { isSoftware() {
return this.$Electron || this.$isEEUiApp; return this.$Electron || this.$isEEUiApp;
@ -258,6 +258,10 @@ export default {
this.$store.dispatch("getBasicData", 600) this.$store.dispatch("getBasicData", 600)
} }
} }
//
window.__onNotificationPermissionStatus = (ret) => {
this.$store.state.appNotificationPermission = $A.runNum(ret) == 1;
}
}, },
otherEvents() { otherEvents() {

View File

@ -689,6 +689,15 @@ export default {
} }
}, },
windowActive(active) {
if (!active) {
$A.eeuiAppSendMessage({
action: 'setBdageNotify',
bdage: this.unreadTotal,
});
}
},
'cacheProjects.length': { 'cacheProjects.length': {
handler() { handler() {
this.$nextTick(_ => { this.$nextTick(_ => {

View File

@ -24,6 +24,9 @@
{{$L(item.name)}} {{$L(item.name)}}
</p> </p>
</div> </div>
<div v-if="$isEEUiApp && !appNotificationPermission" class="messenger-notify-permission" @click="onOpenAppSetting">
{{$L('未开启通知权限')}}<i class="taskfont">&#xe733;</i>
</div>
<ScrollerY <ScrollerY
ref="list" ref="list"
class="messenger-list" class="messenger-list"
@ -198,6 +201,10 @@ export default {
activated() { activated() {
this.updateDialogs(1000); this.updateDialogs(1000);
this.$nextTick(_ => this.activeNum++) this.$nextTick(_ => this.activeNum++)
//
if ($A.isEEUiApp) {
$A.eeuiAppSendMessage({action: 'getNotificationPermission'});
}
}, },
deactivated() { deactivated() {
@ -206,7 +213,7 @@ export default {
}, },
computed: { computed: {
...mapState(['cacheDialogs', 'loadDialogs', 'dialogId']), ...mapState(['cacheDialogs', 'loadDialogs', 'dialogId', 'appNotificationPermission']),
routeName() { routeName() {
return this.$route.name return this.$route.name
@ -708,6 +715,12 @@ export default {
}, timeout) }, timeout)
} }
}, },
onOpenAppSetting() {
$A.eeuiAppSendMessage({
action: 'gotoSetting',
});
}
} }
} }
</script> </script>

View File

@ -11,6 +11,9 @@ const stateData = {
// 窗口是否激活 // 窗口是否激活
windowActive: true, windowActive: true,
// App通知权限
appNotificationPermission: true,
// 播放中的音频地址 // 播放中的音频地址
audioPlaying: null, audioPlaying: null,

View File

@ -84,6 +84,17 @@
} }
} }
} }
.messenger-notify-permission {
position: sticky;
display: flex;
align-items: center;
padding: 6px 12px;
justify-content: space-between;
background-color: #FEF7EE;
border: 1px solid #FAE0B5;
margin: 8px 12px;
border-radius: 6px;
}
.messenger-list { .messenger-list {
flex: 1; flex: 1;
height: 0; height: 0;

@ -1 +1 @@
Subproject commit 0b93e8265db0a734765cd7d8f27a180d11b7223d Subproject commit d94c85bf200250aad19754c9e6c777bdcb22ac90