|
@@ -6,6 +6,8 @@ import { useCallback } from 'react'; |
|
|
import system from '@/services/system'; |
|
|
import system from '@/services/system'; |
|
|
import { useState } from 'react'; |
|
|
import { useState } from 'react'; |
|
|
import { useEffect } from 'react'; |
|
|
import { useEffect } from 'react'; |
|
|
|
|
|
import { fetchLocalApi } from '@/utils/request'; |
|
|
|
|
|
import { handleRequest } from '@/utils/tool'; |
|
|
|
|
|
|
|
|
export default function FolderSetModal(props: ModalProps) { |
|
|
export default function FolderSetModal(props: ModalProps) { |
|
|
const { className, ...restProps } = props; |
|
|
const { className, ...restProps } = props; |
|
@@ -21,20 +23,27 @@ export default function FolderSetModal(props: ModalProps) { |
|
|
}, []); |
|
|
}, []); |
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
useEffect(() => { |
|
|
// todo: 查询当前使用的路径 |
|
|
|
|
|
|
|
|
(async () => { |
|
|
|
|
|
const res = await fetchLocalApi<string>('getWorkSpace'); |
|
|
|
|
|
handleRequest(res).success(() => { |
|
|
|
|
|
setFolderPath(res.data || ''); |
|
|
|
|
|
}); |
|
|
|
|
|
})(); |
|
|
}, []); |
|
|
}, []); |
|
|
|
|
|
|
|
|
const updateFolderPath = useCallback(() => { |
|
|
|
|
|
|
|
|
const updateFolderPath = useCallback(async () => { |
|
|
if (!folderPath) { |
|
|
if (!folderPath) { |
|
|
message.error('请选择文件夹'); |
|
|
message.error('请选择文件夹'); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
setLoading(true); |
|
|
setLoading(true); |
|
|
// todo: 调接口 |
|
|
|
|
|
|
|
|
const res = await fetchLocalApi<null>('setWorkSpace', { path: folderPath }); |
|
|
setLoading(false); |
|
|
setLoading(false); |
|
|
if (restProps.onCancel) { |
|
|
|
|
|
restProps.onCancel(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
handleRequest(res).success(() => { |
|
|
|
|
|
if (restProps.onCancel) { |
|
|
|
|
|
restProps.onCancel(); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
}, [folderPath]); |
|
|
}, [folderPath]); |
|
|
|
|
|
|
|
|
return ( |
|
|
return ( |
|
|