Add smart ACK provider for WeChat MP replies
Replace fixed ackText with a rule-based AckProvider that picks response templates by message type and intent (translate, summary, rewrite, poster, ppt, mindmap, code, search, schedule). Pure sync, zero I/O, auto-falls back to config.ackText on any error. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
import { WechatAccountButton } from './WechatAccountButton';
|
||||
const HEADER_POPOVER_OPEN_EVENT = 'tkmind:header-popover-open';
|
||||
const HEADER_POPOVER_ID = 'header-more-menu';
|
||||
|
||||
type MenuItem = {
|
||||
id: string;
|
||||
@@ -39,6 +41,17 @@ export function ChatHeaderMoreMenu({
|
||||
};
|
||||
}, [open]);
|
||||
|
||||
useEffect(() => {
|
||||
const handleOtherPopoverOpen = (event: Event) => {
|
||||
const detail = (event as CustomEvent<{ id?: string }>).detail;
|
||||
if (detail?.id && detail.id !== HEADER_POPOVER_ID) {
|
||||
setOpen(false);
|
||||
}
|
||||
};
|
||||
window.addEventListener(HEADER_POPOVER_OPEN_EVENT, handleOtherPopoverOpen);
|
||||
return () => window.removeEventListener(HEADER_POPOVER_OPEN_EVENT, handleOtherPopoverOpen);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div className={`header-more-menu${open ? ' open' : ''}`} ref={wrapRef}>
|
||||
<button
|
||||
@@ -47,7 +60,19 @@ export function ChatHeaderMoreMenu({
|
||||
aria-label="更多操作"
|
||||
aria-expanded={open}
|
||||
aria-haspopup="menu"
|
||||
onClick={() => setOpen((prev) => !prev)}
|
||||
onClick={() =>
|
||||
setOpen((prev) => {
|
||||
const next = !prev;
|
||||
if (next) {
|
||||
window.dispatchEvent(
|
||||
new CustomEvent(HEADER_POPOVER_OPEN_EVENT, {
|
||||
detail: { id: HEADER_POPOVER_ID },
|
||||
}),
|
||||
);
|
||||
}
|
||||
return next;
|
||||
})
|
||||
}
|
||||
>
|
||||
<svg width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true">
|
||||
<circle cx="12" cy="5" r="1.75" />
|
||||
|
||||
Reference in New Issue
Block a user