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

48 lines
1.1 KiB
Vue
Raw Normal View History

2023-11-29 09:34:45 +00:00
<template>
2024-05-20 09:50:14 +00:00
<component :is="currentTemplate" :key="route.fullPath" />
2023-11-29 09:34:45 +00:00
</template>
<script setup lang="ts">
2024-07-22 10:52:56 +00:00
import { ref, onMounted, computed } from 'vue'
2024-05-20 09:50:14 +00:00
import { useRoute } from 'vue-router'
2024-07-19 09:13:53 +00:00
import useStore from '@/stores'
2024-07-22 10:52:56 +00:00
const { application, user } = useStore()
2024-05-20 09:50:14 +00:00
const components: any = import.meta.glob('@/views/chat/**/index.vue', {
eager: true
})
2023-11-30 10:50:42 +00:00
const route = useRoute()
const {
2024-05-20 09:50:14 +00:00
query: { mode }
2023-11-30 10:50:42 +00:00
} = route as any
2024-05-20 09:50:14 +00:00
const currentTemplate = computed(() => {
2024-07-22 10:52:56 +00:00
let modeName = ''
if (mode && mode === 'embed') {
modeName = 'embed'
} else {
2024-07-23 10:21:46 +00:00
modeName = show_history.value || !user.showXpack() ? 'pc' : 'base'
2024-07-22 10:52:56 +00:00
}
const name = `/src/views/chat/${modeName}/index.vue`
2024-05-20 09:50:14 +00:00
return components[name].default
2023-11-30 10:50:42 +00:00
})
2024-07-22 10:52:56 +00:00
const loading = ref(false)
const show_history = ref(false)
function getAppProfile() {
application.asyncGetAppProfile(loading).then((res: any) => {
show_history.value = res.data?.show_history
})
}
2024-05-15 02:26:49 +00:00
2024-07-19 09:13:53 +00:00
onMounted(() => {
2024-07-22 10:52:56 +00:00
user.asyncGetProfile().then(() => {
if (user.isEnterprise()) {
getAppProfile()
}
})
2024-07-19 09:13:53 +00:00
})
2024-05-20 09:50:14 +00:00
</script>
<style lang="scss"></style>