perf: 支持项目调整排序

This commit is contained in:
kuaifan 2025-08-20 08:36:19 +08:00
parent b825b5b063
commit 7c94f6bc9a
2 changed files with 10 additions and 13 deletions

View File

@ -785,7 +785,7 @@ export default {
projectLists: {
handler(val) {
if (!this.projectDragging) {
this.projectDraggableList = val
this.projectDraggableList = $A.cloneJSON(val)
}
},
immediate: true
@ -1061,12 +1061,7 @@ export default {
},
onProjectSortEnd() {
//
const nonPinnedItems = this.projectDraggableList.filter(item => !item.top_at)
nonPinnedItems.forEach((item, index) => {
this.$store.dispatch("saveProject", {id: item.id, sort: index})
})
//
this.$store.dispatch("call", {
url: 'project/user/sort',
data: {
@ -1075,8 +1070,12 @@ export default {
method: 'post',
spinner: 2000
}).then(({msg}) => {
nonPinnedItems.forEach((item, index) => {
this.$store.dispatch("saveProject", {id: item.id, sort: index})
})
$A.messageSuccess(msg)
}).catch(({msg}) => {
this.projectDraggableList = $A.cloneJSON(this.projectLists)
$A.modalError(msg)
}).finally(() => {
this.projectDragging = false
@ -1247,7 +1246,6 @@ export default {
},
}).then(({data}) => {
this.$store.dispatch("saveProject", data);
this.projectDraggableList = this.projectLists
this.$nextTick(() => {
const active = this.$refs.menuProject.querySelector(".active")
if (active) {

View File

@ -151,7 +151,7 @@ export default {
projectLists: {
handler(val) {
if (!this.projectDragging) {
this.projectDraggableList = val
this.projectDraggableList = $A.cloneJSON(val)
}
},
immediate: true
@ -184,12 +184,7 @@ export default {
methods: {
transformEmojiToHtml,
onProjectSortEnd() {
//
const nonPinnedItems = this.projectDraggableList.filter(item => !item.top_at)
nonPinnedItems.forEach((item, index) => {
this.$store.dispatch("saveProject", {id: item.id, sort: index})
})
//
this.$store.dispatch("call", {
url: 'project/user/sort',
data: {
@ -198,8 +193,12 @@ export default {
method: 'post',
spinner: 2000
}).then(({msg}) => {
nonPinnedItems.forEach((item, index) => {
this.$store.dispatch("saveProject", {id: item.id, sort: index})
})
$A.messageSuccess(msg)
}).catch(({msg}) => {
this.projectDraggableList = $A.cloneJSON(this.projectLists)
$A.modalError(msg)
}).finally(() => {
this.projectDragging = false