Skip to content

Commit

Permalink
refactor: document generation
Browse files Browse the repository at this point in the history
  • Loading branch information
ng-nest-moon committed Dec 12, 2023
1 parent 1c12b4c commit 8f1e8d0
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 40 deletions.
2 changes: 1 addition & 1 deletion scripts/main/utils/generate-cates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(', ')}
})
"
Expand Down
15 changes: 5 additions & 10 deletions src/app/app.config.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,23 @@
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,
withInMemoryScrolling({ anchorScrolling: 'enabled', scrollPositionRestoration: 'top' }),
withEnabledBlockingInitialNavigation(),
withPreloading(XPreloadingStrategyService)
),
// provideClientHydration(),
provideClientHydration(),
provideServiceWorker('ngsw-worker.js', {
enabled: !isDevMode(),
registrationStrategy: 'registerWhenStable:30000'
Expand Down
11 changes: 7 additions & 4 deletions src/services/online-ide/files/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[]) {
Expand All @@ -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]
})
Expand Down
22 changes: 0 additions & 22 deletions src/services/online-ide/files/ng-nest.module.ts

This file was deleted.

3 changes: 0 additions & 3 deletions src/services/online-ide/online-ide.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -31,7 +30,6 @@ export class OnlineIdeService {
openStackBlitz(
selector: string,
otherSelectors: string[],
modules: string[],
providers: string[],
files: { [fileName: string]: string }
) {
Expand All @@ -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': `<ex-${selector}></ex-${selector}>`,
'src/styles.scss': '/* You can add global styles to this file, and also import other style files */',
Expand Down

0 comments on commit 8f1e8d0

Please sign in to comment.