mirror of
https://git.mirrors.martin98.com/https://github.com/sub-store-org/Sub-Store.git
synced 2025-08-10 07:09:00 +08:00
feat: 支持更多的 subscription-userinfo
This commit is contained in:
parent
cc58a5541e
commit
f4639d9a34
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "sub-store",
|
"name": "sub-store",
|
||||||
"version": "2.14.415",
|
"version": "2.14.416",
|
||||||
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.",
|
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.",
|
||||||
"main": "src/main.js",
|
"main": "src/main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -127,14 +127,18 @@ async function getFlowInfo(req, res) {
|
|||||||
}
|
}
|
||||||
if (sub.subUserinfo) {
|
if (sub.subUserinfo) {
|
||||||
try {
|
try {
|
||||||
success(res, {
|
const remainingDays = getRmainingDays({
|
||||||
...parseFlowHeaders(sub.subUserinfo),
|
resetDay: $arguments.resetDay,
|
||||||
remainingDays: getRmainingDays({
|
startDate: $arguments.startDate,
|
||||||
resetDay: $arguments.resetDay,
|
cycleDays: $arguments.cycleDays,
|
||||||
startDate: $arguments.startDate,
|
|
||||||
cycleDays: $arguments.cycleDays,
|
|
||||||
}),
|
|
||||||
});
|
});
|
||||||
|
const result = {
|
||||||
|
...parseFlowHeaders(sub.subUserinfo),
|
||||||
|
};
|
||||||
|
if (remainingDays != null) {
|
||||||
|
result.remainingDays = remainingDays;
|
||||||
|
}
|
||||||
|
success(res, result);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
$.error(
|
$.error(
|
||||||
`Failed to parse flow info for local subscription ${name}: ${
|
`Failed to parse flow info for local subscription ${name}: ${
|
||||||
@ -169,14 +173,18 @@ async function getFlowInfo(req, res) {
|
|||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
success(res, {
|
const remainingDays = getRmainingDays({
|
||||||
...parseFlowHeaders(flowHeaders),
|
resetDay: $arguments.resetDay,
|
||||||
remainingDays: getRmainingDays({
|
startDate: $arguments.startDate,
|
||||||
resetDay: $arguments.resetDay,
|
cycleDays: $arguments.cycleDays,
|
||||||
startDate: $arguments.startDate,
|
|
||||||
cycleDays: $arguments.cycleDays,
|
|
||||||
}),
|
|
||||||
});
|
});
|
||||||
|
const result = {
|
||||||
|
...parseFlowHeaders(flowHeaders),
|
||||||
|
};
|
||||||
|
if (remainingDays != null) {
|
||||||
|
result.remainingDays = remainingDays;
|
||||||
|
}
|
||||||
|
success(res, result);
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
failed(
|
failed(
|
||||||
|
@ -190,8 +190,23 @@ export function parseFlowHeaders(flowHeaders) {
|
|||||||
? Number(expireMatch[1] + expireMatch[2])
|
? Number(expireMatch[1] + expireMatch[2])
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
return { expires, total, usage: { upload, download } };
|
const remainingDaysMatch = flowHeaders.match(/reset_day=([0-9]+)/);
|
||||||
|
const remainingDays = remainingDaysMatch
|
||||||
|
? Number(remainingDaysMatch[1])
|
||||||
|
: undefined;
|
||||||
|
|
||||||
|
const appUrlMatch = flowHeaders.match(/app_url=(.*?)\s*?(;|$)/);
|
||||||
|
const appUrl = appUrlMatch ? appUrlMatch[1] : undefined;
|
||||||
|
|
||||||
|
return {
|
||||||
|
expires,
|
||||||
|
total,
|
||||||
|
usage: { upload, download },
|
||||||
|
remainingDays,
|
||||||
|
appUrl,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function flowTransfer(flow, unit = 'B') {
|
export function flowTransfer(flow, unit = 'B') {
|
||||||
const unitList = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
const unitList = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
||||||
let unitIndex = unitList.indexOf(unit);
|
let unitIndex = unitList.indexOf(unit);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user