(projectName: string, projectPath: string, _templateId: string)
| 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 | }; |
nothing calls this directly
no test coverage detected