diff --git a/boot/platform/src/main/resources/application-local.yml b/boot/platform/src/main/resources/application-local.yml index 229da568..14544836 100644 --- a/boot/platform/src/main/resources/application-local.yml +++ b/boot/platform/src/main/resources/application-local.yml @@ -23,7 +23,7 @@ spring: max-acquire-time: 5s validation-query: "select version()" sql.init: - mode: never + mode: always platform: postgres encoding: utf-8 data.redis: diff --git a/boot/platform/src/main/resources/data-postgres.sql b/boot/platform/src/main/resources/data-postgres.sql index 0fd51f46..32e9e5ed 100644 --- a/boot/platform/src/main/resources/data-postgres.sql +++ b/boot/platform/src/main/resources/data-postgres.sql @@ -27,4 +27,13 @@ values ('1000', 'FOLDER', 'ROLE_FOLDER_SYSTEM', 'System manager', '', 'U1000', ' insert into se_menus(code, pcode, type, authority, name, path, creator, updater, extend) values ('1001', '1000', 'MENU', 'ROLE_MENU_SYSTEM_MENUS', 'MENUS', '/system/menus', 'U1000', 'U1000', '{ "icons": "menu-2" +}'); +insert into se_menus(code, type, authority, name, path, creator, updater, extend) +values ('1002', 'FOLDER', 'ROLE_FOLDER_SYSTEM1', 'System manager1', '', 'U1000', 'U1000', '{ + "icons": "settings" +}'); + +insert into se_menus(code, pcode, type, authority, name, path, creator, updater, extend) +values ('1003', '1002', 'MENU', 'ROLE_MENU_SYSTEM_MENUS!', 'MENUS1', '/system/menus', 'U1000', 'U1000', '{ + "icons": "menu-2" }'); \ No newline at end of file diff --git a/ui/web/src/app/app.component.html b/ui/web/src/app/app.component.html index c95d6432..645a9b7b 100644 --- a/ui/web/src/app/app.component.html +++ b/ui/web/src/app/app.component.html @@ -1,5 +1,5 @@
- +
diff --git a/ui/web/src/app/app.component.ts b/ui/web/src/app/app.component.ts index 68a065f5..a235f5a5 100644 --- a/ui/web/src/app/app.component.ts +++ b/ui/web/src/app/app.component.ts @@ -1,21 +1,26 @@ -import {Component, OnInit} from '@angular/core'; +import {AfterContentInit, Component, OnInit} from '@angular/core'; import {LoadingService} from "./core/loading.service"; +import {Observable, of} from "rxjs"; @Component({ - selector: 'app-root', - templateUrl: './app.component.html', - styleUrls: ['./app.component.scss'] + selector: 'app-root', + templateUrl: './app.component.html', + styleUrls: ['./app.component.scss'] }) -export class AppComponent implements OnInit { +export class AppComponent implements OnInit, AfterContentInit { - loadingShow: boolean; + loadingShow$: Observable = of(false); - constructor(private loading: LoadingService) { - this.loadingShow = false; - } + constructor(private loading: LoadingService) { + this.loadingShow$ = of(false); + } - ngOnInit(): void { - this.loading.progress$.subscribe(res => this.loadingShow = res); - } + ngOnInit(): void { + //this.loadingShow$ = this.loading.progress$; + } + + ngAfterContentInit(): void { + this.loadingShow$ = this.loading.progress$; + } } diff --git a/ui/web/src/app/core/http-interceptors/handle-error.interceptor.ts b/ui/web/src/app/core/http-interceptors/handle-error.interceptor.ts index 5e95275d..8b50beca 100644 --- a/ui/web/src/app/core/http-interceptors/handle-error.interceptor.ts +++ b/ui/web/src/app/core/http-interceptors/handle-error.interceptor.ts @@ -13,7 +13,7 @@ export class HandleErrorInterceptor implements HttpInterceptor { } intercept(request: HttpRequest, next: HttpHandler): Observable> { - return next.handle(request).pipe(timeout({each: 10000}), + return next.handle(request).pipe(timeout({first: 30_000, each: 10_000}), catchError(err => this.handleError(err))); } diff --git a/ui/web/src/app/core/interfaces/menu.ts b/ui/web/src/app/core/interfaces/menu.ts new file mode 100644 index 00000000..dc5dcf36 --- /dev/null +++ b/ui/web/src/app/core/interfaces/menu.ts @@ -0,0 +1,45 @@ +export interface Menu { + id?: number; + code?: string; + pcode?: string; + tenantCode?: string; + type?: MenuType; + authority?: string; + name?: string; + path?: string; + sort?: number; + extend?: any; + creator?: UserAuditor; + updater?: UserAuditor; + createdTime?: Date; + updatedTime?: Date; + getPermissions?: Permission[]; + getIcons?: string; + children?: Menu[] +} + +export interface UserAuditor { + code: string; + username: string; + name?: string; +} + +export enum MenuType { + FOLDER = "FOLDER", + MENU = "MENU", +} + +export enum HttpMethod { + GET = "GET", + POST = "POST", + PUT = "PUT", + DELETE = "DELETE", + ALL = "ALL", +} + +export interface Permission { + method: HttpMethod; + name: string; + path: string; + authority: string; +} diff --git a/ui/web/src/app/core/menus.service.spec.ts b/ui/web/src/app/core/menus.service.spec.ts new file mode 100644 index 00000000..b79f199a --- /dev/null +++ b/ui/web/src/app/core/menus.service.spec.ts @@ -0,0 +1,16 @@ +import {TestBed} from '@angular/core/testing'; + +import {MenusService} from './menus.service'; + +describe('MenusService', () => { + let service: MenusService; + + beforeEach(() => { + TestBed.configureTestingModule({}); + service = TestBed.inject(MenusService); + }); + + it('should be created', () => { + expect(service).toBeTruthy(); + }); +}); diff --git a/ui/web/src/app/core/menus.service.ts b/ui/web/src/app/core/menus.service.ts new file mode 100644 index 00000000..8f13fa3a --- /dev/null +++ b/ui/web/src/app/core/menus.service.ts @@ -0,0 +1,32 @@ +import {Injectable} from '@angular/core'; +import {HttpClient, HttpParams} from "@angular/common/http"; +import {delay, from, map, mergeMap, Observable, retry, switchMap, toArray} from "rxjs"; +import {Menu} from "./interfaces/menu"; + +@Injectable({ + providedIn: 'root' +}) +export class MenusService { + + constructor(private http: HttpClient) { + } + + getMenus(request: Menu): Observable { + let params = new HttpParams({fromObject: request as any}); + return this.http.get('/menus/me', {params: params}) + .pipe(switchMap(items => { + return from(items).pipe(delay(20), + mergeMap(item => { + return this.getChildren({pcode: item.code}).pipe(map(children => { + item.children = children; + return item; + })); + })); + }), toArray(), retry(3)); + } + + getChildren(request: Menu): Observable { + let params = new HttpParams({fromObject: request as any}); + return this.http.get('/menus/me', {params: params}); + } +} diff --git a/ui/web/src/app/pages/welcome/welcome.component.html b/ui/web/src/app/pages/index/index.component.html similarity index 81% rename from ui/web/src/app/pages/welcome/welcome.component.html rename to ui/web/src/app/pages/index/index.component.html index c20e2478..2b00861d 100644 --- a/ui/web/src/app/pages/welcome/welcome.component.html +++ b/ui/web/src/app/pages/index/index.component.html @@ -1,5 +1,5 @@ - +
  • nav 1
  • @@ -9,10 +9,13 @@ -
      -
    • +
        +
        • -
        • option1
        • +
        • + {{child.name}} +
        • option2
        • option3
        • option4
        • diff --git a/ui/web/src/app/pages/welcome/welcome.component.scss b/ui/web/src/app/pages/index/index.component.scss similarity index 79% rename from ui/web/src/app/pages/welcome/welcome.component.scss rename to ui/web/src/app/pages/index/index.component.scss index 0bd1ca63..dc2ee5c2 100644 --- a/ui/web/src/app/pages/welcome/welcome.component.scss +++ b/ui/web/src/app/pages/index/index.component.scss @@ -7,11 +7,15 @@ min-height: 100vh; } +.nz-header { + padding-left: 1rem !important; +} + .logo { - width: 9.8rem; + width: 12.8rem; height: 2.5rem; background: rgba(255, 255, 255, 0.2); - margin: 0.8rem 2.2rem 1rem 0; + margin: 0.8rem 0.8rem 0.1rem 0; float: left; } diff --git a/ui/web/src/app/pages/index/index.component.ts b/ui/web/src/app/pages/index/index.component.ts new file mode 100644 index 00000000..d2b75130 --- /dev/null +++ b/ui/web/src/app/pages/index/index.component.ts @@ -0,0 +1,29 @@ +import {Component, OnInit} from '@angular/core'; +import {MenusService} from "../../core/menus.service"; +import {Menu} from "../../core/interfaces/menu"; +import {Observable, of} from "rxjs"; + +@Component({ + selector: 'app-welcome', + templateUrl: './index.component.html', + styleUrls: ['./index.component.scss'] +}) +export class IndexComponent implements OnInit { + + menus$: Observable = of([]); + + constructor(private menusService: MenusService) { + } + + ngOnInit() { + this.initMenu(); + } + + initMenu() { + let menuRequest: Menu = { + pcode: "0", + tenantCode: "0" + }; + this.menus$ = this.menusService.getMenus(menuRequest); + } +} diff --git a/ui/web/src/app/pages/page-not-found/page-not-found.component.html b/ui/web/src/app/pages/page-not-found/page-not-found.component.html index b243ec40..abb1dafd 100644 --- a/ui/web/src/app/pages/page-not-found/page-not-found.component.html +++ b/ui/web/src/app/pages/page-not-found/page-not-found.component.html @@ -1,5 +1,5 @@
          - + Back Home
          diff --git a/ui/web/src/app/pages/pages-routing.module.ts b/ui/web/src/app/pages/pages-routing.module.ts index 000db633..c46c5323 100644 --- a/ui/web/src/app/pages/pages-routing.module.ts +++ b/ui/web/src/app/pages/pages-routing.module.ts @@ -1,10 +1,10 @@ import {NgModule} from '@angular/core'; import {RouterModule, Routes} from '@angular/router'; -import {WelcomeComponent} from "./welcome/welcome.component"; +import {IndexComponent} from "./index/index.component"; import {PageNotFoundComponent} from "./page-not-found/page-not-found.component"; const routes: Routes = [ - {path: 'welcome', component: WelcomeComponent, title: '欢迎主页'}, + {path: 'index', component: IndexComponent, title: '欢迎主页'}, { path: 'auth', loadChildren: () => import('./security/security.module').then(m => m.SecurityModule), title: '系统登录' diff --git a/ui/web/src/app/pages/pages.module.ts b/ui/web/src/app/pages/pages.module.ts index b9727430..05c523fb 100644 --- a/ui/web/src/app/pages/pages.module.ts +++ b/ui/web/src/app/pages/pages.module.ts @@ -2,7 +2,7 @@ import {NgModule, Optional, SkipSelf} from '@angular/core'; import {PagesRoutingModule} from './pages-routing.module'; -import {WelcomeComponent} from './welcome/welcome.component'; +import {IndexComponent} from './index/index.component'; import {PageNotFoundComponent} from "./page-not-found/page-not-found.component"; import {SharedModule} from "../shared/shared.module"; @@ -11,7 +11,7 @@ import {SharedModule} from "../shared/shared.module"; PagesRoutingModule, SharedModule ], - declarations: [WelcomeComponent, PageNotFoundComponent], + declarations: [IndexComponent, PageNotFoundComponent], exports: [PageNotFoundComponent] }) export class PagesModule { diff --git a/ui/web/src/app/pages/security/login/login.component.ts b/ui/web/src/app/pages/security/login/login.component.ts index 9c03c5e8..a95e11a7 100644 --- a/ui/web/src/app/pages/security/login/login.component.ts +++ b/ui/web/src/app/pages/security/login/login.component.ts @@ -42,7 +42,7 @@ export class LoginComponent implements OnInit, OnDestroy { this.loginService.clearRememberMe(); } this.loginService.login(credentials).subscribe((res) => { - this.router.navigate(['/welcome'], {relativeTo: this.route}).then(); + this.router.navigate(['/index'], {relativeTo: this.route}).then(); }); } diff --git a/ui/web/src/app/pages/welcome/welcome.component.ts b/ui/web/src/app/pages/welcome/welcome.component.ts deleted file mode 100644 index 5d0e6ddf..00000000 --- a/ui/web/src/app/pages/welcome/welcome.component.ts +++ /dev/null @@ -1,18 +0,0 @@ -import {Component, OnInit} from '@angular/core'; - -@Component({ - selector: 'app-welcome', - templateUrl: './welcome.component.html', - styleUrls: ['./welcome.component.scss'] -}) -export class WelcomeComponent implements OnInit { - - isCollapsed = false; - - constructor() { - } - - ngOnInit() { - } - -} diff --git a/ui/web/src/app/shared/shared-zorro.module.ts b/ui/web/src/app/shared/shared-zorro.module.ts index 5a842f87..675ceb0a 100644 --- a/ui/web/src/app/shared/shared-zorro.module.ts +++ b/ui/web/src/app/shared/shared-zorro.module.ts @@ -9,6 +9,7 @@ import {NzLayoutModule} from "ng-zorro-antd/layout"; import {NzMenuModule} from "ng-zorro-antd/menu"; import {NzSliderModule} from "ng-zorro-antd/slider"; import {NzBreadCrumbModule} from "ng-zorro-antd/breadcrumb"; +import {NzButtonModule} from "ng-zorro-antd/button"; @NgModule({ @@ -26,7 +27,8 @@ import {NzBreadCrumbModule} from "ng-zorro-antd/breadcrumb"; NzMenuModule, NzIconModule, NzResultModule, - NzBreadCrumbModule + NzBreadCrumbModule, + NzButtonModule ] }) export class SharedZorroModule {