Skip to content

Commit

Permalink
feat: OpenAPI 增加 isEgern, isLanceX; /api/utils/env 增加 meta 信息
Browse files Browse the repository at this point in the history
  • Loading branch information
xream committed Mar 8, 2024
1 parent 1c6d761 commit 572f2f5
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 3 deletions.
2 changes: 1 addition & 1 deletion backend/package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
32 changes: 31 additions & 1 deletion backend/src/utils/env.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,46 @@
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';
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,
};
13 changes: 12 additions & 1 deletion backend/src/vendor/open-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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: '' }) {
Expand Down

0 comments on commit 572f2f5

Please sign in to comment.