Refactor(Variable): Optimize variable name

This commit is contained in:
2024-05-06 15:37:45 +08:00
parent 5e6c8f214c
commit 779e0ab2c0
28 changed files with 194 additions and 193 deletions

View File

@@ -60,7 +60,7 @@ const Base = () => {
const [isLoading, setIsLoading] = useState(false)
const [isDrawerOpen, setIsDrawerOpen] = useState(false)
const [isDrawerEdit, setIsDrawerEdit] = useState(false)
const [submittable, setSubmittable] = useState(false)
const [isSubmittable, setIsSubmittable] = useState(false)
const [isSubmitting, setIsSubmitting] = useState(false)
const [editingBaseId, setEditingBaseId] = useState<string>('')
const [editingFiles, setEditingFiles] = useState<Record<string, IFiles>>({})
@@ -70,7 +70,7 @@ const Base = () => {
const [baseDetailData, setBaseDetailData] = useState<Record<string, ToolBaseVo>>({})
const [baseDetailLoading, setBaseDetailLoading] = useState<Record<string, boolean>>({})
const [tsconfig, setTsconfig] = useState<ITsconfig>()
const [compiling, setCompiling] = useState(false)
const [isCompiling, setIsCompiling] = useState(false)
const [compileForm] = AntdForm.useForm<{ entryFileName: string }>()
useBeforeUnload(
@@ -220,10 +220,10 @@ const Base = () => {
const handleOnCompileBtnClick = (value: ToolBaseVo) => {
return () => {
if (compiling || isLoading) {
if (isCompiling || isLoading) {
return
}
setCompiling(true)
setIsCompiling(true)
setIsLoading(true)
void message.loading({ content: '加载文件中', key: 'COMPILE_LOADING', duration: 0 })
@@ -263,7 +263,7 @@ const Base = () => {
const files = base64ToFiles(baseDetail!.source.data!)
if (!Object.keys(files).includes(IMPORT_MAP_FILE_NAME)) {
void message.warning(`编译中止:未包含 ${IMPORT_MAP_FILE_NAME} 文件`)
setCompiling(false)
setIsCompiling(false)
setIsLoading(false)
return
}
@@ -272,7 +272,7 @@ const Base = () => {
importMap = JSON.parse(files[IMPORT_MAP_FILE_NAME].value) as IImportMap
} catch (e) {
void message.warning(`编译中止Import Map 文件转换失败`)
setCompiling(false)
setIsCompiling(false)
setIsLoading(false)
return
}
@@ -353,14 +353,14 @@ const Base = () => {
})
.finally(() => {
message.destroy('UPLOADING')
setCompiling(false)
setIsCompiling(false)
setIsLoading(false)
})
})
.catch((e: Error) => {
void message.error(`编译失败:${e.message}`)
message.destroy('COMPILING')
setCompiling(false)
setIsCompiling(false)
setIsLoading(false)
})
})
@@ -372,13 +372,13 @@ const Base = () => {
}
),
onCancel: () => {
setCompiling(false)
setIsCompiling(false)
setIsLoading(false)
}
})
})
.catch(() => {
setCompiling(false)
setIsCompiling(false)
setIsLoading(false)
message.destroy('COMPILE_LOADING')
})
@@ -1002,10 +1002,10 @@ const Base = () => {
useEffect(() => {
form.validateFields({ validateOnly: true }).then(
() => {
setSubmittable(true)
setIsSubmittable(true)
},
() => {
setSubmittable(false)
setIsSubmittable(false)
}
)
@@ -1034,7 +1034,7 @@ const Base = () => {
</AntdButton>
<AntdButton
type={'primary'}
disabled={!submittable}
disabled={!isSubmittable}
loading={isSubmitting}
onClick={handleOnSubmit}
>

View File

@@ -27,7 +27,7 @@ const Category = () => {
const [isLoading, setIsLoading] = useState(false)
const [isDrawerOpen, setIsDrawerOpen] = useState(false)
const [isDrawerEdit, setIsDrawerEdit] = useState(false)
const [submittable, setSubmittable] = useState(false)
const [isSubmittable, setIsSubmittable] = useState(false)
const [isSubmitting, setIsSubmitting] = useState(false)
const handleOnAddBtnClick = () => {
@@ -230,10 +230,10 @@ const Category = () => {
useEffect(() => {
form.validateFields({ validateOnly: true }).then(
() => {
setSubmittable(true)
setIsSubmittable(true)
},
() => {
setSubmittable(false)
setIsSubmittable(false)
}
)
@@ -256,7 +256,7 @@ const Category = () => {
</AntdButton>
<AntdButton
type={'primary'}
disabled={!submittable}
disabled={!isSubmittable}
loading={isSubmitting}
onClick={handleOnSubmit}
>

View File

@@ -15,7 +15,7 @@ const Code = () => {
const navigate = useNavigate()
const [modal, contextHolder] = AntdModal.useModal()
const { id } = useParams()
const [loading, setLoading] = useState(false)
const [isLoading, setIsLoading] = useState(false)
const [files, setFiles] = useState<IFiles>({})
const [selectedFileName, setSelectedFileName] = useState('')
const [platform, setPlatform] = useState<Platform>('WEB')
@@ -47,10 +47,10 @@ const Code = () => {
}
const getTool = () => {
if (loading) {
if (isLoading) {
return
}
setLoading(true)
setIsLoading(true)
void message.loading({ content: '加载中……', key: 'LOADING', duration: 0 })
void r_sys_tool_get_one(id!)
@@ -69,7 +69,7 @@ const Code = () => {
}
})
.finally(() => {
setLoading(false)
setIsLoading(false)
message.destroy('LOADING')
})
}

View File

@@ -12,7 +12,7 @@ import { base64ToFiles, base64ToStr, IMPORT_MAP_FILE_NAME } from '@/components/P
const Execute = () => {
const navigate = useNavigate()
const { id } = useParams()
const [loading, setLoading] = useState(false)
const [isLoading, setIsLoading] = useState(false)
const [compiledCode, setCompiledCode] = useState('')
const render = (toolVo: ToolVo) => {
@@ -39,10 +39,10 @@ const Execute = () => {
}
const getTool = () => {
if (loading) {
if (isLoading) {
return
}
setLoading(true)
setIsLoading(true)
void message.loading({ content: '加载中……', key: 'LOADING', duration: 0 })
void r_sys_tool_get_one(id!)
@@ -61,7 +61,7 @@ const Execute = () => {
}
})
.finally(() => {
setLoading(false)
setIsLoading(false)
message.destroy('LOADING')
})
}

View File

@@ -60,7 +60,7 @@ const Template = () => {
const [isDrawerEdit, setIsDrawerEdit] = useState(false)
const [baseData, setBaseData] = useState<ToolBaseVo[]>([])
const [isLoadingBaseData, setIsLoadingBaseData] = useState(false)
const [submittable, setSubmittable] = useState(false)
const [isSubmittable, setIsSubmittable] = useState(false)
const [isSubmitting, setIsSubmitting] = useState(false)
const [editingTemplateId, setEditingTemplateId] = useState<string>('')
const [editingFiles, setEditingFiles] = useState<Record<string, IFiles>>({})
@@ -884,10 +884,10 @@ const Template = () => {
useEffect(() => {
form.validateFields({ validateOnly: true }).then(
() => {
setSubmittable(true)
setIsSubmittable(true)
},
() => {
setSubmittable(false)
setIsSubmittable(false)
}
)
@@ -972,7 +972,7 @@ const Template = () => {
</AntdButton>
<AntdButton
type={'primary'}
disabled={!submittable}
disabled={!isSubmittable}
loading={isSubmitting}
onClick={handleOnSubmit}
>