Skip to content

Commit

Permalink
feat(sandbox): support proxy sandbox (#208)
Browse files Browse the repository at this point in the history
  • Loading branch information
walkerkay authored Sep 13, 2021
1 parent 8947be4 commit d281bf8
Show file tree
Hide file tree
Showing 31 changed files with 9,355 additions and 1,157 deletions.
11 changes: 7 additions & 4 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"tsConfig": "packages/planet/tsconfig.spec.json",
"karmaConfig": "packages/planet/karma.conf.js",
"codeCoverage": true,
"codeCoverageExclude": ["packages/planet/src/testing/**/*"]
"codeCoverageExclude": ["packages/planet/src/testing/**/*", "packages/planet/src/sandbox/**/*"]
}
},
"lint": {
Expand Down Expand Up @@ -71,7 +71,8 @@
"styles": ["examples/portal/src/styles.scss", "examples/portal/src/reboot.scss"],
"extractCss": true,
"scripts": [],
"aot": true
"aot": true,
"optimization": false
},
"configurations": {
"production": {
Expand Down Expand Up @@ -164,7 +165,8 @@
"assets": ["examples/app1/src/favicon.ico", "examples/app1/src/assets"],
"styles": ["examples/app1/src/styles.scss"],
"scripts": [],
"vendorChunk": false
"vendorChunk": false,
"optimization": false
},
"configurations": {
"production": {
Expand Down Expand Up @@ -267,7 +269,8 @@
"scripts": [],
"vendorChunk": false,
"aot": true,
"extractCss": true
"extractCss": true,
"optimization": false
},
"configurations": {
"production": {
Expand Down
5 changes: 3 additions & 2 deletions examples/app1/src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { RouterModule } from '@angular/router';
import { DashboardComponent } from './dashboard/dashboard.component';
import { routers } from './app.routing';
Expand Down Expand Up @@ -40,4 +39,6 @@ import { SharedModule } from './shared.module';
entryComponents: [App1DetailComponent, ProjectsDialogComponent],
bootstrap: [AppRootComponent]
})
export class AppModule {}
export class AppModule {
constructor() {}
}
9 changes: 9 additions & 0 deletions examples/app2/src/app/dashboard/dashboard.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ <h4>This is app2's dashboard</h4>
<a><a href="javascript:;" [routerLink]="['/about']">About use routerLink</a></a>
</section-card>

<section-card class="mt-3" title="Sandbox enabled">
<div>
主应用 Lodash 版本: <span thyLabel="primary">{{ portalLodashVersion }}</span>
</div>
<div class="mt-2">
当前应用 Lodash 版本: <span thyLabel="warning">{{ app2LodashVersion }}</span>
</div>
</section-card>

<!-- <section-card class="mt-4" title="Open app1's user detail">
<button thyButton="outline-primary-square" (click)="openApp1UserDetail()">Open user detail (id: 1)</button>
</section-card> -->
Expand Down
8 changes: 7 additions & 1 deletion examples/app2/src/app/dashboard/dashboard.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@ import { PlanetPortalApplication, GlobalEventDispatcher } from 'ngx-planet';
export class DashboardComponent {
@HostBinding('class') class = 'thy-layout';

constructor(private portalApp: PlanetPortalApplication, private globalEventDispatcher: GlobalEventDispatcher) {}
portalLodashVersion = (0, eval)('window')['lodash'].version;

app2LodashVersion = window['lodash'].version;

constructor(private portalApp: PlanetPortalApplication, private globalEventDispatcher: GlobalEventDispatcher) {
console.log(window);
}

toAbout() {
this.portalApp.navigateByUrl('/about');
Expand Down
2 changes: 2 additions & 0 deletions examples/app2/src/app/shared.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { ThyIconModule } from 'ngx-tethys/icon';

import { DemoCommonModule } from '@demo/common';
import { NgxPlanetModule } from 'ngx-planet';
import { ThyLabelModule } from 'ngx-tethys';

@NgModule({
declarations: [],
Expand Down Expand Up @@ -49,6 +50,7 @@ import { NgxPlanetModule } from 'ngx-planet';
ThyNavModule,
ThyInputModule,
ThyIconModule,
ThyLabelModule,
DemoCommonModule,
NgxPlanetModule
],
Expand Down
5 changes: 5 additions & 0 deletions examples/app2/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ if (environment.production) {
enableProdMode();
}

// 测试沙箱模拟APP2 引入低版本的 lodash
window['lodash'] = {
version: '1.0.0'
};

defineApplication('app2', {
template: `<app2-root></app2-root>`,
bootstrap: (portalApp: PlanetPortalApplication) => {
Expand Down
1 change: 1 addition & 0 deletions examples/portal/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export class AppComponent implements OnInit {
resourcePathPrefix: '/static/app2/',
preload: settings.app2.preload,
switchMode: settings.app2.switchMode,
sandbox: true,
stylePrefix: 'app2',
// prettier-ignore
scripts: [
Expand Down
5 changes: 5 additions & 0 deletions examples/portal/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ if (environment.production) {
enableProdMode();
}

// 测试沙箱模拟主应用引入版本为3.0.0的lodash
window['lodash'] = {
version: '3.0.0'
};

platformBrowserDynamic()
.bootstrapModule(AppModule)
.catch(err => console.error(err));
Loading

0 comments on commit d281bf8

Please sign in to comment.