From fb3ffe3dfdccaefee3b01bd7845d89c608bc8a4f Mon Sep 17 00:00:00 2001 From: zhangheng Date: Fri, 5 Jun 2026 12:39:27 +0800 Subject: [PATCH] refactor: remove unused dead-code exports flagged by react-doctor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Low-risk subset only — each verified to have zero external references (tsc + eslint green); API clients, stores, icons and constants left untouched. - libs/util.ts: unexport `is` (still used internally by isNumber) - components/tree-select/libs/util.ts: drop unused recursive `findLabel` - app/person/workload/config.ts: drop unused `dimensionOpts` - components/login/libs/session-cache.ts: drop unused `getCachedSession` - components/setting/PageSurface.tsx: drop 3 unused layout components (SettingTableViewport, SettingSectionHeader, SettingFilterStack) Co-Authored-By: Claude Opus 4.8 (1M context) --- app/person/workload/config.ts | 8 --- components/login/libs/session-cache.ts | 3 -- components/setting/PageSurface.tsx | 72 -------------------------- components/tree-select/libs/util.ts | 18 ------- libs/util.ts | 2 +- 5 files changed, 1 insertion(+), 102 deletions(-) diff --git a/app/person/workload/config.ts b/app/person/workload/config.ts index 607093e..42489ad 100644 --- a/app/person/workload/config.ts +++ b/app/person/workload/config.ts @@ -5,14 +5,6 @@ export type DimensionType = | "order_by_project_name" | "order_by_project_type" -export const dimensionOpts = [ - { label: "全部", value: "all" }, - { label: "用户名", value: "order_by_user_name" }, - { label: "用户组", value: "order_by_group_name" }, - { label: "项目名称", value: "order_by_project_name" }, - { label: "项目类型", value: "order_by_project_type" }, -] - export type MetricColumn = { key: string title: string diff --git a/components/login/libs/session-cache.ts b/components/login/libs/session-cache.ts index 3aa017b..af9b3ee 100644 --- a/components/login/libs/session-cache.ts +++ b/components/login/libs/session-cache.ts @@ -27,9 +27,6 @@ const getValidCachedSession = (redisKey: string) => { return cacheEntry.data as T } -export const getCachedSession = (redisKey: string) => - getValidCachedSession(redisKey) - export const setCachedSession = (redisKey: string, data: T) => { sessionCache.set(redisKey, { data, diff --git a/components/setting/PageSurface.tsx b/components/setting/PageSurface.tsx index 84fcfe3..aaab2e2 100644 --- a/components/setting/PageSurface.tsx +++ b/components/setting/PageSurface.tsx @@ -386,12 +386,6 @@ export function SettingCustomPageSizeControl({ ) } -type SettingTableViewportProps = PropsWithChildren<{ - maxHeight: number | string - className?: string - style?: CSSProperties -}> - export function SettingPage({ className, ...props @@ -428,21 +422,6 @@ export function SettingPanel({ ) } -export function SettingTableViewport({ - maxHeight, - className, - style, - children, -}: SettingTableViewportProps) { - return ( -
- {children} -
- ) -} - export function SettingFilterPanel({ className, ...props @@ -467,43 +446,6 @@ export function SettingContentPanel({ ) } -type SettingSectionHeaderProps = GroupProps & { - eyebrow?: string - title: ReactNode - description?: ReactNode - actions?: ReactNode -} - -export function SettingSectionHeader({ - eyebrow, - title, - description, - actions, - className, - ...props -}: SettingSectionHeaderProps) { - return ( - - - {eyebrow ? ( - {eyebrow} - ) : null} - {title} - {description ? ( - {description} - ) : null} - - {actions} - - ) -} - type SettingListHeaderProps = { title: ReactNode count?: ReactNode @@ -569,20 +511,6 @@ export function SettingFilterActions({ ) } -export function SettingFilterStack({ - className, - gap = 12, - ...props -}: PropsWithChildren) { - return ( - - ) -} - type SettingInlineFilterFieldProps = { label: ReactNode children: ReactNode diff --git a/components/tree-select/libs/util.ts b/components/tree-select/libs/util.ts index 7fd4661..bf8c8cd 100644 --- a/components/tree-select/libs/util.ts +++ b/components/tree-select/libs/util.ts @@ -75,24 +75,6 @@ export const buildTreeValueMap = ( return acc } -export const findLabel = ( - nodes: TreeNodeData[], - targetValue: string, - pathArr: string[] = [] // 内部用,调用端无需传入 -): FindResult => { - for (const node of nodes) { - const curPath = [...pathArr, node.label as string] // 复制一份,避免污染上层 - if (node.value === targetValue) { - return { path: curPath.join(TREE_PATH_SEPARATOR), node } - } - if (node.children) { - const found = findLabel(node.children, targetValue, curPath) - if (found.node) return found - } - } - return { path: "", node: null } -} - export const findNodesByValues = ( valueMap: Record, targetValues: string[] diff --git a/libs/util.ts b/libs/util.ts index caf42f1..0c42ee3 100644 --- a/libs/util.ts +++ b/libs/util.ts @@ -1,7 +1,7 @@ /** * @description: 判断值是否为某个类型 */ -export function is(val: unknown, type: string) { +function is(val: unknown, type: string) { return toString.call(val) === `[object ${type}]` }