提交 ce7e6543 编写于 作者: X xjh22222228

feat(#79): side add pin to top

上级 0b5619b4
......@@ -30,6 +30,7 @@ import { NzTableModule } from 'ng-zorro-antd/table'
import { NzTabsModule } from 'ng-zorro-antd/tabs'
import { NzTagModule } from 'ng-zorro-antd/tag'
import { NzRateModule } from 'ng-zorro-antd/rate'
import { NzSwitchModule } from 'ng-zorro-antd/switch'
import { DragDropModule } from '@angular/cdk/drag-drop'
// components
......@@ -49,6 +50,7 @@ import { SearchEngineComponent } from '../components/search-engine/search-engine
import { LoginComponent } from '../components/login/login.component';
import { CreateWebComponent } from '../components/create-web/index.component';
import { ToolbarTitleWebComponent } from '../components/toolbar-title/index.component';
import { WebListComponent } from '../components/web-list/index.component';
import { NZ_I18N } from 'ng-zorro-antd/i18n';
import { zh_CN } from 'ng-zorro-antd/i18n';
import { registerLocaleData } from '@angular/common';
......@@ -106,6 +108,7 @@ const appRoutes: Routes = [
LoginComponent,
CreateWebComponent,
ToolbarTitleWebComponent,
WebListComponent,
LogoComponent,
CardComponent
],
......@@ -133,6 +136,7 @@ const appRoutes: Routes = [
NzTabsModule,
NzTagModule,
NzRateModule,
NzSwitchModule,
DragDropModule,
BrowserModule,
FormsModule,
......
......@@ -68,6 +68,7 @@ export class CardComponent implements OnInit {
this.dataSource.url = payload.url
this.dataSource.rate = payload.rate
this.dataSource.urls = payload.urls
this.dataSource.top = payload.top
this.message.success('修改成功!')
setWebsiteList(this.websiteList)
......
......@@ -21,6 +21,13 @@
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSpan]="4" nzRequired>是否置顶</nz-form-label>
<nz-form-control [nzSpan]="20">
<nz-switch formControlName="top"></nz-switch>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSpan]="4">推荐指数</nz-form-label>
<nz-form-control [nzSpan]="20">
......
......@@ -41,6 +41,7 @@ export class CreateWebComponent implements OnInit {
this.validateForm = this.fb.group({
title: ['', [Validators.required]],
url: ['', [Validators.required]],
top: [false],
rate: [0],
url0: [''],
url1: [''],
......@@ -64,6 +65,7 @@ export class CreateWebComponent implements OnInit {
this.validateForm.get('title')!.setValue(detail.name)
this.validateForm.get('icon')!.setValue(detail.icon || '')
this.validateForm.get('url')!.setValue(detail.url || '')
this.validateForm.get('top')!.setValue(detail.top ?? false)
this.validateForm.get('rate')!.setValue(detail.rate)
this.validateForm.get('desc')!.setValue(detail.desc || '')
......@@ -153,6 +155,7 @@ export class CreateWebComponent implements OnInit {
title,
icon,
url,
top,
rate,
desc,
url0,
......@@ -182,6 +185,7 @@ export class CreateWebComponent implements OnInit {
createdAt: (this.detail as any)?.createdAt ?? createdAt,
rate: rate ?? 0,
desc: desc || '',
top: top ?? false,
icon,
url,
urls
......
......@@ -10,11 +10,23 @@
>
</app-logo> -->
<i
class="iconfont iconjiantouarrow483 down-arrow"
[class.active]="dataSource.collapsed"
*ngIf="arrowType === '1'; else type"
>
</i>
<ng-template #type>
<i
class="iconfont iconjiantouarrow483 down-arrow"
[class.active]="dataSource.collapsed"
>
</i>
</ng-template>
<span style="margin-left: 10px;align-self: center;vertical-align: middle;">
{{ dataSource.title }} x {{ dataSource.nav.length }}
</span>
<i class="iconfont iconjiantouarrow483 down-arrow" [class.active]="dataSource.collapsed"></i>
</span>
<i
......
......@@ -17,6 +17,7 @@ import { websiteList } from '../../store'
export class ToolbarTitleWebComponent implements OnInit {
@Input() index: number
@Input() dataSource: INavThreeProp
@Input() arrowType: '1'|'2' = '1'
@Output() onCollapse = new EventEmitter()
isLogin = !!getToken()
......
<div class="container">
<a [href]="item.url" target="_blank" *ngFor="let item of dataList">
<div class="wrapper">
<div class="logo">
<app-logo [src]="item.icon" [name]="item.name" [size]="35"></app-logo>
</div>
<div class="name dark-text">{{ item.name }}</div>
</div>
</a>
</div>
.container {
margin-top: 50px;
margin-bottom: 15px;
display: flex;
padding: 0 15px;
.wrapper {
display: flex;
margin-right: 15px;
margin-bottom: 15px;
text-align: center;
cursor: pointer;
align-items: center;
flex-direction: column;
transition: transform .1s ease-in;
&:hover {
transform: translateY(-5px);
}
}
.logo {
border-radius: 50%;
margin-bottom: 3px;
}
.name {
color: #666;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
}
\ No newline at end of file
// Copyright @ 2018-2021 xiejiahe. All rights reserved. MIT license.
// See https://github.com/xjh22222228/nav
import { Component, OnInit } from '@angular/core'
import { getToken } from '../../utils/user'
import { websiteList } from '../../store'
import { INavFourProp } from 'src/types'
@Component({
selector: 'app-web-list',
templateUrl: './index.component.html',
styleUrls: ['./index.component.scss']
})
export class WebListComponent implements OnInit {
isLogin = !!getToken()
dataList: INavFourProp[] = []
constructor() {}
ngOnInit() {
this.getTopWeb()
}
getTopWeb() {
const dataList: INavFourProp[] = []
function r(nav) {
if (!Array.isArray(nav)) return
for (let i = 0; i < nav.length; i++) {
const item = nav[i]
if (item.url) {
if (item.top) {
dataList.push(item)
}
} else {
r(item.nav)
}
}
}
r(websiteList)
this.dataList = dataList
}
}
......@@ -32,10 +32,18 @@
</div>
<div class="box" [style.marginTop]="searchEngineList.length > 0 ? '80px' : '0'">
<app-web-list></app-web-list>
<div *ngIf="currentList.length > 0; else noData">
<div *ngFor="let item of currentList; let i=index">
<div class="nav-wrapper">
<app-toolbar-title [dataSource]="item" (onCollapse)="onCollapse(item, i)" [index]="i"></app-toolbar-title>
<app-toolbar-title
[dataSource]="item"
(onCollapse)="onCollapse(item, i)"
[index]="i"
arrowType="2"
>
</app-toolbar-title>
<div nz-row [nzGutter]="[16, 16]" [style.display]="item.collapsed ? 'none' : ''">
<div
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册