mirror of
https://git.mirrors.martin98.com/https://github.com/sub-store-org/Sub-Store.git
synced 2025-08-11 11:28:59 +08:00
feat: 订阅支持每月重置天数
This commit is contained in:
parent
078bf228de
commit
518de2e919
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "sub-store",
|
"name": "sub-store",
|
||||||
"version": "2.14.245",
|
"version": "2.14.246",
|
||||||
"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": {
|
||||||
|
@ -16,6 +16,7 @@ import {
|
|||||||
parseFlowHeaders,
|
parseFlowHeaders,
|
||||||
validCheck,
|
validCheck,
|
||||||
flowTransfer,
|
flowTransfer,
|
||||||
|
getRmainingDays,
|
||||||
} from '@/utils/flow';
|
} from '@/utils/flow';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -863,6 +864,7 @@ function createDynamicFunction(name, script, $arguments) {
|
|||||||
parseFlowHeaders,
|
parseFlowHeaders,
|
||||||
flowTransfer,
|
flowTransfer,
|
||||||
validCheck,
|
validCheck,
|
||||||
|
getRmainingDays,
|
||||||
};
|
};
|
||||||
if ($.env.isLoon) {
|
if ($.env.isLoon) {
|
||||||
return new Function(
|
return new Function(
|
||||||
|
@ -6,7 +6,11 @@ import {
|
|||||||
} from './errors';
|
} from './errors';
|
||||||
import { deleteByName, findByName, updateByName } from '@/utils/database';
|
import { deleteByName, findByName, updateByName } from '@/utils/database';
|
||||||
import { SUBS_KEY, COLLECTIONS_KEY, ARTIFACTS_KEY } from '@/constants';
|
import { SUBS_KEY, COLLECTIONS_KEY, ARTIFACTS_KEY } from '@/constants';
|
||||||
import { getFlowHeaders, parseFlowHeaders } from '@/utils/flow';
|
import {
|
||||||
|
getFlowHeaders,
|
||||||
|
parseFlowHeaders,
|
||||||
|
getRmainingDays,
|
||||||
|
} from '@/utils/flow';
|
||||||
import { success, failed } from './response';
|
import { success, failed } from './response';
|
||||||
import $ from '@/core/app';
|
import $ from '@/core/app';
|
||||||
|
|
||||||
@ -105,8 +109,10 @@ async function getFlowInfo(req, res) {
|
|||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
success(res, {
|
||||||
success(res, parseFlowHeaders(flowHeaders));
|
...parseFlowHeaders(flowHeaders),
|
||||||
|
remainingDays: getRmainingDays($arguments.resetDay),
|
||||||
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
failed(
|
failed(
|
||||||
res,
|
res,
|
||||||
|
@ -143,3 +143,23 @@ export function validCheck(flow) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getRmainingDays(_resetDay) {
|
||||||
|
if (!_resetDay) return;
|
||||||
|
const resetDay = parseInt(_resetDay);
|
||||||
|
if (isNaN(resetDay) || resetDay <= 0 || resetDay > 31) return;
|
||||||
|
|
||||||
|
let now = new Date();
|
||||||
|
let today = now.getDate();
|
||||||
|
let month = now.getMonth();
|
||||||
|
let year = now.getFullYear();
|
||||||
|
let daysInMonth;
|
||||||
|
|
||||||
|
if (resetDay > today) {
|
||||||
|
daysInMonth = 0;
|
||||||
|
} else {
|
||||||
|
daysInMonth = new Date(year, month + 1, 0).getDate();
|
||||||
|
}
|
||||||
|
|
||||||
|
return daysInMonth - today + resetDay;
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user