From 09e09c91da4ec794f8cd197026c1fcb47daf99a8 Mon Sep 17 00:00:00 2001 From: Mike Huang Date: Thu, 5 Dec 2024 12:26:31 +0800 Subject: [PATCH] fix toggle theme display problem --- src/app/layout/layout-toolbar.component.ts | 40 ++++++++++++++-------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/src/app/layout/layout-toolbar.component.ts b/src/app/layout/layout-toolbar.component.ts index d0f9e9dfae..81ec93ad77 100644 --- a/src/app/layout/layout-toolbar.component.ts +++ b/src/app/layout/layout-toolbar.component.ts @@ -3,7 +3,7 @@ import { Component, inject, input, - output + output, } from '@angular/core'; import { toSignal } from '@angular/core/rxjs-interop'; import { FormControl, ReactiveFormsModule } from '@angular/forms'; @@ -13,24 +13,31 @@ import { MatIconModule } from '@angular/material/icon'; import { MatInputModule } from '@angular/material/input'; import { MatToolbarModule } from '@angular/material/toolbar'; import { RouterLink } from '@angular/router'; -import { combineLatest, debounceTime, defer, distinctUntilChanged, map, switchMap } from 'rxjs'; +import { + combineLatest, + debounceTime, + defer, + distinctUntilChanged, + map, + switchMap, +} from 'rxjs'; import { PlatformService } from 'src/app/site-common/platform.service'; import { SitePostService } from '../site-common/site-post.service'; import { WebsiteTheme } from './website-theme'; @Component({ - selector: 'app-layout-toolbar', - imports: [ - RouterLink, - ReactiveFormsModule, - MatToolbarModule, - MatIconModule, - MatInputModule, - MatAutocompleteModule, - MatButtonModule, - ], - template: ` + @if(!isServer){ + } @if (!(isSmallScreen())) { @@ -115,8 +124,8 @@ import { WebsiteTheme } from './website-theme'; } `, - styles: ``, - changeDetection: ChangeDetectionStrategy.OnPush + styles: ``, + changeDetection: ChangeDetectionStrategy.OnPush, }) export class LayoutToolbarComponent { readonly menuOpen = input(true); @@ -131,6 +140,7 @@ export class LayoutToolbarComponent { private platformService = inject(PlatformService); private sitePostService = inject(SitePostService); + protected isServer = this.platformService.isServer; protected isSmallScreen = this.platformService.isSmallScreen; protected searchKeyword = new FormControl('');