提交 822c0c4e 编写于 作者: X xjh22222228

fix(#70): restore delete

上级 b17bc70c
...@@ -60,7 +60,7 @@ ...@@ -60,7 +60,7 @@
<nz-dropdown-menu #menu="nzDropdownMenu"> <nz-dropdown-menu #menu="nzDropdownMenu">
<ul nz-menu nzSelectable> <ul nz-menu nzSelectable>
<li nz-menu-item (click)="toggleModal(); detail = dataSource">编辑</li> <li nz-menu-item (click)="toggleModal(); detail = dataSource">编辑</li>
<!-- <a <a
nz-popconfirm nz-popconfirm
nzPopconfirmPlacement="rightTop" nzPopconfirmPlacement="rightTop"
nzOkType="danger" nzOkType="danger"
...@@ -69,7 +69,7 @@ ...@@ -69,7 +69,7 @@
(nzOnConfirm)="confirmDel($event)" (nzOnConfirm)="confirmDel($event)"
> >
<li nz-menu-item nzDanger>删除</li> <li nz-menu-item nzDanger>删除</li>
</a> --> </a>
</ul> </ul>
</nz-dropdown-menu> </nz-dropdown-menu>
</ng-template> </ng-template>
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
import { Component, OnInit, Input } from '@angular/core' import { Component, OnInit, Input } from '@angular/core'
import { NzMessageService } from 'ng-zorro-antd/message' import { NzMessageService } from 'ng-zorro-antd/message'
import { getToken } from '../../utils/user' import { getToken } from '../../utils/user'
import { setWebsiteList, copyText } from '../../utils' import { setWebsiteList, copyText, deleteByWeb } from '../../utils'
import { websiteList } from '../../store' import { websiteList } from '../../store'
import { INavProps, ITagProp, INavFourProp } from '../../types' import { INavProps, ITagProp, INavFourProp } from '../../types'
import * as __tag from '../../../data/tag.json' import * as __tag from '../../../data/tag.json'
...@@ -68,5 +68,7 @@ export class CardComponent implements OnInit { ...@@ -68,5 +68,7 @@ export class CardComponent implements OnInit {
this.toggleModal() this.toggleModal()
} }
confirmDel() {} confirmDel() {
deleteByWeb(this.dataSource)
}
} }
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
import qs from 'qs' import qs from 'qs'
import config from '../../nav.config' import config from '../../nav.config'
import Clipboard from 'clipboard' import Clipboard from 'clipboard'
import { INavProps, ISearchEngineProps } from '../types' import { INavFourProp, INavProps, ISearchEngineProps } from '../types'
import * as db from '../../data/db.json' import * as db from '../../data/db.json'
export const websiteList = getWebsiteList() export const websiteList = getWebsiteList()
...@@ -13,29 +13,6 @@ let total = 0 ...@@ -13,29 +13,6 @@ let total = 0
const { lightThemeConfig, searchEngineList } = config const { lightThemeConfig, searchEngineList } = config
const { backgroundLinear } = lightThemeConfig const { backgroundLinear } = lightThemeConfig
export function debounce(func, wait, immediate) {
let timeout
return function () {
let context = this
let args = arguments
if (timeout) clearTimeout(timeout)
if (immediate) {
let callNow = !timeout
timeout = setTimeout(() => {
timeout = null
}, wait)
if (callNow) func.apply(context, args)
} else {
timeout = setTimeout(() => {
func.apply(context, args)
}, wait)
}
}
}
export function randomInt(max: number) { export function randomInt(max: number) {
return Math.floor(Math.random() * max) return Math.floor(Math.random() * max)
} }
...@@ -379,3 +356,35 @@ export async function isValidImg(url: string): Promise<boolean> { ...@@ -379,3 +356,35 @@ export async function isValidImg(url: string): Promise<boolean> {
document.body.append(img) document.body.append(img)
}) })
} }
export function deleteByWeb(data: INavFourProp) {
function f(arr: any[]) {
for (let i = 0; i < arr.length; i++) {
const item = arr[i]
if (Array.isArray(item.nav)) {
f(item.nav)
continue
}
if (item.name) {
const keys = Object.keys(item)
let eq = false
for (let key of keys) {
eq = item[key] === data[key]
}
if (eq) {
arr.splice(i, 1)
const { q } = queryString()
if (q) {
window.location.reload()
}
}
}
}
}
f(websiteList)
setWebsiteList(websiteList)
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册