From 361a5c923d6d03bd98061dabff3eec00ab3ce211 Mon Sep 17 00:00:00 2001 From: FatttSnake Date: Mon, 6 May 2024 16:02:26 +0800 Subject: [PATCH] Refactor(Variable): Optimize variable name --- .../Playground/CodeEditor/Editor/hooks.ts | 8 ++-- .../CodeEditor/FileSelector/Item.tsx | 16 +++---- .../CodeEditor/FileSelector/index.tsx | 16 +++---- .../Playground/Output/Preview/Render.tsx | 14 +++--- .../src/components/common/HideScrollbar.tsx | 48 +++++++++---------- .../src/components/common/LoadingMask.tsx | 1 + .../src/components/common/Sidebar/Footer.tsx | 10 ++-- .../src/components/common/Sidebar/index.tsx | 10 ++-- src/renderer/src/pages/System/Group.tsx | 8 ++-- src/renderer/src/pages/System/Log.tsx | 10 ++-- src/renderer/src/pages/System/Role.tsx | 8 ++-- .../src/pages/System/Settings/Base.tsx | 10 ++-- .../src/pages/System/Settings/Mail.tsx | 10 ++-- .../pages/System/Settings/SensitiveWord.tsx | 10 ++-- .../src/pages/System/Settings/TwoFactor.tsx | 10 ++-- src/renderer/src/pages/System/Tools/Base.tsx | 26 +++++----- .../src/pages/System/Tools/Category.tsx | 8 ++-- src/renderer/src/pages/System/Tools/Code.tsx | 8 ++-- .../src/pages/System/Tools/Execute.tsx | 8 ++-- .../src/pages/System/Tools/Template.tsx | 8 ++-- src/renderer/src/pages/Tools/Create.tsx | 38 +++++++-------- src/renderer/src/pages/Tools/Edit.tsx | 38 +++++++-------- src/renderer/src/pages/Tools/Source.tsx | 8 ++-- src/renderer/src/pages/Tools/Store.tsx | 8 ++-- src/renderer/src/pages/Tools/View.tsx | 8 ++-- src/renderer/src/pages/Tools/index.tsx | 30 ++++++------ src/renderer/src/pages/ToolsFramework.tsx | 8 ++-- 27 files changed, 193 insertions(+), 192 deletions(-) diff --git a/src/renderer/src/components/Playground/CodeEditor/Editor/hooks.ts b/src/renderer/src/components/Playground/CodeEditor/Editor/hooks.ts index 21e47ed..2224b2f 100644 --- a/src/renderer/src/components/Playground/CodeEditor/Editor/hooks.ts +++ b/src/renderer/src/components/Playground/CodeEditor/Editor/hooks.ts @@ -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 } } diff --git a/src/renderer/src/components/Playground/CodeEditor/FileSelector/Item.tsx b/src/renderer/src/components/Playground/CodeEditor/FileSelector/Item.tsx index 4fe7c1f..31ea29b 100644 --- a/src/renderer/src/components/Playground/CodeEditor/FileSelector/Item.tsx +++ b/src/renderer/src/components/Playground/CodeEditor/FileSelector/Item.tsx @@ -31,7 +31,7 @@ const Item = ({ }: ItemProps) => { const inputRef = useRef(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 ? (
{ const hideScrollbarRef = useRef(null) const [tabs, setTabs] = useState([]) - 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} diff --git a/src/renderer/src/components/Playground/Output/Preview/Render.tsx b/src/renderer/src/components/Playground/Output/Preview/Render.tsx index 2965bf0..102dd2c 100644 --- a/src/renderer/src/components/Playground/Output/Preview/Render.tsx +++ b/src/renderer/src/components/Playground/Output/Preview/Render.tsx @@ -42,7 +42,7 @@ const iframeUrl = getIframeUrl(iframeRaw) const Render = ({ iframeKey, compiledCode, mobileMode = false }: RenderProps) => { const iframeRef = useRef(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" />
@@ -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" /> ) diff --git a/src/renderer/src/components/common/HideScrollbar.tsx b/src/renderer/src/components/common/HideScrollbar.tsx index 49b8521..a71ccba 100644 --- a/src/renderer/src/components/common/HideScrollbar.tsx +++ b/src/renderer/src/components/common/HideScrollbar.tsx @@ -183,16 +183,16 @@ const HideScrollbar = forwardRef( 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( 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( 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( } 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( behavior: 'instant' }) } - if (horizontalScrollbarOnClick) { + if (isHorizontalScrollbarOnClick) { rootRef.current?.scrollTo({ left: rootRef.current?.scrollLeft + @@ -372,23 +372,23 @@ const HideScrollbar = forwardRef( } 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( behavior: 'instant' }) } - if (horizontalScrollbarOnTouch) { + if (isHorizontalScrollbarOnTouch) { rootRef.current?.scrollTo({ left: rootRef.current?.scrollLeft + @@ -571,7 +571,7 @@ const HideScrollbar = forwardRef( (!isHiddenVerticalScrollbarWhenFull || verticalScrollbarLength < 100) && (
( horizontalScrollbarLength < 100) && (
{ const loadingIcon = ( <> diff --git a/src/renderer/src/components/common/Sidebar/Footer.tsx b/src/renderer/src/components/common/Sidebar/Footer.tsx index f7cc765..64f2bfd 100644 --- a/src/renderer/src/components/common/Sidebar/Footer.tsx +++ b/src/renderer/src/components/common/Sidebar/Footer.tsx @@ -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 = () => {
diff --git a/src/renderer/src/components/common/Sidebar/index.tsx b/src/renderer/src/components/common/Sidebar/index.tsx index db30b6a..660e062 100644 --- a/src/renderer/src/components/common/Sidebar/index.tsx +++ b/src/renderer/src/components/common/Sidebar/index.tsx @@ -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 ( <>
diff --git a/src/renderer/src/pages/System/Group.tsx b/src/renderer/src/pages/System/Group.tsx index f248ffb..2f91b52 100644 --- a/src/renderer/src/pages/System/Group.tsx +++ b/src/renderer/src/pages/System/Group.tsx @@ -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([]) 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 = () => { diff --git a/src/renderer/src/pages/System/Log.tsx b/src/renderer/src/pages/System/Log.tsx index 145b01c..f11c331 100644 --- a/src/renderer/src/pages/System/Log.tsx +++ b/src/renderer/src/pages/System/Log.tsx @@ -10,7 +10,7 @@ import FlexBox from '@/components/common/FlexBox' const Log = () => { const [logData, setLogData] = useState([]) - const [loading, setLoading] = useState(false) + const [isLoading, setIsLoading] = useState(false) const [tableParams, setTableParams] = useState({ 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} /> diff --git a/src/renderer/src/pages/System/Role.tsx b/src/renderer/src/pages/System/Role.tsx index ce4e5e7..8cab6d9 100644 --- a/src/renderer/src/pages/System/Role.tsx +++ b/src/renderer/src/pages/System/Role.tsx @@ -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 = () => { diff --git a/src/renderer/src/pages/System/Settings/Base.tsx b/src/renderer/src/pages/System/Settings/Base.tsx index 2f11c1e..57351d9 100644 --- a/src/renderer/src/pages/System/Settings/Base.tsx +++ b/src/renderer/src/pages/System/Settings/Base.tsx @@ -5,7 +5,7 @@ import SettingsCard from '@/components/system/SettingCard' const Base = () => { const [baseForm] = AntdForm.useForm() 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 = () => { { const [modal, contextHolder] = AntdModal.useModal() const [mailForm] = AntdForm.useForm() const mailFormValues = AntdForm.useWatch([], mailForm) - const [loading, setLoading] = useState(false) + const [isLoading, setIsLoading] = useState(false) const [mailSendForm] = AntdForm.useForm() 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 = () => { { const [dataSource, setDataSource] = useState() const [targetKeys, setTargetKeys] = useState([]) const [selectedKeys, setSelectedKeys] = useState([]) - 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 = () => { { const [twoFactorForm] = AntdForm.useForm() 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 = () => { { 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('') const [editingFiles, setEditingFiles] = useState>({}) @@ -70,7 +70,7 @@ const Base = () => { const [baseDetailData, setBaseDetailData] = useState>({}) const [baseDetailLoading, setBaseDetailLoading] = useState>({}) const [tsconfig, setTsconfig] = useState() - 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 = () => { diff --git a/src/renderer/src/pages/System/Tools/Category.tsx b/src/renderer/src/pages/System/Tools/Category.tsx index 60652af..b7fc552 100644 --- a/src/renderer/src/pages/System/Tools/Category.tsx +++ b/src/renderer/src/pages/System/Tools/Category.tsx @@ -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 = () => { diff --git a/src/renderer/src/pages/System/Tools/Code.tsx b/src/renderer/src/pages/System/Tools/Code.tsx index a5d8e89..e9e9f1a 100644 --- a/src/renderer/src/pages/System/Tools/Code.tsx +++ b/src/renderer/src/pages/System/Tools/Code.tsx @@ -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({}) const [selectedFileName, setSelectedFileName] = useState('') const [platform, setPlatform] = useState('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') }) } diff --git a/src/renderer/src/pages/System/Tools/Execute.tsx b/src/renderer/src/pages/System/Tools/Execute.tsx index ca8c277..11f88f1 100644 --- a/src/renderer/src/pages/System/Tools/Execute.tsx +++ b/src/renderer/src/pages/System/Tools/Execute.tsx @@ -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') }) } diff --git a/src/renderer/src/pages/System/Tools/Template.tsx b/src/renderer/src/pages/System/Tools/Template.tsx index 1a04639..b3f79d9 100644 --- a/src/renderer/src/pages/System/Tools/Template.tsx +++ b/src/renderer/src/pages/System/Tools/Template.tsx @@ -60,7 +60,7 @@ const Template = () => { const [isDrawerEdit, setIsDrawerEdit] = useState(false) const [baseData, setBaseData] = useState([]) const [isLoadingBaseData, setIsLoadingBaseData] = useState(false) - const [submittable, setSubmittable] = useState(false) + const [isSubmittable, setIsSubmittable] = useState(false) const [isSubmitting, setIsSubmitting] = useState(false) const [editingTemplateId, setEditingTemplateId] = useState('') const [editingFiles, setEditingFiles] = useState>({}) @@ -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 = () => { diff --git a/src/renderer/src/pages/Tools/Create.tsx b/src/renderer/src/pages/Tools/Create.tsx index 21888e0..5fa73b1 100644 --- a/src/renderer/src/pages/Tools/Create.tsx +++ b/src/renderer/src/pages/Tools/Create.tsx @@ -29,13 +29,13 @@ const Create = () => { const [categoryData, setCategoryData] = useState() const [templateDetailData, setTemplateDetailData] = useState>({}) 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} > { 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={'请选择类别'} /> @@ -359,7 +359,7 @@ const Create = () => { className={'create-bt'} type={'primary'} htmlType={'submit'} - loading={creating} + loading={isCreating} > 创建 diff --git a/src/renderer/src/pages/Tools/Edit.tsx b/src/renderer/src/pages/Tools/Edit.tsx index b424d1d..1bac51d 100644 --- a/src/renderer/src/pages/Tools/Edit.tsx +++ b/src/renderer/src/pages/Tools/Edit.tsx @@ -36,7 +36,7 @@ const Edit = () => { }) const [form] = AntdForm.useForm() const formValues = AntdForm.useWatch([], form) - const [loading, setLoading] = useState(false) + const [isLoading, setIsLoading] = useState(false) const [toolData, setToolData] = useState() const [files, setFiles] = useState({}) const [selectedFileName, setSelectedFileName] = useState('') @@ -46,13 +46,13 @@ const Edit = () => { const [tsconfig, setTsconfig] = useState() 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() - 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 = () => { @@ -408,8 +408,8 @@ const Edit = () => { value: value.id, label: value.name }))} - loading={loadingCategory} - disabled={loadingCategory} + loading={isLoadingCategory} + disabled={isLoadingCategory} placeholder={'请选择类别'} /> @@ -421,7 +421,7 @@ const Edit = () => { -