diff --git a/README.md b/README.md
index a2186a61c00755cb47bbedf3a2daf0c6f9ddbdc1..ea794f6cf3930873876d11fa1fcc8afaa716e1e6 100644
--- a/README.md
+++ b/README.md
@@ -152,8 +152,6 @@ yarn build
## contribute
-[Click Here](https://github.com/xjh22222228/nav/tree/master/data)
-
Thank you for your [contribution](https://github.com/xjh22222228/nav/issues), men.
diff --git a/README_zh-CN.md b/README_zh-CN.md
index fe10da02132e104e8a04c06b5d3ecd1d8d79a576..d563b5f0bfc200ea92b7139c66ab3bd5bf1c1892 100644
--- a/README_zh-CN.md
+++ b/README_zh-CN.md
@@ -159,8 +159,6 @@ yarn build
## 贡献
-[点击这里](https://github.com/xjh22222228/nav/tree/master/data)
-
Thank you for your [contribution](https://github.com/xjh22222228/nav/issues), men.
diff --git a/src/app/app.module.ts b/src/app/app.module.ts
index 2b3d70d31f627c8af6a8c0e5d00de5b739efa88f..867708900f2a2322921a20c6eb817bf9b69a3de1 100644
--- a/src/app/app.module.ts
+++ b/src/app/app.module.ts
@@ -31,6 +31,7 @@ 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'
+import { NzCheckboxModule } from 'ng-zorro-antd/checkbox'
// components
import { AppComponent } from './app.component'
@@ -58,6 +59,7 @@ import { HttpClientModule } from '@angular/common/http';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { LogoComponent } from '../components/logo/logo.component';
import { CardComponent } from '../components/card/index.component'
+import { MoveSiteComponent } from '../components/move-site/index.component'
const appRoutes: Routes = [
{
@@ -113,7 +115,8 @@ const appRoutes: Routes = [
ToolbarTitleWebComponent,
WebListComponent,
LogoComponent,
- CardComponent
+ CardComponent,
+ MoveSiteComponent
],
imports: [
NzModalModule,
@@ -138,6 +141,7 @@ const appRoutes: Routes = [
NzTabsModule,
NzTagModule,
NzRateModule,
+ NzCheckboxModule,
NzSwitchModule,
DragDropModule,
BrowserModule,
diff --git a/src/components/card/index.component.html b/src/components/card/index.component.html
index e0bc81550774584a7cd7ce12489a6dd418f5d37f..585fe1bf88118399a0525187dee0cfa3bfad6fd3 100644
--- a/src/components/card/index.component.html
+++ b/src/components/card/index.component.html
@@ -68,7 +68,8 @@
- - {{ $t('_edit') }}
+ - {{ $t('_edit') }}
+ - {{ $t('_move') }}
+
+
+
diff --git a/src/components/card/index.component.ts b/src/components/card/index.component.ts
index 8588012104af831a9c3e1f7ae144d56a312c49d4..ec192d9c74205cdefc9dde298374540ddd8824ef 100644
--- a/src/components/card/index.component.ts
+++ b/src/components/card/index.component.ts
@@ -1,7 +1,7 @@
// Copyright @ 2018-2021 xiejiahe. All rights reserved. MIT license.
// See https://github.com/xjh22222228/nav
-import { Component, OnInit, Input } from '@angular/core'
+import { Component, OnInit, Input, ViewChildren, QueryList } from '@angular/core'
import { NzMessageService } from 'ng-zorro-antd/message'
import { getToken } from '../../utils/user'
import { setWebsiteList, copyText, deleteByWeb, getTextContent, updateByWeb } from '../../utils'
@@ -9,6 +9,7 @@ import { websiteList } from '../../store'
import { INavProps, ITagProp, INavFourProp } from '../../types'
import * as __tag from '../../../data/tag.json'
import { $t } from '../../locale'
+import { MoveSiteComponent } from '../move-site/index.component'
const tagMap: ITagProp = (__tag as any).default
@@ -19,12 +20,17 @@ const tagMap: ITagProp = (__tag as any).default
})
export class CardComponent implements OnInit {
@Input() dataSource: INavFourProp
+ @Input() indexs: Array
+
+ @ViewChildren(MoveSiteComponent)
+ moveSiteChild: QueryList
$t = $t
objectKeys = Object.keys
websiteList: INavProps[] = websiteList
isLogin: boolean = !!getToken()
- showModal = false
+ showCreateModal = false
+ showMoveModal = false
copyUrlDone = false
copyPathDone = false
tagMap = tagMap
@@ -33,7 +39,8 @@ export class CardComponent implements OnInit {
private message: NzMessageService,
) {}
- ngOnInit(): void {}
+ ngOnInit(): void {
+ }
async copyUrl(e, type: number) {
const w = this.dataSource
@@ -53,8 +60,12 @@ export class CardComponent implements OnInit {
this.copyPathDone = false
}
- toggleModal() {
- this.showModal = !this.showModal
+ toggleCreateModal() {
+ this.showCreateModal = !this.showCreateModal
+ }
+
+ toggleMoveModal() {
+ this.showMoveModal = !this.showMoveModal
}
onRateChange(n: number) {
@@ -62,7 +73,7 @@ export class CardComponent implements OnInit {
setWebsiteList(this.websiteList)
}
- handleOk(payload: INavFourProp) {
+ handleUpdateSiteOk(payload: INavFourProp) {
updateByWeb({
...this.dataSource,
name: getTextContent(this.dataSource.name),
@@ -75,7 +86,7 @@ export class CardComponent implements OnInit {
}
this.message.success($t('_modifySuccess'))
- this.toggleModal()
+ this.toggleCreateModal()
}
confirmDel() {
@@ -85,4 +96,12 @@ export class CardComponent implements OnInit {
desc: getTextContent(this.dataSource.desc)
})
}
+
+ handleMove() {
+ this.moveSiteChild.changes.subscribe((comps: QueryList) =>
+ {
+ comps.first?.pushMoveSites([this.dataSource])
+ });
+ this.showMoveModal = true
+ }
}
diff --git a/src/components/move-site/index.component.html b/src/components/move-site/index.component.html
new file mode 100644
index 0000000000000000000000000000000000000000..2322b853eaeeb0979b66c6ed1013609555033dbf
--- /dev/null
+++ b/src/components/move-site/index.component.html
@@ -0,0 +1,58 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/components/move-site/index.component.scss b/src/components/move-site/index.component.scss
new file mode 100644
index 0000000000000000000000000000000000000000..20d7201fbd5a1011978c61b0678013c39739772f
--- /dev/null
+++ b/src/components/move-site/index.component.scss
@@ -0,0 +1,3 @@
+.act {
+ margin-top: 30px;
+}
diff --git a/src/components/move-site/index.component.ts b/src/components/move-site/index.component.ts
new file mode 100644
index 0000000000000000000000000000000000000000..724eea37e6b36424c0e13f401160b5bf899e2600
--- /dev/null
+++ b/src/components/move-site/index.component.ts
@@ -0,0 +1,100 @@
+// Copyright @ 2018-2021 xiejiahe. All rights reserved. MIT license.
+// See https://github.com/xjh22222228/nav
+
+import { Component, Input, Output, EventEmitter } from '@angular/core'
+import { $t } from 'src/locale'
+import { setWebsiteList } from '../../utils'
+import { websiteList } from '../../store'
+import { INavProps, INavTwoProp, INavThreeProp, INavFourProp } from '../../types'
+import { NzMessageService } from 'ng-zorro-antd/message'
+
+@Component({
+ selector: 'app-move-site',
+ templateUrl: './index.component.html',
+ styleUrls: ['./index.component.scss']
+})
+export class MoveSiteComponent {
+ @Input() visible: boolean
+ @Input() indexs: Array
+ @Output() onCancel = new EventEmitter()
+
+ $t = $t
+ websiteList: INavProps[] = websiteList
+ twoOptList: INavTwoProp[] = []
+ threeOptList: INavThreeProp[] = []
+ checked = false
+ oneSelect = ''
+ twoSelect = ''
+ threeSelect = ''
+ moveSites: INavFourProp[] = []
+
+ constructor (
+ private message: NzMessageService
+ ) {}
+
+ ngOnInit() {}
+
+ pushMoveSites(sites: INavFourProp[]) {
+ this.moveSites = sites
+ }
+
+ hanldeOneSelect(index) {
+ this.oneSelect = index
+ const title = this.websiteList[index].title
+ const findItem = this.websiteList.find(item => item.title === title)
+ this.twoOptList = findItem.nav
+ this.twoSelect = ''
+ this.threeSelect = ''
+ }
+
+ hanldeTwoSelect(index) {
+ this.twoSelect = index
+ const title = this.twoOptList[index].title
+ const findItem = this.twoOptList.find(item => item.title === title)
+ this.threeOptList = findItem.nav
+ this.threeSelect = ''
+ }
+
+ hanldeThreeSelect(index) {
+ this.threeSelect = index
+ }
+
+ handleCancel() {
+ this.onCancel.emit()
+ }
+
+ hanldeOk() {
+ if (this.threeSelect === '') {
+ return this.message.error($t('_sel3'))
+ }
+
+ this.moveSites.forEach((item: INavFourProp) => {
+ const exists = this.websiteList[this.oneSelect]
+ .nav[this.twoSelect]
+ .nav[this.threeSelect]
+ .nav.find((el: INavFourProp) => el.name === item.name)
+
+ if (exists) {
+ this.message.error(`${$t('_repeatAdd')} "${item.name}"`)
+ } else {
+ this.websiteList[this.oneSelect]
+ .nav[this.twoSelect]
+ .nav[this.threeSelect]
+ .nav
+ .unshift(item)
+
+ if (!this.checked) {
+ const [a, b, c, d] = this.indexs
+ this.websiteList[a]
+ .nav[b]
+ .nav[c]
+ .nav.splice(d, 1)
+ }
+
+ this.message.success(`"${item.name}" ${$t('_moveSuccess')}`)
+ }
+ });
+ setWebsiteList(this.websiteList)
+ this.handleCancel()
+ }
+}
diff --git a/src/locale/english.ts b/src/locale/english.ts
index 19ea4c5a68e134bdd67e9175acd6361017e2538b..b3330719c26846c49c56efea45f6c1dbf4137ef7 100644
--- a/src/locale/english.ts
+++ b/src/locale/english.ts
@@ -97,5 +97,9 @@ export default {
_iconAddr: 'Icon Link',
_copyUpload: 'Support to paste screenshots or copy pictures here to upload',
_upload: 'Upload',
- _continueAdd: 'Continue to add affiliate links'
+ _continueAdd: 'Continue to add affiliate links',
+ _moveTo: 'Move to',
+ _move: 'Move',
+ _copy: 'Copy',
+ _moveSuccess: 'Moved successfully'
}
diff --git a/src/locale/zh_CN.ts b/src/locale/zh_CN.ts
index 4a82a73cc2b7c9a60a4c3f6370343021476c36ae..138ba4d8148f689eaa69383b10339f00f0834938 100644
--- a/src/locale/zh_CN.ts
+++ b/src/locale/zh_CN.ts
@@ -97,5 +97,9 @@ export default {
_iconAddr: '图标地址',
_copyUpload: '支持将截图或复制图片粘贴此处上传',
_upload: '上传',
- _continueAdd: '继续添加关联链接'
+ _continueAdd: '继续添加关联链接',
+ _moveTo: '移动到',
+ _move: '移动',
+ _copy: '复制',
+ _moveSuccess: '移动成功'
}
diff --git a/src/utils/index.ts b/src/utils/index.ts
index fae7cbb6a8e9ee6f7a2331a922b988cf7fa99484..57c4ba95527e5671f111635409fbb0e5d2b841fc 100644
--- a/src/utils/index.ts
+++ b/src/utils/index.ts
@@ -216,11 +216,11 @@ export function queryString(): {
}
if (page > websiteList.length - 1) {
- page = websiteList.length - 1;
- id = 0;
+ page = websiteList.length - 1
+ id = 0
} else {
if (!(id <= websiteList[page].nav.length - 1)) {
- id = websiteList[page].nav.length - 1;
+ id = websiteList[page].nav.length - 1
}
}
@@ -241,7 +241,7 @@ export function adapterWebsiteList(websiteList: any[], parentItem?: any) {
if (Array.isArray(item.nav)) {
if (item.nav[0]?.url) {
- item.nav = item.nav.filter(item => !item.ownVisible || isLogin);
+ item.nav = item.nav.filter(item => !item.ownVisible || isLogin)
}
adapterWebsiteList(item.nav, item)
}
diff --git a/src/view/index/light/index.component.html b/src/view/index/light/index.component.html
index b1aaf0736a7837f0394745fe3951092b6a06af63..386dcec7e736d0c6fac263fa2f58f012ec6d53d3 100644
--- a/src/view/index/light/index.component.html
+++ b/src/view/index/light/index.component.html
@@ -58,10 +58,10 @@
class="gutter-row"
nz-col
[nzSpan]="8"
- *ngFor="let el of item.nav"
+ *ngFor="let el of item.nav; index as j"
[class.remove]="!isLogin && el.ownVisible"
>
-
+
diff --git a/src/view/index/side/index.component.html b/src/view/index/side/index.component.html
index 5d3a6e5057d03ef99833bfb5831a12a54f50eb85..c1d8df2bfa26f799a45fb7e443465d6214e51d9a 100644
--- a/src/view/index/side/index.component.html
+++ b/src/view/index/side/index.component.html
@@ -71,7 +71,7 @@
diff --git a/src/view/index/sim/index.component.html b/src/view/index/sim/index.component.html
index d3d0cb3a862b28cb478efdc633f28d81236fdcaf..519f4453b0fa6643a8304377f5f4c8695419c591 100644
--- a/src/view/index/sim/index.component.html
+++ b/src/view/index/sim/index.component.html
@@ -45,10 +45,10 @@
class="gutter-row"
nz-col
[nzSpan]="8"
- *ngFor="let el of item.nav; let idx=index"
+ *ngFor="let el of item.nav; let idx=index; let i=j"
[class.remove]="!isLogin && el.ownVisible"
>
-
+