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