mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-25 07:09:20 +08:00
feat: 发布草稿助手 UI 对齐智能助手页交互
This commit is contained in:
@@ -28,9 +28,16 @@ const CollapseIcon = createIconifyIcon('lucide:minimize-2');
|
|||||||
const draft = defineModel<string>({ required: true });
|
const draft = defineModel<string>({ required: true });
|
||||||
const cites = defineModel<CatalogCite[]>('cites', { required: true });
|
const cites = defineModel<CatalogCite[]>('cites', { required: true });
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = withDefaults(
|
||||||
loading?: boolean;
|
defineProps<{
|
||||||
}>();
|
loading?: boolean;
|
||||||
|
/** 输入框占位;默认面向通用助手 */
|
||||||
|
placeholder?: string;
|
||||||
|
}>(),
|
||||||
|
{
|
||||||
|
placeholder: '问点什么,或用 @ 引用店铺 / 商品 / SKU',
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
send: [value: string];
|
send: [value: string];
|
||||||
@@ -432,7 +439,7 @@ onBeforeUnmount(() => {
|
|||||||
v-model="draft"
|
v-model="draft"
|
||||||
class="agent-td-sender"
|
class="agent-td-sender"
|
||||||
:loading="loading"
|
:loading="loading"
|
||||||
placeholder="问点什么,或用 @ 引用店铺 / 商品 / SKU"
|
:placeholder="placeholder"
|
||||||
:textarea-props="{ autosize: textareaAutosize }"
|
:textarea-props="{ autosize: textareaAutosize }"
|
||||||
@send="onChatSend"
|
@send="onChatSend"
|
||||||
@stop="emit('stop')"
|
@stop="emit('stop')"
|
||||||
|
|||||||
@@ -1078,16 +1078,12 @@ html.dark .agent-session-item--active,
|
|||||||
}
|
}
|
||||||
|
|
||||||
.agent-td-item {
|
.agent-td-item {
|
||||||
margin-bottom: 16px;
|
/* ChatItem 根节点即 .t-chat__inner,样式打在本类上 */
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 短消息也固定左右:气泡 fit-content + 贴边,避免被 tdesign justify-center 居中 */
|
|
||||||
.agent-td-item :deep(.t-chat__inner) {
|
|
||||||
display: flex;
|
display: flex;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
padding-inline: 4px;
|
margin-bottom: 16px;
|
||||||
|
padding-inline: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.agent-td-item :deep(.t-chat__content) {
|
.agent-td-item :deep(.t-chat__content) {
|
||||||
@@ -1097,7 +1093,7 @@ html.dark .agent-session-item--active,
|
|||||||
justify-content: flex-start !important;
|
justify-content: flex-start !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.agent-td-item--assistant :deep(.t-chat__inner) {
|
.agent-td-item--assistant {
|
||||||
justify-content: flex-start;
|
justify-content: flex-start;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1108,7 +1104,7 @@ html.dark .agent-session-item--active,
|
|||||||
margin-left: 0;
|
margin-left: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.agent-td-item--user :deep(.t-chat__inner) {
|
.agent-td-item--user {
|
||||||
justify-content: flex-end;
|
justify-content: flex-end;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1132,6 +1128,7 @@ html.dark .agent-session-item--active,
|
|||||||
|
|
||||||
.agent-tool-status {
|
.agent-tool-status {
|
||||||
justify-content: flex-start;
|
justify-content: flex-start;
|
||||||
|
padding-inline: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 浅色:给气泡补边框与底色,避免与主背景糊在一起 */
|
/* 浅色:给气泡补边框与底色,避免与主背景糊在一起 */
|
||||||
@@ -1143,8 +1140,9 @@ html.dark .agent-session-item--active,
|
|||||||
padding-block: 10px;
|
padding-block: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.agent-td-item :deep(.t-chat__inner.user .t-chat__text--variant--base .t-chat__detail),
|
.agent-td-item--user :deep(.t-chat__text--variant--base .t-chat__detail),
|
||||||
.agent-td-item :deep(.t-chat__inner.user .t-chat__detail) {
|
.agent-td-item--user :deep(.t-chat__detail),
|
||||||
|
.agent-td-item.user :deep(.t-chat__detail) {
|
||||||
background: hsl(var(--primary) / 0.1);
|
background: hsl(var(--primary) / 0.1);
|
||||||
border-color: hsl(var(--primary) / 0.22);
|
border-color: hsl(var(--primary) / 0.22);
|
||||||
}
|
}
|
||||||
@@ -1157,10 +1155,12 @@ html.dark .agent-td-item :deep(.t-chat__detail),
|
|||||||
background: hsl(var(--muted) / 0.4);
|
background: hsl(var(--muted) / 0.4);
|
||||||
}
|
}
|
||||||
|
|
||||||
html.dark .agent-td-item :deep(.t-chat__inner.user .t-chat__text--variant--base .t-chat__detail),
|
html.dark .agent-td-item--user :deep(.t-chat__text--variant--base .t-chat__detail),
|
||||||
html.dark .agent-td-item :deep(.t-chat__inner.user .t-chat__detail),
|
html.dark .agent-td-item--user :deep(.t-chat__detail),
|
||||||
.dark .agent-td-item :deep(.t-chat__inner.user .t-chat__text--variant--base .t-chat__detail),
|
html.dark .agent-td-item.user :deep(.t-chat__detail),
|
||||||
.dark .agent-td-item :deep(.t-chat__inner.user .t-chat__detail) {
|
.dark .agent-td-item--user :deep(.t-chat__text--variant--base .t-chat__detail),
|
||||||
|
.dark .agent-td-item--user :deep(.t-chat__detail),
|
||||||
|
.dark .agent-td-item.user :deep(.t-chat__detail) {
|
||||||
background: hsl(var(--primary) / 0.22);
|
background: hsl(var(--primary) / 0.22);
|
||||||
border-color: transparent;
|
border-color: transparent;
|
||||||
}
|
}
|
||||||
|
|||||||
+293
-142
@@ -1,16 +1,13 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
/**
|
/**
|
||||||
* 拼多多发布页右侧智能体栏:一草稿一会话,执行 client_tool 改表单。
|
* 拼多多发布页右侧智能体栏:一草稿一会话,执行 client_tool 改表单。
|
||||||
|
* UI 对齐通用智能助手(气泡、加载、底栏输入与模型选择)。
|
||||||
*/
|
*/
|
||||||
import { computed, nextTick, onBeforeUnmount, ref, watch } from 'vue';
|
import { computed, nextTick, onBeforeUnmount, ref, watch } from 'vue';
|
||||||
|
|
||||||
import {
|
import { createIconifyIcon } from '@vben/icons';
|
||||||
MenuFoldOutlined,
|
import { Empty, Select, Spin, Tooltip, message } from 'ant-design-vue';
|
||||||
MenuUnfoldOutlined,
|
import { ChatItem, ChatLoading } from '@tdesign-vue-next/chat';
|
||||||
SendOutlined,
|
|
||||||
} from '@ant-design/icons-vue';
|
|
||||||
import { Button, Empty, Input, Select, Spin, Tooltip, message } from 'ant-design-vue';
|
|
||||||
import { ChatItem } from '@tdesign-vue-next/chat';
|
|
||||||
import 'tdesign-vue-next/es/style/index.css';
|
import 'tdesign-vue-next/es/style/index.css';
|
||||||
import '@tdesign-vue-next/chat/es/style/index.css';
|
import '@tdesign-vue-next/chat/es/style/index.css';
|
||||||
|
|
||||||
@@ -22,11 +19,21 @@ import {
|
|||||||
streamAgentChat,
|
streamAgentChat,
|
||||||
type AgentVO,
|
type AgentVO,
|
||||||
} from '#/api/agent';
|
} from '#/api/agent';
|
||||||
|
import CatalogCiteSender from '#/views/agent/chat/catalog-cite-sender.vue';
|
||||||
|
import {
|
||||||
|
composeMessageWithCites,
|
||||||
|
stripTrailingMention,
|
||||||
|
type CatalogCite,
|
||||||
|
} from '#/views/agent/chat/catalog-cite';
|
||||||
|
|
||||||
import type { PublishEditorAgentApi } from './commands';
|
import type { PublishEditorAgentApi } from './commands';
|
||||||
|
|
||||||
defineOptions({ name: 'PddPublishAgentPanel' });
|
defineOptions({ name: 'PddPublishAgentPanel' });
|
||||||
|
|
||||||
|
const AgentBrandIcon = createIconifyIcon('lucide:bot');
|
||||||
|
const PanelCloseIcon = createIconifyIcon('lucide:panel-left-close');
|
||||||
|
const PanelOpenIcon = createIconifyIcon('lucide:panel-left');
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
draftId: number;
|
draftId: number;
|
||||||
collapsed?: boolean;
|
collapsed?: boolean;
|
||||||
@@ -42,9 +49,18 @@ const emit = defineEmits<{
|
|||||||
const SCENE = 'ecom_goods_publish' as const;
|
const SCENE = 'ecom_goods_publish' as const;
|
||||||
|
|
||||||
const starterPrompts = [
|
const starterPrompts = [
|
||||||
'根据已填的 SKU 商家编码,找相似拼多多商品并生成标题',
|
{
|
||||||
'参考渠道商品帮我整理规格轴',
|
label: '按编码生成标题',
|
||||||
'把当前标题改得更适合拼多多搜索',
|
prompt: '根据已填的 SKU 商家编码,找相似拼多多商品并生成标题',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '整理规格轴',
|
||||||
|
prompt: '参考渠道商品帮我整理规格轴',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '优化标题',
|
||||||
|
prompt: '把当前标题改得更适合拼多多搜索',
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
type BubbleView = {
|
type BubbleView = {
|
||||||
@@ -64,6 +80,7 @@ const streamingText = ref('');
|
|||||||
const toolStatusLabel = ref('');
|
const toolStatusLabel = ref('');
|
||||||
const toolStatusActive = ref(false);
|
const toolStatusActive = ref(false);
|
||||||
const draft = ref('');
|
const draft = ref('');
|
||||||
|
const citations = ref<CatalogCite[]>([]);
|
||||||
const enabledModels = ref<AgentVO.LlmModelItem[]>([]);
|
const enabledModels = ref<AgentVO.LlmModelItem[]>([]);
|
||||||
const selectedModelKey = ref<string | undefined>(undefined);
|
const selectedModelKey = ref<string | undefined>(undefined);
|
||||||
const patchingModel = ref(false);
|
const patchingModel = ref(false);
|
||||||
@@ -111,6 +128,12 @@ const showStarter = computed(
|
|||||||
!loadingSession.value,
|
!loadingSession.value,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const showMessageLoading = computed(
|
||||||
|
() =>
|
||||||
|
(loadingSession.value || loadingMessages.value) &&
|
||||||
|
messages.value.length === 0,
|
||||||
|
);
|
||||||
|
|
||||||
const bubbleViews = computed<BubbleView[]>(() =>
|
const bubbleViews = computed<BubbleView[]>(() =>
|
||||||
messages.value.map((m, idx) => {
|
messages.value.map((m, idx) => {
|
||||||
const isStreamingAssistant =
|
const isStreamingAssistant =
|
||||||
@@ -148,6 +171,11 @@ function syncSelectedFromSession() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function clearToolStatus() {
|
||||||
|
toolStatusActive.value = false;
|
||||||
|
toolStatusLabel.value = '';
|
||||||
|
}
|
||||||
|
|
||||||
/** 滚到消息区底部;多拍几次等 ChatItem 异步撑高后再定住 */
|
/** 滚到消息区底部;多拍几次等 ChatItem 异步撑高后再定住 */
|
||||||
function scrollChatToBottom() {
|
function scrollChatToBottom() {
|
||||||
const run = () => {
|
const run = () => {
|
||||||
@@ -232,6 +260,8 @@ async function bootstrap() {
|
|||||||
loadingSession.value = true;
|
loadingSession.value = true;
|
||||||
messages.value = [];
|
messages.value = [];
|
||||||
session.value = null;
|
session.value = null;
|
||||||
|
draft.value = '';
|
||||||
|
citations.value = [];
|
||||||
try {
|
try {
|
||||||
await loadEnabledModels();
|
await loadEnabledModels();
|
||||||
const threadId = await ensureSession();
|
const threadId = await ensureSession();
|
||||||
@@ -275,8 +305,7 @@ async function onModelChange(key: string) {
|
|||||||
|
|
||||||
function appendStreamToken(t: string) {
|
function appendStreamToken(t: string) {
|
||||||
if (toolStatusActive.value) {
|
if (toolStatusActive.value) {
|
||||||
toolStatusActive.value = false;
|
clearToolStatus();
|
||||||
toolStatusLabel.value = '';
|
|
||||||
}
|
}
|
||||||
streamingText.value += t;
|
streamingText.value += t;
|
||||||
const idx = messages.value.length - 1;
|
const idx = messages.value.length - 1;
|
||||||
@@ -293,9 +322,7 @@ function onStreamTool(payload: { phase: string; label: string }) {
|
|||||||
toolStatusLabel.value = payload.label;
|
toolStatusLabel.value = payload.label;
|
||||||
void nextTick().then(scrollChatToBottom);
|
void nextTick().then(scrollChatToBottom);
|
||||||
} else if (payload.phase === 'end') {
|
} else if (payload.phase === 'end') {
|
||||||
// 结束后清状态,避免卡在「读取发布表单…」直到下一段 token
|
clearToolStatus();
|
||||||
toolStatusActive.value = false;
|
|
||||||
toolStatusLabel.value = '';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -312,8 +339,12 @@ async function onClientTool(call: AgentVO.ClientToolCall) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function send(textOverride?: string) {
|
async function send(rawOverride?: string) {
|
||||||
const text = (textOverride ?? draft.value).trim();
|
const raw = (rawOverride ?? draft.value).trim();
|
||||||
|
const text = composeMessageWithCites(
|
||||||
|
stripTrailingMention(raw),
|
||||||
|
citations.value,
|
||||||
|
);
|
||||||
if (!text || sending.value) return;
|
if (!text || sending.value) return;
|
||||||
|
|
||||||
sending.value = true;
|
sending.value = true;
|
||||||
@@ -333,9 +364,9 @@ async function send(textOverride?: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
streamingText.value = '';
|
streamingText.value = '';
|
||||||
toolStatusActive.value = false;
|
clearToolStatus();
|
||||||
toolStatusLabel.value = '';
|
|
||||||
draft.value = '';
|
draft.value = '';
|
||||||
|
citations.value = [];
|
||||||
messages.value.push({
|
messages.value.push({
|
||||||
seq: (messages.value.at(-1)?.seq || 0) + 1,
|
seq: (messages.value.at(-1)?.seq || 0) + 1,
|
||||||
role: 'user',
|
role: 'user',
|
||||||
@@ -376,8 +407,7 @@ async function send(textOverride?: string) {
|
|||||||
}
|
}
|
||||||
sending.value = false;
|
sending.value = false;
|
||||||
streamingText.value = '';
|
streamingText.value = '';
|
||||||
toolStatusActive.value = false;
|
clearToolStatus();
|
||||||
toolStatusLabel.value = '';
|
|
||||||
},
|
},
|
||||||
onError: (msg) => {
|
onError: (msg) => {
|
||||||
sending.value = false;
|
sending.value = false;
|
||||||
@@ -387,40 +417,48 @@ async function send(textOverride?: string) {
|
|||||||
messages.value[idx] = { ...last, content: `错误:${msg}` };
|
messages.value[idx] = { ...last, content: `错误:${msg}` };
|
||||||
}
|
}
|
||||||
streamingText.value = '';
|
streamingText.value = '';
|
||||||
toolStatusActive.value = false;
|
clearToolStatus();
|
||||||
toolStatusLabel.value = '';
|
|
||||||
message.error(msg);
|
message.error(msg);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onSenderSend(value: string) {
|
||||||
|
void send(value);
|
||||||
|
}
|
||||||
|
|
||||||
function applyStarterPrompt(text: string) {
|
function applyStarterPrompt(text: string) {
|
||||||
draft.value = text;
|
draft.value = text;
|
||||||
}
|
}
|
||||||
|
|
||||||
function onStop() {
|
function onSenderStop() {
|
||||||
abort?.abort();
|
abort?.abort();
|
||||||
sending.value = false;
|
sending.value = false;
|
||||||
toolStatusActive.value = false;
|
clearToolStatus();
|
||||||
toolStatusLabel.value = '';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onBeforeUnmount(() => abort?.abort());
|
onBeforeUnmount(() => abort?.abort());
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<!-- 收起:窄条 -->
|
<!-- 收起:窄条(悬停 bot→展开图标,对齐智能助手) -->
|
||||||
<div
|
<div
|
||||||
v-if="collapsed"
|
v-if="collapsed"
|
||||||
class="border-border bg-card flex h-full w-14 shrink-0 flex-col items-center border-l py-3"
|
class="publish-agent-rail border-border flex h-full w-14 shrink-0 flex-col items-center border-l px-1.5 py-2"
|
||||||
>
|
>
|
||||||
<Tooltip title="展开发布助手" placement="left">
|
<Tooltip title="展开发布助手" placement="left">
|
||||||
<Button type="text" @click="emit('expand')">
|
<button
|
||||||
<template #icon><MenuUnfoldOutlined /></template>
|
type="button"
|
||||||
</Button>
|
class="hover:bg-muted group flex size-10 items-center justify-center rounded-lg transition-colors"
|
||||||
|
aria-label="展开发布助手"
|
||||||
|
@click="emit('expand')"
|
||||||
|
>
|
||||||
|
<AgentBrandIcon class="size-5 group-hover:hidden" />
|
||||||
|
<PanelOpenIcon class="hidden size-5 group-hover:block" />
|
||||||
|
</button>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
<div
|
<div
|
||||||
class="text-muted-foreground mt-4 write-vertical-right text-xs tracking-widest"
|
class="text-muted-foreground mt-3 text-xs tracking-widest"
|
||||||
style="writing-mode: vertical-rl"
|
style="writing-mode: vertical-rl"
|
||||||
>
|
>
|
||||||
发布助手
|
发布助手
|
||||||
@@ -430,150 +468,263 @@ onBeforeUnmount(() => abort?.abort());
|
|||||||
<!-- 展开 -->
|
<!-- 展开 -->
|
||||||
<aside
|
<aside
|
||||||
v-else
|
v-else
|
||||||
class="border-border bg-card flex h-full min-h-0 w-full min-w-[280px] flex-col border-l"
|
class="publish-agent-panel border-border flex h-full min-h-0 w-full min-w-[280px] flex-col border-l"
|
||||||
>
|
>
|
||||||
<header
|
<header class="flex h-12 shrink-0 items-center gap-1 px-3">
|
||||||
class="flex h-12 shrink-0 items-center gap-2 border-b border-border px-3"
|
<div class="min-w-0 flex-1 truncate text-sm font-semibold">发布助手</div>
|
||||||
>
|
|
||||||
<span class="min-w-0 flex-1 truncate text-sm font-medium">发布助手</span>
|
|
||||||
<Select
|
|
||||||
:value="selectedModelKey"
|
|
||||||
:options="modelOptions"
|
|
||||||
:loading="patchingModel"
|
|
||||||
:disabled="sending || enabledModels.length === 0"
|
|
||||||
placeholder="模型"
|
|
||||||
class="w-36 shrink-0"
|
|
||||||
size="small"
|
|
||||||
:allow-clear="false"
|
|
||||||
@change="(v) => onModelChange(String(v ?? ''))"
|
|
||||||
/>
|
|
||||||
<Tooltip title="收起">
|
<Tooltip title="收起">
|
||||||
<Button type="text" size="small" @click="emit('collapse')">
|
<button
|
||||||
<template #icon><MenuFoldOutlined /></template>
|
type="button"
|
||||||
</Button>
|
class="hover:bg-muted text-muted-foreground hover:text-foreground flex size-9 items-center justify-center rounded-lg transition-colors"
|
||||||
|
aria-label="收起发布助手"
|
||||||
|
@click="emit('collapse')"
|
||||||
|
>
|
||||||
|
<PanelCloseIcon class="size-5" />
|
||||||
|
</button>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<div class="relative flex min-h-0 flex-1 flex-col">
|
<section class="relative flex min-h-0 flex-1 flex-col">
|
||||||
<div
|
<div
|
||||||
v-if="loadingSession || loadingMessages"
|
v-if="showMessageLoading"
|
||||||
class="absolute inset-0 z-10 flex items-center justify-center bg-background/50"
|
class="text-muted-foreground absolute inset-0 z-10 flex items-center justify-center bg-background/60 text-sm"
|
||||||
>
|
>
|
||||||
<Spin size="small" />
|
<Spin size="small" class="mr-2" />
|
||||||
|
加载中…
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- 空态:说明 + 居中输入 + chips -->
|
||||||
<div
|
<div
|
||||||
ref="messagePaneRef"
|
v-if="showStarter"
|
||||||
class="publish-agent-chat t-chat t-chat--normal min-h-0 flex-1 overflow-y-auto py-3"
|
class="flex min-h-0 flex-1 flex-col justify-center px-3 pb-6 pt-4"
|
||||||
>
|
>
|
||||||
<div
|
<div class="mb-5 px-1">
|
||||||
v-if="showStarter"
|
<div class="text-base font-semibold tracking-tight">
|
||||||
class="flex h-full flex-col justify-center px-1 py-4"
|
帮你完善本页草稿
|
||||||
>
|
</div>
|
||||||
<div class="text-sm font-medium">帮你完善本页草稿</div>
|
<p class="text-muted-foreground mt-1.5 text-xs leading-5">
|
||||||
<p class="text-muted-foreground mt-2 text-xs leading-5">
|
可按已填 SKU 编码查商品、生成标题并写回规格轴;改表单会落到左侧编辑区。
|
||||||
可按已填 SKU 编码查内部/拼多多商品,生成标题并写回规格轴。改表单会直接落到左侧编辑区。
|
|
||||||
</p>
|
</p>
|
||||||
<div class="mt-3 flex flex-col gap-1.5">
|
|
||||||
<button
|
|
||||||
v-for="item in starterPrompts"
|
|
||||||
:key="item"
|
|
||||||
type="button"
|
|
||||||
class="hover:border-primary hover:bg-primary/5 rounded-md border border-border bg-background px-2.5 py-1.5 text-left text-xs transition-colors"
|
|
||||||
@click="applyStarterPrompt(item)"
|
|
||||||
>
|
|
||||||
{{ item }}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<Empty
|
<div class="publish-agent-composer w-full">
|
||||||
v-else-if="!loadingSession && !loadingMessages && messages.length === 0"
|
<CatalogCiteSender
|
||||||
class="mt-16"
|
v-model="draft"
|
||||||
description="开始提问吧"
|
v-model:cites="citations"
|
||||||
/>
|
:loading="sending"
|
||||||
<ChatItem
|
placeholder="描述想改的标题、规格,或用 @ 引用"
|
||||||
v-for="item in bubbleViews"
|
@send="onSenderSend"
|
||||||
:key="item.id"
|
@stop="onSenderStop"
|
||||||
class="publish-agent-item"
|
>
|
||||||
:role="item.role"
|
<template #footer-extra>
|
||||||
:name="item.name"
|
<Select
|
||||||
:content="item.content"
|
:value="selectedModelKey"
|
||||||
:text-loading="item.textLoading"
|
:options="modelOptions"
|
||||||
variant="base"
|
:loading="patchingModel"
|
||||||
animation="gradient"
|
:disabled="sending || enabledModels.length === 0"
|
||||||
/>
|
placeholder="模型"
|
||||||
<div
|
size="small"
|
||||||
v-if="toolStatusActive && toolStatusLabel"
|
class="publish-agent-model-select min-w-0 max-w-[160px] flex-1"
|
||||||
class="text-muted-foreground flex items-center gap-2 px-1 py-1 text-xs"
|
:allow-clear="false"
|
||||||
>
|
@change="(v) => onModelChange(String(v ?? ''))"
|
||||||
<span
|
/>
|
||||||
class="border-primary/40 inline-block size-3 animate-spin rounded-full border-2 border-t-transparent"
|
</template>
|
||||||
/>
|
</CatalogCiteSender>
|
||||||
<span>{{ toolStatusLabel }}…</span>
|
<div class="mt-4 flex flex-wrap gap-2">
|
||||||
|
<Tooltip
|
||||||
|
v-for="item in starterPrompts"
|
||||||
|
:key="item.label"
|
||||||
|
:title="item.prompt"
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="hover:bg-muted border-border text-foreground/80 hover:text-foreground inline-flex cursor-pointer items-center rounded-full border bg-card px-3 py-1.5 text-xs transition-colors"
|
||||||
|
@click="applyStarterPrompt(item.prompt)"
|
||||||
|
>
|
||||||
|
{{ item.label }}
|
||||||
|
</button>
|
||||||
|
</Tooltip>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="shrink-0 border-t border-border p-2">
|
<!-- 对话态 -->
|
||||||
<div class="flex gap-1.5">
|
<template v-else>
|
||||||
<Input.TextArea
|
<div
|
||||||
v-model:value="draft"
|
ref="messagePaneRef"
|
||||||
:auto-size="{ minRows: 2, maxRows: 5 }"
|
class="publish-agent-chat t-chat t-chat--normal min-h-0 flex-1 overflow-y-auto px-3 pb-3 pt-4"
|
||||||
:disabled="sending"
|
>
|
||||||
placeholder="描述你想改的标题、规格…"
|
<Empty
|
||||||
class="flex-1"
|
v-if="!showMessageLoading && messages.length === 0"
|
||||||
@keydown.enter.exact.prevent="() => send()"
|
class="mt-16"
|
||||||
|
description="开始提问吧"
|
||||||
/>
|
/>
|
||||||
<div class="flex flex-col gap-1">
|
<ChatItem
|
||||||
<Button
|
v-for="item in bubbleViews"
|
||||||
v-if="sending"
|
:key="item.id"
|
||||||
type="default"
|
class="publish-agent-item"
|
||||||
size="small"
|
:class="[
|
||||||
@click="onStop"
|
item.role === 'user'
|
||||||
>
|
? 'publish-agent-item--user'
|
||||||
停止
|
: 'publish-agent-item--assistant',
|
||||||
</Button>
|
{ 'publish-agent-item--loading': item.textLoading },
|
||||||
<Button
|
]"
|
||||||
v-else
|
:role="item.role"
|
||||||
type="primary"
|
:name="item.name"
|
||||||
size="small"
|
:content="item.textLoading ? undefined : item.content"
|
||||||
:disabled="!draft.trim()"
|
:text-loading="false"
|
||||||
@click="() => send()"
|
variant="base"
|
||||||
>
|
>
|
||||||
<template #icon><SendOutlined /></template>
|
<template v-if="item.textLoading" #content>
|
||||||
</Button>
|
<ChatLoading animation="dots" />
|
||||||
|
</template>
|
||||||
|
</ChatItem>
|
||||||
|
<div
|
||||||
|
v-if="toolStatusActive && toolStatusLabel"
|
||||||
|
class="text-muted-foreground flex items-center gap-2 px-1 py-1 text-xs"
|
||||||
|
>
|
||||||
|
<ChatLoading animation="dots" :text="`${toolStatusLabel}…`" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</div>
|
<div class="publish-agent-composer shrink-0 px-3 pb-3 pt-1">
|
||||||
|
<CatalogCiteSender
|
||||||
|
v-model="draft"
|
||||||
|
v-model:cites="citations"
|
||||||
|
:loading="sending"
|
||||||
|
placeholder="描述想改的标题、规格,或用 @ 引用"
|
||||||
|
@send="onSenderSend"
|
||||||
|
@stop="onSenderStop"
|
||||||
|
>
|
||||||
|
<template #footer-extra>
|
||||||
|
<Select
|
||||||
|
:value="selectedModelKey"
|
||||||
|
:options="modelOptions"
|
||||||
|
:loading="patchingModel"
|
||||||
|
:disabled="sending || enabledModels.length === 0"
|
||||||
|
placeholder="模型"
|
||||||
|
size="small"
|
||||||
|
class="publish-agent-model-select min-w-0 max-w-[160px] flex-1"
|
||||||
|
:allow-clear="false"
|
||||||
|
@change="(v) => onModelChange(String(v ?? ''))"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</CatalogCiteSender>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</section>
|
||||||
</aside>
|
</aside>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
.publish-agent-rail,
|
||||||
|
.publish-agent-panel {
|
||||||
|
background: hsl(var(--muted) / 0.45);
|
||||||
|
}
|
||||||
|
|
||||||
|
html.dark .publish-agent-rail,
|
||||||
|
html.dark .publish-agent-panel,
|
||||||
|
.dark .publish-agent-rail,
|
||||||
|
.dark .publish-agent-panel {
|
||||||
|
background: hsl(var(--background-deep, var(--background)));
|
||||||
|
}
|
||||||
|
|
||||||
|
.publish-agent-composer :deep(.t-chat-sender) {
|
||||||
|
border-radius: 20px;
|
||||||
|
box-shadow: 0 0 0 1px hsl(var(--border) / 0.8);
|
||||||
|
}
|
||||||
|
|
||||||
|
.publish-agent-composer :deep(.t-chat-sender__textarea__wrapper) {
|
||||||
|
border-radius: 20px;
|
||||||
|
padding: 0;
|
||||||
|
margin-bottom: 0 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.publish-agent-model-select :deep(.ant-select-selector) {
|
||||||
|
border-radius: 999px !important;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* TDesign `.t-chat { padding: 0 }` 会盖掉 Tailwind px-*,容器左右留白写这里。
|
* ChatItem 根节点就是 .t-chat__inner,padding / justify 必须打在本类上。
|
||||||
* 不要动 `.t-chat__detail` 的 padding,那是气泡内文字边距。
|
|
||||||
*/
|
*/
|
||||||
.publish-agent-chat.t-chat {
|
|
||||||
--td-bg-color-container: transparent;
|
|
||||||
padding: 12px 16px !important;
|
|
||||||
box-sizing: border-box;
|
|
||||||
}
|
|
||||||
.publish-agent-item {
|
.publish-agent-item {
|
||||||
margin-bottom: 10px;
|
display: flex;
|
||||||
}
|
|
||||||
.publish-agent-item :deep(.t-chat__inner) {
|
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
padding-inline: 4px;
|
width: 100%;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
padding-inline: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.publish-agent-item :deep(.t-chat__content) {
|
.publish-agent-item :deep(.t-chat__content) {
|
||||||
width: auto;
|
flex: 0 1 auto !important;
|
||||||
max-width: calc(100% - 8px);
|
width: fit-content !important;
|
||||||
|
max-width: calc(100% - 4px);
|
||||||
|
justify-content: flex-start !important;
|
||||||
}
|
}
|
||||||
.publish-agent-item :deep(.t-chat__inner.user) {
|
|
||||||
|
.publish-agent-item--assistant {
|
||||||
|
justify-content: flex-start;
|
||||||
|
}
|
||||||
|
|
||||||
|
.publish-agent-item--assistant :deep(.t-chat__content) {
|
||||||
|
align-self: flex-start;
|
||||||
|
align-items: flex-start !important;
|
||||||
|
margin-right: auto;
|
||||||
|
margin-left: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.publish-agent-item--user {
|
||||||
justify-content: flex-end;
|
justify-content: flex-end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.publish-agent-item--user :deep(.t-chat__content) {
|
||||||
|
align-self: flex-end;
|
||||||
|
align-items: flex-end !important;
|
||||||
|
margin-left: auto;
|
||||||
|
margin-right: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.publish-agent-item :deep(.t-chat__detail) {
|
||||||
|
width: fit-content;
|
||||||
|
max-width: 100%;
|
||||||
|
margin-inline: 0;
|
||||||
|
}
|
||||||
|
|
||||||
.publish-agent-item :deep(.t-chat__avatar),
|
.publish-agent-item :deep(.t-chat__avatar),
|
||||||
.publish-agent-item :deep(.t-chat__name) {
|
.publish-agent-item :deep(.t-chat__name) {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 浅色:气泡边框与底色,避免与侧栏糊在一起 */
|
||||||
|
.publish-agent-item :deep(.t-chat__text--variant--base .t-chat__detail),
|
||||||
|
.publish-agent-item :deep(.t-chat__detail) {
|
||||||
|
border: 1px solid hsl(var(--border));
|
||||||
|
border-radius: 12px;
|
||||||
|
background: hsl(var(--background));
|
||||||
|
padding-block: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.publish-agent-item--user :deep(.t-chat__text--variant--base .t-chat__detail),
|
||||||
|
.publish-agent-item--user :deep(.t-chat__detail),
|
||||||
|
.publish-agent-item.user :deep(.t-chat__detail) {
|
||||||
|
background: hsl(var(--primary) / 0.1);
|
||||||
|
border-color: hsl(var(--primary) / 0.22);
|
||||||
|
}
|
||||||
|
|
||||||
|
html.dark .publish-agent-item :deep(.t-chat__text--variant--base .t-chat__detail),
|
||||||
|
html.dark .publish-agent-item :deep(.t-chat__detail),
|
||||||
|
.dark .publish-agent-item :deep(.t-chat__text--variant--base .t-chat__detail),
|
||||||
|
.dark .publish-agent-item :deep(.t-chat__detail) {
|
||||||
|
border-color: transparent;
|
||||||
|
background: hsl(var(--muted) / 0.4);
|
||||||
|
}
|
||||||
|
|
||||||
|
html.dark .publish-agent-item--user :deep(.t-chat__text--variant--base .t-chat__detail),
|
||||||
|
html.dark .publish-agent-item--user :deep(.t-chat__detail),
|
||||||
|
html.dark .publish-agent-item.user :deep(.t-chat__detail),
|
||||||
|
.dark .publish-agent-item--user :deep(.t-chat__text--variant--base .t-chat__detail),
|
||||||
|
.dark .publish-agent-item--user :deep(.t-chat__detail),
|
||||||
|
.dark .publish-agent-item.user :deep(.t-chat__detail) {
|
||||||
|
background: hsl(var(--primary) / 0.22);
|
||||||
|
border-color: transparent;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user