Refactor(Variable): Optimize variable name
This commit is contained in:
@@ -76,11 +76,11 @@ export const useEditor = () => {
|
||||
export const useTypesProgress = () => {
|
||||
const [progress, setProgress] = useState(0)
|
||||
const [total, setTotal] = useState(0)
|
||||
const [finished, setFinished] = useState(false)
|
||||
const [isFinished, setIsFinished] = useState(false)
|
||||
|
||||
const onWatch = (typeHelper: TypeHelper) => {
|
||||
const handleStarted = () => {
|
||||
setFinished(false)
|
||||
setIsFinished(false)
|
||||
}
|
||||
typeHelper.addListener('started', handleStarted)
|
||||
|
||||
@@ -91,7 +91,7 @@ export const useTypesProgress = () => {
|
||||
typeHelper.addListener('progress', handleProgress)
|
||||
|
||||
const handleFinished = () => {
|
||||
setFinished(true)
|
||||
setIsFinished(true)
|
||||
}
|
||||
typeHelper.addListener('progress', handleFinished)
|
||||
|
||||
@@ -105,7 +105,7 @@ export const useTypesProgress = () => {
|
||||
return {
|
||||
progress,
|
||||
total,
|
||||
finished,
|
||||
finished: isFinished,
|
||||
onWatch
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ const Item = ({
|
||||
}: ItemProps) => {
|
||||
const inputRef = useRef<HTMLInputElement>(null)
|
||||
const [fileName, setFileName] = useState(value)
|
||||
const [creating, setCreating] = useState(prop.creating)
|
||||
const [isCreating, setIsCreating] = useState(prop.creating)
|
||||
|
||||
const handleOnClick = () => {
|
||||
if (hasEditing) {
|
||||
@@ -52,35 +52,35 @@ const Item = ({
|
||||
}
|
||||
|
||||
const finishNameFile = () => {
|
||||
if (!creating || onValidate ? !onValidate?.(fileName, value) : false) {
|
||||
if (!isCreating || onValidate ? !onValidate?.(fileName, value) : false) {
|
||||
inputRef.current?.focus()
|
||||
return
|
||||
}
|
||||
|
||||
if (fileName === value && active) {
|
||||
setCreating(false)
|
||||
setIsCreating(false)
|
||||
setHasEditing?.(false)
|
||||
return
|
||||
}
|
||||
|
||||
onOk?.(fileName)
|
||||
setCreating(false)
|
||||
setIsCreating(false)
|
||||
setHasEditing?.(false)
|
||||
}
|
||||
|
||||
const cancelNameFile = () => {
|
||||
setFileName(value)
|
||||
setCreating(false)
|
||||
setIsCreating(false)
|
||||
setHasEditing?.(false)
|
||||
onCancel?.()
|
||||
}
|
||||
|
||||
const handleOnDoubleClick = () => {
|
||||
if (readonly || creating || hasEditing) {
|
||||
if (readonly || isCreating || hasEditing) {
|
||||
return
|
||||
}
|
||||
|
||||
setCreating(true)
|
||||
setIsCreating(true)
|
||||
setHasEditing?.(true)
|
||||
setFileName(value)
|
||||
setTimeout(() => {
|
||||
@@ -112,7 +112,7 @@ const Item = ({
|
||||
className={`tab-item${active ? ' active' : ''}${className ? ` ${className}` : ''}`}
|
||||
onClick={handleOnClick}
|
||||
>
|
||||
{creating ? (
|
||||
{isCreating ? (
|
||||
<div className={'tab-item-input'}>
|
||||
<input
|
||||
ref={inputRef}
|
||||
|
||||
@@ -34,7 +34,7 @@ const FileSelector = ({
|
||||
}: FileSelectorProps) => {
|
||||
const hideScrollbarRef = useRef<HideScrollbarElement>(null)
|
||||
const [tabs, setTabs] = useState<string[]>([])
|
||||
const [creating, setCreating] = useState(false)
|
||||
const [isCreating, setIsCreating] = useState(false)
|
||||
const [hasEditing, setHasEditing] = useState(false)
|
||||
|
||||
const getMaxSequenceTabName = (filesName: string[]) => {
|
||||
@@ -56,7 +56,7 @@ const FileSelector = ({
|
||||
}
|
||||
|
||||
setTabs([...tabs, getMaxSequenceTabName(tabs)])
|
||||
setCreating(true)
|
||||
setIsCreating(true)
|
||||
setTimeout(() => {
|
||||
hideScrollbarRef.current?.scrollRight(1000)
|
||||
})
|
||||
@@ -64,16 +64,16 @@ const FileSelector = ({
|
||||
|
||||
const handleOnCancel = () => {
|
||||
onError?.('')
|
||||
if (!creating) {
|
||||
if (!isCreating) {
|
||||
return
|
||||
}
|
||||
tabs.pop()
|
||||
setTabs([...tabs])
|
||||
setCreating(false)
|
||||
setIsCreating(false)
|
||||
}
|
||||
|
||||
const handleOnClickTab = (fileName: string) => {
|
||||
if (creating) {
|
||||
if (isCreating) {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -97,9 +97,9 @@ const FileSelector = ({
|
||||
}
|
||||
|
||||
const handleOnSaveTab = (value: string, item: string) => {
|
||||
if (creating) {
|
||||
if (isCreating) {
|
||||
onAddFile?.(value)
|
||||
setCreating(false)
|
||||
setIsCreating(false)
|
||||
} else {
|
||||
onUpdateFileName?.(value, item)
|
||||
}
|
||||
@@ -179,7 +179,7 @@ const FileSelector = ({
|
||||
key={index + item}
|
||||
value={item}
|
||||
active={selectedFileName === item}
|
||||
creating={creating}
|
||||
creating={isCreating}
|
||||
readonly={readonly || notRemovableFiles.includes(item)}
|
||||
hasEditing={hasEditing}
|
||||
setHasEditing={setHasEditing}
|
||||
|
||||
@@ -42,7 +42,7 @@ const iframeUrl = getIframeUrl(iframeRaw)
|
||||
|
||||
const Render = ({ iframeKey, compiledCode, mobileMode = false }: RenderProps) => {
|
||||
const iframeRef = useRef<HTMLIFrameElement>(null)
|
||||
const [loaded, setLoaded] = useState(false)
|
||||
const [isLoaded, setIsLoaded] = useState(false)
|
||||
const [selectedDevice, setSelectedDevice] = useState('Pixel 7')
|
||||
const [zoom, setZoom] = useState(1)
|
||||
const [isRotate, setIsRotate] = useState(false)
|
||||
@@ -148,7 +148,7 @@ const Render = ({ iframeKey, compiledCode, mobileMode = false }: RenderProps) =>
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (loaded) {
|
||||
if (isLoaded) {
|
||||
iframeRef.current?.contentWindow?.postMessage(
|
||||
{
|
||||
type: 'UPDATE',
|
||||
@@ -157,10 +157,10 @@ const Render = ({ iframeKey, compiledCode, mobileMode = false }: RenderProps) =>
|
||||
'*'
|
||||
)
|
||||
}
|
||||
}, [loaded, compiledCode])
|
||||
}, [isLoaded, compiledCode])
|
||||
|
||||
useEffect(() => {
|
||||
if (loaded) {
|
||||
if (isLoaded) {
|
||||
iframeRef.current?.contentWindow?.postMessage(
|
||||
{
|
||||
type: 'SCALE',
|
||||
@@ -169,7 +169,7 @@ const Render = ({ iframeKey, compiledCode, mobileMode = false }: RenderProps) =>
|
||||
'*'
|
||||
)
|
||||
}
|
||||
}, [loaded, zoom])
|
||||
}, [isLoaded, zoom])
|
||||
|
||||
return mobileMode ? (
|
||||
<>
|
||||
@@ -202,7 +202,7 @@ const Render = ({ iframeKey, compiledCode, mobileMode = false }: RenderProps) =>
|
||||
key={iframeKey}
|
||||
ref={iframeRef}
|
||||
src={iframeUrl}
|
||||
onLoad={() => setLoaded(true)}
|
||||
onLoad={() => setIsLoaded(true)}
|
||||
sandbox="allow-downloads allow-forms allow-modals allow-scripts"
|
||||
/>
|
||||
</div>
|
||||
@@ -244,7 +244,7 @@ const Render = ({ iframeKey, compiledCode, mobileMode = false }: RenderProps) =>
|
||||
key={iframeKey}
|
||||
ref={iframeRef}
|
||||
src={iframeUrl}
|
||||
onLoad={() => setLoaded(true)}
|
||||
onLoad={() => setIsLoaded(true)}
|
||||
sandbox="allow-downloads allow-forms allow-modals allow-scripts"
|
||||
/>
|
||||
)
|
||||
|
||||
@@ -66,7 +66,7 @@ class Compiler {
|
||||
})
|
||||
|
||||
stop = () => {
|
||||
esbuild.stop()
|
||||
void esbuild.stop()
|
||||
}
|
||||
|
||||
private fileResolverPlugin = (
|
||||
|
||||
@@ -183,16 +183,16 @@ const HideScrollbar = forwardRef<HideScrollbarElement, HideScrollbarProps>(
|
||||
const [verticalScrollbarWidth, setVerticalScrollbarWidth] = useState(0)
|
||||
const [verticalScrollbarLength, setVerticalScrollbarLength] = useState(100)
|
||||
const [verticalScrollbarPosition, setVerticalScrollbarPosition] = useState(0)
|
||||
const [verticalScrollbarOnClick, setVerticalScrollbarOnClick] = useState(false)
|
||||
const [verticalScrollbarOnTouch, setVerticalScrollbarOnTouch] = useState(false)
|
||||
const [verticalScrollbarAutoHide, setVerticalScrollbarAutoHide] = useState(false)
|
||||
const [isVerticalScrollbarOnClick, setIsVerticalScrollbarOnClick] = useState(false)
|
||||
const [isVerticalScrollbarOnTouch, setIsVerticalScrollbarOnTouch] = useState(false)
|
||||
const [isVerticalScrollbarAutoHide, setIsVerticalScrollbarAutoHide] = useState(false)
|
||||
|
||||
const [horizontalScrollbarWidth, setHorizontalScrollbarWidth] = useState(0)
|
||||
const [horizontalScrollbarLength, setHorizontalScrollbarLength] = useState(100)
|
||||
const [horizontalScrollbarPosition, setHorizontalScrollbarPosition] = useState(0)
|
||||
const [horizontalScrollbarOnClick, setHorizontalScrollbarOnClick] = useState(false)
|
||||
const [horizontalScrollbarOnTouch, setHorizontalScrollbarOnTouch] = useState(false)
|
||||
const [horizontalScrollbarAutoHide, setHorizontalScrollbarAutoHide] = useState(false)
|
||||
const [isHorizontalScrollbarOnClick, setIsHorizontalScrollbarOnClick] = useState(false)
|
||||
const [isHorizontalScrollbarOnTouch, setIsHorizontalScrollbarOnTouch] = useState(false)
|
||||
const [isHorizontalScrollbarAutoHide, setIsHorizontalScrollbarAutoHide] = useState(false)
|
||||
|
||||
const isPreventAnyScroll =
|
||||
isPreventScroll || isPreventVerticalScroll || isPreventHorizontalScroll
|
||||
@@ -201,10 +201,10 @@ const HideScrollbar = forwardRef<HideScrollbarElement, HideScrollbarProps>(
|
||||
if (autoHideWaitingTime === undefined) {
|
||||
return
|
||||
}
|
||||
setVerticalScrollbarAutoHide(false)
|
||||
setIsVerticalScrollbarAutoHide(false)
|
||||
if (autoHideWaitingTime > 0) {
|
||||
setTimeout(() => {
|
||||
setVerticalScrollbarAutoHide(true)
|
||||
setIsVerticalScrollbarAutoHide(true)
|
||||
}, autoHideWaitingTime)
|
||||
}
|
||||
}, [autoHideWaitingTime, verticalScrollbarPosition])
|
||||
@@ -213,10 +213,10 @@ const HideScrollbar = forwardRef<HideScrollbarElement, HideScrollbarProps>(
|
||||
if (autoHideWaitingTime === undefined) {
|
||||
return
|
||||
}
|
||||
setHorizontalScrollbarAutoHide(false)
|
||||
setIsHorizontalScrollbarAutoHide(false)
|
||||
if (autoHideWaitingTime > 0) {
|
||||
setTimeout(() => {
|
||||
setHorizontalScrollbarAutoHide(true)
|
||||
setIsHorizontalScrollbarAutoHide(true)
|
||||
}, autoHideWaitingTime)
|
||||
}
|
||||
}, [autoHideWaitingTime, horizontalScrollbarPosition])
|
||||
@@ -318,20 +318,20 @@ const HideScrollbar = forwardRef<HideScrollbarElement, HideScrollbarProps>(
|
||||
}
|
||||
switch (scrollbarFlag) {
|
||||
case 'vertical':
|
||||
setVerticalScrollbarOnClick(true)
|
||||
setIsVerticalScrollbarOnClick(true)
|
||||
break
|
||||
case 'horizontal':
|
||||
setHorizontalScrollbarOnClick(true)
|
||||
setIsHorizontalScrollbarOnClick(true)
|
||||
break
|
||||
}
|
||||
break
|
||||
case 'up':
|
||||
case 'leave':
|
||||
setVerticalScrollbarOnClick(false)
|
||||
setHorizontalScrollbarOnClick(false)
|
||||
setIsVerticalScrollbarOnClick(false)
|
||||
setIsHorizontalScrollbarOnClick(false)
|
||||
break
|
||||
case 'move':
|
||||
if (verticalScrollbarOnClick) {
|
||||
if (isVerticalScrollbarOnClick) {
|
||||
rootRef.current?.scrollTo({
|
||||
top:
|
||||
rootRef.current?.scrollTop +
|
||||
@@ -341,7 +341,7 @@ const HideScrollbar = forwardRef<HideScrollbarElement, HideScrollbarProps>(
|
||||
behavior: 'instant'
|
||||
})
|
||||
}
|
||||
if (horizontalScrollbarOnClick) {
|
||||
if (isHorizontalScrollbarOnClick) {
|
||||
rootRef.current?.scrollTo({
|
||||
left:
|
||||
rootRef.current?.scrollLeft +
|
||||
@@ -372,23 +372,23 @@ const HideScrollbar = forwardRef<HideScrollbarElement, HideScrollbarProps>(
|
||||
}
|
||||
switch (scrollbarFlag) {
|
||||
case 'vertical':
|
||||
setVerticalScrollbarOnTouch(true)
|
||||
setIsVerticalScrollbarOnTouch(true)
|
||||
break
|
||||
case 'horizontal':
|
||||
setHorizontalScrollbarOnTouch(true)
|
||||
setIsHorizontalScrollbarOnTouch(true)
|
||||
break
|
||||
}
|
||||
break
|
||||
case 'end':
|
||||
case 'cancel':
|
||||
setVerticalScrollbarOnTouch(false)
|
||||
setHorizontalScrollbarOnTouch(false)
|
||||
setIsVerticalScrollbarOnTouch(false)
|
||||
setIsHorizontalScrollbarOnTouch(false)
|
||||
break
|
||||
case 'move':
|
||||
if (event.touches.length !== 1) {
|
||||
return
|
||||
}
|
||||
if (verticalScrollbarOnTouch) {
|
||||
if (isVerticalScrollbarOnTouch) {
|
||||
rootRef.current?.scrollTo({
|
||||
top:
|
||||
rootRef.current?.scrollTop +
|
||||
@@ -399,7 +399,7 @@ const HideScrollbar = forwardRef<HideScrollbarElement, HideScrollbarProps>(
|
||||
behavior: 'instant'
|
||||
})
|
||||
}
|
||||
if (horizontalScrollbarOnTouch) {
|
||||
if (isHorizontalScrollbarOnTouch) {
|
||||
rootRef.current?.scrollTo({
|
||||
left:
|
||||
rootRef.current?.scrollLeft +
|
||||
@@ -571,7 +571,7 @@ const HideScrollbar = forwardRef<HideScrollbarElement, HideScrollbarProps>(
|
||||
(!isHiddenVerticalScrollbarWhenFull || verticalScrollbarLength < 100) && (
|
||||
<div
|
||||
className={`scrollbar vertical-scrollbar${
|
||||
verticalScrollbarAutoHide ? ' hide' : ''
|
||||
isVerticalScrollbarAutoHide ? ' hide' : ''
|
||||
}`}
|
||||
style={{
|
||||
height: maskRef.current
|
||||
@@ -614,7 +614,7 @@ const HideScrollbar = forwardRef<HideScrollbarElement, HideScrollbarProps>(
|
||||
horizontalScrollbarLength < 100) && (
|
||||
<div
|
||||
className={`scrollbar horizontal-scrollbar${
|
||||
horizontalScrollbarAutoHide ? ' hide' : ''
|
||||
isHorizontalScrollbarAutoHide ? ' hide' : ''
|
||||
}`}
|
||||
style={{
|
||||
width: maskRef.current
|
||||
|
||||
@@ -7,6 +7,7 @@ interface LoadingMaskProps extends PropsWithChildren {
|
||||
hidden?: boolean
|
||||
maskContent?: ReactNode
|
||||
}
|
||||
|
||||
const LoadingMask = (props: LoadingMaskProps) => {
|
||||
const loadingIcon = (
|
||||
<>
|
||||
|
||||
@@ -10,7 +10,7 @@ const Footer = () => {
|
||||
const lastMatch = matches.reduce((_, second) => second)
|
||||
const location = useLocation()
|
||||
const navigate = useNavigate()
|
||||
const [exiting, setExiting] = useState(false)
|
||||
const [isExiting, setIsExiting] = useState(false)
|
||||
const [nickname, setNickname] = useState('')
|
||||
const [avatar, setAvatar] = useState('')
|
||||
|
||||
@@ -23,11 +23,11 @@ const Footer = () => {
|
||||
}
|
||||
|
||||
const handleLogout = () => {
|
||||
if (exiting) {
|
||||
if (isExiting) {
|
||||
return
|
||||
}
|
||||
|
||||
setExiting(true)
|
||||
setIsExiting(true)
|
||||
void r_auth_logout().finally(() => {
|
||||
removeToken()
|
||||
notification.info({
|
||||
@@ -83,8 +83,8 @@ const Footer = () => {
|
||||
<div className={'content'}>
|
||||
<span hidden={!getLoginStatus()} className={'icon-exit'} onClick={handleLogout}>
|
||||
<Icon
|
||||
component={exiting ? IconOxygenLoading : IconOxygenExit}
|
||||
spin={exiting}
|
||||
component={isExiting ? IconOxygenLoading : IconOxygenExit}
|
||||
spin={isExiting}
|
||||
/>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@@ -17,18 +17,18 @@ interface SidebarProps extends PropsWithChildren {
|
||||
}
|
||||
|
||||
const Sidebar = (props: SidebarProps) => {
|
||||
const [hideSidebar, setHideSidebar] = useState(getLocalStorage('HIDE_SIDEBAR') === 'true')
|
||||
const [isHideSidebar, setIsHideSidebar] = useState(getLocalStorage('HIDE_SIDEBAR') === 'true')
|
||||
|
||||
const switchSidebar = () => {
|
||||
setLocalStorage('HIDE_SIDEBAR', !hideSidebar ? 'true' : 'false')
|
||||
setHideSidebar(!hideSidebar)
|
||||
props.onSidebarSwitch?.(hideSidebar)
|
||||
setLocalStorage('HIDE_SIDEBAR', !isHideSidebar ? 'true' : 'false')
|
||||
setIsHideSidebar(!isHideSidebar)
|
||||
props.onSidebarSwitch?.(isHideSidebar)
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<div
|
||||
className={`sidebar${hideSidebar ? ' hide' : ''}`}
|
||||
className={`sidebar${isHideSidebar ? ' hide' : ''}`}
|
||||
style={{ width: props.width ?? 'clamp(180px, 20vw, 240px)' }}
|
||||
>
|
||||
<div className={'title'}>
|
||||
|
||||
Reference in New Issue
Block a user