mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-13 14:09:00 +08:00
lint: frontend linting issues (#744)
This commit is contained in:
parent
2ba89d0deb
commit
8ae1eb0ebb
@ -1,10 +1,9 @@
|
|||||||
'use client'
|
'use client'
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import Tooltip from '@/app/components/base/tooltip'
|
|
||||||
import { t } from 'i18next'
|
import { t } from 'i18next'
|
||||||
import s from './style.module.css'
|
|
||||||
import copy from 'copy-to-clipboard'
|
import copy from 'copy-to-clipboard'
|
||||||
|
import s from './style.module.css'
|
||||||
|
import Tooltip from '@/app/components/base/tooltip'
|
||||||
|
|
||||||
type ICopyBtnProps = {
|
type ICopyBtnProps = {
|
||||||
value: string
|
value: string
|
||||||
@ -24,18 +23,18 @@ const CopyBtn = ({
|
|||||||
content={(isCopied ? t('appApi.copied') : t('appApi.copy')) as string}
|
content={(isCopied ? t('appApi.copied') : t('appApi.copy')) as string}
|
||||||
className='z-10'
|
className='z-10'
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
className={`box-border p-0.5 flex items-center justify-center rounded-md bg-white cursor-pointer`}
|
className={'box-border p-0.5 flex items-center justify-center rounded-md bg-white cursor-pointer'}
|
||||||
style={{
|
style={{
|
||||||
boxShadow: '0px 4px 8px -2px rgba(16, 24, 40, 0.1), 0px 2px 4px -2px rgba(16, 24, 40, 0.06)'
|
boxShadow: '0px 4px 8px -2px rgba(16, 24, 40, 0.1), 0px 2px 4px -2px rgba(16, 24, 40, 0.06)',
|
||||||
}}
|
}}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
copy(value)
|
copy(value)
|
||||||
setIsCopied(true)
|
setIsCopied(true)
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div className={`w-6 h-6 hover:bg-gray-50 ${s.copyIcon} ${isCopied ? s.copied : ''}`}></div>
|
<div className={`w-6 h-6 hover:bg-gray-50 ${s.copyIcon} ${isCopied ? s.copied : ''}`}></div>
|
||||||
</div>
|
</div>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
@ -1,17 +1,18 @@
|
|||||||
'use client'
|
'use client'
|
||||||
import React, { FC } from 'react'
|
import type { FC } from 'react'
|
||||||
|
import React from 'react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import cn from 'classnames'
|
import cn from 'classnames'
|
||||||
|
import copy from 'copy-to-clipboard'
|
||||||
|
import NoData from './no-data'
|
||||||
import type { SavedMessage } from '@/models/debug'
|
import type { SavedMessage } from '@/models/debug'
|
||||||
import { Markdown } from '@/app/components/base/markdown'
|
import { Markdown } from '@/app/components/base/markdown'
|
||||||
import { SimpleBtn, copyIcon } from '@/app/components/app/text-generate/item'
|
import { SimpleBtn, copyIcon } from '@/app/components/app/text-generate/item'
|
||||||
import copy from 'copy-to-clipboard'
|
|
||||||
import Toast from '@/app/components/base/toast'
|
import Toast from '@/app/components/base/toast'
|
||||||
import NoData from './no-data'
|
|
||||||
|
|
||||||
export interface ISavedItemsProps {
|
export type ISavedItemsProps = {
|
||||||
className?: string
|
className?: string
|
||||||
list: SavedMessage[],
|
list: SavedMessage[]
|
||||||
onRemove: (id: string) => void
|
onRemove: (id: string) => void
|
||||||
onStartCreateContent: () => void
|
onStartCreateContent: () => void
|
||||||
}
|
}
|
||||||
@ -26,52 +27,54 @@ const SavedItems: FC<ISavedItemsProps> = ({
|
|||||||
className,
|
className,
|
||||||
list,
|
list,
|
||||||
onRemove,
|
onRemove,
|
||||||
onStartCreateContent
|
onStartCreateContent,
|
||||||
}) => {
|
}) => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={cn(className, 'space-y-3')}>
|
<div className={cn(className, 'space-y-3')}>
|
||||||
{list.length === 0 ? (
|
{list.length === 0
|
||||||
<div className='px-6'>
|
? (
|
||||||
<NoData onStartCreateContent={onStartCreateContent} />
|
<div className='px-6'>
|
||||||
</div>
|
<NoData onStartCreateContent={onStartCreateContent} />
|
||||||
) : (<>
|
|
||||||
{list.map(({ id, answer }) => (
|
|
||||||
<div
|
|
||||||
key={id}
|
|
||||||
className='p-4 rounded-xl bg-gray-50'
|
|
||||||
style={{
|
|
||||||
boxShadow: '0px 1px 2px rgba(16, 24, 40, 0.05)'
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Markdown content={answer} />
|
|
||||||
<div className='flex items-center justify-between mt-3'>
|
|
||||||
<div className='flex items-center space-x-2'>
|
|
||||||
<SimpleBtn
|
|
||||||
className='space-x-1'
|
|
||||||
onClick={() => {
|
|
||||||
copy(answer)
|
|
||||||
Toast.notify({ type: 'success', message: t('common.actionMsg.copySuccessfully') })
|
|
||||||
}}>
|
|
||||||
{copyIcon}
|
|
||||||
<div>{t('common.operation.copy')}</div>
|
|
||||||
</SimpleBtn>
|
|
||||||
|
|
||||||
<SimpleBtn
|
|
||||||
className='space-x-1'
|
|
||||||
onClick={() => {
|
|
||||||
onRemove(id)
|
|
||||||
}}>
|
|
||||||
{removeIcon}
|
|
||||||
<div>{t('common.operation.remove')}</div>
|
|
||||||
</SimpleBtn>
|
|
||||||
</div>
|
|
||||||
<div className='text-xs text-gray-500'>{answer?.length} {t('common.unit.char')}</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
))}
|
)
|
||||||
</>)}
|
: (<>
|
||||||
|
{list.map(({ id, answer }) => (
|
||||||
|
<div
|
||||||
|
key={id}
|
||||||
|
className='p-4 rounded-xl bg-gray-50'
|
||||||
|
style={{
|
||||||
|
boxShadow: '0px 1px 2px rgba(16, 24, 40, 0.05)',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Markdown content={answer} />
|
||||||
|
<div className='flex items-center justify-between mt-3'>
|
||||||
|
<div className='flex items-center space-x-2'>
|
||||||
|
<SimpleBtn
|
||||||
|
className='space-x-1'
|
||||||
|
onClick={() => {
|
||||||
|
copy(answer)
|
||||||
|
Toast.notify({ type: 'success', message: t('common.actionMsg.copySuccessfully') })
|
||||||
|
}}>
|
||||||
|
{copyIcon}
|
||||||
|
<div>{t('common.operation.copy')}</div>
|
||||||
|
</SimpleBtn>
|
||||||
|
|
||||||
|
<SimpleBtn
|
||||||
|
className='space-x-1'
|
||||||
|
onClick={() => {
|
||||||
|
onRemove(id)
|
||||||
|
}}>
|
||||||
|
{removeIcon}
|
||||||
|
<div>{t('common.operation.remove')}</div>
|
||||||
|
</SimpleBtn>
|
||||||
|
</div>
|
||||||
|
<div className='text-xs text-gray-500'>{answer?.length} {t('common.unit.char')}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</>)}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user