更新项目名称为 CodePod,调整相关配置和依赖版本
This commit is contained in:
@@ -409,10 +409,23 @@ const RootContextMenu: React.FC<{ children: React.ReactNode }> = ({ children })
|
||||
|
||||
export const Sidebar: React.FC = () => {
|
||||
const { menu, isLoading } = useMenuStore();
|
||||
const [folder, setFolder] = useState<string>('');
|
||||
const [mount, setMount] = useState(false);
|
||||
useEffect(() => {
|
||||
const folder = getFolder();
|
||||
init('', folder);
|
||||
setFolder(folder);
|
||||
|
||||
setMount(true);
|
||||
}, []);
|
||||
useEffect(() => {
|
||||
if (mount) {
|
||||
if (!folder.endsWith('/')) {
|
||||
toast.error('文件夹路径必须以 / 结尾');
|
||||
return;
|
||||
}
|
||||
init('', folder);
|
||||
}
|
||||
}, [mount, folder]);
|
||||
|
||||
const rootItems = useMemo(() => {
|
||||
const _menu = menu.filter((item) => {
|
||||
@@ -431,7 +444,7 @@ export const Sidebar: React.FC = () => {
|
||||
<h2 className='text-sm font-semibold text-gray-600 dark:text-gray-400 uppercase tracking-wider'>文件</h2>
|
||||
{isLoading && <Loader2 className='w-4 h-4 animate-spin text-gray-400' />}
|
||||
</div>
|
||||
<div className='overflow-y-auto scrollbar p-2' style={{ maxHeight: 'calc(100% - 68px)' }}>
|
||||
<div className='overflow-y-auto scrollbar p-2' style={{ maxHeight: 'calc(100% - 68px - 54px)' }}>
|
||||
{menu.length === 0 && !isLoading ? (
|
||||
<div className='text-sm text-gray-400 px-2'>暂无文件</div>
|
||||
) : (
|
||||
|
||||
@@ -251,8 +251,14 @@ export const init = async (resource: string = '', prefix: string = '') => {
|
||||
export const getCurrentContent = async (currentPath: string): Promise<string | null> => {
|
||||
if (!currentPath) return null;
|
||||
const loadingToast = toast.loading('正在加载文件内容...');
|
||||
const res = await queryResources.fetchFile(currentPath);
|
||||
const res = await queryResources.fetchFile(currentPath, {});
|
||||
|
||||
toast.dismiss(loadingToast);
|
||||
if (res instanceof Response) {
|
||||
const text = await res.text();
|
||||
toast.success('文件内容加载成功');
|
||||
return text;
|
||||
}
|
||||
if (res.code === 200) {
|
||||
return res.data || '';
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user