11import { MediaMatcher } from '@angular/cdk/layout' ;
22import { isPlatformBrowser } from '@angular/common' ;
3+ import { HttpClient } from '@angular/common/http' ;
34import { ChangeDetectorRef , Component , Inject , inject , OnDestroy , OnInit , PLATFORM_ID } from '@angular/core' ;
45import { MatButtonModule } from '@angular/material/button' ;
56import { MatCardModule } from '@angular/material/card' ;
@@ -23,7 +24,10 @@ export class AppComponent implements OnInit, OnDestroy {
2324
2425 private _mobileQueryListener : ( ) => void ;
2526
26- constructor ( @Inject ( PLATFORM_ID ) private platformId : any ) {
27+ constructor (
28+ @Inject ( PLATFORM_ID ) private platformId : any ,
29+ private http : HttpClient
30+ ) {
2731 const changeDetectorRef = inject ( ChangeDetectorRef ) ;
2832 const media = inject ( MediaMatcher ) ;
2933
@@ -47,6 +51,17 @@ export class AppComponent implements OnInit, OnDestroy {
4751 this . setTheme ( ) ;
4852 }
4953
54+ download ( os : string ) : void {
55+ const url = "https://api.github.com/repos/sQeeZ-scripting-language/interpreter/releases/latest" ;
56+ this . http . get ( url ) . subscribe ( ( data : any ) => {
57+ data . assets . find ( ( asset : any ) => {
58+ if ( asset . browser_download_url . includes ( os . toLowerCase ( ) ) ) {
59+ window . location . href = asset . browser_download_url ;
60+ }
61+ } ) ;
62+ } ) ;
63+ }
64+
5065 private getSystemTheme ( ) : string {
5166 return ( typeof window !== 'undefined' && window . matchMedia && window . matchMedia ( '(prefers-color-scheme: dark)' ) . matches ) ? 'dark' : 'light' ;
5267 }
0 commit comments