From 629145202019c1e7109371f3fa9da727f4032706 Mon Sep 17 00:00:00 2001 From: Evan <2869018789@qq.com> Date: Mon, 8 Jun 2026 13:48:04 +0800 Subject: [PATCH] refactor(web): mark Props of base/ components as read-only (#25219) (#37161) --- web/app/components/base/agent-log-modal/detail.tsx | 4 ++-- web/app/components/base/agent-log-modal/index.tsx | 4 ++-- web/app/components/base/agent-log-modal/iteration.tsx | 4 ++-- web/app/components/base/agent-log-modal/result.tsx | 4 ++-- web/app/components/base/agent-log-modal/tool-call.tsx | 4 ++-- web/app/components/base/agent-log-modal/tracing.tsx | 4 ++-- web/app/components/base/audio-gallery/AudioPlayer.tsx | 4 ++-- web/app/components/base/audio-gallery/index.tsx | 4 ++-- web/app/components/base/badge/index.tsx | 4 ++-- web/app/components/base/carousel/index.tsx | 8 ++++---- web/app/components/base/linked-apps-panel/index.tsx | 8 ++++---- web/app/components/base/loading/index.tsx | 4 ++-- web/app/components/base/new-audio-button/index.tsx | 4 ++-- web/app/components/base/tab-header/index.tsx | 4 ++-- web/app/components/base/tab-slider-plain/index.tsx | 8 ++++---- 15 files changed, 36 insertions(+), 36 deletions(-) diff --git a/web/app/components/base/agent-log-modal/detail.tsx b/web/app/components/base/agent-log-modal/detail.tsx index e3f638769c..fc3f491ced 100644 --- a/web/app/components/base/agent-log-modal/detail.tsx +++ b/web/app/components/base/agent-log-modal/detail.tsx @@ -15,12 +15,12 @@ import { fetchAgentLogDetail } from '@/service/log' import ResultPanel from './result' import TracingPanel from './tracing' -type AgentLogDetailProps = { +type AgentLogDetailProps = Readonly<{ activeTab?: 'DETAIL' | 'TRACING' conversationID: string log: IChatItem messageID: string -} +}> const AgentLogDetail: FC = ({ activeTab = 'DETAIL', conversationID, messageID, log }) => { const { t } = useTranslation() const [currentTab, setCurrentTab] = useState(activeTab) diff --git a/web/app/components/base/agent-log-modal/index.tsx b/web/app/components/base/agent-log-modal/index.tsx index abcba5b530..42c0250f8a 100644 --- a/web/app/components/base/agent-log-modal/index.tsx +++ b/web/app/components/base/agent-log-modal/index.tsx @@ -7,11 +7,11 @@ import { useEffect, useRef, useState } from 'react' import { useTranslation } from 'react-i18next' import AgentLogDetail from './detail' -type AgentLogModalProps = { +type AgentLogModalProps = Readonly<{ currentLogItem?: IChatItem width: number onCancel: () => void -} +}> const AgentLogModal: FC = ({ currentLogItem, width, diff --git a/web/app/components/base/agent-log-modal/iteration.tsx b/web/app/components/base/agent-log-modal/iteration.tsx index ebfb863f6f..3f8f8cca72 100644 --- a/web/app/components/base/agent-log-modal/iteration.tsx +++ b/web/app/components/base/agent-log-modal/iteration.tsx @@ -6,11 +6,11 @@ import { useTranslation } from 'react-i18next' import Divider from '@/app/components/base/divider' import ToolCall from './tool-call' -type Props = { +type Props = Readonly<{ isFinal: boolean index: number iterationInfo: AgentIteration -} +}> const Iteration: FC = ({ iterationInfo, isFinal, index }) => { const { t } = useTranslation() diff --git a/web/app/components/base/agent-log-modal/result.tsx b/web/app/components/base/agent-log-modal/result.tsx index 6266b1855b..6eb72a0b75 100644 --- a/web/app/components/base/agent-log-modal/result.tsx +++ b/web/app/components/base/agent-log-modal/result.tsx @@ -6,7 +6,7 @@ import { CodeLanguage } from '@/app/components/workflow/nodes/code/types' import StatusPanel from '@/app/components/workflow/run/status' import useTimestamp from '@/hooks/use-timestamp' -type ResultPanelProps = { +type ResultPanelProps = Readonly<{ status: string elapsed_time?: number total_tokens?: number @@ -18,7 +18,7 @@ type ResultPanelProps = { agentMode?: string tools?: string[] iterations?: number -} +}> const ResultPanel: FC = ({ elapsed_time, diff --git a/web/app/components/base/agent-log-modal/tool-call.tsx b/web/app/components/base/agent-log-modal/tool-call.tsx index 29c2261a37..d00b9790f7 100644 --- a/web/app/components/base/agent-log-modal/tool-call.tsx +++ b/web/app/components/base/agent-log-modal/tool-call.tsx @@ -15,14 +15,14 @@ import { CodeLanguage } from '@/app/components/workflow/nodes/code/types' import { BlockEnum } from '@/app/components/workflow/types' import { useLocale } from '@/context/i18n' -type Props = { +type Props = Readonly<{ toolCall: ToolCall isLLM: boolean isFinal?: boolean tokens?: number observation?: any finalAnswer?: any -} +}> const ToolCallItem: FC = ({ toolCall, isLLM = false, isFinal, tokens, observation, finalAnswer }) => { const [collapseState, setCollapseState] = useState(true) diff --git a/web/app/components/base/agent-log-modal/tracing.tsx b/web/app/components/base/agent-log-modal/tracing.tsx index a3c4886182..0edd217694 100644 --- a/web/app/components/base/agent-log-modal/tracing.tsx +++ b/web/app/components/base/agent-log-modal/tracing.tsx @@ -3,9 +3,9 @@ import type { FC } from 'react' import type { AgentIteration } from '@/models/log' import Iteration from './iteration' -type TracingPanelProps = { +type TracingPanelProps = Readonly<{ list: AgentIteration[] -} +}> const TracingPanel: FC = ({ list }) => { return ( diff --git a/web/app/components/base/audio-gallery/AudioPlayer.tsx b/web/app/components/base/audio-gallery/AudioPlayer.tsx index c31e4aa2e8..184f10a3b9 100644 --- a/web/app/components/base/audio-gallery/AudioPlayer.tsx +++ b/web/app/components/base/audio-gallery/AudioPlayer.tsx @@ -6,10 +6,10 @@ import { useTranslation } from 'react-i18next' import useTheme from '@/hooks/use-theme' import { Theme } from '@/types/app' -type AudioPlayerProps = { +type AudioPlayerProps = Readonly<{ src?: string // Keep backward compatibility srcs?: string[] // Support multiple sources -} +}> const AudioPlayer: React.FC = ({ src, srcs }) => { const { t } = useTranslation() const [isPlaying, setIsPlaying] = useState(false) diff --git a/web/app/components/base/audio-gallery/index.tsx b/web/app/components/base/audio-gallery/index.tsx index e5f0b7f46b..9995f81c0b 100644 --- a/web/app/components/base/audio-gallery/index.tsx +++ b/web/app/components/base/audio-gallery/index.tsx @@ -1,9 +1,9 @@ import * as React from 'react' import AudioPlayer from './AudioPlayer' -type Props = { +type Props = Readonly<{ srcs: string[] -} +}> const AudioGallery: React.FC = ({ srcs }) => { const validSrcs = srcs.filter(src => src) diff --git a/web/app/components/base/badge/index.tsx b/web/app/components/base/badge/index.tsx index f245306048..366087d379 100644 --- a/web/app/components/base/badge/index.tsx +++ b/web/app/components/base/badge/index.tsx @@ -26,14 +26,14 @@ const BadgeVariants = cva( }, ) -type BadgeProps = { +type BadgeProps = Readonly<{ size?: 's' | 'm' | 'l' iconOnly?: boolean uppercase?: boolean state?: BadgeState styleCss?: CSSProperties children?: ReactNode -} & React.HTMLAttributes & VariantProps +}> & React.HTMLAttributes & VariantProps function getBadgeState(state: BadgeState) { switch (state) { diff --git a/web/app/components/base/carousel/index.tsx b/web/app/components/base/carousel/index.tsx index 52486b9751..38c3f65971 100644 --- a/web/app/components/base/carousel/index.tsx +++ b/web/app/components/base/carousel/index.tsx @@ -10,11 +10,11 @@ type UseCarouselParameters = Parameters type CarouselOptions = UseCarouselParameters[0] type CarouselPlugin = UseCarouselParameters[1] -type CarouselProps = { +type CarouselProps = Readonly<{ opts?: CarouselOptions plugins?: CarouselPlugin orientation?: 'horizontal' | 'vertical' -} +}> type CarouselContextValue = { carouselRef: ReturnType[0] @@ -160,9 +160,9 @@ const CarouselItem = React.forwardRef, 'disabled' | 'onClick'> +}> & Omit, 'disabled' | 'onClick'> const CarouselPrevious = React.forwardRef( ({ children, ...props }, ref) => { diff --git a/web/app/components/base/linked-apps-panel/index.tsx b/web/app/components/base/linked-apps-panel/index.tsx index 681817061f..579f548291 100644 --- a/web/app/components/base/linked-apps-panel/index.tsx +++ b/web/app/components/base/linked-apps-panel/index.tsx @@ -8,11 +8,11 @@ import AppIcon from '@/app/components/base/app-icon' import Link from '@/next/link' import { AppModeEnum } from '@/types/app' -type ILikedItemProps = { +type ILikedItemProps = Readonly<{ appStatus?: boolean detail: RelatedApp isMobile: boolean -} +}> const appTypeMap = { [AppModeEnum.CHAT]: 'Chatbot', @@ -40,10 +40,10 @@ const LikedItem = ({ ) } -type Props = { +type Props = Readonly<{ relatedApps: RelatedApp[] isMobile: boolean -} +}> const LinkedAppsPanel: FC = ({ relatedApps, diff --git a/web/app/components/base/loading/index.tsx b/web/app/components/base/loading/index.tsx index f66ba3511d..97a7df6378 100644 --- a/web/app/components/base/loading/index.tsx +++ b/web/app/components/base/loading/index.tsx @@ -4,10 +4,10 @@ import { cn } from '@langgenius/dify-ui/cn' import { useTranslation } from 'react-i18next' import './style.css' -type ILoadingProps = { +type ILoadingProps = Readonly<{ type?: 'area' | 'app' className?: string -} +}> const Loading = (props?: ILoadingProps) => { const { type = 'area', className } = props || {} diff --git a/web/app/components/base/new-audio-button/index.tsx b/web/app/components/base/new-audio-button/index.tsx index c702b829bd..e81a084aed 100644 --- a/web/app/components/base/new-audio-button/index.tsx +++ b/web/app/components/base/new-audio-button/index.tsx @@ -9,11 +9,11 @@ import ActionButton, { ActionButtonState } from '@/app/components/base/action-bu import { AudioPlayerManager } from '@/app/components/base/audio-btn/audio.player.manager' import { useParams, usePathname } from '@/next/navigation' -type AudioBtnProps = { +type AudioBtnProps = Readonly<{ id?: string voice?: string value?: string -} +}> type AudioState = 'initial' | 'loading' | 'playing' | 'paused' | 'ended' diff --git a/web/app/components/base/tab-header/index.tsx b/web/app/components/base/tab-header/index.tsx index dd72fd964b..ebe2350acc 100644 --- a/web/app/components/base/tab-header/index.tsx +++ b/web/app/components/base/tab-header/index.tsx @@ -12,14 +12,14 @@ type Item = { disabled?: boolean } -export type ITabHeaderProps = { +export type ITabHeaderProps = Readonly<{ items: Item[] value: string itemClassName?: string itemWrapClassName?: string activeItemClassName?: string onChange: (value: string) => void -} +}> const TabHeader: FC = ({ items, diff --git a/web/app/components/base/tab-slider-plain/index.tsx b/web/app/components/base/tab-slider-plain/index.tsx index a70d8597de..b523252dc6 100644 --- a/web/app/components/base/tab-slider-plain/index.tsx +++ b/web/app/components/base/tab-slider-plain/index.tsx @@ -8,13 +8,13 @@ type Option = { text: string | React.JSX.Element } -type ItemProps = { +type ItemProps = Readonly<{ className?: string isActive: boolean onClick: (v: string) => void option: Option smallItem?: boolean -} +}> const Item: FC = ({ className, isActive, @@ -51,7 +51,7 @@ const Item: FC = ({ ) } -type Props = { +type Props = Readonly<{ className?: string value: string onChange: (v: string) => void @@ -59,7 +59,7 @@ type Props = { noBorderBottom?: boolean smallItem?: boolean itemClassName?: string -} +}> const TabSlider: FC = ({ className,