Explorar el Código

完成同步设置的接口对接

main
郑州 hace 3 años
padre
commit
151a77998f
Se han modificado 2 ficheros con 17 adiciones y 6 borrados
  1. +15
    -6
      src/components/AppHeader/components/userCenter/FolderSetModal.tsx
  2. +2
    -0
      src/utils/tool.ts

+ 15
- 6
src/components/AppHeader/components/userCenter/FolderSetModal.tsx Ver fichero

@@ -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 (


+ 2
- 0
src/utils/tool.ts Ver fichero

@@ -1,3 +1,5 @@
import { API } from '@/services/API';

export const isClient = !!window.ipcRenderer; // process.env.IS_CLIENT; export const isClient = !!window.ipcRenderer; // process.env.IS_CLIENT;


export function firstCharToLowerCase(obj: any) { export function firstCharToLowerCase(obj: any) {


Cargando…
Cancelar
Guardar