改进star的导入导出时的排序问题

This commit is contained in:
haiyangcui
2020-11-03 16:34:12 +01:00
parent 46de044214
commit 68960ab5bb
2 changed files with 11 additions and 4 deletions

View File

@@ -275,7 +275,9 @@ export default {
},
getRecommandations () {
recommandation.all().then(res => {
this.recommandations = res.reverse()
this.recommandations = res.sort(function (a, b) {
return b.id - a.id
})
this.getFilterData()
})
},

View File

@@ -345,7 +345,9 @@ export default {
},
getFavorites () {
star.all().then(res => {
this.list = res.reverse()
this.list = res.sort(function (a, b) {
return b.id - a.id
})
})
},
getAllsites () {
@@ -384,13 +386,15 @@ export default {
remote.dialog.showOpenDialog(options).then(result => {
if (!result.canceled) {
var starList = this.list
var id = this.list.length + 1
result.filePaths.forEach(file => {
var str = fs.readFileSync(file)
const json = JSON.parse(str)
json.forEach(ele => {
const starExists = starList.includes(x => x.key === ele.key && x.ids === ele.ids)
json.reverse().forEach(ele => {
const starExists = starList.some(x => x.key === ele.key && x.ids === ele.ids)
if (!starExists) {
var doc = {
id: id,
key: ele.key,
ids: ele.ids,
site: ele.site === undefined ? ele.site = this.sites.find(x => x.key === ele.key) : ele.site,
@@ -409,6 +413,7 @@ export default {
note: ele.note
} : ele.detail
}
id += 1
starList.push(doc)
}
})