mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-02 02:09:03 +08:00
refactor: update imports and button event handlers in story files
- Refactored import statements in CodeEditor, ThinkingEffect, ErrorBoundary, and Spinner story files for consistency and clarity. - Changed button event handlers from `onPress` to `onClick` to align with standard React practices. - Improved type imports for better organization and maintainability.
This commit is contained in:
parent
292f7f7b75
commit
4ef4297391
@ -1,8 +1,8 @@
|
||||
import type { Meta, StoryObj } from '@storybook/react-vite'
|
||||
import { action } from 'storybook/actions'
|
||||
|
||||
import type { LanguageConfig } from '../../../src/components'
|
||||
import CodeEditor, { getCmThemeByName, getCmThemeNames } from '../../../src/components'
|
||||
import { CodeEditor, getCmThemeByName, getCmThemeNames } from '../../../src/components'
|
||||
import type { LanguageConfig } from '../../../src/components/composites/CodeEditor/types'
|
||||
|
||||
// 示例语言配置 - 为 Storybook 提供更丰富的语言支持演示
|
||||
const exampleLanguageConfig: LanguageConfig = {
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { Button } from '../../../src/components'
|
||||
import type { Meta, StoryObj } from '@storybook/react'
|
||||
import { useEffect, useMemo, useState } from 'react'
|
||||
|
||||
import { Button } from '../../../src/components'
|
||||
import { ThinkingEffect } from '../../../src/components'
|
||||
|
||||
const meta: Meta<typeof ThinkingEffect> = {
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
import { Button } from '../../../src/components'
|
||||
import type { Meta, StoryObj } from '@storybook/react'
|
||||
import { useState } from 'react'
|
||||
|
||||
import type { CustomFallbackProps } from '../../../src/components'
|
||||
import { Button } from '../../../src/components'
|
||||
import { ErrorBoundary } from '../../../src/components'
|
||||
|
||||
// 错误组件 - 用于触发错误
|
||||
@ -30,7 +30,7 @@ const AsyncErrorComponent = () => {
|
||||
return (
|
||||
<div className="p-4 space-y-2">
|
||||
<p>这是一个可以触发异步错误的组件</p>
|
||||
<Button onPress={handleAsyncError}>1秒后触发错误</Button>
|
||||
<Button onClick={handleAsyncError}>1秒后触发错误</Button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@ -138,7 +138,7 @@ export const InteractiveDemo: Story = {
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
<div className="flex gap-2">
|
||||
<Button color={shouldThrow ? 'danger' : 'primary'} onPress={() => setShouldThrow(!shouldThrow)}>
|
||||
<Button variant={shouldThrow ? 'destructive' : 'default'} onClick={() => setShouldThrow(!shouldThrow)}>
|
||||
{shouldThrow ? '取消错误' : '触发错误'}
|
||||
</Button>
|
||||
<input
|
||||
@ -174,12 +174,12 @@ export const CustomFallback: Story = {
|
||||
<p className="text-sm opacity-90 mb-4">{error?.message}</p>
|
||||
<div className="flex gap-2 justify-center">
|
||||
{onDebugClick && (
|
||||
<Button size="sm" variant="flat" onPress={onDebugClick}>
|
||||
<Button size="sm" variant="outline" onClick={onDebugClick}>
|
||||
检查错误
|
||||
</Button>
|
||||
)}
|
||||
{onReloadClick && (
|
||||
<Button size="sm" variant="flat" onPress={onReloadClick}>
|
||||
<Button size="sm" variant="outline" onClick={onReloadClick}>
|
||||
重试
|
||||
</Button>
|
||||
)}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { Button } from '../../../src/components'
|
||||
import type { Meta, StoryObj } from '@storybook/react'
|
||||
import { useState } from 'react'
|
||||
|
||||
import { Button } from '../../../src/components'
|
||||
import { Spinner } from '../../../src/components'
|
||||
|
||||
const meta: Meta<typeof Spinner> = {
|
||||
@ -108,7 +108,7 @@ export const InteractiveDemo: Story = {
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
<div className="flex gap-2">
|
||||
<Button onPress={handleStartLoading} disabled={isLoading} color="primary">
|
||||
<Button onClick={handleStartLoading} disabled={isLoading}>
|
||||
{isLoading ? '正在处理...' : '开始加载'}
|
||||
</Button>
|
||||
<input
|
||||
@ -269,7 +269,7 @@ export const LoadingSequence: Story = {
|
||||
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
<Button onPress={nextStep}>{isComplete ? '重新开始' : '下一步'}</Button>
|
||||
<Button onClick={nextStep}>{isComplete ? '重新开始' : '下一步'}</Button>
|
||||
|
||||
<div className="p-6 border border-gray-200 dark:border-gray-700 rounded-lg">
|
||||
{isComplete ? (
|
||||
|
||||
Loading…
Reference in New Issue
Block a user