mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-23 23:19:19 +08:00
feat: aichat 改用 tdesign chat
This commit is contained in:
@@ -59,20 +59,28 @@ class OpenAICompatibleStreamer(ChatStreamer):
|
||||
yield text
|
||||
return
|
||||
|
||||
# 工具轮:先非流式执行 tool_calls,最后一轮流式输出正文
|
||||
# 工具轮:每轮用 astream 边生成边推 token;出现 tool_call 再执行工具后继续
|
||||
bound = model.bind_tools(tools)
|
||||
tool_map = {t.name: t for t in tools if getattr(t, "name", None)}
|
||||
for _ in range(5):
|
||||
ai = await bound.ainvoke(messages)
|
||||
messages.append(ai)
|
||||
tool_calls = getattr(ai, "tool_calls", None) or []
|
||||
gathered = None
|
||||
saw_tool = False
|
||||
async for chunk in bound.astream(messages):
|
||||
gathered = chunk if gathered is None else gathered + chunk
|
||||
if getattr(chunk, "tool_call_chunks", None) or getattr(chunk, "tool_calls", None):
|
||||
saw_tool = True
|
||||
continue
|
||||
if saw_tool:
|
||||
continue
|
||||
text = _chunk_text(getattr(chunk, "content", None))
|
||||
if text:
|
||||
yield text
|
||||
if gathered is None:
|
||||
yield "(模型未返回内容)"
|
||||
return
|
||||
messages.append(gathered)
|
||||
tool_calls = getattr(gathered, "tool_calls", None) or []
|
||||
if not tool_calls:
|
||||
content = ai.content if isinstance(ai.content, str) else _chunk_text(ai.content)
|
||||
if content:
|
||||
# 按小段 yield,便于前端渐进展示
|
||||
step = 24
|
||||
for i in range(0, len(content), step):
|
||||
yield content[i : i + step]
|
||||
return
|
||||
|
||||
yield f"\n[调用工具: {', '.join(tc.get('name', '?') for tc in tool_calls)}]\n"
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
"#/*": "./src/*"
|
||||
},
|
||||
"dependencies": {
|
||||
"@tdesign-vue-next/chat": "^0.7.0",
|
||||
"@vben/access": "workspace:*",
|
||||
"@vben/common-ui": "workspace:*",
|
||||
"@vben/constants": "workspace:*",
|
||||
@@ -42,20 +43,16 @@
|
||||
"@vben/utils": "workspace:*",
|
||||
"@vueuse/core": "catalog:",
|
||||
"ant-design-vue": "catalog:",
|
||||
"ant-design-x-vue": "^1.6.0",
|
||||
"dayjs": "catalog:",
|
||||
"dompurify": "^3.4.15",
|
||||
"marked": "^18.0.13",
|
||||
"papaparse": "^5.4.1",
|
||||
"pinia": "catalog:",
|
||||
"spark-md5": "^3.0.2",
|
||||
"tdesign-vue-next": "^1.20.8",
|
||||
"vue": "catalog:",
|
||||
"vue-router": "catalog:",
|
||||
"vue-waterfall-plugin-next": "^3.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/dompurify": "^3.2.0",
|
||||
"@types/marked": "^6.0.0",
|
||||
"@types/papaparse": "^5.3.14",
|
||||
"@types/spark-md5": "^3.0.5"
|
||||
}
|
||||
|
||||
@@ -1,19 +1,8 @@
|
||||
<script lang="ts" setup>
|
||||
import type {
|
||||
BubbleListProps,
|
||||
BubbleProps,
|
||||
Conversation,
|
||||
} from 'ant-design-x-vue';
|
||||
|
||||
import { computed, h, nextTick, onBeforeUnmount, ref, watch } from 'vue';
|
||||
import { computed, nextTick, onBeforeUnmount, ref, watch } from 'vue';
|
||||
|
||||
import { Page } from '@vben/common-ui';
|
||||
import {
|
||||
PlusOutlined,
|
||||
RobotOutlined,
|
||||
SettingOutlined,
|
||||
UserOutlined,
|
||||
} from '@ant-design/icons-vue';
|
||||
import { PlusOutlined, SettingOutlined } from '@ant-design/icons-vue';
|
||||
|
||||
import {
|
||||
Button,
|
||||
@@ -26,7 +15,9 @@ import {
|
||||
Spin,
|
||||
message,
|
||||
} from 'ant-design-vue';
|
||||
import { BubbleList, Conversations, Sender } from 'ant-design-x-vue';
|
||||
import { ChatItem, ChatSender } from '@tdesign-vue-next/chat';
|
||||
import 'tdesign-vue-next/es/style/index.css';
|
||||
import '@tdesign-vue-next/chat/es/style/index.css';
|
||||
|
||||
import {
|
||||
createAgentSessionApi,
|
||||
@@ -40,10 +31,17 @@ import {
|
||||
updateAgentLlmSettingsApi,
|
||||
} from '#/api/agent';
|
||||
|
||||
import { renderAgentMarkdown } from './markdown';
|
||||
|
||||
defineOptions({ name: 'AgentChat' });
|
||||
|
||||
/** 消息气泡视图模型(走 Vue ChatItem,避免 ChatList→WebComponent 丢正文) */
|
||||
type BubbleView = {
|
||||
id: string;
|
||||
role: 'user' | 'assistant';
|
||||
name: string;
|
||||
content: string;
|
||||
textLoading: boolean;
|
||||
};
|
||||
|
||||
const loadingSessions = ref(false);
|
||||
const loadingMessages = ref(false);
|
||||
const sending = ref(false);
|
||||
@@ -63,12 +61,7 @@ const llmForm = ref({
|
||||
apiKeyMasked: '' as string | null,
|
||||
configured: false,
|
||||
});
|
||||
const bubbleListRef = ref<{
|
||||
scrollTo?: (info: {
|
||||
key?: string | number;
|
||||
block?: ScrollLogicalPosition;
|
||||
}) => void;
|
||||
} | null>(null);
|
||||
const messagePaneRef = ref<HTMLElement | null>(null);
|
||||
let abort: AbortController | null = null;
|
||||
let messagesLoadSeq = 0;
|
||||
|
||||
@@ -80,79 +73,38 @@ const showMessageLoading = computed(
|
||||
() => loadingMessages.value && !sending.value && messages.value.length === 0,
|
||||
);
|
||||
|
||||
const renderAssistantMarkdown: BubbleProps['messageRender'] = (content) => {
|
||||
const html = renderAgentMarkdown(String(content ?? ''));
|
||||
return h('div', { class: 'agent-md', innerHTML: html || '…' });
|
||||
};
|
||||
|
||||
/** Bubble.List 角色预设:SSE 已流式输出,关闭组件自带 typing 动画 */
|
||||
const bubbleRoles: BubbleListProps['roles'] = {
|
||||
assistant: {
|
||||
placement: 'start',
|
||||
variant: 'filled',
|
||||
avatar: {
|
||||
icon: h(RobotOutlined),
|
||||
style: { background: '#1677ff', color: '#fff' },
|
||||
},
|
||||
messageRender: renderAssistantMarkdown,
|
||||
styles: { content: { maxWidth: 'min(720px, 85%)' } },
|
||||
},
|
||||
user: {
|
||||
placement: 'end',
|
||||
variant: 'filled',
|
||||
avatar: {
|
||||
icon: h(UserOutlined),
|
||||
style: { background: '#87d068', color: '#fff' },
|
||||
},
|
||||
styles: { content: { maxWidth: 'min(720px, 85%)' } },
|
||||
},
|
||||
};
|
||||
|
||||
const bubbleItems = computed<BubbleListProps['items']>(() =>
|
||||
const bubbleViews = computed<BubbleView[]>(() =>
|
||||
messages.value.map((m, idx) => {
|
||||
const isStreamingAssistant =
|
||||
sending.value &&
|
||||
idx === messages.value.length - 1 &&
|
||||
m.role === 'assistant';
|
||||
const content = isStreamingAssistant
|
||||
const text = isStreamingAssistant
|
||||
? streamingText.value || m.content || ''
|
||||
: m.content || '';
|
||||
const role = m.role === 'user' ? 'user' : 'assistant';
|
||||
return {
|
||||
key: m.id || `${m.seq}-${idx}`,
|
||||
id: m.id || `${m.seq}-${idx}`,
|
||||
role,
|
||||
content,
|
||||
loading: isStreamingAssistant && !content,
|
||||
name: role === 'user' ? '我' : '智能助手',
|
||||
content: text,
|
||||
textLoading: isStreamingAssistant && !text,
|
||||
};
|
||||
}),
|
||||
);
|
||||
|
||||
/** 侧栏会话列表:映射为 Conversations items(label 用字符串,避免 Typography ellipsis+children 告警) */
|
||||
const conversationItems = computed<Conversation[]>(() =>
|
||||
sessions.value.map((s) => {
|
||||
const ts = s.updatedAt || s.lastMessageAt || s.createdAt;
|
||||
const timeMs = ts ? Date.parse(ts) : undefined;
|
||||
return {
|
||||
key: s.threadId,
|
||||
label: s.title || '新对话',
|
||||
timestamp: Number.isFinite(timeMs) ? timeMs : undefined,
|
||||
};
|
||||
}),
|
||||
);
|
||||
function scrollChatToBottom() {
|
||||
const el = messagePaneRef.value;
|
||||
if (!el) return;
|
||||
el.scrollTop = el.scrollHeight;
|
||||
}
|
||||
|
||||
function onConversationActiveChange(key: string) {
|
||||
function onSessionClick(threadId: string) {
|
||||
if (sending.value) {
|
||||
message.warning('回复生成中,请稍候再切换会话');
|
||||
return;
|
||||
}
|
||||
activeThreadId.value = key;
|
||||
}
|
||||
|
||||
function scrollBubblesToBottom() {
|
||||
const items = bubbleItems.value || [];
|
||||
const last = items[items.length - 1];
|
||||
if (last?.key == null) return;
|
||||
bubbleListRef.value?.scrollTo?.({ key: last.key, block: 'end' });
|
||||
activeThreadId.value = threadId;
|
||||
}
|
||||
|
||||
async function refreshSessions() {
|
||||
@@ -185,7 +137,7 @@ async function loadMessages(threadId: string) {
|
||||
messages.value = res.items || [];
|
||||
streamingText.value = '';
|
||||
await nextTick();
|
||||
scrollBubblesToBottom();
|
||||
scrollChatToBottom();
|
||||
} catch (e: any) {
|
||||
if (seq === messagesLoadSeq && !sending.value) {
|
||||
message.error(e?.message || '加载消息失败');
|
||||
@@ -281,7 +233,7 @@ function appendStreamToken(t: string) {
|
||||
if (last?.role === 'assistant') {
|
||||
messages.value[idx] = { ...last, content: streamingText.value };
|
||||
}
|
||||
void nextTick().then(scrollBubblesToBottom);
|
||||
void nextTick().then(scrollChatToBottom);
|
||||
}
|
||||
|
||||
async function send(textOverride?: string) {
|
||||
@@ -309,7 +261,7 @@ async function send(textOverride?: string) {
|
||||
content: '',
|
||||
});
|
||||
await nextTick();
|
||||
scrollBubblesToBottom();
|
||||
scrollChatToBottom();
|
||||
|
||||
abort?.abort();
|
||||
abort = streamAgentChat({
|
||||
@@ -340,11 +292,11 @@ async function send(textOverride?: string) {
|
||||
});
|
||||
}
|
||||
|
||||
function onSenderSubmit(msg: string) {
|
||||
void send(msg);
|
||||
function onSenderSend(value: string) {
|
||||
void send(value);
|
||||
}
|
||||
|
||||
function onSenderCancel() {
|
||||
function onSenderStop() {
|
||||
abort?.abort();
|
||||
sending.value = false;
|
||||
}
|
||||
@@ -374,17 +326,32 @@ void refreshSessions();
|
||||
<Spin size="small" />
|
||||
</div>
|
||||
<Empty
|
||||
v-if="!loadingSessions && conversationItems.length === 0"
|
||||
v-if="!loadingSessions && sessions.length === 0"
|
||||
class="mt-10 px-2"
|
||||
description="暂无会话"
|
||||
/>
|
||||
<Conversations
|
||||
v-else
|
||||
class="agent-conversations h-full overflow-y-auto px-3 py-2"
|
||||
:items="conversationItems"
|
||||
:active-key="activeThreadId ?? undefined"
|
||||
@active-change="onConversationActiveChange"
|
||||
/>
|
||||
<div v-else class="h-full space-y-1 overflow-y-auto px-3 py-2">
|
||||
<button
|
||||
v-for="s in sessions"
|
||||
:key="s.threadId"
|
||||
type="button"
|
||||
class="w-full rounded-lg px-3 py-2 text-left text-sm transition-colors"
|
||||
:class="
|
||||
s.threadId === activeThreadId
|
||||
? 'bg-primary/10 text-primary'
|
||||
: 'hover:bg-muted text-foreground'
|
||||
"
|
||||
@click="onSessionClick(s.threadId)"
|
||||
>
|
||||
<div class="truncate font-medium">{{ s.title || '新对话' }}</div>
|
||||
<div
|
||||
v-if="s.updatedAt || s.lastMessageAt"
|
||||
class="text-muted-foreground mt-0.5 truncate text-xs"
|
||||
>
|
||||
{{ s.updatedAt || s.lastMessageAt }}
|
||||
</div>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="border-t border-border p-3">
|
||||
<Button block @click="openSettings">
|
||||
@@ -394,7 +361,7 @@ void refreshSessions();
|
||||
</div>
|
||||
</aside>
|
||||
|
||||
<section class="flex min-h-0 min-w-0 flex-1 flex-col">
|
||||
<section class="agent-chat-main flex min-h-0 min-w-0 flex-1 flex-col">
|
||||
<header
|
||||
class="flex h-12 shrink-0 items-center border-b border-border px-4"
|
||||
>
|
||||
@@ -403,7 +370,7 @@ void refreshSessions();
|
||||
</span>
|
||||
</header>
|
||||
|
||||
<div class="relative min-h-0 flex-1">
|
||||
<div class="relative flex min-h-0 flex-1 flex-col">
|
||||
<div
|
||||
v-if="showMessageLoading"
|
||||
class="text-muted-foreground absolute inset-0 z-10 flex items-center justify-center bg-background/60 text-sm"
|
||||
@@ -415,27 +382,34 @@ void refreshSessions();
|
||||
class="absolute inset-0 flex items-center justify-center"
|
||||
description="开始提问吧(需先配置公司模型 API)"
|
||||
/>
|
||||
<BubbleList
|
||||
v-show="messages.length > 0"
|
||||
ref="bubbleListRef"
|
||||
class="h-full px-4 py-4"
|
||||
:roles="bubbleRoles"
|
||||
:items="bubbleItems"
|
||||
:auto-scroll="true"
|
||||
/>
|
||||
<div
|
||||
ref="messagePaneRef"
|
||||
class="agent-td-chat t-chat t-chat--normal min-h-0 flex-1 overflow-y-auto py-4"
|
||||
>
|
||||
<ChatItem
|
||||
v-for="item in bubbleViews"
|
||||
:key="item.id"
|
||||
class="agent-td-item"
|
||||
:role="item.role"
|
||||
:name="item.name"
|
||||
:content="item.content"
|
||||
:text-loading="item.textLoading"
|
||||
variant="base"
|
||||
animation="gradient"
|
||||
/>
|
||||
</div>
|
||||
<div class="shrink-0 border-t border-border p-3">
|
||||
<ChatSender
|
||||
v-model="draft"
|
||||
class="agent-td-sender"
|
||||
:loading="sending"
|
||||
placeholder="输入问题,Enter 发送"
|
||||
:textarea-props="{ autosize: { minRows: 2, maxRows: 6 } }"
|
||||
@send="onSenderSend"
|
||||
@stop="onSenderStop"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<footer class="shrink-0 border-t border-border p-3">
|
||||
<Sender
|
||||
v-model:value="draft"
|
||||
:loading="sending"
|
||||
placeholder="输入问题,Enter 发送(Shift+Enter 换行)"
|
||||
:auto-size="{ minRows: 2, maxRows: 6 }"
|
||||
submit-type="enter"
|
||||
@submit="onSenderSubmit"
|
||||
@cancel="onSenderCancel"
|
||||
/>
|
||||
</footer>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
@@ -499,57 +473,26 @@ void refreshSessions();
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.agent-conversations :deep(.ant-conversations-list) {
|
||||
padding-inline: 0;
|
||||
.agent-td-chat {
|
||||
--td-bg-color-container: transparent;
|
||||
padding-inline: 28px;
|
||||
}
|
||||
.agent-md :deep(p) {
|
||||
margin: 0.35em 0;
|
||||
.agent-td-item {
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
.agent-md :deep(p:first-child) {
|
||||
margin-top: 0;
|
||||
/* 气泡按内容收缩,左右再留一截,避免贴边铺满 */
|
||||
.agent-td-item :deep(.t-chat__inner) {
|
||||
box-sizing: border-box;
|
||||
padding-inline: 4px;
|
||||
}
|
||||
.agent-md :deep(p:last-child) {
|
||||
margin-bottom: 0;
|
||||
.agent-td-item :deep(.t-chat__content) {
|
||||
width: auto;
|
||||
max-width: min(720px, calc(100% - 32px));
|
||||
}
|
||||
.agent-md :deep(ul),
|
||||
.agent-md :deep(ol) {
|
||||
margin: 0.35em 0;
|
||||
padding-left: 1.25em;
|
||||
.agent-td-item :deep(.t-chat__inner.user) {
|
||||
justify-content: flex-end;
|
||||
}
|
||||
.agent-md :deep(pre) {
|
||||
margin: 0.5em 0;
|
||||
overflow-x: auto;
|
||||
border-radius: 0.5rem;
|
||||
background: rgba(0, 0, 0, 0.06);
|
||||
padding: 0.6em 0.75em;
|
||||
font-size: 0.85em;
|
||||
}
|
||||
.agent-md :deep(code) {
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
||||
font-size: 0.9em;
|
||||
}
|
||||
.agent-md :deep(:not(pre) > code) {
|
||||
border-radius: 0.25rem;
|
||||
background: rgba(0, 0, 0, 0.06);
|
||||
padding: 0.1em 0.35em;
|
||||
}
|
||||
.agent-md :deep(a) {
|
||||
text-decoration: underline;
|
||||
}
|
||||
.agent-md :deep(blockquote) {
|
||||
margin: 0.4em 0;
|
||||
border-left: 3px solid rgba(0, 0, 0, 0.2);
|
||||
padding-left: 0.75em;
|
||||
opacity: 0.9;
|
||||
}
|
||||
.agent-md :deep(table) {
|
||||
margin: 0.5em 0;
|
||||
border-collapse: collapse;
|
||||
font-size: 0.9em;
|
||||
}
|
||||
.agent-md :deep(th),
|
||||
.agent-md :deep(td) {
|
||||
border: 1px solid rgba(0, 0, 0, 0.12);
|
||||
padding: 0.25em 0.5em;
|
||||
.agent-td-sender {
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
/** 轻量 Markdown → 安全 HTML(流式场景下未闭合围栏也能尽量渲染)。 */
|
||||
import DOMPurify from 'dompurify';
|
||||
import { marked } from 'marked';
|
||||
|
||||
marked.setOptions({
|
||||
gfm: true,
|
||||
breaks: true,
|
||||
});
|
||||
|
||||
export function renderAgentMarkdown(source: string): string {
|
||||
const raw = source || '';
|
||||
if (!raw.trim()) return '';
|
||||
try {
|
||||
const html = marked.parse(raw, { async: false }) as string;
|
||||
return DOMPurify.sanitize(html, {
|
||||
USE_PROFILES: { html: true },
|
||||
});
|
||||
} catch {
|
||||
return DOMPurify.sanitize(raw.replace(/</g, '<').replace(/>/g, '>'));
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
diff --git a/es/conversations/ConversationsItem.mjs b/es/conversations/ConversationsItem.mjs
|
||||
index 7245467416f4bff50d882a1cc4b0e6085150d507..45ccd67847af10d4706e476e6d2682aac1b13a16 100644
|
||||
--- a/es/conversations/ConversationsItem.mjs
|
||||
+++ b/es/conversations/ConversationsItem.mjs
|
||||
@@ -84,14 +84,18 @@ const j = /* @__PURE__ */ h({
|
||||
onClick: x
|
||||
}), [e.info.icon && n("div", {
|
||||
class: `${e.prefixCls}-icon`
|
||||
- }, [e.info.icon]), n(M.Text, {
|
||||
- class: `${e.prefixCls}-label`,
|
||||
- ellipsis: {
|
||||
- onEllipsis: v
|
||||
- }
|
||||
- }, {
|
||||
- default: () => [e.info.label]
|
||||
- }), !o.value && e.menu && n(N, {
|
||||
+ }, [e.info.icon]), (() => {
|
||||
+ const A = e.info.label, S = typeof A == "string" || typeof A == "number";
|
||||
+ return n(M.Text, {
|
||||
+ class: `${e.prefixCls}-label`,
|
||||
+ content: S ? A : void 0,
|
||||
+ ellipsis: {
|
||||
+ onEllipsis: v
|
||||
+ }
|
||||
+ }, S ? void 0 : {
|
||||
+ default: () => [A]
|
||||
+ });
|
||||
+ })(), !o.value && e.menu && n(N, {
|
||||
placement: e.direction === "rtl" ? "bottomLeft" : "bottomRight",
|
||||
trigger: ["click"],
|
||||
disabled: o.value,
|
||||
diff --git a/lib/conversations/ConversationsItem.js b/lib/conversations/ConversationsItem.js
|
||||
index ded16c252b0d9b4c5fe8bdb98bad0366f77ebe2c..582665631e71ac65215803f616b74d0d88bfd869 100644
|
||||
--- a/lib/conversations/ConversationsItem.js
|
||||
+++ b/lib/conversations/ConversationsItem.js
|
||||
@@ -1 +1 @@
|
||||
-"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("vue"),d=require("../chunks/helper-chunk.js"),s=require("../chunks/module-chunk.js"),P=require("../_util/pick-attrs.js"),a=require("ant-design-vue"),c=require("../_util/hooks/use-state.js"),N=t.defineComponent({name:"AXConversationsItem",__name:"ConversationsItem",props:{info:{type:Object,required:!0},prefixCls:{type:String,required:!1},direction:{required:!1},menu:{type:Object,required:!1},active:{type:Boolean,required:!1},onClick:{type:Function,required:!1}},setup(e,{expose:f}){f();const g=d.createPropsRestProxy(e,["prefixCls","info","class","direction","onClick","active","menu"]);t.toRef(e,"class");const m=t.computed(()=>P.default(g,{aria:!0,data:!0,attr:!0})),v=n=>{n.stopPropagation()},i=t.computed(()=>e.info.disabled),[C,p]=c.default(!1),[b,r]=c.default(!1),x=t.computed(()=>s.classnames(e.class,`${e.prefixCls}-item`,{[`${e.prefixCls}-item-active`]:e.active&&!i.value},{[`${e.prefixCls}-item-disabled`]:i.value})),h=()=>{!i.value&&e.onClick&&e.onClick(e.info)},k=n=>{n&&r(!n)},o=t.computed(()=>{var n;return(n=e.menu)==null?void 0:n.trigger}),u=t.computed(()=>{const{trigger:n,...l}=e.menu||{};return l}),q=t.computed(()=>{var n;return(n=u.value)==null?void 0:n.getPopupContainer}),y=n=>{const l=t.createVNode(s.EllipsisOutlined,{onClick:v,class:`${e.prefixCls}-menu-icon`},null);return o.value?typeof o.value=="function"?o.value(n,{originNode:l}):o.value:l};return()=>t.createVNode(a.Tooltip,{title:e.info.label,open:C.value&&b.value,onOpenChange:r,placement:e.direction==="rtl"?"left":"right"},{default:()=>[t.createVNode("li",t.mergeProps(m.value,{class:x.value,onClick:h}),[e.info.icon&&t.createVNode("div",{class:`${e.prefixCls}-icon`},[e.info.icon]),t.createVNode(a.Typography.Text,{class:`${e.prefixCls}-label`,ellipsis:{onEllipsis:p}},{default:()=>[e.info.label]}),!i.value&&e.menu&&t.createVNode(a.Dropdown,{placement:e.direction==="rtl"?"bottomLeft":"bottomRight",trigger:["click"],disabled:i.value,onOpenChange:k,getPopupContainer:q.value},{default:()=>y(e.info),overlay:()=>t.createVNode(a.Menu,u.value,null)})])]})}}),O=d._export_sfc(N,[["__file","/Users/wangzhichao/办公/code/github/ant-design-x-vue-pure/ant-design-x-vue/src/conversations/ConversationsItem.vue"]]);exports.default=O;
|
||||
+"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("vue"),d=require("../chunks/helper-chunk.js"),s=require("../chunks/module-chunk.js"),P=require("../_util/pick-attrs.js"),a=require("ant-design-vue"),c=require("../_util/hooks/use-state.js"),N=t.defineComponent({name:"AXConversationsItem",__name:"ConversationsItem",props:{info:{type:Object,required:!0},prefixCls:{type:String,required:!1},direction:{required:!1},menu:{type:Object,required:!1},active:{type:Boolean,required:!1},onClick:{type:Function,required:!1}},setup(e,{expose:f}){f();const g=d.createPropsRestProxy(e,["prefixCls","info","class","direction","onClick","active","menu"]);t.toRef(e,"class");const m=t.computed(()=>P.default(g,{aria:!0,data:!0,attr:!0})),v=n=>{n.stopPropagation()},i=t.computed(()=>e.info.disabled),[C,p]=c.default(!1),[b,r]=c.default(!1),x=t.computed(()=>s.classnames(e.class,`${e.prefixCls}-item`,{[`${e.prefixCls}-item-active`]:e.active&&!i.value},{[`${e.prefixCls}-item-disabled`]:i.value})),h=()=>{!i.value&&e.onClick&&e.onClick(e.info)},k=n=>{n&&r(!n)},o=t.computed(()=>{var n;return(n=e.menu)==null?void 0:n.trigger}),u=t.computed(()=>{const{trigger:n,...l}=e.menu||{};return l}),q=t.computed(()=>{var n;return(n=u.value)==null?void 0:n.getPopupContainer}),y=n=>{const l=t.createVNode(s.EllipsisOutlined,{onClick:v,class:`${e.prefixCls}-menu-icon`},null);return o.value?typeof o.value=="function"?o.value(n,{originNode:l}):o.value:l};return()=>t.createVNode(a.Tooltip,{title:e.info.label,open:C.value&&b.value,onOpenChange:r,placement:e.direction==="rtl"?"left":"right"},{default:()=>[t.createVNode("li",t.mergeProps(m.value,{class:x.value,onClick:h}),[e.info.icon&&t.createVNode("div",{class:`${e.prefixCls}-icon`},[e.info.icon]),((A)=>{const S=typeof A=="string"||typeof A=="number";return t.createVNode(a.Typography.Text,{class:`${e.prefixCls}-label`,content:S?A:void 0,ellipsis:{onEllipsis:p}},S?void 0:{default:()=>[A]})})(e.info.label),!i.value&&e.menu&&t.createVNode(a.Dropdown,{placement:e.direction==="rtl"?"bottomLeft":"bottomRight",trigger:["click"],disabled:i.value,onOpenChange:k,getPopupContainer:q.value},{default:()=>y(e.info),overlay:()=>t.createVNode(a.Menu,u.value,null)})])]})}}),O=d._export_sfc(N,[["__file","/Users/wangzhichao/办公/code/github/ant-design-x-vue-pure/ant-design-x-vue/src/conversations/ConversationsItem.vue"]]);exports.default=O;
|
||||
Generated
+1660
-74
File diff suppressed because it is too large
Load Diff
@@ -13,10 +13,6 @@ packages:
|
||||
- docs
|
||||
- playground
|
||||
|
||||
# ConversationsItem:Typography ellipsis 改用 content,消除 ant-design-vue 控制台告警
|
||||
patchedDependencies:
|
||||
ant-design-x-vue@1.6.0: patches/ant-design-x-vue@1.6.0.patch
|
||||
|
||||
catalog:
|
||||
'@ast-grep/napi': ^0.37.0
|
||||
'@changesets/changelog-github': ^0.5.1
|
||||
|
||||
Reference in New Issue
Block a user