mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-19 22:52:08 +08:00
refactor: streamline event listener management in useAppInit and update ToolPermissionRequestCard styling
This commit is contained in:
parent
3834c5d402
commit
ab7b207d29
@ -221,13 +221,12 @@ export function useAppInit() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
window.electron.ipcRenderer.on(IpcChannel.AgentToolPermission_Request, requestListener)
|
const removeListeners = [
|
||||||
window.electron.ipcRenderer.on(IpcChannel.AgentToolPermission_Result, resultListener)
|
window.electron.ipcRenderer.on(IpcChannel.AgentToolPermission_Request, requestListener),
|
||||||
|
window.electron.ipcRenderer.on(IpcChannel.AgentToolPermission_Result, resultListener)
|
||||||
|
]
|
||||||
|
|
||||||
return () => {
|
return () => removeListeners.forEach((removeListener) => removeListener())
|
||||||
window.electron?.ipcRenderer.removeListener(IpcChannel.AgentToolPermission_Request, requestListener)
|
|
||||||
window.electron?.ipcRenderer.removeListener(IpcChannel.AgentToolPermission_Result, resultListener)
|
|
||||||
}
|
|
||||||
}, [dispatch, t])
|
}, [dispatch, t])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import { loggerService } from '@logger'
|
|||||||
import { useAppDispatch, useAppSelector } from '@renderer/store'
|
import { useAppDispatch, useAppSelector } from '@renderer/store'
|
||||||
import { selectPendingPermissionByToolName, toolPermissionsActions } from '@renderer/store/toolPermissions'
|
import { selectPendingPermissionByToolName, toolPermissionsActions } from '@renderer/store/toolPermissions'
|
||||||
import type { NormalToolResponse } from '@renderer/types'
|
import type { NormalToolResponse } from '@renderer/types'
|
||||||
import { Button, Tag } from 'antd'
|
import { Button } from 'antd'
|
||||||
import { ChevronDown, CirclePlay, CircleX } from 'lucide-react'
|
import { ChevronDown, CirclePlay, CircleX } from 'lucide-react'
|
||||||
import { useCallback, useEffect, useMemo, useState } from 'react'
|
import { useCallback, useEffect, useMemo, useState } from 'react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
@ -127,11 +127,14 @@ export function ToolPermissionRequestCard({ toolResponse }: Props) {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex flex-wrap items-center justify-end gap-2">
|
<div className="flex flex-wrap items-center justify-end gap-2">
|
||||||
<Tag color={isExpired ? 'error' : 'warning'}>
|
<div
|
||||||
|
className={`rounded px-2 py-0.5 font-medium text-xs ${
|
||||||
|
isExpired ? 'text-[var(--color-error)]' : 'text-[var(--color-status-warning)]'
|
||||||
|
}`}>
|
||||||
{isExpired
|
{isExpired
|
||||||
? t('agent.toolPermission.expired')
|
? t('agent.toolPermission.expired')
|
||||||
: t('agent.toolPermission.pending', { seconds: remainingSeconds })}
|
: t('agent.toolPermission.pending', { seconds: remainingSeconds })}
|
||||||
</Tag>
|
</div>
|
||||||
|
|
||||||
<div className="flex items-center gap-1">
|
<div className="flex items-center gap-1">
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user