From 572f2f5533f684c1dbfdffc95741f1ed64108fd6 Mon Sep 17 00:00:00 2001 From: xream Date: Fri, 8 Mar 2024 13:56:59 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20OpenAPI=20=E5=A2=9E=E5=8A=A0=20isEgern,?= =?UTF-8?q?=20isLanceX;=20/api/utils/env=20=E5=A2=9E=E5=8A=A0=20meta=20?= =?UTF-8?q?=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/package.json | 2 +- backend/src/utils/env.js | 32 +++++++++++++++++++++++++++++++- backend/src/vendor/open-api.js | 13 ++++++++++++- 3 files changed, 44 insertions(+), 3 deletions(-) diff --git a/backend/package.json b/backend/package.json index acfd4e50f..36ec5736c 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,6 +1,6 @@ { "name": "sub-store", - "version": "2.14.240", + "version": "2.14.241", "description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.", "main": "src/main.js", "scripts": { diff --git a/backend/src/utils/env.js b/backend/src/utils/env.js index f99068a7b..244d9b255 100644 --- a/backend/src/utils/env.js +++ b/backend/src/utils/env.js @@ -1,7 +1,16 @@ import { version as substoreVersion } from '../../package.json'; import { ENV } from '@/vendor/open-api'; -const { isNode, isQX, isLoon, isSurge, isStash, isShadowRocket } = ENV(); +const { + isNode, + isQX, + isLoon, + isSurge, + isStash, + isShadowRocket, + isLanceX, + isEgern, +} = ENV(); let backend = 'Node'; if (isNode) backend = 'Node'; if (isQX) backend = 'QX'; @@ -9,8 +18,29 @@ if (isLoon) backend = 'Loon'; if (isSurge) backend = 'Surge'; if (isStash) backend = 'Stash'; if (isShadowRocket) backend = 'ShadowRocket'; +if (isEgern) backend = 'Egern'; +if (isLanceX) backend = 'LanceX'; + +let meta = {}; + +try { + if (typeof $environment !== 'undefined') { + // eslint-disable-next-line no-undef + meta.env = $environment; + } + if (typeof $loon !== 'undefined') { + // eslint-disable-next-line no-undef + meta.loon = $loon; + } + if (typeof $script !== 'undefined') { + // eslint-disable-next-line no-undef + meta.script = $script; + } + // eslint-disable-next-line no-empty +} catch (e) {} export default { backend, version: substoreVersion, + meta, }; diff --git a/backend/src/vendor/open-api.js b/backend/src/vendor/open-api.js index e792e1ac2..408542203 100644 --- a/backend/src/vendor/open-api.js +++ b/backend/src/vendor/open-api.js @@ -6,6 +6,8 @@ const isNode = eval(`typeof process !== "undefined"`); // eval is needed in orde const isStash = 'undefined' !== typeof $environment && $environment['stash-version']; const isShadowRocket = 'undefined' !== typeof $rocket; +const isEgern = 'object' == typeof egern; +const isLanceX = 'undefined' != typeof $native; export class OpenAPI { constructor(name = 'untitled', debug = false) { @@ -251,7 +253,16 @@ export class OpenAPI { } export function ENV() { - return { isQX, isLoon, isSurge, isNode, isStash, isShadowRocket }; + return { + isQX, + isLoon, + isSurge, + isNode, + isStash, + isShadowRocket, + isEgern, + isLanceX, + }; } export function HTTP(defaultOptions = { baseURL: '' }) {