48 lines
1.4 KiB
Vue
48 lines
1.4 KiB
Vue
<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";
|
|
import { useCurrentStoreStore } from "@/store/currentStoreStore";
|
|
import { gaoRoleCodes } from "@/utils/permission";
|
|
|
|
defineOptions({
|
|
name: "AiChatPage"
|
|
});
|
|
|
|
const userStore = useUserStore();
|
|
const currentStoreStore = useCurrentStoreStore();
|
|
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);
|
|
|
|
function startNewConversation(): void {
|
|
conversationResetToken.value += 1;
|
|
}
|
|
</script>
|
|
|
|
<style scoped lang="less">
|
|
.ai-chat-page {
|
|
height: 100%;
|
|
overflow: hidden;
|
|
min-height: 0;
|
|
}
|
|
|
|
:global(html.theme-dark) {
|
|
.ai-chat-page {
|
|
background: #10161f;
|
|
}
|
|
}
|
|
</style>
|