提交 d4703dc4 编写于 作者: X xjh22222228

feat(#76): add rate

上级 19119a4c
...@@ -29,6 +29,7 @@ import { NzMenuModule } from 'ng-zorro-antd/menu' ...@@ -29,6 +29,7 @@ import { NzMenuModule } from 'ng-zorro-antd/menu'
import { NzTableModule } from 'ng-zorro-antd/table' import { NzTableModule } from 'ng-zorro-antd/table'
import { NzTabsModule } from 'ng-zorro-antd/tabs' import { NzTabsModule } from 'ng-zorro-antd/tabs'
import { NzTagModule } from 'ng-zorro-antd/tag' import { NzTagModule } from 'ng-zorro-antd/tag'
import { NzRateModule } from 'ng-zorro-antd/rate'
import { DragDropModule } from '@angular/cdk/drag-drop' import { DragDropModule } from '@angular/cdk/drag-drop'
// components // components
...@@ -131,6 +132,7 @@ const appRoutes: Routes = [ ...@@ -131,6 +132,7 @@ const appRoutes: Routes = [
NzTableModule, NzTableModule,
NzTabsModule, NzTabsModule,
NzTagModule, NzTagModule,
NzRateModule,
DragDropModule, DragDropModule,
BrowserModule, BrowserModule,
FormsModule, FormsModule,
......
...@@ -6,6 +6,15 @@ ...@@ -6,6 +6,15 @@
nzHoverable nzHoverable
nzType="inner" nzType="inner"
> >
<div class="rate">
<nz-rate
[ngModel]="dataSource.rate"
[nzDisabled]="!isLogin"
nzAllowHalf
(ngModelChange)="onRateChange($event)"
>
</nz-rate>
</div>
<a [href]="dataSource.url" target="_blank" rel="noreferer noopener"> <a [href]="dataSource.url" target="_blank" rel="noreferer noopener">
<nz-card-meta <nz-card-meta
[nzTitle]="title" [nzTitle]="title"
......
...@@ -2,6 +2,11 @@ ...@@ -2,6 +2,11 @@
position: relative; position: relative;
height: 100%; height: 100%;
.rate {
margin-bottom: 10px;
margin-top: -10px;
}
.desc { .desc {
color: rgba(0,0,0,.45); color: rgba(0,0,0,.45);
} }
......
...@@ -55,12 +55,18 @@ export class CardComponent implements OnInit { ...@@ -55,12 +55,18 @@ export class CardComponent implements OnInit {
this.showModal = !this.showModal this.showModal = !this.showModal
} }
onRateChange(n: number) {
this.dataSource.rate = n
setWebsiteList(this.websiteList)
}
handleOk(payload: INavFourProp) { handleOk(payload: INavFourProp) {
this.dataSource.name = payload.name this.dataSource.name = payload.name
this.dataSource.createdAt = payload.createdAt this.dataSource.createdAt = payload.createdAt
this.dataSource.desc = payload.desc this.dataSource.desc = payload.desc
this.dataSource.icon = payload.icon this.dataSource.icon = payload.icon
this.dataSource.url = payload.url this.dataSource.url = payload.url
this.dataSource.rate = payload.rate
this.dataSource.urls = payload.urls this.dataSource.urls = payload.urls
this.message.success('修改成功!') this.message.success('修改成功!')
......
...@@ -21,6 +21,13 @@ ...@@ -21,6 +21,13 @@
</nz-form-control> </nz-form-control>
</nz-form-item> </nz-form-item>
<nz-form-item>
<nz-form-label [nzSpan]="4">推荐指数</nz-form-label>
<nz-form-control [nzSpan]="20">
<nz-rate formControlName="rate" nzAllowHalf></nz-rate>
</nz-form-control>
</nz-form-item>
<nz-form-item> <nz-form-item>
<nz-form-label [nzSpan]="4">图标地址</nz-form-label> <nz-form-label [nzSpan]="4">图标地址</nz-form-label>
<nz-form-control [nzSpan]="20"> <nz-form-control [nzSpan]="20">
...@@ -35,7 +42,7 @@ ...@@ -35,7 +42,7 @@
<i nz-icon nzType="loading" nzTheme="outline" *ngIf="uploading; else loading"></i> <i nz-icon nzType="loading" nzTheme="outline" *ngIf="uploading; else loading"></i>
<ng-template #loading> <ng-template #loading>
<label id="file"> <label id="file">
<i nz-icon nzType="upload" nzTheme="outline" class="cursor-pointer"></i> <i nz-icon nzType="upload" nzTheme="outline" class="cursor-pointer" title="上传"></i>
<input <input
type="file" type="file"
name="file" name="file"
......
...@@ -41,6 +41,7 @@ export class CreateWebComponent implements OnInit { ...@@ -41,6 +41,7 @@ export class CreateWebComponent implements OnInit {
this.validateForm = this.fb.group({ this.validateForm = this.fb.group({
title: ['', [Validators.required]], title: ['', [Validators.required]],
url: ['', [Validators.required]], url: ['', [Validators.required]],
rate: [0],
url0: [''], url0: [''],
url1: [''], url1: [''],
url2: [''], url2: [''],
...@@ -63,6 +64,7 @@ export class CreateWebComponent implements OnInit { ...@@ -63,6 +64,7 @@ export class CreateWebComponent implements OnInit {
this.validateForm.get('title')!.setValue(detail.name) this.validateForm.get('title')!.setValue(detail.name)
this.validateForm.get('icon')!.setValue(detail.icon || '') this.validateForm.get('icon')!.setValue(detail.icon || '')
this.validateForm.get('url')!.setValue(detail.url || '') this.validateForm.get('url')!.setValue(detail.url || '')
this.validateForm.get('rate')!.setValue(detail.rate)
this.validateForm.get('desc')!.setValue(detail.desc || '') this.validateForm.get('desc')!.setValue(detail.desc || '')
if (typeof detail.urls === 'object') { if (typeof detail.urls === 'object') {
...@@ -151,6 +153,7 @@ export class CreateWebComponent implements OnInit { ...@@ -151,6 +153,7 @@ export class CreateWebComponent implements OnInit {
title, title,
icon, icon,
url, url,
rate,
desc, desc,
url0, url0,
url1, url1,
...@@ -177,6 +180,7 @@ export class CreateWebComponent implements OnInit { ...@@ -177,6 +180,7 @@ export class CreateWebComponent implements OnInit {
const payload = { const payload = {
name: title, name: title,
createdAt: (this.detail as any)?.createdAt ?? createdAt, createdAt: (this.detail as any)?.createdAt ?? createdAt,
rate: rate ?? 0,
desc: desc || '', desc: desc || '',
icon, icon,
url, url,
......
.icon { .icon {
display: inline-block; display: inline-block;
vertical-align: middle; vertical-align: middle;
border-radius: 50%;
pointer-events: none; pointer-events: none;
border: 1px solid #eee;
background-color: #fff;
} }
...@@ -12,6 +12,7 @@ export class LogoComponent { ...@@ -12,6 +12,7 @@ export class LogoComponent {
@Input() name: string @Input() name: string
@Input() colour: string @Input() colour: string
@Input() size: number @Input() size: number
@Input() check: boolean = true
hasError = true hasError = true
color = '#1890ff' color = '#1890ff'
...@@ -28,6 +29,10 @@ export class LogoComponent { ...@@ -28,6 +29,10 @@ export class LogoComponent {
} }
ngAfterViewInit() { ngAfterViewInit() {
if (!this.check) {
this.hasError = false
return
}
setTimeout(async() => { setTimeout(async() => {
const isValid = await isValidImg(this.url) const isValid = await isValidImg(this.url)
if (isValid) { if (isValid) {
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
*ngFor="let item of searchEngineList; let i=index" *ngFor="let item of searchEngineList; let i=index"
(click)="clickEngineItem(i)" (click)="clickEngineItem(i)"
> >
<img class="icon" [src]="item.icon" alt="" /> <app-logo [src]="item.icon" [size]="20" [check]="false"></app-logo>
<span class="name dark-text">{{ item.name }}</span> <span class="name dark-text">{{ item.name }}</span>
</div> </div>
</div> </div>
......
...@@ -73,11 +73,6 @@ $width: 500px; ...@@ -73,11 +73,6 @@ $width: 500px;
margin-right: 15px; margin-right: 15px;
} }
.icon {
width: 20px;
height: 20px;
}
.name { .name {
margin-left: 10px; margin-left: 10px;
font-size: 16px; font-size: 16px;
......
...@@ -3,12 +3,12 @@ ...@@ -3,12 +3,12 @@
*ngIf="dataSource && dataSource.title" *ngIf="dataSource && dataSource.title"
> >
<span class="cursor-pointer" (click)="onCollapse.emit()"> <span class="cursor-pointer" (click)="onCollapse.emit()">
<app-logo <!-- <app-logo
[src]="dataSource.icon" [src]="dataSource.icon"
[name]="dataSource.title" [name]="dataSource.title"
colour="#ff4d4f" colour="#ff4d4f"
> >
</app-logo> </app-logo> -->
<span style="margin-left: 10px;align-self: center;vertical-align: middle;"> <span style="margin-left: 10px;align-self: center;vertical-align: middle;">
{{ dataSource.title }} x {{ dataSource.nav.length }} {{ dataSource.title }} x {{ dataSource.nav.length }}
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
font-size: 18px; font-size: 18px;
border-bottom: 1px solid #eee; border-bottom: 1px solid #eee;
padding: 10px 0; padding: 10px 0;
padding-left: 20px;
color: #3f51b5; color: #3f51b5;
font-weight: 500; font-weight: 500;
display: flex; display: flex;
......
...@@ -18,6 +18,7 @@ export interface ITagProp { ...@@ -18,6 +18,7 @@ export interface ITagProp {
export interface INavFourProp { export interface INavFourProp {
icon?: string | null icon?: string | null
createdAt?: string createdAt?: string
rate?: number
name: string name: string
desc: string desc: string
url: string url: string
......
...@@ -174,6 +174,7 @@ export function adapterWebsiteList(websiteList: any[], parentItem?: any) { ...@@ -174,6 +174,7 @@ export function adapterWebsiteList(websiteList: any[], parentItem?: any) {
} }
item.urls ||= {} item.urls ||= {}
item.rate ??= 5
} }
} }
......
...@@ -318,8 +318,7 @@ export default class WebpComponent { ...@@ -318,8 +318,7 @@ export default class WebpComponent {
} }
handleOk() { handleOk() {
const now = new Date() const createdAt = new Date().toISOString()
const createdAt = now.toISOString()
for (const i in this.validateForm.controls) { for (const i in this.validateForm.controls) {
this.validateForm.controls[i].markAsDirty(); this.validateForm.controls[i].markAsDirty();
......
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
<div *ngIf="currentList.length > 0; else noData"> <div *ngIf="currentList.length > 0; else noData">
<div *ngFor="let item of currentList; let i=index"> <div *ngFor="let item of currentList; let i=index">
<app-toolbar-title [dataSource]="item" (onCollapse)="onCollapse(item, i)"></app-toolbar-title> <app-toolbar-title [dataSource]="item" (onCollapse)="onCollapse(item, i)" [index]="i"></app-toolbar-title>
<div style="padding: 0 10px;" nz-row [nzGutter]="[16, 16]" *ngIf="!item.collapsed"> <div style="padding: 0 10px;" nz-row [nzGutter]="[16, 16]" *ngIf="!item.collapsed">
<div class="gutter-row" nz-col [nzSpan]="8" *ngFor="let el of item.nav"> <div class="gutter-row" nz-col [nzSpan]="8" *ngFor="let el of item.nav">
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册