Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
biaogebusy committed Nov 8, 2024
2 parents f1d6800 + 7e91239 commit 2f9c28f
Show file tree
Hide file tree
Showing 45 changed files with 435 additions and 344 deletions.
6 changes: 4 additions & 2 deletions src/app/app.component.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
@if (loading) {
<div class="loading-container flex fixed top-0 left-0 w-screen h-screen z-10">
<div class="loader">Loading...</div>
<div
class="app-loading bg-white flex fixed top-0 left-0 w-screen h-full z-10 overflow-hidden"
>
<div class="app-loader">Loading...</div>
</div>
}
@if (coreConfig.loadingBar) {
Expand Down
6 changes: 4 additions & 2 deletions src/app/app.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
}
}

.loading-container {
background-color: rgba(255, 255, 255, 1);
.app-loading {
.app-loader {
position: absolute;
}
}
3 changes: 2 additions & 1 deletion src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { ThemeService } from '@core/service/theme.service';
})
export class AppComponent implements OnInit, AfterViewInit {
mobileMenuOpened: boolean;
loading = false;
loading = true;
screen = inject(ScreenState);
activateRouter = inject(ActivatedRoute);
configService = inject(ConfigService);
Expand All @@ -38,6 +38,7 @@ export class AppComponent implements OnInit, AfterViewInit {

ngAfterViewInit(): void {
if (this.screenService.isPlatformBrowser()) {
this.loading = false;
this.themeService.initTheme();
this.screen.drawer$.subscribe(() => {
this.mobileMenuOpened = !this.mobileMenuOpened;
Expand Down
13 changes: 7 additions & 6 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,20 @@ import { BrandingModule } from '@core/branding/branding.module';
import { AppComponent } from './app.component';
import { httpInterceptorProviders } from '@core/interceptors';
import {
USER,
LANG,
THEME,
API_URL,
BRANDING,
BUILDER_FULL_SCREEN,
CORE_CONFIG,
DEBUG_ANIMATE,
IS_BUILDER_MODE,
LANG,
MEDIA_ASSETS,
DEBUG_ANIMATE,
NOTIFY_CONTENT,
USER,
IS_BUILDER_MODE,
BUILDER_FULL_SCREEN,
} from '@core/token/token-providers';
import { LoadingBarHttpClientModule } from '@ngx-loading-bar/http-client';
import { LoadingBarModule } from '@ngx-loading-bar/core';
import { API_URL, THEME } from '@core/token/token-providers';
import { RenderModule } from '@modules/render/render.module';
import {
apiUrlFactory,
Expand Down
18 changes: 7 additions & 11 deletions src/app/core/branding/footer/inverse/inverse.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ChangeDetectorRef, Component, Input, OnInit } from '@angular/core';
import { ChangeDetectorRef, Component, Input, inject } from '@angular/core';
import { UntypedFormGroup } from '@angular/forms';
import { FormService } from '@core/service/form.service';
import { UtilitiesService } from '@core/service/utilities.service';
Expand All @@ -9,19 +9,15 @@ import { UtilitiesService } from '@core/service/utilities.service';
styleUrls: ['./inverse.component.scss'],
host: { ngSkipHydration: 'true' },
})
export class InverseComponent implements OnInit {
export class InverseComponent {
@Input() content: any;
form: UntypedFormGroup = new UntypedFormGroup({});
success = false;
submited = false;

constructor(
private cd: ChangeDetectorRef,
public formService: FormService,
private utilitiesService: UtilitiesService
) {}

ngOnInit(): void {}
private cd = inject(ChangeDetectorRef);
public formService = inject(FormService);
private util = inject(UtilitiesService);

onSubmit(): void {
if (this.form.invalid) {
Expand All @@ -36,12 +32,12 @@ export class InverseComponent implements OnInit {
() => {
this.submited = false;
this.success = true;
this.utilitiesService.openSnackbar('成功订阅!');
this.util.openSnackbar('成功订阅!');
this.cd.detectChanges();
},
(error) => {
this.submited = false;
this.utilitiesService.openSnackbar(`Error: ${error.message}`);
this.util.openSnackbar(`Error: ${error.message}`);
}
);
}
Expand Down
9 changes: 4 additions & 5 deletions src/app/core/branding/footer/menu-item/menu-item.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
Component,
Input,
OnInit,
inject,
} from '@angular/core';
import { ScreenState } from '@core/state/screen/ScreenState';
import { ScreenService } from '@core/service/screen.service';
Expand All @@ -18,11 +19,9 @@ export class MenuItemComponent implements OnInit {
@Input() content: any;
@Input() mobileMenu: any;
showXs: boolean;
constructor(
private screen: ScreenState,
private screenService: ScreenService,
private cd: ChangeDetectorRef
) {}
private screen = inject(ScreenState);
private cd = inject(ChangeDetectorRef);
private screenService = inject(ScreenService);

ngOnInit(): void {
if (this.screenService.isPlatformBrowser()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import {
Input,
OnInit,
ElementRef,
OnDestroy,
ChangeDetectionStrategy,
ChangeDetectorRef,
inject,
} from '@angular/core';
import { fromEvent, of } from 'rxjs';
import { mergeMap, delay, takeUntil } from 'rxjs/operators';
Expand All @@ -19,15 +19,13 @@ import type { IMainMenu } from '@core/interface/branding/IBranding';
styleUrls: ['./mega-menu.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class MegaMenuComponent implements OnInit, OnDestroy {
export class MegaMenuComponent implements OnInit {
@Input() content: IMainMenu;
active: boolean;
constructor(
private eleRef: ElementRef,
private screenState: ScreenState,
private screenService: ScreenService,
private cd: ChangeDetectorRef
) {}
private eleRef = inject(ElementRef);
private screenState = inject(ScreenState);
private screenService = inject(ScreenService);
private cd = inject(ChangeDetectorRef);

ngOnInit(): void {
if (this.screenService.isPlatformBrowser()) {
Expand Down Expand Up @@ -73,6 +71,4 @@ export class MegaMenuComponent implements OnInit, OnDestroy {
trackByFn(index: number, item: any): number {
return index;
}

ngOnDestroy(): void {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {
ChangeDetectionStrategy,
Component,
Input,
OnInit,
ViewChild,
} from '@angular/core';

Expand All @@ -12,10 +11,7 @@ import {
styleUrls: ['./sub-menu.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class SubMenuComponent implements OnInit {
export class SubMenuComponent {
@Input() content: any;
@ViewChild('childMenu', { static: true }) public childMenu: any;
constructor() {}

ngOnInit(): void {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ export class SearchBoxComponent extends BaseComponent implements OnInit {
nodeService = inject(NodeService);
formService = inject(FormService);
router = inject(Router);
constructor(private cd: ChangeDetectorRef) {
super();
}
private cd = inject(ChangeDetectorRef);

ngOnInit(): void {
this.initForm(this.content);
Expand All @@ -52,9 +50,9 @@ export class SearchBoxComponent extends BaseComponent implements OnInit {
page: '0',
loading: 0,
},
value,
value
),
isEmpty,
isEmpty
);

this.nodeService
Expand Down
18 changes: 9 additions & 9 deletions src/app/core/guards/auth.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class AuthGuard {
}
canActivate(
route: ActivatedRouteSnapshot,
state: RouterStateSnapshot,
state: RouterStateSnapshot
):
| Observable<boolean | UrlTree>
| Promise<boolean | UrlTree>
Expand Down Expand Up @@ -65,14 +65,14 @@ export class AuthGuard {
this.userService.logoutUser();
if (environment?.drupalProxy) {
window.location.href =
defaultDrupalLoginPage || '/user/login';
defaultDrupalLoginPage ?? '/user/login';
return false;
} else {
this.router.navigate(
[defaultFrontLoginPage || '/me/login'],
[defaultFrontLoginPage ?? '/me/login'],
{
queryParams: { returnUrl: state.url },
},
}
);
return false;
}
Expand All @@ -81,15 +81,15 @@ export class AuthGuard {
catchError(() => {
if (environment?.drupalProxy) {
window.location.href =
defaultDrupalLoginPage || '/user/login';
defaultDrupalLoginPage ?? '/user/login';
return of(false);
} else {
this.router.navigate([
defaultFrontLoginPage || '/me/login',
defaultFrontLoginPage ?? '/me/login',
]);
return of(false);
}
}),
})
);
} else {
if (checkUserState) {
Expand All @@ -104,13 +104,13 @@ export class AuthGuard {
if (status && !this.user) {
this.userService.updateUserBySession();
}
}),
})
)
.subscribe();
}
return of(true);
}
}),
})
);
} else {
return of(true);
Expand Down
16 changes: 8 additions & 8 deletions src/app/core/guards/builder.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class BuilderGuard {
}
canActivate(
route: ActivatedRouteSnapshot,
state: RouterStateSnapshot,
state: RouterStateSnapshot
):
| Observable<boolean | UrlTree>
| Promise<boolean | UrlTree>
Expand Down Expand Up @@ -69,14 +69,14 @@ export class BuilderGuard {
this.userService.logoutUser();
if (environment?.drupalProxy) {
window.location.href =
defaultDrupalLoginPage || '/user/login';
defaultDrupalLoginPage ?? '/user/login';
return false;
} else {
this.router.navigate(
[defaultFrontLoginPage || '/me/login'],
[defaultFrontLoginPage ?? '/me/login'],
{
queryParams: { returnUrl: state.url },
},
}
);
return false;
}
Expand All @@ -85,20 +85,20 @@ export class BuilderGuard {
catchError(() => {
if (environment?.drupalProxy) {
window.location.href =
defaultDrupalLoginPage || '/user/login';
defaultDrupalLoginPage ?? '/user/login';
return of(false);
} else {
this.router.navigate([
defaultFrontLoginPage || '/me/login',
defaultFrontLoginPage ?? '/me/login',
]);
return of(false);
}
}),
})
);
} else {
return of(true);
}
}),
})
);
} else {
return of(true);
Expand Down
1 change: 1 addition & 0 deletions src/app/core/interface/IBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { IMainMenu } from './branding/IBranding';

export interface IBuilderConfig {
menu: IMainMenu[];
newSection: any;
tour: {
enable: boolean;
delay: number;
Expand Down
1 change: 0 additions & 1 deletion src/app/core/interface/combs/ICombsBase.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { IBg } from '../widgets/IBg';
import { IBgImg } from '../widgets/IBgImg';
import { IText } from '../widgets/IText';

Expand Down
1 change: 0 additions & 1 deletion src/app/core/interface/widgets/IContentWidget.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { ILink } from './ILink';
import { IImg } from './IImg';
import { IRatios } from './IWidgets';
import { IText } from './IText';

export interface IContentBox extends IRatios {
type: 'content-box';
Expand Down
2 changes: 1 addition & 1 deletion src/app/core/service/amap.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Injectable, inject } from '@angular/core';
import { Observable, Subject, of, BehaviorSubject } from 'rxjs';
import { Observable, Subject, BehaviorSubject } from 'rxjs';
import type { IAmap, IMark, IMarkInfo } from '../interface/IAmap';
import { ScreenService } from './screen.service';

Expand Down
5 changes: 2 additions & 3 deletions src/app/core/service/analytics.service.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import { Injectable, inject } from '@angular/core';
import { UtilitiesService } from '@core/service/utilities.service';

declare var gtag: any;
declare var window: any;
declare let gtag: any;
declare let window: any;

@Injectable({
providedIn: 'root',
})
export class AnalyticsService {
utility = inject(UtilitiesService);
constructor() {}

loadGoogleAnalytics(id: string): void {
// injecting GA main script asynchronously
Expand Down
Loading

0 comments on commit 2f9c28f

Please sign in to comment.