feat: Dialogue built-in user information function (#4188)
parent
622780e77d
commit
f470cd134c
|
|
@ -2,6 +2,7 @@
|
||||||
declare module 'katex'
|
declare module 'katex'
|
||||||
interface Window {
|
interface Window {
|
||||||
sendMessage: ?((message: string, other_params_data: any) => void)
|
sendMessage: ?((message: string, other_params_data: any) => void)
|
||||||
|
chatUserProfile: ?(() => any)
|
||||||
MaxKB: {
|
MaxKB: {
|
||||||
prefix: string
|
prefix: string
|
||||||
chatPrefix: string
|
chatPrefix: string
|
||||||
|
|
|
||||||
|
|
@ -114,6 +114,7 @@ import {
|
||||||
onMounted,
|
onMounted,
|
||||||
onBeforeUnmount,
|
onBeforeUnmount,
|
||||||
provide,
|
provide,
|
||||||
|
onBeforeMount,
|
||||||
} from 'vue'
|
} from 'vue'
|
||||||
import { useRoute } from 'vue-router'
|
import { useRoute } from 'vue-router'
|
||||||
import applicationApi from '@/api/application/application'
|
import applicationApi from '@/api/application/application'
|
||||||
|
|
@ -169,7 +170,7 @@ const emit = defineEmits([
|
||||||
'openParagraph',
|
'openParagraph',
|
||||||
'openParagraphDocument',
|
'openParagraphDocument',
|
||||||
])
|
])
|
||||||
const { application, common } = useStore()
|
const { application, common, chatUser } = useStore()
|
||||||
const isMobile = computed(() => {
|
const isMobile = computed(() => {
|
||||||
return common.isMobile() || mode === 'embed' || mode === 'mobile'
|
return common.isMobile() || mode === 'embed' || mode === 'mobile'
|
||||||
})
|
})
|
||||||
|
|
@ -645,7 +646,16 @@ const handleScroll = () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
onBeforeMount(() => {
|
||||||
|
window.chatUserProfile = () => {
|
||||||
|
if (props.type === 'ai-chat') {
|
||||||
|
if (chatUser.chat_profile?.authentication_type === 'login') {
|
||||||
|
return chatUser.getChatUserProfile()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Promise.resolve(null)
|
||||||
|
}
|
||||||
|
})
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
if (isUserInput.value && localStorage.getItem(`${accessToken}userForm`)) {
|
if (isUserInput.value && localStorage.getItem(`${accessToken}userForm`)) {
|
||||||
const userFormData = JSON.parse(localStorage.getItem(`${accessToken}userForm`) || '{}')
|
const userFormData = JSON.parse(localStorage.getItem(`${accessToken}userForm`) || '{}')
|
||||||
|
|
@ -668,6 +678,7 @@ onMounted(() => {
|
||||||
|
|
||||||
onBeforeUnmount(() => {
|
onBeforeUnmount(() => {
|
||||||
window.sendMessage = null
|
window.sendMessage = null
|
||||||
|
window.userProfile = null
|
||||||
})
|
})
|
||||||
|
|
||||||
function setScrollBottom() {
|
function setScrollBottom() {
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
import {defineStore} from 'pinia'
|
import { defineStore } from 'pinia'
|
||||||
import ChatAPI from '@/api/chat/chat'
|
import ChatAPI from '@/api/chat/chat'
|
||||||
import type {ChatProfile, ChatUserProfile} from '@/api/type/chat'
|
import type { ChatProfile, ChatUserProfile } from '@/api/type/chat'
|
||||||
import type {LoginRequest} from '@/api/type/user'
|
import type { LoginRequest } from '@/api/type/user'
|
||||||
import type {Ref} from 'vue'
|
import type { Ref } from 'vue'
|
||||||
import {getBrowserLang} from '@/locales/index'
|
import { getBrowserLang } from '@/locales/index'
|
||||||
|
|
||||||
interface ChatUser {
|
interface ChatUser {
|
||||||
// 用户id
|
// 用户id
|
||||||
|
|
@ -41,6 +41,7 @@ const useChatUserStore = defineStore('chat-user', {
|
||||||
async getChatUserProfile() {
|
async getChatUserProfile() {
|
||||||
const res = await ChatAPI.getChatUserProfile()
|
const res = await ChatAPI.getChatUserProfile()
|
||||||
this.chatUserProfile = res.data
|
this.chatUserProfile = res.data
|
||||||
|
return res.data
|
||||||
},
|
},
|
||||||
applicationProfile() {
|
applicationProfile() {
|
||||||
return ChatAPI.applicationProfile().then((ok) => {
|
return ChatAPI.applicationProfile().then((ok) => {
|
||||||
|
|
@ -148,7 +149,6 @@ const useChatUserStore = defineStore('chat-user', {
|
||||||
return ok.data
|
return ok.data
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue