Browse Source

fix: resolve react-doctor lint warnings (#11786)

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
pull/11788/head
afc163 5 months ago
committed by GitHub
parent
commit
58956a71b8
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 14
      src/pages/chatbot/index.tsx
  2. 27
      src/pages/list/search/applications/index.tsx
  3. 27
      src/pages/list/search/articles/index.tsx
  4. 27
      src/pages/list/search/projects/index.tsx

14
src/pages/chatbot/index.tsx

@ -8,7 +8,13 @@ import type {
import XMarkdown from '@ant-design/x-markdown'; import XMarkdown from '@ant-design/x-markdown';
import { useXChat } from '@ant-design/x-sdk'; import { useXChat } from '@ant-design/x-sdk';
import { Avatar, Card } from 'antd'; import { Avatar, Card } from 'antd';
import React, { useEffect, useMemo, useState } from 'react'; import React, {
useCallback,
useEffect,
useMemo,
useRef,
useState,
} from 'react';
import type { ConversationItem, ParsedMessage } from './data'; import type { ConversationItem, ParsedMessage } from './data';
import { createChatProvider } from './service'; import { createChatProvider } from './service';
@ -109,6 +115,8 @@ const roleConfig: BubbleListProps['role'] = {
const ChatbotPage: React.FC = () => { const ChatbotPage: React.FC = () => {
const { styles } = useStyles(); const { styles } = useStyles();
const idCounter = useRef(0);
const generateId = useCallback(() => `conv-${++idCounter.current}`, []);
const [conversations, setConversations] = useState<ConversationItem[]>([ const [conversations, setConversations] = useState<ConversationItem[]>([
{ key: 'default', label: '💬 新对话', group: '今天', isDraft: true }, { key: 'default', label: '💬 新对话', group: '今天', isDraft: true },
@ -180,7 +188,7 @@ const ChatbotPage: React.FC = () => {
}; };
const newChat = () => { const newChat = () => {
const key = crypto.randomUUID(); const key = generateId();
setConversations((prev) => [ setConversations((prev) => [
{ key, label: '新对话', group: '今天', isDraft: true }, { key, label: '新对话', group: '今天', isDraft: true },
...prev, ...prev,
@ -261,7 +269,7 @@ const ChatbotPage: React.FC = () => {
(c) => c.key !== conversation.key, (c) => c.key !== conversation.key,
); );
if (next.length === 0) { if (next.length === 0) {
const key = crypto.randomUUID(); const key = generateId();
next.push({ next.push({
key, key,
label: '💬 新对话', label: '💬 新对话',

27
src/pages/list/search/applications/index.tsx

@ -112,21 +112,18 @@ const Applications: FC<Record<string, any>> = () => {
> >
<Form.Item name="category"> <Form.Item name="category">
<TagSelect expandable> <TagSelect expandable>
{categoryOptions {categoryOptions.flatMap((category) =>
.filter( category.value !== undefined && category.value !== null
( ? [
category, <TagSelect.Option
): category is { value: string | number; label: string } => value={category.value}
category.value !== undefined && category.value !== null, key={category.value}
) >
.map((category) => ( {category.label}
<TagSelect.Option </TagSelect.Option>,
value={category.value} ]
key={category.value} : [],
> )}
{category.label}
</TagSelect.Option>
))}
</TagSelect> </TagSelect>
</Form.Item> </Form.Item>
</StandardFormRow> </StandardFormRow>

27
src/pages/list/search/articles/index.tsx

@ -156,21 +156,18 @@ const Articles: FC = () => {
<StandardFormRow title="所属类目" block style={{ paddingBottom: 11 }}> <StandardFormRow title="所属类目" block style={{ paddingBottom: 11 }}>
<FormItem name="category"> <FormItem name="category">
<TagSelect expandable> <TagSelect expandable>
{categoryOptions {categoryOptions.flatMap((category) =>
.filter( category.value !== undefined && category.value !== null
( ? [
category, <TagSelect.Option
): category is { value: string | number; label: string } => value={category.value}
category.value !== undefined && category.value !== null, key={category.value}
) >
.map((category) => ( {category.label}
<TagSelect.Option </TagSelect.Option>,
value={category.value} ]
key={category.value} : [],
> )}
{category.label}
</TagSelect.Option>
))}
</TagSelect> </TagSelect>
</FormItem> </FormItem>
</StandardFormRow> </StandardFormRow>

27
src/pages/list/search/projects/index.tsx

@ -110,21 +110,18 @@ const Projects: FC = () => {
> >
<FormItem name="category"> <FormItem name="category">
<TagSelect expandable> <TagSelect expandable>
{categoryOptions {categoryOptions.flatMap((category) =>
.filter( category.value !== undefined && category.value !== null
( ? [
category, <TagSelect.Option
): category is { value: string | number; label: string } => value={category.value}
category.value !== undefined && category.value !== null, key={category.value}
) >
.map((category) => ( {category.label}
<TagSelect.Option </TagSelect.Option>,
value={category.value} ]
key={category.value} : [],
> )}
{category.label}
</TagSelect.Option>
))}
</TagSelect> </TagSelect>
</FormItem> </FormItem>
</StandardFormRow> </StandardFormRow>

Loading…
Cancel
Save