MCPcopy Create free account
hub / github.com/esengine/esengine / handleCreateProjectFromWizard

Function handleCreateProjectFromWizard

packages/editor-app/src/App.tsx:832–889  ·  view source on GitHub ↗
(projectName: string, projectPath: string, _templateId: string)

Source from the content-addressed store, hash-verified

830 };
831
832 const handleCreateProjectFromWizard = async (projectName: string, projectPath: string, _templateId: string) => {
833 // 使用与 projectPath 相同的路径分隔符 | Use same separator as projectPath
834 const sep = projectPath.includes('/') ? '/' : '\\';
835 const fullProjectPath = `${projectPath}${sep}${projectName}`;
836
837 try {
838 setIsLoading(true, t('project.creating'));
839
840 const projectService = Core.services.resolve(ProjectService);
841 if (!projectService) {
842 console.error('ProjectService not available');
843 setIsLoading(false);
844 setErrorDialog({
845 title: t('project.createFailed'),
846 message: t('project.serviceUnavailable')
847 });
848 return;
849 }
850
851 await projectService.createProject(fullProjectPath);
852
853 setIsLoading(true, t('project.createdOpening'));
854
855 await handleOpenRecentProject(fullProjectPath);
856 } catch (error) {
857 console.error('Failed to create project:', error);
858 setIsLoading(false);
859
860 const errorMessage = error instanceof Error ? error.message : String(error);
861
862 if (errorMessage.includes('already exists')) {
863 setConfirmDialog({
864 title: t('project.alreadyExists'),
865 message: t('project.existsQuestion'),
866 confirmText: t('project.open'),
867 cancelText: t('common.cancel'),
868 onConfirm: () => {
869 setConfirmDialog(null);
870 setIsLoading(true, t('project.opening'));
871 handleOpenRecentProject(fullProjectPath).catch((err) => {
872 console.error('Failed to open project:', err);
873 setIsLoading(false);
874 setErrorDialog({
875 title: t('project.openFailed'),
876 message: `${t('project.openFailed')}:\n${err instanceof Error ? err.message : String(err)}`
877 });
878 });
879 }
880 });
881 } else {
882 setStatus(t('project.createFailed'));
883 setErrorDialog({
884 title: t('project.createFailed'),
885 message: `${t('project.createFailed')}:\n${errorMessage}`
886 });
887 }
888 }
889 };

Callers

nothing calls this directly

Calls 4

handleOpenRecentProjectFunction · 0.85
createProjectMethod · 0.80
resolveMethod · 0.65
errorMethod · 0.45

Tested by

no test coverage detected