forked from gzydong/LumenIM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.vue
101 lines (88 loc) · 2.27 KB
/
App.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<script lang="ts" setup>
import '@icon-park/vue-next/styles/index.css'
import { IconProvider, DEFAULT_ICON_CONFIGS } from '@icon-park/vue-next'
import {
NNotificationProvider,
NMessageProvider,
NDialogProvider,
NConfigProvider,
zhCN,
dateZhCN,
NLayoutContent
} from 'naive-ui'
import hljs from 'highlight.js/lib/core'
import { useUserStore, useTalkStore } from '@/store'
import ws from '@/connect'
import { bus } from '@/utils/event-bus'
import { isLoggedIn } from '@/utils/auth'
import { NotificationApi, MessageApi, DialogApi } from '@/components/common'
import UserCardModal from '@/components/user/UserCardModal.vue'
import { ContactConst } from '@/constant/event-bus'
import {
useProvideUserModal,
useThemeMode,
useVisibilityChange,
useAccessPrompt,
useUnreadMessage,
useConnectStatus,
useClickEvent
} from '@/hooks'
IconProvider({
...DEFAULT_ICON_CONFIGS,
theme: 'outline',
size: 24,
strokeWidth: 3,
strokeLinejoin: 'bevel'
})
const { uid: showUserId, isShow: isShowUser } = useProvideUserModal()
const { getDarkTheme, getThemeOverride } = useThemeMode()
const userStore = useUserStore()
const talkStore = useTalkStore()
const onChangeRemark = (value: string) => {
bus.emit(ContactConst.UpdateRemark, value)
talkStore.setRemark(value)
}
const init = () => {
if (!isLoggedIn()) return
ws.connect()
userStore.loadSetting()
}
init()
useVisibilityChange()
useAccessPrompt()
useUnreadMessage()
useConnectStatus()
useClickEvent()
</script>
<template>
<!--接收信息提示音-->
<audio id="audio" preload="preload" muted>
<source src="@/assets/music.mp3" type="audio/mp3" />
</audio>
<!-- 调整 naive-ui 的字重配置 -->
<n-config-provider
:theme="getDarkTheme"
:theme-overrides="getThemeOverride"
:locale="zhCN"
:date-locale="dateZhCN"
:hljs="hljs"
>
<n-message-provider>
<message-api />
</n-message-provider>
<n-notification-provider>
<notification-api />
</n-notification-provider>
<n-dialog-provider>
<dialog-api />
</n-dialog-provider>
<n-layout-content>
<router-view />
<UserCardModal
v-model:show="isShowUser"
v-model:uid="showUserId"
@update-remark="onChangeRemark"
/>
</n-layout-content>
</n-config-provider>
</template>