mirror of
https://github.com/langgenius/dify.git
synced 2026-04-20 22:28:09 +08:00
style: lint
This commit is contained in:
parent
25f34f6703
commit
b6a560ce86
@ -3,7 +3,6 @@ import type { FC } from 'react'
|
|||||||
import React, { useState } from 'react'
|
import React, { useState } from 'react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { useBoolean } from 'ahooks'
|
import { useBoolean } from 'ahooks'
|
||||||
import type { Timeout } from 'ahooks/lib/useRequest/src/types'
|
|
||||||
import { useContext } from 'use-context-selector'
|
import { useContext } from 'use-context-selector'
|
||||||
import produce from 'immer'
|
import produce from 'immer'
|
||||||
import {
|
import {
|
||||||
@ -50,7 +49,7 @@ export type IConfigVarProps = {
|
|||||||
onPromptVariablesChange?: (promptVariables: PromptVariable[]) => void
|
onPromptVariablesChange?: (promptVariables: PromptVariable[]) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
let conflictTimer: Timeout
|
let conflictTimer: number
|
||||||
|
|
||||||
const ConfigVar: FC<IConfigVarProps> = ({ promptVariables, readonly, onPromptVariablesChange }) => {
|
const ConfigVar: FC<IConfigVarProps> = ({ promptVariables, readonly, onPromptVariablesChange }) => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
@ -107,7 +106,7 @@ const ConfigVar: FC<IConfigVarProps> = ({ promptVariables, readonly, onPromptVar
|
|||||||
onPromptVariablesChange?.(newPromptVariables)
|
onPromptVariablesChange?.(newPromptVariables)
|
||||||
}
|
}
|
||||||
const updatePromptKey = (index: number, newKey: string) => {
|
const updatePromptKey = (index: number, newKey: string) => {
|
||||||
clearTimeout(conflictTimer)
|
window.clearTimeout(conflictTimer)
|
||||||
const { isValid, errorKey, errorMessageKey } = checkKeys([newKey], true)
|
const { isValid, errorKey, errorMessageKey } = checkKeys([newKey], true)
|
||||||
if (!isValid) {
|
if (!isValid) {
|
||||||
Toast.notify({
|
Toast.notify({
|
||||||
@ -127,7 +126,7 @@ const ConfigVar: FC<IConfigVarProps> = ({ promptVariables, readonly, onPromptVar
|
|||||||
return item
|
return item
|
||||||
})
|
})
|
||||||
|
|
||||||
conflictTimer = setTimeout(() => {
|
conflictTimer = window.setTimeout(() => {
|
||||||
const isKeyExists = promptVariables.some(item => item.key?.trim() === newKey.trim())
|
const isKeyExists = promptVariables.some(item => item.key?.trim() === newKey.trim())
|
||||||
if (isKeyExists) {
|
if (isKeyExists) {
|
||||||
Toast.notify({
|
Toast.notify({
|
||||||
|
|||||||
@ -19,10 +19,10 @@ const CooldownTimer = ({ secondsRemaining, onFinish }: CooldownTimerProps) => {
|
|||||||
[currentTime],
|
[currentTime],
|
||||||
)
|
)
|
||||||
|
|
||||||
const countdownTimeout = useRef<NodeJS.Timeout>()
|
const countdownTimeout = useRef<number>(undefined)
|
||||||
const clearCountdown = useCallback(() => {
|
const clearCountdown = useCallback(() => {
|
||||||
if (countdownTimeout.current) {
|
if (countdownTimeout.current) {
|
||||||
clearTimeout(countdownTimeout.current)
|
window.clearTimeout(countdownTimeout.current)
|
||||||
countdownTimeout.current = undefined
|
countdownTimeout.current = undefined
|
||||||
}
|
}
|
||||||
}, [])
|
}, [])
|
||||||
@ -31,7 +31,7 @@ const CooldownTimer = ({ secondsRemaining, onFinish }: CooldownTimerProps) => {
|
|||||||
|
|
||||||
const countdown = useCallback(() => {
|
const countdown = useCallback(() => {
|
||||||
clearCountdown()
|
clearCountdown()
|
||||||
countdownTimeout.current = setTimeout(() => {
|
countdownTimeout.current = window.setTimeout(() => {
|
||||||
const now = Date.now()
|
const now = Date.now()
|
||||||
if (now <= targetTime.current) {
|
if (now <= targetTime.current) {
|
||||||
setCurrentTime(Date.now())
|
setCurrentTime(Date.now())
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user