From d7e3659f240b3777bedb96301b6b032cdef990eb Mon Sep 17 00:00:00 2001 From: xream Date: Thu, 5 Mar 2026 14:24:15 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=20tokens=20=E6=8E=92?= =?UTF-8?q?=E5=BA=8F=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/package.json | 2 +- backend/src/restful/sort.js | 14 ++++++++++++++ backend/src/restful/token.js | 1 - 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/backend/package.json b/backend/package.json index a21c6e2f..66ac941d 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,6 +1,6 @@ { "name": "sub-store", - "version": "2.21.40", + "version": "2.21.42", "description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and Shadowrocket.", "main": "src/main.js", "scripts": { diff --git a/backend/src/restful/sort.js b/backend/src/restful/sort.js index 03240e05..3a8a9493 100644 --- a/backend/src/restful/sort.js +++ b/backend/src/restful/sort.js @@ -3,6 +3,7 @@ import { COLLECTIONS_KEY, SUBS_KEY, FILES_KEY, + TOKENS_KEY, } from '@/constants'; import $ from '@/core/app'; import { success } from '@/restful/response'; @@ -12,6 +13,7 @@ export default function register($app) { $app.post('/api/sort/collections', sortCollections); $app.post('/api/sort/artifacts', sortArtifacts); $app.post('/api/sort/files', sortFiles); + $app.post('/api/sort/tokens', sortTokens); } function sortSubs(req, res) { @@ -47,3 +49,15 @@ function sortFiles(req, res) { $.write(allFiles, FILES_KEY); success(res, allFiles); } + +function sortTokens(req, res) { + const orders = req.body; + const allTokens = $.read(TOKENS_KEY); + allTokens.sort( + (a, b) => + orders.indexOf(`${a.type}-${a.name}-${a.token}`) - + orders.indexOf(`${b.type}-${b.name}-${b.token}`), + ); + $.write(allTokens, TOKENS_KEY); + success(res, allTokens); +} diff --git a/backend/src/restful/token.js b/backend/src/restful/token.js index 02460885..df94586c 100644 --- a/backend/src/restful/token.js +++ b/backend/src/restful/token.js @@ -1,4 +1,3 @@ -import { deleteByName } from '@/utils/database'; import { ENV } from '@/vendor/open-api'; import { TOKENS_KEY, SUBS_KEY, FILES_KEY, COLLECTIONS_KEY } from '@/constants'; import { failed, success } from '@/restful/response';