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

View File

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