diff --git a/src/components/AppHeader/components/userCenter/FolderSetModal.tsx b/src/components/AppHeader/components/userCenter/FolderSetModal.tsx index 2b36bdc..b4b3f0d 100644 --- a/src/components/AppHeader/components/userCenter/FolderSetModal.tsx +++ b/src/components/AppHeader/components/userCenter/FolderSetModal.tsx @@ -6,6 +6,8 @@ import { useCallback } from 'react'; import system from '@/services/system'; import { useState } from 'react'; import { useEffect } from 'react'; +import { fetchLocalApi } from '@/utils/request'; +import { handleRequest } from '@/utils/tool'; export default function FolderSetModal(props: ModalProps) { const { className, ...restProps } = props; @@ -21,20 +23,27 @@ export default function FolderSetModal(props: ModalProps) { }, []); useEffect(() => { - // todo: 查询当前使用的路径 + (async () => { + const res = await fetchLocalApi('getWorkSpace'); + handleRequest(res).success(() => { + setFolderPath(res.data || ''); + }); + })(); }, []); - const updateFolderPath = useCallback(() => { + const updateFolderPath = useCallback(async () => { if (!folderPath) { message.error('请选择文件夹'); return; } setLoading(true); - // todo: 调接口 + const res = await fetchLocalApi('setWorkSpace', { path: folderPath }); setLoading(false); - if (restProps.onCancel) { - restProps.onCancel(); - } + handleRequest(res).success(() => { + if (restProps.onCancel) { + restProps.onCancel(); + } + }); }, [folderPath]); return ( diff --git a/src/utils/tool.ts b/src/utils/tool.ts index 5a015cd..5736eee 100644 --- a/src/utils/tool.ts +++ b/src/utils/tool.ts @@ -1,3 +1,5 @@ +import { API } from '@/services/API'; + export const isClient = !!window.ipcRenderer; // process.env.IS_CLIENT; export function firstCharToLowerCase(obj: any) {