karin-plugin-mys-core 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +674 -0
- package/lib/apps/MiHoYoLogin.d.ts +3 -1
- package/lib/apps/MiHoYoLogin.js +177 -109
- package/lib/apps/MysDevice.d.ts +2 -2
- package/lib/apps/MysDevice.js +65 -23
- package/lib/apps/UIDManage.d.ts +10 -0
- package/lib/apps/UIDManage.js +52 -0
- package/lib/array-CZDr9qst.d.ts +62 -0
- package/lib/chunk-2DHTKQ34.js +0 -0
- package/lib/chunk-3BIQN6QA.js +27 -0
- package/lib/chunk-3CNBOOKY.js +31 -0
- package/lib/chunk-5NA7ZPDS.js +54 -0
- package/lib/chunk-6PIXUPZ6.js +82 -0
- package/lib/chunk-7KEG6SDX.js +0 -0
- package/lib/chunk-7SZX3RBZ.js +0 -0
- package/lib/chunk-7VAWV6ZE.js +0 -0
- package/lib/chunk-7WESXE4X.js +29 -0
- package/lib/chunk-7YZHHLS5.js +130 -0
- package/lib/chunk-ARLTXJFJ.js +0 -0
- package/lib/chunk-CFS2WFOO.js +0 -0
- package/lib/chunk-EMAUATE3.js +217 -0
- package/lib/chunk-FBWSEBAW.js +0 -0
- package/lib/chunk-FOAQZIZ2.js +0 -0
- package/lib/chunk-G547WVGV.js +73 -0
- package/lib/chunk-G5W5WAY5.js +64 -0
- package/lib/chunk-HVYNK5BN.js +45 -0
- package/lib/chunk-I7XZONDN.js +13 -0
- package/lib/chunk-IVZICDGW.js +19 -0
- package/lib/chunk-JBGXPVO2.js +179 -0
- package/lib/chunk-JRH4JC43.js +0 -0
- package/lib/chunk-JVJQKRJ4.js +89 -0
- package/lib/chunk-K5U2O3HH.js +0 -0
- package/lib/chunk-KN5SHBVI.js +30 -0
- package/lib/chunk-LG34FPBI.js +50 -0
- package/lib/chunk-LJSDSOY6.js +0 -0
- package/lib/chunk-LYTNREAI.js +0 -0
- package/lib/chunk-MWYDWDR4.js +0 -0
- package/lib/chunk-QMSYS77M.js +38 -0
- package/lib/chunk-SEWEEPJN.js +0 -0
- package/lib/{chunk-JML6VYXN.js → chunk-SHLPPEAY.js} +13 -17
- package/lib/chunk-SHW6FHIB.js +10 -0
- package/lib/chunk-W4DBT7AD.js +0 -0
- package/lib/chunk-X75DW4KI.js +510 -0
- package/lib/chunk-XQWTJIT4.js +0 -0
- package/lib/chunk-Y3J3J5B2.js +124 -0
- package/lib/chunk-Z5I6A73Y.js +0 -0
- package/lib/common-Dw5l6Uud.d.ts +33 -0
- package/lib/define-BWuQ7acM.d.ts +131 -0
- package/lib/dir.d.ts +11 -13
- package/lib/dir.js +1 -1
- package/lib/exports/config/array.d.ts +1 -0
- package/lib/exports/config/array.js +7 -0
- package/lib/exports/config/config.d.ts +1 -0
- package/lib/exports/config/config.js +8 -0
- package/lib/exports/config/index.d.ts +2 -0
- package/lib/exports/config/index.js +14 -0
- package/lib/exports/config/types/config.d.ts +12 -0
- package/lib/exports/config/types/config.js +1 -0
- package/lib/exports/config/types/index.d.ts +1 -0
- package/lib/exports/config/types/index.js +2 -0
- package/lib/exports/database/database.d.ts +30 -0
- package/lib/exports/database/database.js +18 -0
- package/lib/exports/database/dbs/base.d.ts +23 -0
- package/lib/exports/database/dbs/base.js +15 -0
- package/lib/exports/database/dbs/index.d.ts +4 -0
- package/lib/exports/database/dbs/index.js +23 -0
- package/lib/exports/database/dbs/sqlite3.d.ts +23 -0
- package/lib/exports/database/dbs/sqlite3.js +19 -0
- package/lib/exports/database/dbs/table.d.ts +13 -0
- package/lib/exports/database/dbs/table.js +19 -0
- package/lib/exports/database/index.d.ts +12 -0
- package/lib/exports/database/index.js +62 -0
- package/lib/exports/database/tables/index.d.ts +9 -0
- package/lib/exports/database/tables/index.js +39 -0
- package/lib/exports/database/tables/mysAccountInfo.d.ts +9 -0
- package/lib/exports/database/tables/mysAccountInfo.js +23 -0
- package/lib/exports/database/tables/mysDeviceInfo.d.ts +9 -0
- package/lib/exports/database/tables/mysDeviceInfo.js +26 -0
- package/lib/exports/database/tables/mysUserInfo.d.ts +9 -0
- package/lib/exports/database/tables/mysUserInfo.js +23 -0
- package/lib/exports/database/types/database.d.ts +6 -0
- package/lib/exports/database/types/database.js +1 -0
- package/lib/exports/database/types/dbs/base.d.ts +114 -0
- package/lib/exports/database/types/dbs/base.js +11 -0
- package/lib/exports/database/types/dbs/index.d.ts +2 -0
- package/lib/exports/database/types/dbs/index.js +12 -0
- package/lib/exports/database/types/index.d.ts +6 -0
- package/lib/exports/database/types/index.js +24 -0
- package/lib/exports/database/types/tables/index.d.ts +5 -0
- package/lib/exports/database/types/tables/index.js +13 -0
- package/lib/exports/database/types/tables/mysAccountInfo.d.ts +14 -0
- package/lib/exports/database/types/tables/mysAccountInfo.js +7 -0
- package/lib/exports/database/types/tables/mysDeviceInfo.d.ts +19 -0
- package/lib/exports/database/types/tables/mysDeviceInfo.js +1 -0
- package/lib/exports/database/types/tables/mysUserInfo.d.ts +31 -0
- package/lib/exports/database/types/tables/mysUserInfo.js +7 -0
- package/lib/exports/mys/api/apis.d.ts +82 -0
- package/lib/exports/mys/api/apis.js +57 -0
- package/lib/exports/mys/api/app.d.ts +60 -0
- package/lib/exports/mys/api/app.js +31 -0
- package/lib/exports/mys/api/define.d.ts +6 -0
- package/lib/exports/mys/api/define.js +43 -0
- package/lib/exports/mys/api/index.d.ts +11 -0
- package/lib/exports/mys/api/index.js +64 -0
- package/lib/exports/mys/index.d.ts +13 -0
- package/lib/exports/mys/index.js +77 -0
- package/lib/exports/mys/types/api/define.d.ts +6 -0
- package/lib/exports/mys/types/api/define.js +1 -0
- package/lib/exports/mys/types/api/index.d.ts +6 -0
- package/lib/exports/mys/types/api/index.js +2 -0
- package/lib/exports/mys/types/index.d.ts +10 -0
- package/lib/exports/mys/types/index.js +12 -0
- package/lib/exports/mys/types/user/game.d.ts +10 -0
- package/lib/exports/mys/types/user/game.js +1 -0
- package/lib/exports/mys/types/user/index.d.ts +10 -0
- package/lib/exports/mys/types/user/index.js +9 -0
- package/lib/exports/mys/types/user/userInfo.d.ts +10 -0
- package/lib/exports/mys/types/user/userInfo.js +7 -0
- package/lib/exports/mys/user/deviceInfo.d.ts +11 -0
- package/lib/exports/mys/user/deviceInfo.js +29 -0
- package/lib/exports/mys/user/game.d.ts +20 -0
- package/lib/exports/mys/user/game.js +7 -0
- package/lib/exports/mys/user/index.d.ts +12 -0
- package/lib/exports/mys/user/index.js +51 -0
- package/lib/exports/mys/user/userInfo.d.ts +10 -0
- package/lib/exports/mys/user/userInfo.js +45 -0
- package/lib/exports/utils/common.d.ts +1 -0
- package/lib/exports/utils/common.js +13 -0
- package/lib/exports/utils/index.d.ts +2 -0
- package/lib/exports/utils/index.js +12 -0
- package/lib/exports/utils/render.d.ts +21 -0
- package/lib/exports/utils/render.js +7 -0
- package/lib/index-DEEWbZ0V.d.ts +102 -0
- package/lib/index.js +1 -1
- package/package.json +29 -15
- package/resources/fonts/HYWenHei-55W.ttf +0 -0
- package/resources/image/launcher-icon//345/216/237/347/245/236.png +0 -0
- package/resources/image/launcher-icon//345/264/251/345/235/2173.png +0 -0
- package/resources/image/launcher-icon//345/264/251/345/235/217/345/255/246/345/233/2552.png +0 -0
- package/resources/image/launcher-icon//345/264/251/345/235/217/357/274/232/345/233/240/347/274/230/347/262/276/347/201/265.png +0 -0
- package/resources/image/launcher-icon//345/264/251/345/235/217/357/274/232/346/230/237/347/251/271/351/223/201/351/201/223.png +0 -0
- package/resources/image/launcher-icon//346/230/237/345/270/203/350/260/267/345/234/260.png +0 -0
- package/resources/image/launcher-icon//346/234/252/345/256/232/344/272/213/344/273/266/347/260/277.png +0 -0
- package/resources/image/launcher-icon//347/273/235/345/214/272/351/233/266.png +0 -0
- package/resources/image/mys-logo.png +0 -0
- package/resources/template/ShowBindAccount/index.css +1 -0
- package/resources/template/ShowBindAccount/index.html +65 -0
- package/resources/template/ShowBindDevice/index.html +20 -0
- package/resources/template/ShowBindDevice/inex.css +1 -0
- package/resources/template/layout/default.css +1 -0
- package/resources/template/layout/default.html +27 -0
- package/lib/app.d.ts +0 -2
- package/lib/base-BJv9XnQP.d.ts +0 -120
- package/lib/chunk-CQNW7LJI.js +0 -38
- package/lib/chunk-MV2UE7C7.js +0 -410
- package/lib/chunk-NHUNEZXM.js +0 -371
- package/lib/chunk-WYRIRWT5.js +0 -213
- package/lib/database-byVXw91u.d.ts +0 -5
- package/lib/define-pa_pWNWT.d.ts +0 -182
- package/lib/exports/core.d.ts +0 -249
- package/lib/exports/core.js +0 -45
- package/lib/exports/database.d.ts +0 -48
- package/lib/exports/database.js +0 -20
- package/lib/exports/types.d.ts +0 -5
- package/lib/exports/types.js +0 -13
- package/lib/index.d.ts +0 -2
- package/lib/web.config.d.ts +0 -5
- package/lib/web.config.js +0 -55
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import {
|
|
2
|
+
MysDeviceInfoDB
|
|
3
|
+
} from "./chunk-QMSYS77M.js";
|
|
4
|
+
|
|
5
|
+
// src/exports/mys/user/deviceInfo.ts
|
|
6
|
+
import md5 from "md5";
|
|
7
|
+
var DeviceInfo = class {
|
|
8
|
+
static async get(Md5) {
|
|
9
|
+
return await (await MysDeviceInfoDB()).findByPk(Md5);
|
|
10
|
+
}
|
|
11
|
+
static async create(userId, deviceInfo) {
|
|
12
|
+
const deviceMd5 = md5([
|
|
13
|
+
userId,
|
|
14
|
+
deviceInfo.deviceId || "",
|
|
15
|
+
deviceInfo.name || "",
|
|
16
|
+
deviceInfo.board || "",
|
|
17
|
+
deviceInfo.model || "",
|
|
18
|
+
deviceInfo.oaid || "",
|
|
19
|
+
deviceInfo.version || "",
|
|
20
|
+
deviceInfo.fingerprint || "",
|
|
21
|
+
deviceInfo.product || ""
|
|
22
|
+
].join("_"));
|
|
23
|
+
const MysDeviceInfo = await (await MysDeviceInfoDB()).findByPk(deviceMd5, true);
|
|
24
|
+
await MysDeviceInfo.save(deviceInfo);
|
|
25
|
+
return deviceMd5;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export {
|
|
30
|
+
DeviceInfo
|
|
31
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Database
|
|
3
|
+
} from "./chunk-G547WVGV.js";
|
|
4
|
+
|
|
5
|
+
// src/exports/database/dbs/table.ts
|
|
6
|
+
var Table = class {
|
|
7
|
+
#dialect;
|
|
8
|
+
#Database;
|
|
9
|
+
#DataDir;
|
|
10
|
+
#tableName;
|
|
11
|
+
#type;
|
|
12
|
+
constructor(DataDir, tableName, type) {
|
|
13
|
+
this.#Database = Database.get();
|
|
14
|
+
this.#dialect = this.#Database.dialect;
|
|
15
|
+
this.#DataDir = DataDir;
|
|
16
|
+
this.#tableName = tableName;
|
|
17
|
+
this.#type = type;
|
|
18
|
+
}
|
|
19
|
+
#cache() {
|
|
20
|
+
return async () => {
|
|
21
|
+
const Db = Database.get();
|
|
22
|
+
if (Db.dialect !== this.#dialect) {
|
|
23
|
+
this.#dialect = Db.dialect;
|
|
24
|
+
this.#Database = Db;
|
|
25
|
+
await this.init(this.modelSchema);
|
|
26
|
+
}
|
|
27
|
+
return this.initCache;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
async init(Schema) {
|
|
31
|
+
this.modelSchema = Schema;
|
|
32
|
+
this.initCache = await this.#Database.init(
|
|
33
|
+
this.#DataDir,
|
|
34
|
+
this.#tableName,
|
|
35
|
+
this.modelSchema,
|
|
36
|
+
this.#type
|
|
37
|
+
);
|
|
38
|
+
return this.#cache();
|
|
39
|
+
}
|
|
40
|
+
async addSchem(newSchema) {
|
|
41
|
+
this.modelSchema = Object.assign(this.modelSchema, newSchema);
|
|
42
|
+
this.initCache = await this.#Database.init(
|
|
43
|
+
this.#DataDir,
|
|
44
|
+
this.#tableName,
|
|
45
|
+
this.modelSchema,
|
|
46
|
+
this.#type
|
|
47
|
+
);
|
|
48
|
+
return this.#cache();
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export {
|
|
53
|
+
Table
|
|
54
|
+
};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// src/exports/config/array.ts
|
|
2
|
+
import { logger } from "node-karin";
|
|
3
|
+
import lodash from "node-karin/lodash";
|
|
4
|
+
var EnhancedArray = class _EnhancedArray extends Array {
|
|
5
|
+
#keyPath;
|
|
6
|
+
#cfg;
|
|
7
|
+
constructor(cfg, items, path) {
|
|
8
|
+
super();
|
|
9
|
+
Object.setPrototypeOf(this, _EnhancedArray.prototype);
|
|
10
|
+
if (Array.isArray(items)) {
|
|
11
|
+
this.push(...items);
|
|
12
|
+
}
|
|
13
|
+
this.#cfg = cfg;
|
|
14
|
+
this.#keyPath = path;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* @param element - string | number
|
|
18
|
+
* @returns
|
|
19
|
+
*/
|
|
20
|
+
has(element) {
|
|
21
|
+
return new Set(this).has(element);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* @param isEqual 是否不添加重复元素
|
|
25
|
+
* @param save 是否立即保存
|
|
26
|
+
*/
|
|
27
|
+
add(element, isEqual, save) {
|
|
28
|
+
if (isEqual) {
|
|
29
|
+
const existingSet = new Set(this.map((item) => JSON.stringify(item)));
|
|
30
|
+
if (existingSet.has(JSON.stringify(element))) return this;
|
|
31
|
+
}
|
|
32
|
+
this.push(element);
|
|
33
|
+
this.#cfg.set(this.#keyPath, this.slice(), save);
|
|
34
|
+
return this;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* @param isEqual 是否不添加重复元素
|
|
38
|
+
* @param save 是否立即保存
|
|
39
|
+
*/
|
|
40
|
+
addSome(elements, isEqual, save) {
|
|
41
|
+
if (isEqual) {
|
|
42
|
+
const existingSet = new Set(this.map((item) => JSON.stringify(item)));
|
|
43
|
+
elements = elements.filter((element) => !existingSet.has(JSON.stringify(element)));
|
|
44
|
+
if (elements.length === 0) return this;
|
|
45
|
+
}
|
|
46
|
+
this.push(...elements);
|
|
47
|
+
this.#cfg.set(this.#keyPath, this.slice(), save);
|
|
48
|
+
return this;
|
|
49
|
+
}
|
|
50
|
+
remove(predicate, save, isIndex = false) {
|
|
51
|
+
if (isIndex && lodash.isNumber(predicate)) {
|
|
52
|
+
if (predicate < 0 || predicate >= this.length) {
|
|
53
|
+
logger.error(`\u7D22\u5F15 ${predicate} \u8D85\u51FA\u8303\u56F4 [0, ${this.length - 1}]`);
|
|
54
|
+
return this;
|
|
55
|
+
}
|
|
56
|
+
lodash.pullAt(this, predicate);
|
|
57
|
+
} else if (lodash.isFunction(predicate)) {
|
|
58
|
+
lodash.remove(this, predicate);
|
|
59
|
+
} else {
|
|
60
|
+
lodash.pull(this, predicate);
|
|
61
|
+
}
|
|
62
|
+
this.#cfg.set(this.#keyPath, this.slice(), save);
|
|
63
|
+
return this;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* @param predicate - 要删除的元素数组
|
|
67
|
+
* @param save - 是否立即保存
|
|
68
|
+
*/
|
|
69
|
+
removeSome(elements, save) {
|
|
70
|
+
lodash.pullAll(this, elements);
|
|
71
|
+
this.#cfg.set(this.#keyPath, this.slice(), save);
|
|
72
|
+
return this;
|
|
73
|
+
}
|
|
74
|
+
clear() {
|
|
75
|
+
this.length = 0;
|
|
76
|
+
return this;
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export {
|
|
81
|
+
EnhancedArray
|
|
82
|
+
};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Table
|
|
3
|
+
} from "./chunk-5NA7ZPDS.js";
|
|
4
|
+
import {
|
|
5
|
+
Database
|
|
6
|
+
} from "./chunk-G547WVGV.js";
|
|
7
|
+
import {
|
|
8
|
+
dir
|
|
9
|
+
} from "./chunk-SHLPPEAY.js";
|
|
10
|
+
|
|
11
|
+
// src/exports/database/tables/mysUserInfo.ts
|
|
12
|
+
var MysUserInfoTable = new Table(
|
|
13
|
+
dir.DataDir,
|
|
14
|
+
"mys_user_info_data",
|
|
15
|
+
"db" /* Db */
|
|
16
|
+
);
|
|
17
|
+
var MysUserInfoDB = await MysUserInfoTable.init(
|
|
18
|
+
{
|
|
19
|
+
userId: Database.PkColumn("STRING"),
|
|
20
|
+
ltuids: Database.ArrayColumn("ltuids"),
|
|
21
|
+
stuids: Database.ArrayColumn("stuids"),
|
|
22
|
+
deviceList: Database.ArrayColumn("deviceList")
|
|
23
|
+
}
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
export {
|
|
27
|
+
MysUserInfoTable,
|
|
28
|
+
MysUserInfoDB
|
|
29
|
+
};
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import {
|
|
2
|
+
EnhancedArray
|
|
3
|
+
} from "./chunk-6PIXUPZ6.js";
|
|
4
|
+
|
|
5
|
+
// src/exports/config/config.ts
|
|
6
|
+
import { existsSync, logger, requireFileSync, watch, writeJsonSync } from "node-karin";
|
|
7
|
+
import lodash from "node-karin/lodash";
|
|
8
|
+
var Config = class {
|
|
9
|
+
#cfgName;
|
|
10
|
+
/**
|
|
11
|
+
* @description 配置缓存
|
|
12
|
+
*/
|
|
13
|
+
#ConfigCache = null;
|
|
14
|
+
/**
|
|
15
|
+
* @description 默认配置
|
|
16
|
+
*/
|
|
17
|
+
#DefaultConfig;
|
|
18
|
+
#IgnoreConfig;
|
|
19
|
+
/**
|
|
20
|
+
* @description 配置保存路径
|
|
21
|
+
*/
|
|
22
|
+
#ConfigPath;
|
|
23
|
+
/**
|
|
24
|
+
* @param name 插件名称:配置名称
|
|
25
|
+
*/
|
|
26
|
+
constructor(name, ConfigPath, DefaultConfig, IgnoreConfig) {
|
|
27
|
+
this.#cfgName = name;
|
|
28
|
+
this.#ConfigPath = ConfigPath;
|
|
29
|
+
this.#DefaultConfig = DefaultConfig;
|
|
30
|
+
this.#IgnoreConfig = IgnoreConfig;
|
|
31
|
+
!existsSync(ConfigPath) && writeJsonSync(ConfigPath, DefaultConfig);
|
|
32
|
+
this.loadConfig();
|
|
33
|
+
}
|
|
34
|
+
loadConfig() {
|
|
35
|
+
const config = requireFileSync(this.#ConfigPath);
|
|
36
|
+
const mergedConfig = this.mergeWithDefaults(config, this.#DefaultConfig, this.#IgnoreConfig);
|
|
37
|
+
this.#ConfigCache = mergedConfig;
|
|
38
|
+
return mergedConfig;
|
|
39
|
+
}
|
|
40
|
+
mergeWithDefaults(userConfig, defaultConfig, IgnoreConfig) {
|
|
41
|
+
const filterUserConfig = (user, defaults, Ignore) => {
|
|
42
|
+
if (Array.isArray(user) && Array.isArray(defaults)) {
|
|
43
|
+
if (Ignore?.defaultConfigItem) {
|
|
44
|
+
const filtered = [];
|
|
45
|
+
const required = Ignore.defaultConfigItem.required;
|
|
46
|
+
user.forEach((value, key) => {
|
|
47
|
+
if (required && lodash.isPlainObject(value)) {
|
|
48
|
+
const hasAllRequired = required.every((requiredKey) => requiredKey in value && value[requiredKey] !== void 0 && value[requiredKey] !== null && value[requiredKey] !== "");
|
|
49
|
+
if (!hasAllRequired) return;
|
|
50
|
+
}
|
|
51
|
+
filtered[key] = filterUserConfig(value, Ignore.defaultConfigItem.defaultConfig, Ignore.defaultConfigItem.defaultConfig);
|
|
52
|
+
});
|
|
53
|
+
return filtered;
|
|
54
|
+
}
|
|
55
|
+
return user;
|
|
56
|
+
} else if (lodash.isPlainObject(user) && lodash.isPlainObject(defaults)) {
|
|
57
|
+
const filtered = {};
|
|
58
|
+
const mergedValue = lodash.merge({}, defaults, user);
|
|
59
|
+
if (Ignore?.defaultConfig) {
|
|
60
|
+
lodash.forEach(user, (value, key) => {
|
|
61
|
+
const mergedValue2 = lodash.merge(Array.isArray(value) ? [] : {}, Ignore.defaultConfig, value);
|
|
62
|
+
filtered[key] = filterUserConfig(mergedValue2, Ignore.defaultConfig, Array.isArray(value) ? Ignore : Ignore[key]);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
lodash.forEach(defaults, (value, key) => {
|
|
66
|
+
filtered[key] = filterUserConfig(mergedValue[key], value, Ignore?.[key]);
|
|
67
|
+
});
|
|
68
|
+
return filtered;
|
|
69
|
+
}
|
|
70
|
+
return user;
|
|
71
|
+
};
|
|
72
|
+
const filteredUserConfig = filterUserConfig(userConfig, defaultConfig, IgnoreConfig);
|
|
73
|
+
const result = lodash.merge({}, defaultConfig, filteredUserConfig);
|
|
74
|
+
if (!lodash.isEqual(result, userConfig)) {
|
|
75
|
+
try {
|
|
76
|
+
writeJsonSync(this.#ConfigPath, result);
|
|
77
|
+
} catch (err) {
|
|
78
|
+
logger.error(err);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return result;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* @description 获取配置路径对应的默认配置
|
|
85
|
+
*/
|
|
86
|
+
getDef(path) {
|
|
87
|
+
const defConfig = JSON.parse(JSON.stringify(this.#DefaultConfig));
|
|
88
|
+
return lodash.get(defConfig, path);
|
|
89
|
+
}
|
|
90
|
+
get(path, isArray = false, def) {
|
|
91
|
+
const conf = JSON.parse(JSON.stringify(this.#ConfigCache));
|
|
92
|
+
const result = path ? lodash.get(conf, path, def) : conf;
|
|
93
|
+
if (isArray) {
|
|
94
|
+
if (!Array.isArray(result)) {
|
|
95
|
+
logger.error(`\u914D\u7F6E\u8DEF\u5F84 ${path} \u4E0D\u662F\u6570\u7EC4\u7C7B\u578B`);
|
|
96
|
+
return new EnhancedArray(this, [], path);
|
|
97
|
+
}
|
|
98
|
+
return new EnhancedArray(this, result, path);
|
|
99
|
+
}
|
|
100
|
+
return result;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* @param save 是否立即保存
|
|
104
|
+
*/
|
|
105
|
+
set(path, value, save) {
|
|
106
|
+
lodash.set(this.#ConfigCache, path, value);
|
|
107
|
+
save && this.save();
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* @description 立即保存配置
|
|
111
|
+
*/
|
|
112
|
+
save() {
|
|
113
|
+
try {
|
|
114
|
+
logger.debug(`[${this.#cfgName}] \u4FDD\u5B58\u914D\u7F6E`, this.#ConfigCache);
|
|
115
|
+
writeJsonSync(this.#ConfigPath, this.#ConfigCache);
|
|
116
|
+
} catch (err) {
|
|
117
|
+
logger.error(err);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
watch() {
|
|
121
|
+
watch(this.#ConfigPath, () => {
|
|
122
|
+
this.loadConfig();
|
|
123
|
+
});
|
|
124
|
+
return this;
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
export {
|
|
129
|
+
Config
|
|
130
|
+
};
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DbBase
|
|
3
|
+
} from "./chunk-Y3J3J5B2.js";
|
|
4
|
+
import {
|
|
5
|
+
DatabaseArray
|
|
6
|
+
} from "./chunk-JVJQKRJ4.js";
|
|
7
|
+
import {
|
|
8
|
+
dir
|
|
9
|
+
} from "./chunk-SHLPPEAY.js";
|
|
10
|
+
|
|
11
|
+
// src/exports/database/dbs/sqlite3.ts
|
|
12
|
+
import { existsSync, json, logger, mkdirSync, rmSync } from "node-karin";
|
|
13
|
+
import fs from "fs";
|
|
14
|
+
import path from "path";
|
|
15
|
+
import { DataTypes, Op, Sequelize } from "sequelize";
|
|
16
|
+
var dialect = "sqlite" /* Sqlite */;
|
|
17
|
+
var sequelize = new Sequelize({
|
|
18
|
+
storage: path.join(dir.DataDir, "database", "sqlite3.db"),
|
|
19
|
+
dialect,
|
|
20
|
+
logging: false
|
|
21
|
+
});
|
|
22
|
+
var Sqlite3 = class extends DbBase {
|
|
23
|
+
dialect = dialect;
|
|
24
|
+
async check() {
|
|
25
|
+
try {
|
|
26
|
+
await sequelize.authenticate();
|
|
27
|
+
return true;
|
|
28
|
+
} catch (error) {
|
|
29
|
+
logger.error(error);
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
async init(DataDir, modelName, modelSchema, type) {
|
|
34
|
+
this.initBase(DataDir, modelName, modelSchema, type);
|
|
35
|
+
if (this.databaseType === "db" /* Db */) {
|
|
36
|
+
this.model = sequelize.define(this.modelName, this.modelSchema, {
|
|
37
|
+
timestamps: false,
|
|
38
|
+
freezeTableName: true
|
|
39
|
+
});
|
|
40
|
+
await this.model.sync();
|
|
41
|
+
const queryInterface = sequelize.getQueryInterface();
|
|
42
|
+
const tableDescription = await queryInterface.describeTable(this.modelName);
|
|
43
|
+
for (const key in this.modelSchema) {
|
|
44
|
+
if (!tableDescription[key]) {
|
|
45
|
+
await queryInterface.addColumn(this.modelName, key, this.modelSchema[key]);
|
|
46
|
+
if (typeof this.modelSchema[key] === "string") continue;
|
|
47
|
+
const defaultValue = this.modelSchema[key].defaultValue;
|
|
48
|
+
if (defaultValue !== void 0) {
|
|
49
|
+
await this.model.update({ [key]: defaultValue }, { where: {} });
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return this;
|
|
55
|
+
}
|
|
56
|
+
async findByPk(pk, create = false) {
|
|
57
|
+
if (this.databaseType !== "db" /* Db */) {
|
|
58
|
+
const path2 = this.userPath(pk);
|
|
59
|
+
if (!existsSync(path2)) {
|
|
60
|
+
if (create) {
|
|
61
|
+
const data = this.schemaToJSON(pk);
|
|
62
|
+
if (this.databaseType === "dir" /* Dir */) {
|
|
63
|
+
mkdirSync(path2);
|
|
64
|
+
this.writeDirSync(pk, data);
|
|
65
|
+
return {
|
|
66
|
+
...data,
|
|
67
|
+
save: this.saveDir(pk),
|
|
68
|
+
destroy: () => this.destroyPath(pk)
|
|
69
|
+
};
|
|
70
|
+
} else {
|
|
71
|
+
json.writeSync(path2, data);
|
|
72
|
+
return {
|
|
73
|
+
...data,
|
|
74
|
+
save: this.saveFile(pk),
|
|
75
|
+
destroy: () => this.destroyPath(pk)
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return void 0;
|
|
80
|
+
}
|
|
81
|
+
if (this.databaseType === "dir" /* Dir */) {
|
|
82
|
+
return this.readDirSync(pk);
|
|
83
|
+
} else {
|
|
84
|
+
return this.readSync(path2, pk);
|
|
85
|
+
}
|
|
86
|
+
} else {
|
|
87
|
+
let result = await this.model.findByPk(pk);
|
|
88
|
+
if (!result && create) {
|
|
89
|
+
result = await this.model.create(this.schemaToJSON(pk));
|
|
90
|
+
}
|
|
91
|
+
if (!result) return void 0;
|
|
92
|
+
return {
|
|
93
|
+
...result.toJSON(),
|
|
94
|
+
save: this.saveSql(result, pk),
|
|
95
|
+
destroy: () => this.destroySql(pk)
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
async findAllByPks(pks) {
|
|
100
|
+
if (this.databaseType !== "db" /* Db */) {
|
|
101
|
+
const result = [];
|
|
102
|
+
pks.forEach((pk) => {
|
|
103
|
+
const path2 = this.userPath(pk);
|
|
104
|
+
if (existsSync(path2)) {
|
|
105
|
+
if (this.databaseType === "dir" /* Dir */) {
|
|
106
|
+
result.push(this.readDirSync(pk));
|
|
107
|
+
} else {
|
|
108
|
+
result.push(this.readSync(path2, pk));
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
return result;
|
|
113
|
+
} else {
|
|
114
|
+
const result = await this.model.findAll({
|
|
115
|
+
where: {
|
|
116
|
+
[this.model.primaryKeyAttribute]: pks
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
return result.map((item) => ({
|
|
120
|
+
...item.toJSON(),
|
|
121
|
+
save: this.saveSql(item, item[this.model.primaryKeyAttribute]),
|
|
122
|
+
destroy: () => this.destroySql(item[this.model.primaryKeyAttribute])
|
|
123
|
+
}));
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
async findAll(excludePks) {
|
|
127
|
+
const excludeSet = new Set(excludePks || []);
|
|
128
|
+
if (this.databaseType !== "db" /* Db */) {
|
|
129
|
+
const result = [];
|
|
130
|
+
const files = fs.readdirSync(this.databasePath);
|
|
131
|
+
if (this.databaseType === "dir" /* Dir */) {
|
|
132
|
+
files.forEach((file) => {
|
|
133
|
+
if (excludeSet.has(file)) return;
|
|
134
|
+
const stat = fs.statSync(path.join(this.databasePath, file));
|
|
135
|
+
if (stat.isDirectory()) {
|
|
136
|
+
result.push(this.readDirSync(file));
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
} else {
|
|
140
|
+
files.forEach((file) => {
|
|
141
|
+
if (!file.endsWith(".json")) return;
|
|
142
|
+
const pk = file.replace(".json", "");
|
|
143
|
+
if (excludeSet.has(pk)) return;
|
|
144
|
+
result.push(this.readSync(this.userPath(pk), pk));
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
return result;
|
|
148
|
+
} else {
|
|
149
|
+
const whereClause = excludePks && excludePks.length > 0 ? { [this.model.primaryKeyAttribute]: { [Op.notIn]: excludePks } } : {};
|
|
150
|
+
const result = await this.model.findAll({ where: whereClause });
|
|
151
|
+
return result.map((item) => ({
|
|
152
|
+
...item.toJSON(),
|
|
153
|
+
save: this.saveSql(item, item[this.model.primaryKeyAttribute]),
|
|
154
|
+
destroy: () => this.destroySql(item[this.model.primaryKeyAttribute])
|
|
155
|
+
}));
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
async destroy(pk) {
|
|
159
|
+
if (this.databaseType !== "db" /* Db */) {
|
|
160
|
+
rmSync(this.userPath(pk), { recursive: true });
|
|
161
|
+
return true;
|
|
162
|
+
} else {
|
|
163
|
+
const destroyed = await this.model.destroy({
|
|
164
|
+
where: { [this.model.primaryKeyAttribute]: pk }
|
|
165
|
+
});
|
|
166
|
+
return destroyed > 0;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
var Sqlite3Static = new class Sqlite3Static2 {
|
|
171
|
+
dialect = dialect;
|
|
172
|
+
description = "\u63D2\u4EF6\u9ED8\u8BA4\u6570\u636E\u5E93";
|
|
173
|
+
Column(type, def, option) {
|
|
174
|
+
return {
|
|
175
|
+
type: DataTypes[type],
|
|
176
|
+
defaultValue: def,
|
|
177
|
+
...option
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
ArrayColumn(key, fn) {
|
|
181
|
+
return {
|
|
182
|
+
type: DataTypes.STRING,
|
|
183
|
+
defaultValue: [].join(","),
|
|
184
|
+
get() {
|
|
185
|
+
const data = this.getDataValue(key).split(",").filter(Boolean);
|
|
186
|
+
return new DatabaseArray(data);
|
|
187
|
+
},
|
|
188
|
+
set(data) {
|
|
189
|
+
const setData = (fn ? fn(data) : data) || [];
|
|
190
|
+
this.setDataValue(key, setData.join(","));
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
JsonColumn(key, def) {
|
|
195
|
+
return {
|
|
196
|
+
type: DataTypes.STRING,
|
|
197
|
+
defaultValue: JSON.stringify(def),
|
|
198
|
+
get() {
|
|
199
|
+
let data = this.getDataValue(key);
|
|
200
|
+
try {
|
|
201
|
+
data = JSON.parse(data) || def;
|
|
202
|
+
} catch (e) {
|
|
203
|
+
data = def;
|
|
204
|
+
}
|
|
205
|
+
return data;
|
|
206
|
+
},
|
|
207
|
+
set(data) {
|
|
208
|
+
this.setDataValue(key, JSON.stringify(data));
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
}();
|
|
213
|
+
|
|
214
|
+
export {
|
|
215
|
+
Sqlite3,
|
|
216
|
+
Sqlite3Static
|
|
217
|
+
};
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Sqlite3,
|
|
3
|
+
Sqlite3Static
|
|
4
|
+
} from "./chunk-EMAUATE3.js";
|
|
5
|
+
|
|
6
|
+
// src/exports/database/database.ts
|
|
7
|
+
import { logger } from "node-karin";
|
|
8
|
+
import { DataTypes } from "sequelize";
|
|
9
|
+
var Database = new class DatabaseClass {
|
|
10
|
+
#defaultDialect = "sqlite" /* Sqlite */;
|
|
11
|
+
#DatabaseMap = /* @__PURE__ */ new Map();
|
|
12
|
+
default(dialect) {
|
|
13
|
+
const db = this.#DatabaseMap.get(dialect);
|
|
14
|
+
if (!db) {
|
|
15
|
+
logger.error(`\u672A\u627E\u5230\u6570\u636E\u5E93: ${dialect}\uFF01\u4F7F\u7528\u9ED8\u8BA4\u6570\u636E\u5E93\u3002`);
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
this.#defaultDialect = dialect;
|
|
19
|
+
}
|
|
20
|
+
/** @description 添加数据库 */
|
|
21
|
+
async Add(Db, Static) {
|
|
22
|
+
const db = Db();
|
|
23
|
+
if (await db.check()) {
|
|
24
|
+
this.#DatabaseMap.set(Static.dialect, { Database: Db, Static });
|
|
25
|
+
} else {
|
|
26
|
+
logger.error(`${Static.dialect} check failed!`);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
get Db() {
|
|
30
|
+
const dialect = this.#defaultDialect;
|
|
31
|
+
const db = this.#DatabaseMap.get(dialect);
|
|
32
|
+
if (!db) {
|
|
33
|
+
logger.error(`\u672A\u627E\u5230\u6570\u636E\u5E93: ${dialect}\uFF01\u4F7F\u7528\u9ED8\u8BA4\u6570\u636E\u5E93\u3002`);
|
|
34
|
+
return this.#DatabaseMap.get("sqlite" /* Sqlite */);
|
|
35
|
+
}
|
|
36
|
+
return db;
|
|
37
|
+
}
|
|
38
|
+
get details() {
|
|
39
|
+
return Array.from(this.#DatabaseMap.entries()).map(([dialect, { Static }]) => ({
|
|
40
|
+
dialect,
|
|
41
|
+
desc: Static.description
|
|
42
|
+
}));
|
|
43
|
+
}
|
|
44
|
+
/** @description 获取当前使用的数据库 */
|
|
45
|
+
get() {
|
|
46
|
+
return this.Db.Database();
|
|
47
|
+
}
|
|
48
|
+
get PkColumn() {
|
|
49
|
+
return (type, option) => ({
|
|
50
|
+
type: DataTypes[type],
|
|
51
|
+
primaryKey: true,
|
|
52
|
+
allowNull: false,
|
|
53
|
+
...option
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
get Column() {
|
|
57
|
+
return this.Db.Static.Column;
|
|
58
|
+
}
|
|
59
|
+
get ArrayColumn() {
|
|
60
|
+
return this.Db.Static.ArrayColumn;
|
|
61
|
+
}
|
|
62
|
+
get JsonColumn() {
|
|
63
|
+
return this.Db.Static.JsonColumn;
|
|
64
|
+
}
|
|
65
|
+
}();
|
|
66
|
+
await Database.Add(
|
|
67
|
+
() => new Sqlite3(),
|
|
68
|
+
Sqlite3Static
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
export {
|
|
72
|
+
Database
|
|
73
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// src/exports/mys/api/app.ts
|
|
2
|
+
var version = { cn: "2.70.1", os: "1.5.0" };
|
|
3
|
+
var appId = 2;
|
|
4
|
+
var salt = {
|
|
5
|
+
os: "6cqshh5dhw73bzxn20oexa9k516chk7s",
|
|
6
|
+
"4X": "xV8v4Qu54lUKrEYFZkJhB8cuOh9Asafs",
|
|
7
|
+
"6X": "t0qEgfub6cvueAPgR5m9aQWWVciEer7v",
|
|
8
|
+
K2: "S9Hrn38d2b55PamfIR9BNA3Tx9sQTOem",
|
|
9
|
+
LK2: "sjdNFJB7XxyDWGIAk0eTV8AOCfMJmyEo",
|
|
10
|
+
PROD: "JwYDpKvLj6MrMqqYU6jTKF17KNO2PXoS"
|
|
11
|
+
};
|
|
12
|
+
var MysApp = Object.freeze({
|
|
13
|
+
version,
|
|
14
|
+
appId,
|
|
15
|
+
salt
|
|
16
|
+
});
|
|
17
|
+
var MysHosts = Object.freeze({
|
|
18
|
+
bbs: {
|
|
19
|
+
["mihoyo" /* cn */]: "https://bbs-api.miyoushe.com/",
|
|
20
|
+
["hoyolab" /* os */]: "https://bbs-api-os.mihoyo.com/"
|
|
21
|
+
},
|
|
22
|
+
web: {
|
|
23
|
+
["mihoyo" /* cn */]: "https://api-takumi.mihoyo.com/",
|
|
24
|
+
["hoyolab" /* os */]: "https://api-os-takumi.mihoyo.com/",
|
|
25
|
+
/** new web host */
|
|
26
|
+
miyoushe: "https://api-takumi.miyoushe.com/"
|
|
27
|
+
},
|
|
28
|
+
static: "https://api-takumi-static.mihoyo.com/",
|
|
29
|
+
record: {
|
|
30
|
+
["mihoyo" /* cn */]: "https://api-takumi-record.mihoyo.com/",
|
|
31
|
+
["hoyolab" /* os */]: "https://bbs-api-os.mihoyo.com/"
|
|
32
|
+
},
|
|
33
|
+
hk4e: {
|
|
34
|
+
["mihoyo" /* cn */]: "https://hk4e-api.mihoyo.com/",
|
|
35
|
+
["hoyolab" /* os */]: "https://hk4e-api-os.hoyoverse.com/"
|
|
36
|
+
},
|
|
37
|
+
hk4eGacha: "https://public-operation-hk4e.mihoyo.com/",
|
|
38
|
+
hk4eSdk: "https://hk4e-sdk.mihoyo.com/",
|
|
39
|
+
napGacha: {
|
|
40
|
+
["mihoyo" /* cn */]: "https://public-operation-nap.mihoyo.com/",
|
|
41
|
+
["hoyolab" /* os */]: "https://public-operation-nap-sg.hoyoverse.com/"
|
|
42
|
+
},
|
|
43
|
+
publicData: {
|
|
44
|
+
["mihoyo" /* cn */]: "https://public-data-api.mihoyo.com/",
|
|
45
|
+
["hoyolab" /* os */]: "https://sg-public-data-api.hoyoverse.com/"
|
|
46
|
+
},
|
|
47
|
+
napAct: {
|
|
48
|
+
["mihoyo" /* cn */]: "https://act-nap-api.mihoyo.com/",
|
|
49
|
+
["hoyolab" /* os */]: "https://sg-act-nap-api.mihoyo.com/"
|
|
50
|
+
},
|
|
51
|
+
passport: "https://passport-api.mihoyo.com/",
|
|
52
|
+
hk4eSg: {
|
|
53
|
+
["hoyolab" /* os */]: "https://sg-hk4e-api.hoyolab.com/"
|
|
54
|
+
},
|
|
55
|
+
publicSg: {
|
|
56
|
+
["hoyolab" /* os */]: "https://sg-public-api.hoyolab.com/",
|
|
57
|
+
hoyoverse: "https://sg-public-api.hoyoverse.com/"
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
export {
|
|
62
|
+
MysApp,
|
|
63
|
+
MysHosts
|
|
64
|
+
};
|