refactor KefuChatShell component by removing unused host actions state and simplifying button rendering
This commit is contained in:
@@ -75,7 +75,6 @@ export function KefuChatShell() {
|
|||||||
const [isMaximized, setIsMaximized] = useState(false)
|
const [isMaximized, setIsMaximized] = useState(false)
|
||||||
const [isCloseDialogOpen, setIsCloseDialogOpen] = useState(false)
|
const [isCloseDialogOpen, setIsCloseDialogOpen] = useState(false)
|
||||||
const [isClosingConversation, setIsClosingConversation] = useState(false)
|
const [isClosingConversation, setIsClosingConversation] = useState(false)
|
||||||
const [showHostActions, setShowHostActions] = useState(false)
|
|
||||||
|
|
||||||
const {
|
const {
|
||||||
title,
|
title,
|
||||||
@@ -142,9 +141,6 @@ export function KefuChatShell() {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
return bindKefuHostBridge({
|
return bindKefuHostBridge({
|
||||||
onInit: () => {
|
|
||||||
setShowHostActions(true)
|
|
||||||
},
|
|
||||||
onOpen: () => {
|
onOpen: () => {
|
||||||
setIsOpen(true)
|
setIsOpen(true)
|
||||||
setIsVisible(true)
|
setIsVisible(true)
|
||||||
@@ -265,36 +261,32 @@ export function KefuChatShell() {
|
|||||||
>
|
>
|
||||||
<RotateCwIcon className="size-4" />
|
<RotateCwIcon className="size-4" />
|
||||||
</Button>
|
</Button>
|
||||||
{showHostActions ? (
|
<Button
|
||||||
<Button
|
type="button"
|
||||||
type="button"
|
variant="outline"
|
||||||
variant="outline"
|
size="icon-sm"
|
||||||
size="icon-sm"
|
onClick={handleMinimize}
|
||||||
onClick={handleMinimize}
|
aria-label="收起聊天窗口"
|
||||||
aria-label="收起聊天窗口"
|
title="收起聊天窗口"
|
||||||
title="收起聊天窗口"
|
className="bg-background text-muted-foreground hover:text-foreground"
|
||||||
className="bg-background text-muted-foreground hover:text-foreground"
|
>
|
||||||
>
|
<MinusIcon className="size-4" />
|
||||||
<MinusIcon className="size-4" />
|
</Button>
|
||||||
</Button>
|
<Button
|
||||||
) : null}
|
type="button"
|
||||||
{showHostActions ? (
|
variant="outline"
|
||||||
<Button
|
size="icon-sm"
|
||||||
type="button"
|
onClick={handleToggleMaximize}
|
||||||
variant="outline"
|
aria-label={isMaximized ? "取消最大化" : "最大化聊天窗口"}
|
||||||
size="icon-sm"
|
title={isMaximized ? "取消最大化" : "最大化聊天窗口"}
|
||||||
onClick={handleToggleMaximize}
|
className="bg-background text-muted-foreground hover:text-emerald-700 dark:hover:text-emerald-400"
|
||||||
aria-label={isMaximized ? "取消最大化" : "最大化聊天窗口"}
|
>
|
||||||
title={isMaximized ? "取消最大化" : "最大化聊天窗口"}
|
{isMaximized ? (
|
||||||
className="bg-background text-muted-foreground hover:text-emerald-700 dark:hover:text-emerald-400"
|
<Minimize2Icon className="size-4" />
|
||||||
>
|
) : (
|
||||||
{isMaximized ? (
|
<Maximize2Icon className="size-4" />
|
||||||
<Minimize2Icon className="size-4" />
|
)}
|
||||||
) : (
|
</Button>
|
||||||
<Maximize2Icon className="size-4" />
|
|
||||||
)}
|
|
||||||
</Button>
|
|
||||||
) : null}
|
|
||||||
<Button
|
<Button
|
||||||
type="button"
|
type="button"
|
||||||
variant="outline"
|
variant="outline"
|
||||||
|
|||||||
Reference in New Issue
Block a user