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

@@ -50,7 +50,7 @@ const Group = () => {
const [isRegexLegal, setIsRegexLegal] = useState(true)
const [isDrawerOpen, setIsDrawerOpen] = useState(false)
const [isDrawerEdit, setIsDrawerEdit] = useState(false)
const [submittable, setSubmittable] = useState(false)
const [isSubmittable, setIsSubmittable] = useState(false)
const [roleData, setRoleData] = useState<RoleVo[]>([])
const [isLoadingRole, setIsLoadingRole] = useState(false)
const [isSubmitting, setIsSubmitting] = useState(false)
@@ -471,10 +471,10 @@ const Group = () => {
useEffect(() => {
form.validateFields({ validateOnly: true }).then(
() => {
setSubmittable(true)
setIsSubmittable(true)
},
() => {
setSubmittable(false)
setIsSubmittable(false)
}
)
@@ -589,7 +589,7 @@ const Group = () => {
</AntdButton>
<AntdButton
type={'primary'}
disabled={!submittable}
disabled={!isSubmittable}
loading={isSubmitting}
onClick={handleOnSubmit}
>

View File

@@ -10,7 +10,7 @@ import FlexBox from '@/components/common/FlexBox'
const Log = () => {
const [logData, setLogData] = useState<SysLogGetVo[]>([])
const [loading, setLoading] = useState(false)
const [isLoading, setIsLoading] = useState(false)
const [tableParams, setTableParams] = useState<TableParam>({
pagination: {
current: 1,
@@ -181,11 +181,11 @@ const Log = () => {
}
const getLog = () => {
if (loading) {
if (isLoading) {
return
}
setLoading(true)
setIsLoading(true)
void r_sys_log_get({
currentPage: tableParams.pagination?.current,
@@ -218,7 +218,7 @@ const Log = () => {
}
})
.finally(() => {
setLoading(false)
setIsLoading(false)
})
}
@@ -276,7 +276,7 @@ const Log = () => {
columns={dataColumns}
rowKey={(record) => record.id}
pagination={tableParams.pagination}
loading={loading}
loading={isLoading}
onChange={handleOnTableChange}
/>
</Card>

View File

@@ -50,7 +50,7 @@ const Role = () => {
const [isRegexLegal, setIsRegexLegal] = useState(true)
const [isDrawerOpen, setIsDrawerOpen] = useState(false)
const [isDrawerEdit, setIsDrawerEdit] = useState(false)
const [submittable, setSubmittable] = useState(false)
const [isSubmittable, setIsSubmittable] = useState(false)
const [powerTreeData, setPowerTreeData] = useState<_DataNode[]>([])
const [isLoadingPower, setIsLoadingPower] = useState(false)
const [isSubmitting, setIsSubmitting] = useState(false)
@@ -480,10 +480,10 @@ const Role = () => {
useEffect(() => {
form.validateFields({ validateOnly: true }).then(
() => {
setSubmittable(true)
setIsSubmittable(true)
},
() => {
setSubmittable(false)
setIsSubmittable(false)
}
)
@@ -598,7 +598,7 @@ const Role = () => {
</AntdButton>
<AntdButton
type={'primary'}
disabled={!submittable}
disabled={!isSubmittable}
loading={isSubmitting}
onClick={handleOnSubmit}
>

View File

@@ -5,7 +5,7 @@ import SettingsCard from '@/components/system/SettingCard'
const Base = () => {
const [baseForm] = AntdForm.useForm<BaseSettingsParam>()
const baseFormValues = AntdForm.useWatch([], baseForm)
const [loading, setLoading] = useState(false)
const [isLoading, setIsLoading] = useState(false)
const handleOnReset = () => {
getBaseSettings()
@@ -24,17 +24,17 @@ const Base = () => {
}
const getBaseSettings = () => {
if (loading) {
if (isLoading) {
return
}
setLoading(true)
setIsLoading(true)
void r_sys_settings_base_get().then((res) => {
const response = res.data
if (response.success) {
const data = response.data
data && baseForm.setFieldsValue(data)
setLoading(false)
setIsLoading(false)
}
})
}
@@ -48,7 +48,7 @@ const Base = () => {
<SettingsCard
icon={IconOxygenBase}
title={'基础'}
loading={loading}
loading={isLoading}
onReset={handleOnReset}
onSave={handleOnSave}
modifyOperationCode={['system:settings:modify:base']}

View File

@@ -11,7 +11,7 @@ const Mail = () => {
const [modal, contextHolder] = AntdModal.useModal()
const [mailForm] = AntdForm.useForm<MailSettingsParam>()
const mailFormValues = AntdForm.useWatch([], mailForm)
const [loading, setLoading] = useState(false)
const [isLoading, setIsLoading] = useState(false)
const [mailSendForm] = AntdForm.useForm<MailSendParam>()
const handleOnTest = () => {
@@ -95,17 +95,17 @@ const Mail = () => {
}
const getMailSettings = () => {
if (loading) {
if (isLoading) {
return
}
setLoading(true)
setIsLoading(true)
void r_sys_settings_mail_get().then((res) => {
const response = res.data
if (response.success) {
const data = response.data
data && mailForm.setFieldsValue(data)
setLoading(false)
setIsLoading(false)
}
})
}
@@ -119,7 +119,7 @@ const Mail = () => {
<SettingsCard
icon={IconOxygenEmail}
title={'邮件'}
loading={loading}
loading={isLoading}
onReset={handleOnReset}
onSave={handleOnSave}
modifyOperationCode={['system:settings:modify:mail']}

View File

@@ -13,7 +13,7 @@ const SensitiveWord = () => {
const [dataSource, setDataSource] = useState<SensitiveWordVo[]>()
const [targetKeys, setTargetKeys] = useState<string[]>([])
const [selectedKeys, setSelectedKeys] = useState<string[]>([])
const [loading, setLoading] = useState(false)
const [isLoading, setIsLoading] = useState(false)
const [isAdding, setIsAdding] = useState(false)
const [newWord, setNewWord] = useState('')
@@ -47,10 +47,10 @@ const SensitiveWord = () => {
}
const getSensitiveWordSettings = () => {
if (loading) {
if (isLoading) {
return
}
setLoading(true)
setIsLoading(true)
void r_sys_settings_sensitive_get().then((res) => {
const response = res.data
@@ -58,7 +58,7 @@ const SensitiveWord = () => {
const data = response.data
data && setDataSource(data)
data && setTargetKeys(data.filter((value) => value.enable).map((value) => value.id))
setLoading(false)
setIsLoading(false)
}
})
}
@@ -103,7 +103,7 @@ const SensitiveWord = () => {
<SettingsCard
icon={IconOxygenSensitive}
title={'敏感词'}
loading={loading}
loading={isLoading}
onReset={handleOnReset}
onSave={handleOnSave}
modifyOperationCode={['system:settings:modify:sensitive']}

View File

@@ -5,7 +5,7 @@ import SettingsCard from '@/components/system/SettingCard'
const TwoFactor = () => {
const [twoFactorForm] = AntdForm.useForm<TwoFactorSettingsParam>()
const twoFactorFormValues = AntdForm.useWatch([], twoFactorForm)
const [loading, setLoading] = useState(false)
const [isLoading, setIsLoading] = useState(false)
const handleOnReset = () => {
getTwoFactorSettings()
@@ -24,17 +24,17 @@ const TwoFactor = () => {
}
const getTwoFactorSettings = () => {
if (loading) {
if (isLoading) {
return
}
setLoading(true)
setIsLoading(true)
void r_sys_settings_two_factor_get().then((res) => {
const response = res.data
if (response.success) {
const data = response.data
data && twoFactorForm.setFieldsValue(data)
setLoading(false)
setIsLoading(false)
}
})
}
@@ -48,7 +48,7 @@ const TwoFactor = () => {
<SettingsCard
icon={IconOxygenSafe}
title={'双因素'}
loading={loading}
loading={isLoading}
onReset={handleOnReset}
onSave={handleOnSave}
modifyOperationCode={['system:settings:modify:two-factor']}

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}
>

View File

@@ -29,13 +29,13 @@ const Create = () => {
const [categoryData, setCategoryData] = useState<ToolCategoryVo[]>()
const [templateDetailData, setTemplateDetailData] = useState<Record<string, ToolTemplateVo>>({})
const [previewTemplate, setPreviewTemplate] = useState('')
const [loadingTemplate, setLoadingTemplate] = useState(false)
const [loadingCategory, setLoadingCategory] = useState(false)
const [creating, setCreating] = useState(false)
const [isLoadingTemplate, setIsLoadingTemplate] = useState(false)
const [isLoadingCategory, setIsLoadingCategory] = useState(false)
const [isCreating, setIsCreating] = useState(false)
const [compiledCode, setCompiledCode] = useState('')
const handleOnFinish = (toolAddParam: ToolCreateParam) => {
setCreating(true)
setIsCreating(true)
void r_tool_create(toolAddParam)
.then((res) => {
@@ -49,15 +49,15 @@ const Create = () => {
break
case DATABASE_DUPLICATE_KEY:
void message.warning('已存在相同 ID 的应用')
setCreating(false)
setIsCreating(false)
break
default:
void message.error('创建失败,请稍后重试')
setCreating(false)
setIsCreating(false)
}
})
.catch(() => {
setCreating(false)
setIsCreating(false)
})
}
@@ -84,7 +84,7 @@ const Create = () => {
}
const handleOnPlatformChange = (value: string) => {
setLoadingTemplate(true)
setIsLoadingTemplate(true)
void r_tool_template_get({
platform: value
})
@@ -103,7 +103,7 @@ const Create = () => {
}
})
.finally(() => {
setLoadingTemplate(false)
setIsLoadingTemplate(false)
})
}
@@ -113,7 +113,7 @@ const Create = () => {
return
}
setLoadingTemplate(true)
setIsLoadingTemplate(true)
void r_tool_template_get_one(value)
.then((res) => {
const response = res.data
@@ -126,7 +126,7 @@ const Create = () => {
}
})
.finally(() => {
setLoadingTemplate(false)
setIsLoadingTemplate(false)
})
}
@@ -167,7 +167,7 @@ const Create = () => {
}, [form, formValues?.keywords])
useEffect(() => {
setLoadingCategory(true)
setIsLoadingCategory(true)
void r_tool_category_get()
.then((res) => {
const response = res.data
@@ -180,7 +180,7 @@ const Create = () => {
}
})
.finally(() => {
setLoadingCategory(false)
setIsLoadingCategory(false)
})
}, [])
@@ -198,7 +198,7 @@ const Create = () => {
form={form}
layout={'vertical'}
onFinish={handleOnFinish}
disabled={creating}
disabled={isCreating}
>
<AntdForm.Item
label={'图标'}
@@ -319,8 +319,8 @@ const Create = () => {
value: value.id,
label: value.name
}))}
loading={loadingTemplate}
disabled={loadingTemplate}
loading={isLoadingTemplate}
disabled={isLoadingTemplate}
onChange={handleOnTemplateChange}
placeholder={'请选择模板'}
/>
@@ -349,8 +349,8 @@ const Create = () => {
value: value.id,
label: value.name
}))}
loading={loadingCategory}
disabled={loadingCategory}
loading={isLoadingCategory}
disabled={isLoadingCategory}
placeholder={'请选择类别'}
/>
</AntdForm.Item>
@@ -359,7 +359,7 @@ const Create = () => {
className={'create-bt'}
type={'primary'}
htmlType={'submit'}
loading={creating}
loading={isCreating}
>
</AntdButton>

View File

@@ -36,7 +36,7 @@ const Edit = () => {
})
const [form] = AntdForm.useForm<ToolUpdateParam>()
const formValues = AntdForm.useWatch([], form)
const [loading, setLoading] = useState(false)
const [isLoading, setIsLoading] = useState(false)
const [toolData, setToolData] = useState<ToolVo>()
const [files, setFiles] = useState<IFiles>({})
const [selectedFileName, setSelectedFileName] = useState('')
@@ -46,13 +46,13 @@ const Edit = () => {
const [tsconfig, setTsconfig] = useState<ITsconfig>()
const [entryPoint, setEntryPoint] = useState('')
const [baseDist, setBaseDist] = useState('')
const [showDraggableMask, setShowDraggableMask] = useState(false)
const [isShowDraggableMask, setIsShowDraggableMask] = useState(false)
const [isDrawerOpen, setIsDrawerOpen] = useState(false)
const [submittable, setSubmittable] = useState(false)
const [isSubmittable, setIsSubmittable] = useState(false)
const [isSubmitting, setIsSubmitting] = useState(false)
const [hasEdited, setHasEdited] = useState(false)
const [categoryData, setCategoryData] = useState<ToolCategoryVo[]>()
const [loadingCategory, setLoadingCategory] = useState(false)
const [isLoadingCategory, setIsLoadingCategory] = useState(false)
useBeforeUnload(
useCallback(
@@ -196,10 +196,10 @@ const Edit = () => {
}
const getCategory = () => {
if (loadingCategory) {
if (isLoadingCategory) {
return
}
setLoadingCategory(true)
setIsLoadingCategory(true)
void r_tool_category_get()
.then((res) => {
@@ -213,15 +213,15 @@ const Edit = () => {
}
})
.finally(() => {
setLoadingCategory(false)
setIsLoadingCategory(false)
})
}
const getTool = () => {
if (loading) {
if (isLoading) {
return
}
setLoading(true)
setIsLoading(true)
void message.loading({ content: '加载中……', key: 'LOADING', duration: 0 })
void r_tool_detail('!', toolId!, 'latest', searchParams.get('platform') as Platform)
@@ -253,7 +253,7 @@ const Edit = () => {
}
})
.finally(() => {
setLoading(false)
setIsLoading(false)
message.destroy('LOADING')
})
}
@@ -299,10 +299,10 @@ const Edit = () => {
useEffect(() => {
form.validateFields({ validateOnly: true }).then(
() => {
setSubmittable(true)
setIsSubmittable(true)
},
() => {
setSubmittable(false)
setIsSubmittable(false)
}
)
}, [formValues])
@@ -327,7 +327,7 @@ const Edit = () => {
</AntdButton>
<AntdButton
type={'primary'}
disabled={!submittable}
disabled={!isSubmittable}
loading={isSubmitting}
onClick={handleOnSubmit}
>
@@ -408,8 +408,8 @@ const Edit = () => {
value: value.id,
label: value.name
}))}
loading={loadingCategory}
disabled={loadingCategory}
loading={isLoadingCategory}
disabled={isLoadingCategory}
placeholder={'请选择类别'}
/>
</AntdForm.Item>
@@ -421,7 +421,7 @@ const Edit = () => {
<FitFullscreen data-component={'tools-edit'}>
<Card>
<FlexBox direction={'horizontal'} className={'root-content'}>
<LoadingMask hidden={!loading}>
<LoadingMask hidden={!isLoading}>
<Playground.CodeEditor
tsconfig={tsconfig}
files={{
@@ -454,12 +454,12 @@ const Edit = () => {
mobileMode={toolData?.platform === 'ANDROID'}
/>
</LoadingMask>
{showDraggableMask && <div className={'draggable-mask'} />}
{isShowDraggableMask && <div className={'draggable-mask'} />}
</FlexBox>
</Card>
<Draggable
onStart={() => setShowDraggableMask(true)}
onStop={() => setShowDraggableMask(false)}
onStart={() => setIsShowDraggableMask(true)}
onStop={() => setIsShowDraggableMask(false)}
bounds={'#root'}
>
<div className={'draggable-content'}>

View File

@@ -15,7 +15,7 @@ const Source = () => {
const [searchParams] = useSearchParams({
platform: import.meta.env.VITE_PLATFORM
})
const [loading, setLoading] = useState(false)
const [isLoading, setIsLoading] = useState(false)
const [files, setFiles] = useState<IFiles>({})
const [selectedFileName, setSelectedFileName] = useState('')
@@ -29,10 +29,10 @@ const Source = () => {
}
const getTool = () => {
if (loading) {
if (isLoading) {
return
}
setLoading(true)
setIsLoading(true)
void message.loading({ content: '加载中……', key: 'LOADING', duration: 0 })
void r_tool_detail(
@@ -56,7 +56,7 @@ const Source = () => {
}
})
.finally(() => {
setLoading(false)
setIsLoading(false)
message.destroy('LOADING')
})
}

View File

@@ -15,7 +15,7 @@ const Store = () => {
const [currentPage, setCurrentPage] = useState(0)
const [hasNextPage, setHasNextPage] = useState(false)
const [toolData, setToolData] = useState<ToolVo[]>([])
const [hideSearch, setHideSearch] = useState(false)
const [isHideSearch, setIsHideSearch] = useState(false)
const [searchValue, setSearchValue] = useState('')
const handleOnSearch = (value: string) => {
@@ -25,9 +25,9 @@ const Store = () => {
const handleOnScroll = (event: UIEvent<HTMLDivElement>) => {
if (event.currentTarget.scrollTop < scrollTopRef.current) {
setHideSearch(false)
setIsHideSearch(false)
} else {
setHideSearch(true)
setIsHideSearch(true)
}
scrollTopRef.current = event.currentTarget.scrollTop
}
@@ -89,7 +89,7 @@ const Store = () => {
autoHideWaitingTime={1000}
onScroll={handleOnScroll}
>
<div className={`search${hideSearch ? ' hide' : ''}`}>
<div className={`search${isHideSearch ? ' hide' : ''}`}>
<AntdInput.Search
enterButton
allowClear

View File

@@ -16,7 +16,7 @@ const View = () => {
const [searchParams] = useSearchParams({
platform: import.meta.env.VITE_PLATFORM
})
const [loading, setLoading] = useState(false)
const [isLoading, setIsLoading] = useState(false)
const [compiledCode, setCompiledCode] = useState('')
const [isAndroid, setIsAndroid] = useState(false)
@@ -58,10 +58,10 @@ const View = () => {
}
const getTool = () => {
if (loading) {
if (isLoading) {
return
}
setLoading(true)
setIsLoading(true)
void message.loading({ content: '加载中……', key: 'LOADING', duration: 0 })
void r_tool_detail(
@@ -85,7 +85,7 @@ const View = () => {
}
})
.finally(() => {
setLoading(false)
setIsLoading(false)
message.destroy('LOADING')
})
}

View File

@@ -208,7 +208,7 @@ const ToolCard = ({ tools, onDelete, onUpgrade, onSubmit, onCancel }: ToolCardPr
const Tools = () => {
const navigate = useNavigate()
const [modal, contextHolder] = AntdModal.useModal()
const [loading, setLoading] = useState(false)
const [isLoading, setIsLoading] = useState(false)
const [currentPage, setCurrentPage] = useState(0)
const [hasNextPage, setHasNextPage] = useState(false)
const [toolData, setToolData] = useState<ToolVo[]>([])
@@ -228,7 +228,7 @@ const Tools = () => {
.then(
(confirmed) => {
if (confirmed) {
setLoading(true)
setIsLoading(true)
void r_tool_delete(tool.id)
.then((res) => {
@@ -241,7 +241,7 @@ const Tools = () => {
}
})
.finally(() => {
setLoading(false)
setIsLoading(false)
})
}
},
@@ -371,7 +371,7 @@ const Tools = () => {
.then(
(confirmed) => {
if (confirmed) {
setLoading(true)
setIsLoading(true)
void r_tool_submit(tool.id)
.then((res) => {
@@ -392,7 +392,7 @@ const Tools = () => {
}
})
.finally(() => {
setLoading(false)
setIsLoading(false)
})
}
},
@@ -411,7 +411,7 @@ const Tools = () => {
.then(
(confirmed) => {
if (confirmed) {
setLoading(true)
setIsLoading(true)
void r_tool_cancel(tool.id)
.then((res) => {
@@ -431,7 +431,7 @@ const Tools = () => {
}
})
.finally(() => {
setLoading(false)
setIsLoading(false)
getTool(1)
})
}
@@ -441,24 +441,24 @@ const Tools = () => {
}
const handleOnLoadMore = () => {
if (loading) {
if (isLoading) {
return
}
getTool(currentPage + 1)
}
const handleOnLoadMoreStar = () => {
if (loading) {
if (isLoading) {
return
}
getStarTool(currentStarPage + 1)
}
const getTool = (page: number) => {
if (loading) {
if (isLoading) {
return
}
setLoading(true)
setIsLoading(true)
void message.loading({ content: '加载工具列表中', key: 'LOADING', duration: 0 })
void r_tool_get({ currentPage: page })
@@ -487,7 +487,7 @@ const Tools = () => {
}
})
.finally(() => {
setLoading(false)
setIsLoading(false)
message.destroy('LOADING')
if (currentStarPage === 0) {
getStarTool(1)
@@ -496,10 +496,10 @@ const Tools = () => {
}
const getStarTool = (page: number) => {
if (loading) {
if (isLoading) {
return
}
setLoading(true)
setIsLoading(true)
void message.loading({ content: '加载收藏列表中', key: 'LOADING', duration: 0 })
void r_tool_get_favorite({ currentPage: page })
@@ -528,7 +528,7 @@ const Tools = () => {
}
})
.finally(() => {
setLoading(false)
setIsLoading(false)
message.destroy('LOADING')
})
}

View File

@@ -18,12 +18,12 @@ const ToolsFramework = () => {
const [isDelete, setIsDelete] = useState(false)
const [toolMenuItem, setToolMenuItem] = useState<ToolMenuItem[]>(getToolMenuItem)
const [activeItem, setActiveItem] = useState<ToolMenuItem | null>(null)
const [showDropMask, setShowDropMask] = useState(false)
const [isShowDropMask, setIsShowDropMask] = useState(false)
const handleOnDragStart = ({ active }: DragStartEvent) => {
setActiveItem(active.data.current as ToolMenuItem)
if (!active.data.current?.sortable) {
setShowDropMask(true)
setIsShowDropMask(true)
}
}
@@ -73,7 +73,7 @@ const ToolsFramework = () => {
}
setActiveItem(null)
setShowDropMask(false)
setIsShowDropMask(false)
}
const handleOnDragCancel = () => {
@@ -174,7 +174,7 @@ const ToolsFramework = () => {
</DraggableOverlay>
</Sidebar.ItemList>
</Sidebar.Scroll>
{showDropMask && <DropMask />}
{isShowDropMask && <DropMask />}
</Droppable>
</Sidebar>
</div>