add ai chat entry
This commit is contained in:
@@ -8,6 +8,29 @@
|
||||
:hide-nav="!tabBarStore.isShowing"
|
||||
@change="onChangeTab"
|
||||
>
|
||||
<template #rail-extra>
|
||||
<t-button
|
||||
class="ai-entry"
|
||||
:class="{ on: route.path.startsWith('/management/help') }"
|
||||
:aria-current="route.path.startsWith('/management/help') ? 'page' : undefined"
|
||||
variant="text"
|
||||
@click="router.push('/management/help')"
|
||||
>
|
||||
<t-icon name="file-1" size="1.375rem" />
|
||||
<span>使用说明</span>
|
||||
</t-button>
|
||||
<t-button
|
||||
v-if="userStore.hasRoles(gaoRoleCodes.storeManager)"
|
||||
class="ai-entry"
|
||||
:class="{ on: route.name === 'AiChat' }"
|
||||
:aria-current="route.name === 'AiChat' ? 'page' : undefined"
|
||||
variant="text"
|
||||
@click="router.push('/ai/chat')"
|
||||
>
|
||||
<t-icon name="robot-2" size="1.375rem" />
|
||||
<span>AI 小糕</span>
|
||||
</t-button>
|
||||
</template>
|
||||
<page-transition
|
||||
:keep-alive="shouldKeepAlive"
|
||||
:page-background="globalUIStore.bodyBackground"
|
||||
@@ -20,7 +43,7 @@
|
||||
import { AppShell, PageTransition, useLayout } from "timi-tdesign-mobile";
|
||||
import { useGlobalUIStore } from "@/store/globalUI";
|
||||
import { useTabBarStore } from "@/store/tabBarStore";
|
||||
import { permissionCodes } from "@/utils/permission";
|
||||
import { gaoRoleCodes, permissionCodes } from "@/utils/permission";
|
||||
import { useUserStore } from "timi-web-api/store";
|
||||
import type { RouteLocationNormalizedLoaded } from "vue-router";
|
||||
|
||||
@@ -117,6 +140,10 @@ async function syncVisibleTab(): Promise<void> {
|
||||
watch(list, syncVisibleTab, { immediate: true });
|
||||
|
||||
function resolveTabValue(path: string): string {
|
||||
if (railVisible.value && path.startsWith("/management/help")) {
|
||||
return path;
|
||||
}
|
||||
|
||||
if (path.startsWith("/customers")) {
|
||||
return "/customers";
|
||||
}
|
||||
@@ -176,3 +203,32 @@ const pageClass = computed(() => ({
|
||||
}));
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
.ai-entry {
|
||||
--td-button-border-radius: var(--tui-rail-item-radius, .75rem);
|
||||
|
||||
width: calc(100% - 1.25rem);
|
||||
height: auto;
|
||||
display: flex;
|
||||
margin: .125rem .625rem;
|
||||
padding: var(--tui-rail-item-padding, .75rem 0);
|
||||
color: var(--td-text-color-secondary);
|
||||
font-size: var(--tui-rail-item-font-size, .75rem);
|
||||
line-height: 1.4;
|
||||
flex-direction: column;
|
||||
|
||||
:deep(.t-button__content) {
|
||||
gap: .25rem;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
&.on {
|
||||
color: var(--tui-rail-active-color, var(--td-brand-color));
|
||||
font-weight: 600;
|
||||
background: var(--tui-rail-active-background, var(--td-brand-color-light));
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
>
|
||||
<template #right>
|
||||
<t-button
|
||||
v-if="canUseAi"
|
||||
v-if="canUseAi && !railVisible"
|
||||
:disabled="aiChatPanelRef?.isBusy"
|
||||
@click="aiChatPanelRef?.openConversationList()"
|
||||
theme="primary"
|
||||
@@ -21,6 +21,7 @@
|
||||
<div v-if="canUseAi" class="ai-chat-page">
|
||||
<ai-chat-panel
|
||||
ref="aiChatPanel"
|
||||
:split="railVisible"
|
||||
:store-name="currentStoreStore.currentStoreName"
|
||||
:session-key="sessionKey"
|
||||
:store-id="aiStoreId"
|
||||
@@ -30,6 +31,7 @@
|
||||
<t-empty v-else description="当前账号无权使用门店智能助手" />
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { useLayout } from "timi-tdesign-mobile";
|
||||
import { useUserStore } from "timi-web-api/store";
|
||||
import AiChatPanel from "@/pages/ai/components/AiChatPanel.vue";
|
||||
import { useCurrentStoreStore } from "@/store/currentStoreStore";
|
||||
@@ -39,6 +41,7 @@ defineOptions({
|
||||
name: "AiChatPage"
|
||||
});
|
||||
|
||||
const { railVisible } = useLayout({ tablet: true });
|
||||
const userStore = useUserStore();
|
||||
const currentStoreStore = useCurrentStoreStore();
|
||||
const conversationResetToken = ref(0);
|
||||
|
||||
@@ -1,4 +1,15 @@
|
||||
<template>
|
||||
<div class="chat-layout">
|
||||
<ai-conversation-list
|
||||
v-if="props.split"
|
||||
:visible="true"
|
||||
inline
|
||||
:active-conversation-id="conversationId"
|
||||
:disabled="isBusy"
|
||||
:session-key="props.sessionKey"
|
||||
@select="selectConversation"
|
||||
@delete="handleConversationDelete"
|
||||
/>
|
||||
<shared-ai-chat-panel
|
||||
ref="messageList"
|
||||
class="shared-panel"
|
||||
@@ -61,6 +72,7 @@
|
||||
</template>
|
||||
</shared-ai-chat-panel>
|
||||
<ai-conversation-list
|
||||
v-if="!props.split"
|
||||
v-model:visible="conversationVisible"
|
||||
:active-conversation-id="conversationId"
|
||||
:disabled="isBusy"
|
||||
@@ -68,6 +80,7 @@
|
||||
@select="selectConversation"
|
||||
@delete="handleConversationDelete"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
@@ -98,6 +111,7 @@ defineOptions({
|
||||
});
|
||||
|
||||
interface Props {
|
||||
split?: boolean;
|
||||
storeName: string;
|
||||
sessionKey: string;
|
||||
storeId?: string;
|
||||
@@ -430,3 +444,16 @@ onMounted(async () => {
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
<style scoped lang="less">
|
||||
.chat-layout {
|
||||
height: 100%;
|
||||
display: flex;
|
||||
min-height: 0;
|
||||
|
||||
.shared-panel {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
<template>
|
||||
<t-popup
|
||||
<component
|
||||
:is="props.inline ? 'div' : TPopup"
|
||||
v-model="popupVisible"
|
||||
placement="right"
|
||||
destroy-on-close
|
||||
:z-index="popupZIndex"
|
||||
:overlay-props="{ zIndex: popupZIndex - 1 }"
|
||||
>
|
||||
<section class="ai-conversation-list" @scroll="handleScroll">
|
||||
<section class="ai-conversation-list" :class="{ inline: props.inline }" @scroll="handleScroll">
|
||||
<header class="header glass-header">
|
||||
<h3>历史会话</h3>
|
||||
<t-button
|
||||
v-if="!props.inline"
|
||||
theme="danger"
|
||||
shape="circle"
|
||||
variant="text"
|
||||
@@ -77,11 +79,11 @@
|
||||
/>
|
||||
</div>
|
||||
</section>
|
||||
</t-popup>
|
||||
</component>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { DialogPlugin } from "tdesign-mobile-vue";
|
||||
import { DialogPlugin, Popup as TPopup } from "tdesign-mobile-vue";
|
||||
import { deleteConversation as removeConversation, type GaoAiConversation, listConversations } from "@/api/GaoAiAPI";
|
||||
import { getErrorMessage } from "@/utils/error";
|
||||
import { Message } from "@/utils/message";
|
||||
@@ -93,6 +95,7 @@ defineOptions({
|
||||
|
||||
interface Props {
|
||||
visible: boolean;
|
||||
inline?: boolean;
|
||||
activeConversationId: string;
|
||||
disabled: boolean;
|
||||
sessionKey: string;
|
||||
@@ -251,18 +254,18 @@ function formatConversationTime(conversation: GaoAiConversation): number {
|
||||
return timestamp < 100000000000 ? timestamp * 1000 : timestamp;
|
||||
}
|
||||
|
||||
watch(() => props.visible, async visible => {
|
||||
watch(() => props.inline || props.visible, async visible => {
|
||||
if (visible) {
|
||||
await reloadList();
|
||||
}
|
||||
});
|
||||
}, { immediate: true });
|
||||
|
||||
watch(() => props.sessionKey, async () => {
|
||||
requestToken += 1;
|
||||
conversationList.value = [];
|
||||
lastId.value = "";
|
||||
isNoMore.value = false;
|
||||
if (props.visible) {
|
||||
if (props.inline || props.visible) {
|
||||
await reloadList();
|
||||
}
|
||||
});
|
||||
@@ -278,6 +281,13 @@ watch(() => props.sessionKey, async () => {
|
||||
position: relative;
|
||||
flex-direction: column;
|
||||
|
||||
&.inline {
|
||||
width: 18rem;
|
||||
height: 100%;
|
||||
padding: calc(var(--tui-nav-height) + .5rem) 0 0 0;
|
||||
border-right: 1px solid var(--td-component-border);
|
||||
}
|
||||
|
||||
.header {
|
||||
top: 0;
|
||||
z-index: 1;
|
||||
|
||||
Reference in New Issue
Block a user