added chat 2
This commit is contained in:
+46
-18
@@ -2,39 +2,67 @@
|
||||
<AConfigProvider direction="rtl">
|
||||
<RouterView />
|
||||
<CustomerImportProgress />
|
||||
<!-- <button @click="test">this is ssss</button>-->
|
||||
</AConfigProvider>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { onMounted } from 'vue'
|
||||
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 { useUserStore } from '@/store/userStore'
|
||||
import { bootstrapAdminChat, useAdminChatService } from '@/utils/adminChat'
|
||||
import { supportChatMenuEnabledSetting } from '@/utils/config'
|
||||
|
||||
const router = useRouter()
|
||||
const config = useConfigStore()
|
||||
const userStore = useUserStore()
|
||||
const { latestIncomingNotification } = useAdminChatService()
|
||||
|
||||
initDarkmode()
|
||||
|
||||
function test() {
|
||||
console.log('roussss', router)
|
||||
router.push({ name: 'users' })
|
||||
}
|
||||
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()
|
||||
})
|
||||
|
||||
/*const router = useRouter()
|
||||
console.log('this is router', router.currentRoute.value)*/
|
||||
/*import { useStaticApiListsStore } from '@/store/staticApisStore'
|
||||
useStaticApiListsStore().getWholeData()*/
|
||||
//define store
|
||||
/*import { useStaticApiListsStore } from '@/store/staticApisStore'
|
||||
import { getToken } from '@/utils'*/
|
||||
/*const store = useStaticApiListsStore()
|
||||
const token = getToken()
|
||||
if (token) store.getMyInfo()*/
|
||||
</script>
|
||||
|
||||
<style lang="less"></style>
|
||||
|
||||
Reference in New Issue
Block a user