From d342de849a070868ef6a13fafdf64d52c5fc8dec Mon Sep 17 00:00:00 2001 From: myml Date: Thu, 15 Nov 2018 09:49:15 +0800 Subject: [PATCH] feat: add tag field Change-Id: I2b2cc904406ff19a8615dc49d1d6f1e3027bdd9a --- .../modules/details/app-detail.component.html | 90 +++++++++++-------- .../modules/details/app-detail.component.scss | 11 +++ .../app-list/app-list.component.html | 2 +- .../components/app-list/app-list.component.ts | 11 ++- .../tag-apps/tag-apps.component.html | 11 +++ .../tag-apps/tag-apps.component.scss | 0 .../components/tag-apps/tag-apps.component.ts | 25 ++++++ .../app/modules/tags/tags-routing.module.ts | 16 ++++ src/web/src/app/modules/tags/tags.module.ts | 12 +++ src/web/src/app/routing/routing.module.ts | 4 + 10 files changed, 144 insertions(+), 38 deletions(-) create mode 100644 src/web/src/app/modules/tags/components/tag-apps/tag-apps.component.html create mode 100644 src/web/src/app/modules/tags/components/tag-apps/tag-apps.component.scss create mode 100644 src/web/src/app/modules/tags/components/tag-apps/tag-apps.component.ts create mode 100644 src/web/src/app/modules/tags/tags-routing.module.ts create mode 100644 src/web/src/app/modules/tags/tags.module.ts diff --git a/src/web/src/app/modules/details/app-detail.component.html b/src/web/src/app/modules/details/app-detail.component.html index a14cef0d..be944f7b 100644 --- a/src/web/src/app/modules/details/app-detail.component.html +++ b/src/web/src/app/modules/details/app-detail.component.html @@ -1,25 +1,22 @@
-
+
- + - +
@@ -34,32 +31,49 @@
Size:
Updated Date:
-
Website:
+
Website:
+
Tags:
Description:
{{ app.rate.toFixed(1) }} - {{ app.downloads }} downloads - {{ app.ratings }} ratings + {{ app.downloads }} downloads + {{ app.ratings }} ratings
{{ app.localCategory }}
{{ app.version.remoteVersion || app.version.localVersion }}
- Calculating - Downloaded + Calculating + Downloaded {{ size | sizeHuman }}
{{ app.updateTime | date: 'yyyy-MM-dd HH:mm' }} < - +
-
+
{{ app.homePage }}
+
+ {{tag}} +
{{ app.localInfo.description.description }}
@@ -68,32 +82,36 @@

- + ">

- -
CDN supported by UPYUN
+ +
CDN supported by UPYUN
- -
+ +
+ +
- Sorry + Sorry It's in adjustment, you can return to - Previous + Previous
@@ -107,4 +125,4 @@
Sorry Something goes wrong.
-
+
\ No newline at end of file diff --git a/src/web/src/app/modules/details/app-detail.component.scss b/src/web/src/app/modules/details/app-detail.component.scss index 996fe405..20debd1b 100644 --- a/src/web/src/app/modules/details/app-detail.component.scss +++ b/src/web/src/app/modules/details/app-detail.component.scss @@ -123,3 +123,14 @@ align-items: center; color: gray; } + +.tags { + .tag { + color: white; + padding: 0 0.5rem; + background-color: coral; + border-radius: 4px; + margin-right: 0.5rem; + cursor: pointer; + } +} diff --git a/src/web/src/app/modules/share/components/app-list/app-list.component.html b/src/web/src/app/modules/share/components/app-list/app-list.component.html index 0454d842..1029fef5 100644 --- a/src/web/src/app/modules/share/components/app-list/app-list.component.html +++ b/src/web/src/app/modules/share/components/app-list/app-list.component.html @@ -7,7 +7,7 @@ [hidden]="loading" *ngIf="apps as $apps">
diff --git a/src/web/src/app/modules/share/components/app-list/app-list.component.ts b/src/web/src/app/modules/share/components/app-list/app-list.component.ts index 6646f4c9..511d69cb 100644 --- a/src/web/src/app/modules/share/components/app-list/app-list.component.ts +++ b/src/web/src/app/modules/share/components/app-list/app-list.component.ts @@ -49,6 +49,10 @@ export class AppListComponent implements OnInit, OnChanges, OnDestroy { @Input() apps$: Observable; @Input() + appList: App[]; + @Input() + routePrefix: string; + @Input() sortBy: SortOrder; @Input() maxCount: number; @@ -72,6 +76,9 @@ export class AppListComponent implements OnInit, OnChanges, OnDestroy { openApp = this.storeService.openApp; ngOnInit() { + if (this.appList) { + this.apps = this.appList; + } this.jobs$ = this.jobService.jobsInfo().subscribe(jobInfos => { const jobs: { [key: string]: StoreJobInfo } = {}; jobInfos.forEach(job => { @@ -95,7 +102,9 @@ export class AppListComponent implements OnInit, OnChanges, OnDestroy { }); } ngOnDestroy() { - this.jobs$.unsubscribe(); + if (this.jobs$) { + this.jobs$.unsubscribe(); + } } ngOnChanges() { diff --git a/src/web/src/app/modules/tags/components/tag-apps/tag-apps.component.html b/src/web/src/app/modules/tags/components/tag-apps/tag-apps.component.html new file mode 100644 index 00000000..67a755de --- /dev/null +++ b/src/web/src/app/modules/tags/components/tag-apps/tag-apps.component.html @@ -0,0 +1,11 @@ + + 包含"{{ list.tag }}"的应用 + + + +
+ +
+
\ No newline at end of file diff --git a/src/web/src/app/modules/tags/components/tag-apps/tag-apps.component.scss b/src/web/src/app/modules/tags/components/tag-apps/tag-apps.component.scss new file mode 100644 index 00000000..e69de29b diff --git a/src/web/src/app/modules/tags/components/tag-apps/tag-apps.component.ts b/src/web/src/app/modules/tags/components/tag-apps/tag-apps.component.ts new file mode 100644 index 00000000..79654dfa --- /dev/null +++ b/src/web/src/app/modules/tags/components/tag-apps/tag-apps.component.ts @@ -0,0 +1,25 @@ +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; +import { map, switchMap } from 'rxjs/operators'; + +import { AppService } from 'app/services/app.service'; + +@Component({ + selector: 'dstore-tag-apps', + templateUrl: './tag-apps.component.html', + styleUrls: ['./tag-apps.component.scss'], +}) +export class TagAppsComponent implements OnInit { + constructor(private appService: AppService, private route: ActivatedRoute) {} + list$ = this.route.paramMap.pipe( + map(param => param.get('tag')), + switchMap( + () => this.appService.list(), + (tag, apps) => { + apps = apps.filter(app => app.localInfo.tags.includes(tag)); + return { tag, apps }; + }, + ), + ); + ngOnInit() {} +} diff --git a/src/web/src/app/modules/tags/tags-routing.module.ts b/src/web/src/app/modules/tags/tags-routing.module.ts new file mode 100644 index 00000000..0e195751 --- /dev/null +++ b/src/web/src/app/modules/tags/tags-routing.module.ts @@ -0,0 +1,16 @@ +import { NgModule } from '@angular/core'; +import { Routes, RouterModule } from '@angular/router'; +import { TagAppsComponent } from './components/tag-apps/tag-apps.component'; + +const routes: Routes = [ + { + path: '', + component: TagAppsComponent, + }, +]; + +@NgModule({ + imports: [RouterModule.forChild(routes)], + exports: [RouterModule], +}) +export class TagsRoutingModule {} diff --git a/src/web/src/app/modules/tags/tags.module.ts b/src/web/src/app/modules/tags/tags.module.ts new file mode 100644 index 00000000..6b0e368b --- /dev/null +++ b/src/web/src/app/modules/tags/tags.module.ts @@ -0,0 +1,12 @@ +import { NgModule } from '@angular/core'; +import { CommonModule } from '@angular/common'; + +import { ShareModule } from 'app/modules/share/share.module'; +import { TagsRoutingModule } from './tags-routing.module'; +import { TagAppsComponent } from './components/tag-apps/tag-apps.component'; + +@NgModule({ + declarations: [TagAppsComponent], + imports: [CommonModule, TagsRoutingModule, ShareModule], +}) +export class TagsModule {} diff --git a/src/web/src/app/routing/routing.module.ts b/src/web/src/app/routing/routing.module.ts index b8dfcc3d..1171e404 100644 --- a/src/web/src/app/routing/routing.module.ts +++ b/src/web/src/app/routing/routing.module.ts @@ -54,6 +54,10 @@ const routes: Routes = [ path: 'search', loadChildren: 'app/modules/search/search.module#SearchModule', }, + { + path: 'tag/:tag', + loadChildren: 'app/modules/tags/tags.module#TagsModule', + }, ]; @NgModule({ imports: [