From 361b113b8ab1e5350c70dfd1e7c1f40a9c07fa02 Mon Sep 17 00:00:00 2001 From: xjh22222228 Date: Sun, 24 Jan 2021 09:41:44 +0800 Subject: [PATCH] remove edit mode --- README.md | 1 - src/components/card/index.component.html | 40 ++------ src/components/card/index.component.ts | 114 +-------------------- src/components/fixbar/index.component.html | 6 -- src/components/fixbar/index.component.ts | 11 +- src/constants/index.ts | 5 +- src/store/index.ts | 4 - src/view/admin/index.component.html | 2 +- src/view/index/light/index.component.html | 6 +- src/view/index/side/index.component.html | 2 +- src/view/index/sim/index.component.html | 6 +- 11 files changed, 24 insertions(+), 173 deletions(-) diff --git a/README.md b/README.md index 669f414..1b36f29 100644 --- a/README.md +++ b/README.md @@ -123,7 +123,6 @@ server { ## 快捷键 mac下是 `Command`,windows 下是 `Ctrl` -- `ctrl+e` 开启或关闭编辑模式 - `ctrl+v` 查看信息 - `ctrl+d` 开启或关闭暗黑模式 diff --git a/src/components/card/index.component.html b/src/components/card/index.component.html index 6521e51..9013a39 100644 --- a/src/components/card/index.component.html +++ b/src/components/card/index.component.html @@ -86,31 +86,7 @@ -
- -
- - - +
- {{ getEditType() === EditType.isWebsite ? '网站名称' : '分类名称'}} + 网站名称 - + 网站链接 @@ -148,10 +124,16 @@ - + 网站描述 - + diff --git a/src/components/card/index.component.ts b/src/components/card/index.component.ts index f0f1caf..e009063 100644 --- a/src/components/card/index.component.ts +++ b/src/components/card/index.component.ts @@ -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) diff --git a/src/components/fixbar/index.component.html b/src/components/fixbar/index.component.html index 898b62d..17243dc 100644 --- a/src/components/fixbar/index.component.html +++ b/src/components/fixbar/index.component.html @@ -39,12 +39,6 @@ - -
- -
-
-
diff --git a/src/components/fixbar/index.component.ts b/src/components/fixbar/index.component.ts index 49e4fd8..d5431a2 100644 --- a/src/components/fixbar/index.component.ts +++ b/src/components/fixbar/index.component.ts @@ -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) diff --git a/src/constants/index.ts b/src/constants/index.ts index f4e414b..24b0142 100644 --- a/src/constants/index.ts +++ b/src/constants/index.ts @@ -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`, diff --git a/src/store/index.ts b/src/store/index.ts index ace4f5e..a99db95 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -3,7 +3,3 @@ import { websiteList as w } from '../utils' export const websiteList = w - -export const isEditing = { - value: false -} diff --git a/src/view/admin/index.component.html b/src/view/admin/index.component.html index 0186def..5009f26 100644 --- a/src/view/admin/index.component.html +++ b/src/view/admin/index.component.html @@ -1,6 +1,6 @@
- + diff --git a/src/view/index/light/index.component.html b/src/view/index/light/index.component.html index e223173..9dec1c2 100644 --- a/src/view/index/light/index.component.html +++ b/src/view/index/light/index.component.html @@ -15,7 +15,7 @@ [class.dark-text-active]="page === i" class="ripple-btn dark-text" > - + {{ item.title }} @@ -31,7 +31,7 @@ (click)="handleSidebarNav(i)" *ngFor="let item of websiteList[page].nav; let i = index" > - +
{{ item.title }}
@@ -44,7 +44,7 @@
- +

- + - + {{ item.title }} @@ -29,7 +29,7 @@ [class.dark-item-active]="id === i" class="ripple-btn dark-text" > - + {{ item.title }}

@@ -43,7 +43,7 @@ class="title dark-primary dark-border-color" *ngIf="item.title" > - +