From ea31b1d0ec58c59e95b3f4f845c4d599cfb54d8c Mon Sep 17 00:00:00 2001 From: xream Date: Mon, 4 Sep 2023 21:31:55 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=8E=92=E5=BA=8F=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E4=B8=BA=E4=BD=BF=E7=94=A8=20name=20?= =?UTF-8?q?=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/restful/sort.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/backend/src/restful/sort.js b/backend/src/restful/sort.js index f11f6eb..aa6400e 100644 --- a/backend/src/restful/sort.js +++ b/backend/src/restful/sort.js @@ -11,7 +11,7 @@ export default function register($app) { function sortSubs(req, res) { const orders = req.body; const allSubs = $.read(SUBS_KEY); - allSubs.sort((a, b) => orders.indexOf(a) - orders.indexOf(b)); + allSubs.sort((a, b) => orders.indexOf(a.name) - orders.indexOf(b.name)); $.write(allSubs, SUBS_KEY); success(res, allSubs); } @@ -19,7 +19,7 @@ function sortSubs(req, res) { function sortCollections(req, res) { const orders = req.body; const allCols = $.read(COLLECTIONS_KEY); - allCols.sort((a, b) => orders.indexOf(a) - orders.indexOf(b)); + allCols.sort((a, b) => orders.indexOf(a.name) - orders.indexOf(b.name)); $.write(allCols, COLLECTIONS_KEY); success(res, allCols); } @@ -27,7 +27,9 @@ function sortCollections(req, res) { function sortArtifacts(req, res) { const orders = req.body; const allArtifacts = $.read(ARTIFACTS_KEY); - allArtifacts.sort((a, b) => orders.indexOf(a) - orders.indexOf(b)); + allArtifacts.sort( + (a, b) => orders.indexOf(a.name) - orders.indexOf(b.name), + ); $.write(allArtifacts, ARTIFACTS_KEY); success(res, allArtifacts); }