@@ -11,6 +11,9 @@ import SDKMenu from "../components/SDKMenu";
1111import ErrorIcon from "@mui/icons-material/Error" ;
1212import WarningIcon from "@mui/icons-material/Warning" ;
1313import { getVersion } from "@tauri-apps/api/app" ;
14+ import { invoke } from "@tauri-apps/api/core" ;
15+ import { useToast } from "react-toast-plus" ;
16+ import { relaunch } from "@tauri-apps/plugin-process" ;
1417
1518export interface OnboardingProps { }
1619
@@ -26,6 +29,7 @@ export default ({}: OnboardingProps) => {
2629 const [ ready , setReady ] = useState ( false ) ;
2730 const [ version , setVersion ] = useState < string > ( "" ) ;
2831 const navigate = useNavigate ( ) ;
32+ const { addToast } = useToast ( ) ;
2933
3034 useEffect ( ( ) => {
3135 if ( toolchains !== null && isWindows !== null && hasWSL !== null ) {
@@ -132,7 +136,7 @@ export default ({}: OnboardingProps) => {
132136 ) }
133137 </ Typography >
134138 < div className = "onboarding-cards" >
135- { isWindows && (
139+ { ! isWindows && (
136140 < Card variant = "soft" >
137141 < Typography level = "h3" > Windows Subsystem for Linux</ Typography >
138142 < Typography level = "body-sm" >
@@ -147,9 +151,9 @@ export default ({}: OnboardingProps) => {
147151 >
148152 microsoft.com
149153 </ Link >
150- . We recommended installing WSL 2 and Ubuntu 24.04. Other
151- distributions may work, but are not officially supported.
152- CrossCode will use your default WSL distribution.
154+ . We recommended WSL 2 and Ubuntu 24.04. Other distributions may
155+ work, but are not officially supported. CrossCode will use your
156+ default WSL distribution.
153157 </ Typography >
154158 < Divider />
155159 < CardContent >
@@ -160,7 +164,8 @@ export default ({}: OnboardingProps) => {
160164 "WSL is already installed on your system!"
161165 ) : (
162166 < >
163- WSL is not installed on your system. Please follow the guide
167+ WSL is not installed on your system. CrossCode can attempt
168+ to automatically install WSL. If it fails, follow the guide
164169 on{ " " }
165170 < Link
166171 href = "#"
@@ -177,6 +182,37 @@ export default ({}: OnboardingProps) => {
177182 </ >
178183 ) }
179184 </ Typography >
185+ { hasWSL && < Divider /> }
186+ { hasWSL && (
187+ < Button
188+ onClick = { async ( ) => {
189+ try {
190+ await invoke ( "install_wsl" ) ;
191+ } catch ( error ) {
192+ addToast . error (
193+ "Failed to launch WSL installation. Please try installing it manually."
194+ ) ;
195+ }
196+ } }
197+ >
198+ Install WSL
199+ </ Button >
200+ ) }
201+ { hasWSL && (
202+ < Button
203+ onClick = { async ( ) => {
204+ try {
205+ await relaunch ( ) ;
206+ } catch ( error ) {
207+ addToast . error (
208+ "Failed to relaunch CrossCode. Please try manually."
209+ ) ;
210+ }
211+ } }
212+ >
213+ Relaunch CrossCode (post-installation)
214+ </ Button >
215+ ) }
180216 </ CardContent >
181217 </ Card >
182218 ) }
0 commit comments