提交 361b113b 编写于 作者: X xjh22222228

remove edit mode

上级 642c0998
......@@ -123,7 +123,6 @@ server {
## 快捷键
mac下是 `Command`,windows 下是 `Ctrl`
- `ctrl+e` 开启或关闭编辑模式
- `ctrl+v` 查看信息
- `ctrl+d` 开启或关闭暗黑模式
......
......@@ -86,31 +86,7 @@
</div>
<ng-template #card>
<div
class="container"
nz-dropdown
[nzDropdownMenu]="menu"
[nzDisabled]="!isEditing.value || hasKeyword() || !isLogin"
[nzClickHide]="false"
>
<ng-content></ng-content>
</div>
<nz-dropdown-menu #menu="nzDropdownMenu">
<ul nz-menu nzSelectable>
<li nz-menu-item (click)="clickEdit()">编辑</li>
<a
*ngIf="isLogin"
nz-popconfirm
nzPopconfirmPlacement="rightTop"
nzOkType="danger"
nzPopconfirmTitle="您确定要删除吗?"
nzPopconfirmPlacement="bottom"
(nzOnConfirm)="confirmDel($event)"
>
<li nz-menu-item nzDanger>删除</li>
</a>
</ul>
</nz-dropdown-menu>
<ng-content></ng-content>
</ng-template>
<nz-modal
......@@ -122,13 +98,13 @@
<ng-container *nzModalContent>
<form nz-form [formGroup]="validateForm" (ngSubmit)="handleOk()">
<nz-form-item>
<nz-form-label [nzSpan]="4" nzRequired>{{ getEditType() === EditType.isWebsite ? '网站名称' : '分类名称'}}</nz-form-label>
<nz-form-label [nzSpan]="4" nzRequired>网站名称</nz-form-label>
<nz-form-control [nzSpan]="20" nzErrorTip="请输入名称">
<input formControlName="title" nz-input placeholder="发现导航" />
</nz-form-control>
</nz-form-item>
<nz-form-item *ngIf="getEditType() === EditType.isWebsite">
<nz-form-item>
<nz-form-label [nzSpan]="4" nzRequired>网站链接</nz-form-label>
<nz-form-control [nzSpan]="20">
<input formControlName="url" nz-input placeholder="https://nav3.cn" (blur)="onUrlBlur($event)" />
......@@ -148,10 +124,16 @@
</nz-form-control>
</nz-form-item>
<nz-form-item *ngIf="getEditType() === EditType.isWebsite">
<nz-form-item>
<nz-form-label [nzSpan]="4">网站描述</nz-form-label>
<nz-form-control [nzSpan]="20">
<input formControlName="desc" nz-input placeholder="发现导航, 精选实用导航网站" />
<textarea
formControlName="desc"
placeholder="发现导航, 精选实用导航网站"
nz-input
[nzAutosize]="{ minRows: 3, maxRows: 5 }"
>
</textarea>
</nz-form-control>
</nz-form-item>
</form>
......
......@@ -6,10 +6,8 @@ import { FormBuilder, FormGroup, Validators } from '@angular/forms'
import { NzMessageService } from 'ng-zorro-antd/message'
import { NzNotificationService } from 'ng-zorro-antd/notification'
import { getToken } from '../../utils/user'
import { setWebsiteList, queryString, getLogoUrl, copyText } from '../../utils'
import { websiteList, isEditing } from '../../store'
import { Router } from '@angular/router'
import { setAnnotate } from '../../utils/ripple'
import { setWebsiteList, getLogoUrl, copyText } from '../../utils'
import { websiteList } from '../../store'
import { INavProps } from '../../types'
enum EditType {
......@@ -35,7 +33,6 @@ export class CardComponent implements OnInit {
objectKeys = Object.keys
websiteList: INavProps[] = websiteList
isLogin: boolean = !!getToken()
isEditing = isEditing
showModal = false
EditType = EditType
iconUrl = ''
......@@ -45,7 +42,6 @@ export class CardComponent implements OnInit {
constructor(
private fb: FormBuilder,
private message: NzMessageService,
private router: Router,
private notification: NzNotificationService,
) {}
......@@ -94,10 +90,6 @@ export class CardComponent implements OnInit {
this.iconUrl = e.target.value
}
hasKeyword() {
return !!queryString().q
}
toggleModal() {
this.showModal = !this.showModal
}
......@@ -114,44 +106,6 @@ export class CardComponent implements OnInit {
if (!title) return
title = title.trim()
if (type === EditType.isOne) {
const exists = this.websiteList.some((item, idx) => (
item.title === title && idx !== this.oIdx
))
if (exists) {
this.message.error(`已存在 ${title}, 不可重复添加`)
return
}
this.websiteList[this.oIdx].title = title
this.websiteList[this.oIdx].icon = icon
}
if (type === EditType.isTwo) {
const w = this.websiteList[this.oIdx].nav
const exists = w.some((item, idx) => (
item.title === title && idx !== this.twoIdx
))
if (exists) {
this.message.error(`已存在 ${title}, 不可重复添加`)
return
}
w[this.twoIdx].title = title
w[this.twoIdx].icon = icon
}
if (type === EditType.isThree) {
const w = this.websiteList[this.oIdx].nav[this.twoIdx].nav
const exists = w.some((item, idx) => (
item.title === title && idx !== this.threeIdx
))
if (exists) {
this.message.error(`已存在 ${title}, 不可重复添加`)
return
}
w[this.threeIdx].title = title
w[this.threeIdx].icon= icon
}
if (type === EditType.isWebsite) {
const w = this.websiteList[this.oIdx]
.nav[this.twoIdx]
......@@ -161,7 +115,7 @@ export class CardComponent implements OnInit {
item.name === title && idx !== this.fourIdx
))
if (exists) {
this.message.error(`已存在 ${title}, 不可重复添加`)
this.message.error(`已存在 ${title}, 请修改`)
return
}
w[this.fourIdx].name = title
......@@ -183,26 +137,6 @@ export class CardComponent implements OnInit {
const type = this.getEditType()
try {
if (type === EditType.isOne) {
const { title, icon } = this.websiteList[this.oIdx]
this.validateForm.get('title')!.setValue(title)
this.validateForm.get('icon')!.setValue(icon)
}
if (type === EditType.isTwo) {
const { title, icon } = this.websiteList[this.oIdx].nav[this.twoIdx]
this.validateForm.get('title')!.setValue(title)
this.validateForm.get('icon')!.setValue(icon)
}
if (type === EditType.isThree) {
const { title, icon } = this.websiteList[this.oIdx]
.nav[this.twoIdx]
.nav[this.threeIdx]
this.validateForm.get('title')!.setValue(title)
this.validateForm.get('icon')!.setValue(icon)
}
if (type === EditType.isWebsite) {
const { name, icon, url, desc } = this.websiteList[this.oIdx]
.nav[this.twoIdx]
......@@ -247,53 +181,11 @@ export class CardComponent implements OnInit {
}
confirmDel() {
const { page, id } = queryString()
try {
switch (this.getEditType() as EditType) {
case EditType.isWebsite:
this.websiteList[this.oIdx].nav[this.twoIdx].nav[this.threeIdx].nav.splice(this.fourIdx, 1)
break
case EditType.isThree:
this.websiteList[this.oIdx].nav[this.twoIdx].nav.splice(this.threeIdx, 1)
break
case EditType.isTwo:
// 删除二级分类
if (this.websiteList[this.oIdx]?.nav?.length <= 1) {
return this.message.error('至少保留一项, 请先添加再删除!')
}
this.router.navigate([this.router.url.split('?')[0]], {
queryParams: {
page,
id: id > 0 ? id - 1 : 0,
}
})
delete this.websiteList[this.oIdx].id
this.websiteList[this.oIdx].nav.splice(this.twoIdx, 1)
break
case EditType.isOne:
if (this.websiteList.length === 1) {
this.message.error('至少保留一项, 请先添加再删除!')
return
}
this.router.navigate([this.router.url.split('?')[0]], {
queryParams: {
page: page > 0 ? page - 1 : 0,
id: 0
}
})
this.websiteList.splice(this.oIdx, 1)
setTimeout(() => {
setAnnotate()
}, 100)
break
}
setWebsiteList(this.websiteList)
......
......@@ -39,12 +39,6 @@
</div>
</span>
<span *ngIf="isLogin" nz-tooltip [nzTooltipTitle]="isEditing.value ? '关闭编辑模式' : '开启编辑模式'">
<div class="wrapper dark-bg dark-border-color dark-action-hover" (click)="toggleEditMode()">
<i class="iconfont iconsuo" [class.iconunlock]="isEditing.value"></i>
</div>
</span>
<span nz-tooltip nzTooltipTitle="新增数据">
<div class="wrapper dark-bg dark-border-color dark-action-hover" (click)="toggleModal()">
<i class="iconfont iconchuangjian"></i>
......
......@@ -9,7 +9,7 @@ import { NzMessageService } from 'ng-zorro-antd/message'
import { NzNotificationService } from 'ng-zorro-antd/notification'
import { getToken } from '../../utils/user'
import { updateFileContent } from '../../services'
import { websiteList, isEditing } from '../../store'
import { websiteList } from '../../store'
import { DB_PATH, KEY_MAP, VERSION } from '../../constants'
import { Router, ActivatedRoute } from '@angular/router'
import { setAnnotate } from '../../utils/ripple'
......@@ -29,7 +29,6 @@ export class FixbarComponent {
showCreateModal = false
syncLoading = false
isLogin = !!getToken()
isEditing = isEditing
themeList = [
{
name: '切换到 Light',
......@@ -76,10 +75,6 @@ export class FixbarComponent {
e.preventDefault()
this.viewInfo()
})
hotkeys(KEY_MAP.edit, (e) => {
e.preventDefault()
this.isEditing.value = !this.isEditing.value
})
hotkeys(KEY_MAP.dark, (e) => {
e.preventDefault()
this.toggleMode()
......@@ -127,10 +122,6 @@ export class FixbarComponent {
}, 100)
}
toggleEditMode() {
this.isEditing.value = !this.isEditing.value
}
goTop() {
if (this.selector) {
const el = document.querySelector(this.selector)
......
......@@ -7,14 +7,11 @@ function isMac() {
export const DB_PATH = 'data/db.json'
export const VERSION = '5.0.7'
export const VERSION = '5.0.8'
// keyboard event
const prefix = isMac() ? 'command' : 'ctrl'
export const KEY_MAP = {
// 编辑模式
edit: `${prefix}+e`,
// 查看信息
view: `${prefix}+v`,
......
......@@ -3,7 +3,3 @@
import { websiteList as w } from '../utils'
export const websiteList = w
export const isEditing = {
value: false
}
<div class="admin">
<button nz-button style="margin-bottom: 15px;" (click)="goBack()">返回主页</button>
<button nz-button style="margin-left: 15px;" (click)="handleSync()">同步到远端</button>
<button nz-button style="margin-left: 15px;" (click)="handleSync()" [nzLoading]="syncLoading">同步到远端</button>
<button nz-button style="margin-left: 15px;" (click)="handleReset()">重置初始数据</button>
<nz-tabset *ngIf="isLogin" [nzSelectedIndex]="tabActive" (nzSelectedIndexChange)="onTabChange($event)">
......
......@@ -15,7 +15,7 @@
[class.dark-text-active]="page === i"
class="ripple-btn dark-text"
>
<app-card [oIdx]="i">
<app-card>
{{ item.title }}
</app-card>
</a>
......@@ -31,7 +31,7 @@
(click)="handleSidebarNav(i)"
*ngFor="let item of websiteList[page].nav; let i = index"
>
<app-card [oIdx]="page" [twoIdx]="i">
<app-card>
<div class="ripple-btn">{{ item.title }}</div>
</app-card>
</li>
......@@ -44,7 +44,7 @@
<div *ngIf="currentList.length > 0; else noData">
<div *ngFor="let item of currentList; let i=index">
<div class="title-wrapper dark-border-color" *ngIf="item.title">
<app-card [oIdx]="page" [twoIdx]="id" [threeIdx]="i">
<app-card>
<h2 class="block-title">
<app-logo
[src]="item.icon"
......
......@@ -37,7 +37,7 @@
class="title dark-primary dark-border-color"
*ngIf="item.title"
>
<app-card [oIdx]="page" [twoIdx]="id" [threeIdx]="i">
<app-card>
<span class="cursor-pointer" (click)="onCollapse(item, i)">
<app-logo
[src]="item.icon"
......
......@@ -13,7 +13,7 @@
class="ripple-btn dark-text"
(click)="handleCilckTopNav(i)"
>
<app-card [oIdx]="i">
<app-card>
{{ item.title }}
</app-card>
</a>
......@@ -29,7 +29,7 @@
[class.dark-item-active]="id === i"
class="ripple-btn dark-text"
>
<app-card [oIdx]="page" [twoIdx]="i">
<app-card>
{{ item.title }}
</app-card>
</div>
......@@ -43,7 +43,7 @@
class="title dark-primary dark-border-color"
*ngIf="item.title"
>
<app-card [oIdx]="page" [twoIdx]="id" [threeIdx]="i">
<app-card>
<span class="cursor-pointer" (click)="onCollapse(item, i)">
<app-logo
[src]="item.icon"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册