[web-app] 初始化web端,angular+ts+less+ng-zorro
This commit is contained in:
13
web-app/src/app/app-routing.module.ts
Normal file
13
web-app/src/app/app-routing.module.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { Routes, RouterModule } from '@angular/router';
|
||||
|
||||
const routes: Routes = [
|
||||
{ path: '', pathMatch: 'full', redirectTo: '/welcome' },
|
||||
{ path: 'welcome', loadChildren: () => import('./pages/welcome/welcome.module').then(m => m.WelcomeModule) }
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
imports: [RouterModule.forRoot(routes)],
|
||||
exports: [RouterModule]
|
||||
})
|
||||
export class AppRoutingModule { }
|
||||
54
web-app/src/app/app.component.html
Normal file
54
web-app/src/app/app.component.html
Normal file
@@ -0,0 +1,54 @@
|
||||
<nz-layout class="app-layout">
|
||||
<nz-sider class="menu-sidebar"
|
||||
nzCollapsible
|
||||
nzWidth="256px"
|
||||
nzBreakpoint="md"
|
||||
[(nzCollapsed)]="isCollapsed"
|
||||
[nzTrigger]="null">
|
||||
<div class="sidebar-logo">
|
||||
<a href="https://ng.ant.design/" target="_blank">
|
||||
<img src="https://ng.ant.design/assets/img/logo.svg" alt="logo">
|
||||
<h1>Ant Design Of Angular</h1>
|
||||
</a>
|
||||
</div>
|
||||
<ul nz-menu nzTheme="dark" nzMode="inline" [nzInlineCollapsed]="isCollapsed">
|
||||
<li nz-submenu nzOpen nzTitle="Dashboard" nzIcon="dashboard">
|
||||
<ul>
|
||||
<li nz-menu-item nzMatchRouter>
|
||||
<a routerLink="/welcome">Welcome</a>
|
||||
</li>
|
||||
<li nz-menu-item nzMatchRouter>
|
||||
<a>Monitor</a>
|
||||
</li>
|
||||
<li nz-menu-item nzMatchRouter>
|
||||
<a>Workplace</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li nz-submenu nzOpen nzTitle="Form" nzIcon="form">
|
||||
<ul>
|
||||
<li nz-menu-item nzMatchRouter>
|
||||
<a>Basic Form</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</nz-sider>
|
||||
<nz-layout>
|
||||
<nz-header>
|
||||
<div class="app-header">
|
||||
<span class="header-trigger" (click)="isCollapsed = !isCollapsed">
|
||||
<i class="trigger"
|
||||
nz-icon
|
||||
[nzType]="isCollapsed ? 'menu-unfold' : 'menu-fold'"
|
||||
></i>
|
||||
</span>
|
||||
</div>
|
||||
</nz-header>
|
||||
<nz-content>
|
||||
<div class="inner-content">
|
||||
<router-outlet></router-outlet>
|
||||
</div>
|
||||
</nz-content>
|
||||
</nz-layout>
|
||||
</nz-layout>
|
||||
80
web-app/src/app/app.component.less
Normal file
80
web-app/src/app/app.component.less
Normal file
@@ -0,0 +1,80 @@
|
||||
:host {
|
||||
display: flex;
|
||||
text-rendering: optimizeLegibility;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
|
||||
.app-layout {
|
||||
height: 100vh;
|
||||
}
|
||||
|
||||
.menu-sidebar {
|
||||
position: relative;
|
||||
z-index: 10;
|
||||
min-height: 100vh;
|
||||
box-shadow: 2px 0 6px rgba(0,21,41,.35);
|
||||
}
|
||||
|
||||
.header-trigger {
|
||||
height: 64px;
|
||||
padding: 20px 24px;
|
||||
font-size: 20px;
|
||||
cursor: pointer;
|
||||
transition: all .3s,padding 0s;
|
||||
}
|
||||
|
||||
.trigger:hover {
|
||||
color: #1890ff;
|
||||
}
|
||||
|
||||
.sidebar-logo {
|
||||
position: relative;
|
||||
height: 64px;
|
||||
padding-left: 24px;
|
||||
overflow: hidden;
|
||||
line-height: 64px;
|
||||
background: #001529;
|
||||
transition: all .3s;
|
||||
}
|
||||
|
||||
.sidebar-logo img {
|
||||
display: inline-block;
|
||||
height: 32px;
|
||||
width: 32px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.sidebar-logo h1 {
|
||||
display: inline-block;
|
||||
margin: 0 0 0 20px;
|
||||
color: #fff;
|
||||
font-weight: 600;
|
||||
font-size: 14px;
|
||||
font-family: Avenir,Helvetica Neue,Arial,Helvetica,sans-serif;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
nz-header {
|
||||
padding: 0;
|
||||
width: 100%;
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
.app-header {
|
||||
position: relative;
|
||||
height: 64px;
|
||||
padding: 0;
|
||||
background: #fff;
|
||||
box-shadow: 0 1px 4px rgba(0,21,41,.08);
|
||||
}
|
||||
|
||||
nz-content {
|
||||
margin: 24px;
|
||||
}
|
||||
|
||||
.inner-content {
|
||||
padding: 24px;
|
||||
background: #fff;
|
||||
height: 100%;
|
||||
}
|
||||
35
web-app/src/app/app.component.spec.ts
Normal file
35
web-app/src/app/app.component.spec.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
import { AppComponent } from './app.component';
|
||||
|
||||
describe('AppComponent', () => {
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [
|
||||
RouterTestingModule
|
||||
],
|
||||
declarations: [
|
||||
AppComponent
|
||||
],
|
||||
}).compileComponents();
|
||||
});
|
||||
|
||||
it('should create the app', () => {
|
||||
const fixture = TestBed.createComponent(AppComponent);
|
||||
const app = fixture.componentInstance;
|
||||
expect(app).toBeTruthy();
|
||||
});
|
||||
|
||||
it(`should have as title 'web-app'`, () => {
|
||||
const fixture = TestBed.createComponent(AppComponent);
|
||||
const app = fixture.componentInstance;
|
||||
expect(app.title).toEqual('web-app');
|
||||
});
|
||||
|
||||
it('should render title', () => {
|
||||
const fixture = TestBed.createComponent(AppComponent);
|
||||
fixture.detectChanges();
|
||||
const compiled = fixture.nativeElement as HTMLElement;
|
||||
expect(compiled.querySelector('.content span')?.textContent).toContain('web-app app is running!');
|
||||
});
|
||||
});
|
||||
10
web-app/src/app/app.component.ts
Normal file
10
web-app/src/app/app.component.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { Component } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'app-root',
|
||||
templateUrl: './app.component.html',
|
||||
styleUrls: ['./app.component.less']
|
||||
})
|
||||
export class AppComponent {
|
||||
isCollapsed = false;
|
||||
}
|
||||
36
web-app/src/app/app.module.ts
Normal file
36
web-app/src/app/app.module.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { BrowserModule } from '@angular/platform-browser';
|
||||
|
||||
import { AppRoutingModule } from './app-routing.module';
|
||||
import { AppComponent } from './app.component';
|
||||
import { NZ_I18N } from 'ng-zorro-antd/i18n';
|
||||
import { en_US } from 'ng-zorro-antd/i18n';
|
||||
import { registerLocaleData } from '@angular/common';
|
||||
import en from '@angular/common/locales/en';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { HttpClientModule } from '@angular/common/http';
|
||||
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { IconsProviderModule } from './icons-provider.module';
|
||||
import { NzLayoutModule } from 'ng-zorro-antd/layout';
|
||||
import { NzMenuModule } from 'ng-zorro-antd/menu';
|
||||
|
||||
registerLocaleData(en);
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
AppComponent
|
||||
],
|
||||
imports: [
|
||||
BrowserModule,
|
||||
AppRoutingModule,
|
||||
FormsModule,
|
||||
HttpClientModule,
|
||||
BrowserAnimationsModule,
|
||||
IconsProviderModule,
|
||||
NzLayoutModule,
|
||||
NzMenuModule
|
||||
],
|
||||
providers: [{ provide: NZ_I18N, useValue: en_US }],
|
||||
bootstrap: [AppComponent]
|
||||
})
|
||||
export class AppModule { }
|
||||
21
web-app/src/app/icons-provider.module.ts
Normal file
21
web-app/src/app/icons-provider.module.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { NZ_ICONS, NzIconModule } from 'ng-zorro-antd/icon';
|
||||
|
||||
import {
|
||||
MenuFoldOutline,
|
||||
MenuUnfoldOutline,
|
||||
FormOutline,
|
||||
DashboardOutline
|
||||
} from '@ant-design/icons-angular/icons';
|
||||
|
||||
const icons = [MenuFoldOutline, MenuUnfoldOutline, DashboardOutline, FormOutline];
|
||||
|
||||
@NgModule({
|
||||
imports: [NzIconModule],
|
||||
exports: [NzIconModule],
|
||||
providers: [
|
||||
{ provide: NZ_ICONS, useValue: icons }
|
||||
]
|
||||
})
|
||||
export class IconsProviderModule {
|
||||
}
|
||||
13
web-app/src/app/pages/welcome/welcome-routing.module.ts
Normal file
13
web-app/src/app/pages/welcome/welcome-routing.module.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { Routes, RouterModule } from '@angular/router';
|
||||
import { WelcomeComponent } from './welcome.component';
|
||||
|
||||
const routes: Routes = [
|
||||
{ path: '', component: WelcomeComponent },
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
imports: [RouterModule.forChild(routes)],
|
||||
exports: [RouterModule]
|
||||
})
|
||||
export class WelcomeRoutingModule { }
|
||||
15
web-app/src/app/pages/welcome/welcome.component.ts
Normal file
15
web-app/src/app/pages/welcome/welcome.component.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'app-welcome',
|
||||
templateUrl: './welcome.component.html',
|
||||
styleUrls: ['./welcome.component.less']
|
||||
})
|
||||
export class WelcomeComponent implements OnInit {
|
||||
|
||||
constructor() { }
|
||||
|
||||
ngOnInit() {
|
||||
}
|
||||
|
||||
}
|
||||
13
web-app/src/app/pages/welcome/welcome.module.ts
Normal file
13
web-app/src/app/pages/welcome/welcome.module.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
|
||||
import { WelcomeRoutingModule } from './welcome-routing.module';
|
||||
|
||||
import { WelcomeComponent } from './welcome.component';
|
||||
|
||||
|
||||
@NgModule({
|
||||
imports: [WelcomeRoutingModule],
|
||||
declarations: [WelcomeComponent],
|
||||
exports: [WelcomeComponent]
|
||||
})
|
||||
export class WelcomeModule { }
|
||||
Reference in New Issue
Block a user