71 lines
1.8 KiB
Vue
71 lines
1.8 KiB
Vue
<template>
|
|
<AConfigProvider direction="rtl">
|
|
<RouterView />
|
|
<CustomerImportProgress />
|
|
<GroupSmsSendProgress />
|
|
</AConfigProvider>
|
|
</template>
|
|
|
|
<script lang="ts" setup>
|
|
import { onMounted, watch } from 'vue'
|
|
import { message } from 'ant-design-vue'
|
|
import { useConfigStore } from '@/store/configStore'
|
|
import { initDarkmode } from '@core/stores/darkmode'
|
|
import CustomerImportProgress from '@/components/CustomerImportProgress.vue'
|
|
import GroupSmsSendProgress from '@/components/GroupSmsSendProgress.vue'
|
|
import { useUserStore } from '@/store/userStore'
|
|
import { bootstrapAdminChat, useAdminChatService } from '@/utils/adminChat'
|
|
import { supportChatMenuEnabledSetting } from '@/utils/config'
|
|
|
|
const config = useConfigStore()
|
|
const userStore = useUserStore()
|
|
const { latestIncomingNotification } = useAdminChatService()
|
|
|
|
initDarkmode()
|
|
|
|
let started = false
|
|
let lastToastAt = 0
|
|
|
|
watch(
|
|
() => [
|
|
userStore.userInfo?.id,
|
|
supportChatMenuEnabledSetting.value,
|
|
userStore.findSettingByKey('chat_api_key'),
|
|
],
|
|
async ([userId, chatMenuOn, chatApiKey]) => {
|
|
if (started) return
|
|
if (!userId || !chatMenuOn || !chatApiKey) {
|
|
return
|
|
}
|
|
|
|
started = true
|
|
try {
|
|
await bootstrapAdminChat({
|
|
connectEvenIfNoRooms: true,
|
|
askNotificationPermission: false,
|
|
})
|
|
} catch (error) {
|
|
started = false
|
|
console.error('bootstrapAdminChat failed:', error)
|
|
}
|
|
},
|
|
{ immediate: true },
|
|
)
|
|
|
|
watch(latestIncomingNotification, (payload) => {
|
|
if (!payload) return
|
|
if (payload.at === lastToastAt) return
|
|
lastToastAt = payload.at
|
|
message.info({
|
|
content: `پیام پشتیبانی جدید: ${payload.title}`,
|
|
duration: 3,
|
|
})
|
|
})
|
|
|
|
onMounted(async () => {
|
|
await config.getConfigData()
|
|
})
|
|
</script>
|
|
|
|
<style lang="less"></style>
|