diff --git a/src/components/Star.vue b/src/components/Star.vue index 2dbf05a..dff9e75 100644 --- a/src/components/Star.vue +++ b/src/components/Star.vue @@ -7,7 +7,7 @@ 清空 同步所有收藏 -
+
{ this.getFavorites() }) + }, + updateDatabase (data) { + star.clear().then(res => { + var id = length + data.forEach(ele => { + ele.id = id + id -= 1 + }) + star.bulkAdd(data) + }) + }, + rowDrop () { + const tbody = document.getElementById('list-table').querySelector('.el-table__body-wrapper tbody') + const _this = this + Sortable.create(tbody, { + onEnd ({ newIndex, oldIndex }) { + const currRow = _this.list.splice(oldIndex, 1)[0] + _this.list.splice(newIndex, 0, currRow) + _this.updateDatabase(_this.list) + } + }) } }, + mounted () { + this.rowDrop() + }, created () { this.getFavorites() }