mirror of
https://github.com/1Panel-dev/MaxKB.git
synced 2025-12-26 01:33:05 +00:00
feat: Dialogue built-in user information function (#4188)
This commit is contained in:
parent
622780e77d
commit
f470cd134c
|
|
@ -2,6 +2,7 @@
|
|||
declare module 'katex'
|
||||
interface Window {
|
||||
sendMessage: ?((message: string, other_params_data: any) => void)
|
||||
chatUserProfile: ?(() => any)
|
||||
MaxKB: {
|
||||
prefix: string
|
||||
chatPrefix: string
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
})
|
||||
},
|
||||
|
||||
},
|
||||
})
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue