diff --git a/lib/data/config.js b/lib/data/config.js index 9cf7449..a11f006 100644 --- a/lib/data/config.js +++ b/lib/data/config.js @@ -6,16 +6,16 @@ const config = { */ UIDs: [], + /** + * 监视的tag + */ + + TAGs: [], /** * 监视的专栏关键词 */ Articles: [], - /** - * 监视的tag - */ - TAGs: [], - /** * 从API接口中获取抽奖信息 * @typedef {object} LotteryInfo @@ -40,6 +40,18 @@ const config = { */ APIs: [], + /** + * 抽奖参与顺序组合 + * * 0 - UIDs + * * 1 - TAGs + * * 2 - Articles + * * 3 - APIs + * @example + * [3,2,1,0] + * [1,2,1,2,1] + */ + LotteryOrder: [2, 0, 1, 3], + /** * API发送数据类型 {LotteryInfo[]} * 上传抽奖信息的链接字符串 diff --git a/lib/data/global_var.js b/lib/data/global_var.js index 286cb0d..04c5780 100644 --- a/lib/data/global_var.js +++ b/lib/data/global_var.js @@ -1,8 +1,6 @@ const { getRemoteConfig, createDir, createFile } = require("../utils"); const config = require("../data/config"); -const key_map = new Map([['DedeUserID', 'myUID'], ['bili_jct', 'csrf']]); - let global_var = { inner: {}, get(key) { @@ -19,6 +17,16 @@ let global_var = { */ async init(cookie, num) { if (cookie) { + const + key_map = new Map([ + ['DedeUserID', 'myUID'], + ['bili_jct', 'csrf']]), + LotteryOrderMap = new Map([ + [0, "UIDs"], + [1, "TAGs"], + [2, "Articles"], + [3, "APIs"]]); + config.updata(num); this.set('cookie', cookie); @@ -29,13 +37,12 @@ let global_var = { this.set(key_map.get(_item[0]), _item[1]); }); - const { UIDs = [], TAGs = [], Articles = [], APIs = [] } = config; - this.set('Lottery', [ - ...UIDs.map(it => ['UIDs', it]), - ...TAGs.map(it => ['TAGs', it]), - ...Articles.map(it => ['Articles', it]), - ...APIs.map(it => ['APIs', it]) - ]); + const { LotteryOrder } = config; + this.set('Lottery', + LotteryOrder + .map(it => LotteryOrderMap.get(it)) + .filter(it => typeof it === "string") + .map(lottery_option => [lottery_option, config[lottery_option]])); this.set('remoteconfig', await getRemoteConfig()); } await createDir('dyids'); diff --git a/my_config.example.js b/my_config.example.js index d85ca5b..94d2aa4 100644 --- a/my_config.example.js +++ b/my_config.example.js @@ -11,13 +11,6 @@ module.exports = Object.freeze({ 241675899 ], - /** - * 监视的专栏关键词 - */ - Articles: [ - '抽奖合集' - ], - /** * 监视的tag */ @@ -28,6 +21,13 @@ module.exports = Object.freeze({ '抽奖', ], + /** + * 监视的专栏关键词 + */ + Articles: [ + '抽奖合集' + ], + /** * 从API接口中获取抽奖信息 * @typedef {object} LotteryInfo @@ -54,6 +54,18 @@ module.exports = Object.freeze({ */ APIs: [], + /** + * 抽奖参与顺序组合 + * * 0 - UIDs + * * 1 - TAGs + * * 2 - Articles + * * 3 - APIs + * @example + * [3,2,1,0] + * [1,2,1,2,1] + */ + LotteryOrder: [2, 0, 1, 3], + /** * API发送数据类型 {LotteryInfo[]} * 上传抽奖信息的链接字符串