Skip to content

Commit

Permalink
fix: #174
Browse files Browse the repository at this point in the history
  • Loading branch information
xjh22222228 committed Dec 18, 2021
1 parent 408891f commit b4f2ba4
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 81 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,4 @@ Thank you for your [contribution](https://github.com/xjh22222228/nav/issues), me
If you have any functional suggestions, you can initiate an [issue](https://github.com/xjh22222228/nav/issues), Thank you.

## LICENSE
Commercial use is prohibited without the consent of the author.

[MIT](./LICENSE)
2 changes: 0 additions & 2 deletions README_zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,4 @@ Thank you for your [contribution](https://github.com/xjh22222228/nav/issues), me


## 协议
未经作者同意,禁止商业用途。

[MIT](./LICENSE)
2 changes: 1 addition & 1 deletion src/components/fixbar/index.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export class FixbarComponent {
this.router.navigate(['system'])
setTimeout(() => {
window.location.reload()
}, 500)
}, 200)
}

handleSync() {
Expand Down
2 changes: 1 addition & 1 deletion src/view/system/about/index.component.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<p><a href="https://github.com/xjh22222228/nav" target="_blank">开源项目</a>,未经作者同意,不得以抄袭/复制代码/修改源代码版权信息或作为任何商业途径</p>
<p><a href="https://github.com/xjh22222228/nav" target="_blank">开源项目</a>,未经作者同意,不得以抄袭/复制代码/修改源代码版权信息,允许商业途径</p>

<p>如果这个项目能帮到您,支持一下作者!我会努力维护!</p>

Expand Down
57 changes: 33 additions & 24 deletions src/view/system/search/index.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { NzMessageService } from 'ng-zorro-antd/message'
import { NzNotificationService } from 'ng-zorro-antd/notification'
import { ISearchEngineProps } from 'src/types'
import { updateFileContent } from 'src/services'
import { NzModalService } from 'ng-zorro-antd/modal'
import { SEARCH_PATH } from 'src/constants'
import { searchEngineList } from 'src/store'

Expand All @@ -23,6 +24,7 @@ export default class SystemSearchComponent {
constructor (
private message: NzMessageService,
private notification: NzNotificationService,
private modal: NzModalService,
) {}

handleAdd() {
Expand All @@ -45,33 +47,40 @@ export default class SystemSearchComponent {
return
}

const o = {}
this.searchList.forEach(item => {
if (item.name.trim()) {
o[item.name] = null
}
})
this.modal.info({
nzTitle: $t('_syncDataOut'),
nzOkText: $t('_confirmSync'),
nzContent: $t('_confirmSyncTip'),
nzOnOk: () => {
const o = {}
this.searchList.forEach(item => {
if (item.name.trim()) {
o[item.name] = null
}
})

if (Object.keys(o).length !== this.searchList.length) {
this.message.error($t('_repeatAdd'))
return
}
if (Object.keys(o).length !== this.searchList.length) {
this.message.error($t('_repeatAdd'))
return
}

this.submitting = true
updateFileContent({
message: 'Update Search',
content: JSON.stringify(this.searchList, null, 2),
path: SEARCH_PATH
this.submitting = true
updateFileContent({
message: 'Update Search',
content: JSON.stringify(this.searchList, null, 2),
path: SEARCH_PATH
})
.then(() => {
this.message.success($t('_saveSuccess'))
})
.catch(res => {
this.notification.error($t('_error'), res.message as string)
})
.finally(() => {
this.submitting = false
})
}
})
.then(() => {
this.message.success($t('_saveSuccess'))
})
.catch(res => {
this.notification.error($t('_error'), res.message as string)
})
.finally(() => {
this.submitting = false
})
}

onChangeUpload(path, idx: number) {
Expand Down
57 changes: 33 additions & 24 deletions src/view/system/setting/index.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { $t } from 'src/locale'
import { FormBuilder, FormGroup } from '@angular/forms'
import { NzMessageService } from 'ng-zorro-antd/message'
import { NzNotificationService } from 'ng-zorro-antd/notification'
import { NzModalService } from 'ng-zorro-antd/modal'
import { SETTING_PATH } from 'src/constants'
import { updateFileContent } from 'src/services'
import { settings } from 'src/store'
Expand All @@ -25,6 +26,7 @@ export default class SystemSettingComponent {
private fb: FormBuilder,
private notification: NzNotificationService,
private message: NzMessageService,
private modal: NzModalService,
) {}

ngOnInit () {
Expand Down Expand Up @@ -123,30 +125,37 @@ export default class SystemSettingComponent {
return
}

const values = {
...this.validateForm.value,
simThemeImages: this.settings.simThemeImages,
shortcutThemeImages: this.settings.shortcutThemeImages,
sideThemeImages: this.settings.sideThemeImages,
mirrorList: this.settings.mirrorList.filter(item => (
item.url && item.name
))
}

this.submitting = true
updateFileContent({
message: 'Update settings',
content: JSON.stringify(values, null, 2),
path: SETTING_PATH
this.modal.info({
nzTitle: $t('_syncDataOut'),
nzOkText: $t('_confirmSync'),
nzContent: $t('_confirmSyncTip'),
nzOnOk: () => {
const values = {
...this.validateForm.value,
simThemeImages: this.settings.simThemeImages,
shortcutThemeImages: this.settings.shortcutThemeImages,
sideThemeImages: this.settings.sideThemeImages,
mirrorList: this.settings.mirrorList.filter(item => (
item.url && item.name
))
}

this.submitting = true
updateFileContent({
message: 'Update settings',
content: JSON.stringify(values, null, 2),
path: SETTING_PATH
})
.then(() => {
this.message.success($t('_saveSuccess'))
})
.catch(res => {
this.notification.error($t('_error'), res.message as string)
})
.finally(() => {
this.submitting = false
})
}
})
.then(() => {
this.message.success($t('_saveSuccess'))
})
.catch(res => {
this.notification.error($t('_error'), res.message as string)
})
.finally(() => {
this.submitting = false
})
}
}
63 changes: 36 additions & 27 deletions src/view/system/tag/index.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Component } from '@angular/core'
import { $t } from 'src/locale'
import { NzMessageService } from 'ng-zorro-antd/message'
import { NzNotificationService } from 'ng-zorro-antd/notification'
import { NzModalService } from 'ng-zorro-antd/modal'
import { ITagPropValues } from 'src/types'
import { updateFileContent } from 'src/services'
import { TAG_PATH } from 'src/constants'
Expand All @@ -23,6 +24,7 @@ export default class SystemTagComponent {
constructor (
private message: NzMessageService,
private notification: NzNotificationService,
private modal: NzModalService,
) {}

ngOnInit () {
Expand Down Expand Up @@ -60,35 +62,42 @@ export default class SystemTagComponent {
return
}

const o = {}
this.tagList.forEach(item => {
if (item.name.trim()) {
o[item.name] = {
...item,
name: undefined
}
}
})
this.modal.info({
nzTitle: $t('_syncDataOut'),
nzOkText: $t('_confirmSync'),
nzContent: $t('_confirmSyncTip'),
nzOnOk: () => {
const o = {}
this.tagList.forEach(item => {
if (item.name.trim()) {
o[item.name] = {
...item,
name: undefined
}
}
})

if (Object.keys(o).length !== this.tagList.length) {
this.message.error($t('_repeatAdd'))
return
}
if (Object.keys(o).length !== this.tagList.length) {
this.message.error($t('_repeatAdd'))
return
}

this.submitting = true
updateFileContent({
message: 'Update Tag',
content: JSON.stringify(o, null, 2),
path: TAG_PATH
this.submitting = true
updateFileContent({
message: 'Update Tag',
content: JSON.stringify(o, null, 2),
path: TAG_PATH
})
.then(() => {
this.message.success($t('_saveSuccess'))
})
.catch(res => {
this.notification.error($t('_error'), res.message as string)
})
.finally(() => {
this.submitting = false
})
}
})
.then(() => {
this.message.success($t('_saveSuccess'))
})
.catch(res => {
this.notification.error($t('_error'), res.message as string)
})
.finally(() => {
this.submitting = false
})
}
}

0 comments on commit b4f2ba4

Please sign in to comment.