add new session button
This commit is contained in:
+17
-12
@@ -1,3 +1,14 @@
|
||||
<template>
|
||||
<div v-if="canUseAi" class="ai-chat-page">
|
||||
<ai-chat-panel
|
||||
:store-name="currentStoreStore.currentStoreName"
|
||||
:session-key="sessionKey"
|
||||
:store-id="aiStoreId"
|
||||
@new-conversation="startNewConversation"
|
||||
/>
|
||||
</div>
|
||||
<t-empty v-else description="当前账号无权使用门店智能助手" />
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { useUserStore } from "timi-web-api/store";
|
||||
import AiChatPanel from "@/pages/ai/components/AiChatPanel.vue";
|
||||
@@ -10,22 +21,16 @@ defineOptions({
|
||||
|
||||
const userStore = useUserStore();
|
||||
const currentStoreStore = useCurrentStoreStore();
|
||||
const sessionKey = computed(() => `${userStore.loginUser.user?.id || userStore.loginUser.id || ""}:${currentStoreStore.currentStoreId}`);
|
||||
const conversationResetToken = ref(0);
|
||||
const sessionKey = computed(() => `${userStore.loginUser.user?.id || userStore.loginUser.id || ""}:${currentStoreStore.currentStoreId}:${conversationResetToken.value}`);
|
||||
const canUseAi = computed(() => userStore.hasRoles(gaoRoleCodes.storeManager));
|
||||
const isGlobalManager = computed(() => userStore.hasRoles(gaoRoleCodes.globalManager));
|
||||
const aiStoreId = computed(() => canUseAi.value && isGlobalManager.value ? currentStoreStore.currentStoreId : undefined);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-if="canUseAi" class="ai-chat-page">
|
||||
<ai-chat-panel
|
||||
:store-name="currentStoreStore.currentStoreName"
|
||||
:session-key="sessionKey"
|
||||
:store-id="aiStoreId"
|
||||
/>
|
||||
</div>
|
||||
<t-empty v-else description="当前账号无权使用门店智能助手" />
|
||||
</template>
|
||||
function startNewConversation(): void {
|
||||
conversationResetToken.value += 1;
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
.ai-chat-page {
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
@send="submitMessage"
|
||||
@stop="stopGeneration"
|
||||
@retry="retryLastMessage"
|
||||
@new-conversation="emit('new-conversation')"
|
||||
>
|
||||
<template #welcome>
|
||||
<div class="welcome">
|
||||
@@ -25,10 +26,9 @@
|
||||
<p v-entrance-transition="140">我会根据当前门店的实时业务数据回答经营问题。</p>
|
||||
<div class="quick-list" v-entrance-transition="210">
|
||||
<t-button
|
||||
class="quick-question bg-white"
|
||||
v-for="question in aiQuickQuestionList"
|
||||
:key="question"
|
||||
class="quick-question"
|
||||
variant="outline"
|
||||
size="small"
|
||||
@click="submitMessage(question)"
|
||||
>
|
||||
@@ -104,6 +104,9 @@ interface Props {
|
||||
}
|
||||
|
||||
const props = defineProps<Props>();
|
||||
const emit = defineEmits<{
|
||||
"new-conversation": [];
|
||||
}>();
|
||||
const userStore = useUserStore();
|
||||
const navBarStore = useNavBarStore();
|
||||
type MessageListExpose = {
|
||||
@@ -339,9 +342,7 @@ onUnmounted(() => navBarStore.clearRight());
|
||||
|
||||
<style scoped lang="less">
|
||||
.shared-panel {
|
||||
:deep(.ai-chat-panel) {
|
||||
padding-top: var(--app-nav-height);
|
||||
}
|
||||
padding-top: var(--app-nav-height);
|
||||
|
||||
:deep(.welcome) {
|
||||
margin: auto 0;
|
||||
|
||||
Reference in New Issue
Block a user