feat: Dialogue built-in user information function (#4188)

This commit is contained in:
shaohuzhang1 2025-10-14 17:53:58 +08:00 committed by GitHub
parent 622780e77d
commit f470cd134c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 20 additions and 8 deletions

1
ui/env.d.ts vendored
View File

@ -2,6 +2,7 @@
declare module 'katex'
interface Window {
sendMessage: ?((message: string, other_params_data: any) => void)
chatUserProfile: ?(() => any)
MaxKB: {
prefix: string
chatPrefix: string

View File

@ -114,6 +114,7 @@ import {
onMounted,
onBeforeUnmount,
provide,
onBeforeMount,
} from 'vue'
import { useRoute } from 'vue-router'
import applicationApi from '@/api/application/application'
@ -169,7 +170,7 @@ const emit = defineEmits([
'openParagraph',
'openParagraphDocument',
])
const { application, common } = useStore()
const { application, common, chatUser } = useStore()
const isMobile = computed(() => {
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(() => {
if (isUserInput.value && localStorage.getItem(`${accessToken}userForm`)) {
const userFormData = JSON.parse(localStorage.getItem(`${accessToken}userForm`) || '{}')
@ -668,6 +678,7 @@ onMounted(() => {
onBeforeUnmount(() => {
window.sendMessage = null
window.userProfile = null
})
function setScrollBottom() {

View File

@ -1,9 +1,9 @@
import {defineStore} from 'pinia'
import { defineStore } from 'pinia'
import ChatAPI from '@/api/chat/chat'
import type {ChatProfile, ChatUserProfile} from '@/api/type/chat'
import type {LoginRequest} from '@/api/type/user'
import type {Ref} from 'vue'
import {getBrowserLang} from '@/locales/index'
import type { ChatProfile, ChatUserProfile } from '@/api/type/chat'
import type { LoginRequest } from '@/api/type/user'
import type { Ref } from 'vue'
import { getBrowserLang } from '@/locales/index'
interface ChatUser {
// 用户id
@ -41,6 +41,7 @@ const useChatUserStore = defineStore('chat-user', {
async getChatUserProfile() {
const res = await ChatAPI.getChatUserProfile()
this.chatUserProfile = res.data
return res.data
},
applicationProfile() {
return ChatAPI.applicationProfile().then((ok) => {
@ -148,7 +149,6 @@ const useChatUserStore = defineStore('chat-user', {
return ok.data
})
},
},
})