Files
boursecu_admin/src/App.vue
T

71 lines
1.8 KiB
Vue
Raw Normal View History

2026-01-24 17:45:54 +03:30
<template>
<AConfigProvider direction="rtl">
<RouterView />
2026-06-28 23:41:46 +03:30
<CustomerImportProgress />
2026-08-16 20:01:54 +03:30
<GroupSmsSendProgress />
2026-01-24 17:45:54 +03:30
</AConfigProvider>
</template>
<script lang="ts" setup>
2026-07-30 18:30:32 +03:30
import { onMounted, watch } from 'vue'
import { message } from 'ant-design-vue'
2026-06-14 21:04:26 +03:30
import { useConfigStore } from '@/store/configStore'
import { initDarkmode } from '@core/stores/darkmode'
2026-06-28 23:41:46 +03:30
import CustomerImportProgress from '@/components/CustomerImportProgress.vue'
2026-08-16 20:01:54 +03:30
import GroupSmsSendProgress from '@/components/GroupSmsSendProgress.vue'
2026-07-30 18:30:32 +03:30
import { useUserStore } from '@/store/userStore'
import { bootstrapAdminChat, useAdminChatService } from '@/utils/adminChat'
import { supportChatMenuEnabledSetting } from '@/utils/config'
2026-01-24 17:45:54 +03:30
2026-06-14 21:04:26 +03:30
const config = useConfigStore()
2026-07-30 18:30:32 +03:30
const userStore = useUserStore()
const { latestIncomingNotification } = useAdminChatService()
2026-06-14 21:04:26 +03:30
initDarkmode()
2026-07-30 18:30:32 +03:30
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,
})
})
2026-06-14 21:04:26 +03:30
onMounted(async () => {
await config.getConfigData()
2026-01-24 17:45:54 +03:30
})
</script>
<style lang="less"></style>