diff --git a/scripts/main/utils/generate-cates.ts b/scripts/main/utils/generate-cates.ts index 92d02a14c..e9182a330 100644 --- a/scripts/main/utils/generate-cates.ts +++ b/scripts/main/utils/generate-cates.ts @@ -107,7 +107,7 @@ export function generateTools(name: string, otherNames: string[], providers: str content="从 StackBlitz 打开" placement="top" (click)=" - this.ois.openStackBlitz('${name}', [${otherNames.join(', ')}], [{{ __modules }}], [${providers.join(', ')}], { + this.ois.openStackBlitz('${name}', [${otherNames.join(', ')}], [${providers.join(', ')}], { ${files.join(', ')} }) " diff --git a/src/app/app.config.ts b/src/app/app.config.ts index 4b616fe6d..4b9744ab5 100644 --- a/src/app/app.config.ts +++ b/src/app/app.config.ts @@ -1,20 +1,15 @@ import { ApplicationConfig, isDevMode } from '@angular/core'; -import { - provideRouter, - withEnabledBlockingInitialNavigation, - withInMemoryScrolling, - withPreloading -} from '@angular/router'; +import { provideRouter, withEnabledBlockingInitialNavigation, withInMemoryScrolling, withPreloading } from '@angular/router'; import { MainRoutes, TestRoutes } from './app.routes'; -// import { provideClientHydration } from '@angular/platform-browser'; +import { provideClientHydration } from '@angular/platform-browser'; import { provideServiceWorker } from '@angular/service-worker'; import { provideHttpClient } from '@angular/common/http'; -import { provideAnimations } from '@angular/platform-browser/animations'; +import { provideAnimationsAsync } from '@angular/platform-browser/animations/async'; import { XPreloadingStrategyService } from '@ng-nest/ui/core'; export const appConfig: ApplicationConfig = { providers: [ - provideAnimations(), + provideAnimationsAsync(), provideHttpClient(), provideRouter( !isDevMode() ? MainRoutes : TestRoutes, @@ -22,7 +17,7 @@ export const appConfig: ApplicationConfig = { withEnabledBlockingInitialNavigation(), withPreloading(XPreloadingStrategyService) ), - // provideClientHydration(), + provideClientHydration(), provideServiceWorker('ngsw-worker.js', { enabled: !isDevMode(), registrationStrategy: 'registerWhenStable:30000' diff --git a/src/services/online-ide/files/app.module.ts b/src/services/online-ide/files/app.module.ts index 9b89bf9a0..6e3e164a8 100644 --- a/src/services/online-ide/files/app.module.ts +++ b/src/services/online-ide/files/app.module.ts @@ -7,7 +7,9 @@ export function importFromProviders(selector: string, providers: string[]) { export function importFromOtherSelectors(selector: string, otherSelectors: string[]) { if (otherSelectors.length === 0) return ''; - return otherSelectors.map((x) => `import { Ex${classify(x)}Component } from "./${selector}/${x}.component";`).join('\n'); + return otherSelectors + .map((x) => `import { Ex${classify(x)}Component } from "./${selector}/${x}.component";`) + .join('\n'); } export function importProviders(providers: string[]) { @@ -28,13 +30,14 @@ import { NgModule } from '@angular/core'; import { AppComponent } from './app.component'; import { HttpClientModule } from '@angular/common/http'; -import { NgNestModule } from './ng-nest.module'; import { Ex${classify(selector)}Component } from "./${selector}/${selector}.component"; ${importFromOtherSelectors(selector, otherSelectors)} ${importFromProviders(selector, providers)} @NgModule({ - declarations: [AppComponent, Ex${classify(selector)}Component, ${declarationOtherSelectors(otherSelectors)}], - imports: [BrowserModule, BrowserAnimationsModule, FormsModule, ReactiveFormsModule, HttpClientModule, NgNestModule], + declarations: [AppComponent, ${declarationOtherSelectors(otherSelectors)}], + imports: [BrowserModule, BrowserAnimationsModule, FormsModule, ReactiveFormsModule, HttpClientModule, Ex${classify( + selector + )}Component,], providers: [${importProviders(providers)}], bootstrap: [AppComponent] }) diff --git a/src/services/online-ide/files/ng-nest.module.ts b/src/services/online-ide/files/ng-nest.module.ts deleted file mode 100644 index 5326276c1..000000000 --- a/src/services/online-ide/files/ng-nest.module.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { classify } from '@utils'; - -export function importFromModules(modules: string[]) { - if (modules.length === 0) return ''; - return modules.map((x) => `import { X${classify(x)}Module } from "@ng-nest/ui/${x}";`).join('\n'); -} - -export function importModules(modules: string[]) { - if (modules.length === 0) return ''; - return modules.map((x) => `X${classify(x)}Module`).join(', '); -} - -export default (modules: string[]) => { - return `import { NgModule } from '@angular/core'; -${importFromModules(modules)} -const modules = [${importModules(modules)}]; - -@NgModule({ - exports: [...modules] -}) -export class NgNestModule {}`; -}; diff --git a/src/services/online-ide/online-ide.service.ts b/src/services/online-ide/online-ide.service.ts index 52d235a1c..4f0a27bd5 100644 --- a/src/services/online-ide/online-ide.service.ts +++ b/src/services/online-ide/online-ide.service.ts @@ -5,7 +5,6 @@ import mainTs from './files/main'; import polyfillTS from './files/polyfills'; import appComponentTs from './files/app.component'; import appModuleTs from './files/app.module'; -import ngNestModuleTs from './files/ng-nest.module'; import environmentTS from './files/environment'; import tsconfigTS from './files/tsconfig.json'; import tsconfigAppTS from './files/tsconfig.app.json'; @@ -31,7 +30,6 @@ export class OnlineIdeService { openStackBlitz( selector: string, otherSelectors: string[], - modules: string[], providers: string[], files: { [fileName: string]: string } ) { @@ -49,7 +47,6 @@ export class OnlineIdeService { 'src/main.ts': mainTs, 'src/polyfills.ts': polyfillTS, 'src/app/app.module.ts': appModuleTs(selector, otherSelectors, providers), - 'src/app/ng-nest.module.ts': ngNestModuleTs(modules), 'src/app/app.component.ts': appComponentTs, 'src/app/app.component.html': ``, 'src/styles.scss': '/* You can add global styles to this file, and also import other style files */',