UnisKB/ui/src/views/chat/index.vue

48 lines
1.1 KiB
Vue
Raw Normal View History

2025-06-03 08:08:49 +00:00
<template>
<component
:applicationAvailable="applicationAvailable"
:is="currentTemplate"
2025-06-17 03:58:35 +00:00
:application_profile="chatUser.application"
2025-06-03 08:08:49 +00:00
:key="route.fullPath"
/>
</template>
<script setup lang="ts">
2025-07-10 09:09:19 +00:00
import { ref, computed, onBeforeMount } from 'vue'
2025-06-03 08:08:49 +00:00
import { useRoute } from 'vue-router'
import useStore from '@/stores'
2025-07-10 09:09:19 +00:00
import { useI18n } from 'vue-i18n'
const { locale } = useI18n({ useScope: 'global' })
2025-06-03 08:08:49 +00:00
const route = useRoute()
2025-07-03 03:31:22 +00:00
const { chatUser, common } = useStore()
2025-06-03 08:08:49 +00:00
const components: any = import.meta.glob('@/views/chat/**/index.vue', {
2025-06-16 04:08:09 +00:00
eager: true,
2025-06-03 08:08:49 +00:00
})
const {
query: { mode },
} = route as any
2025-06-17 03:58:35 +00:00
2025-06-03 08:08:49 +00:00
const currentTemplate = computed(() => {
2025-07-28 09:59:12 +00:00
console.log(common.isMobile())
2025-06-03 08:08:49 +00:00
let modeName = ''
if (chatUser.application) {
if (!mode || mode === 'pc') {
modeName = common.isMobile() ? 'mobile' : 'pc'
} else {
modeName = mode
}
2025-06-03 08:08:49 +00:00
} else {
modeName = 'no-service'
2025-06-03 08:08:49 +00:00
}
2025-06-03 08:08:49 +00:00
const name = `/src/views/chat/${modeName}/index.vue`
return components[name].default
})
const applicationAvailable = ref<boolean>(true)
2025-07-10 09:09:19 +00:00
onBeforeMount(() => {
locale.value = chatUser.getLanguage()
})
2025-06-03 08:08:49 +00:00
</script>