karin-plugin-mys-core 1.0.10 → 1.0.12
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/README.md +1 -1
- package/lib/apps/MiHoYoLogin.js +6 -38
- package/lib/apps/MysDevice.js +5 -37
- package/lib/apps/UIDManage.js +6 -38
- package/lib/{chunk-JT3SU5UU.js → chunk-A5FZEOIN.js} +78 -6
- package/lib/{chunk-4BTKE3LO.js → chunk-HTL64YH2.js} +300 -178
- package/lib/chunk-IASM5MM5.js +639 -0
- package/lib/{chunk-5DXIT7UB.js → chunk-RX4VMVAI.js} +0 -5
- package/lib/{chunk-MQ52BX7O.js → chunk-SZHK7OGF.js} +9 -13
- package/lib/chunk-UIPRZFST.js +184 -0
- package/lib/exports/config/index.d.ts +56 -1
- package/lib/exports/config/index.js +3 -9
- package/lib/exports/database/index.d.ts +78 -12
- package/lib/exports/database/index.js +12 -40
- package/lib/exports/mys/index.d.ts +379 -14
- package/lib/exports/mys/index.js +9 -43
- package/lib/exports/render/index.d.ts +38 -4
- package/lib/exports/render/index.js +3 -8
- package/lib/exports/utils/index.d.ts +45 -2
- package/lib/exports/utils/index.js +1 -4
- package/lib/{exports/database/types/dbs/base.d.ts → mysUserInfo-BsyEENbc.d.ts} +60 -1
- package/package.json +1 -1
- package/resources/image/frame-logo.webp +0 -0
- package/resources/image/launcher-icon//345/216/237/347/245/236.webp +0 -0
- package/resources/image/launcher-icon//345/264/251/345/235/2173.webp +0 -0
- package/resources/image/launcher-icon//345/264/251/345/235/217/345/255/246/345/233/2552.webp +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.webp +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.webp +0 -0
- package/resources/image/launcher-icon//346/230/237/345/270/203/350/260/267/345/234/260.webp +0 -0
- package/resources/image/launcher-icon//346/234/252/345/256/232/344/272/213/344/273/266/347/260/277.webp +0 -0
- package/resources/image/launcher-icon//347/273/235/345/214/272/351/233/266.webp +0 -0
- package/resources/image/mys-core-logo.webp +0 -0
- package/resources/image/mys-logo.webp +0 -0
- package/resources/styles/karin-plugin-mys-core.css +4 -4
- package/lib/chunk-2BVJS5VE.js +0 -49
- package/lib/chunk-3ERB3ILC.js +0 -0
- package/lib/chunk-3JN5WYUN.js +0 -135
- package/lib/chunk-7KEG6SDX.js +0 -0
- package/lib/chunk-7VAWV6ZE.js +0 -0
- package/lib/chunk-ARLTXJFJ.js +0 -0
- package/lib/chunk-CFS2WFOO.js +0 -0
- package/lib/chunk-DMJ5OQR6.js +0 -73
- package/lib/chunk-EDNBKOMS.js +0 -30
- package/lib/chunk-FBWSEBAW.js +0 -0
- package/lib/chunk-FOAQZIZ2.js +0 -0
- package/lib/chunk-G5W5WAY5.js +0 -64
- package/lib/chunk-G7TMVDGP.js +0 -68
- package/lib/chunk-HJ6HX5HB.js +0 -29
- package/lib/chunk-I7XZONDN.js +0 -13
- package/lib/chunk-JRH4JC43.js +0 -0
- package/lib/chunk-JVJQKRJ4.js +0 -89
- package/lib/chunk-K5U2O3HH.js +0 -0
- package/lib/chunk-KQVWWGRH.js +0 -31
- package/lib/chunk-LBLGKL3W.js +0 -77
- package/lib/chunk-LJSDSOY6.js +0 -0
- package/lib/chunk-LYTNREAI.js +0 -0
- package/lib/chunk-MPZP23EX.js +0 -219
- package/lib/chunk-MWYDWDR4.js +0 -0
- package/lib/chunk-PMFOX5HA.js +0 -80
- package/lib/chunk-PYTECG57.js +0 -0
- package/lib/chunk-SEWEEPJN.js +0 -0
- package/lib/chunk-SHW6FHIB.js +0 -10
- package/lib/chunk-T7W4DXRM.js +0 -0
- package/lib/chunk-TTN7NFCA.js +0 -109
- package/lib/chunk-W4DBT7AD.js +0 -0
- package/lib/chunk-WCX7WZAQ.js +0 -0
- package/lib/chunk-Z5I6A73Y.js +0 -0
- package/lib/chunk-ZTOR2DXG.js +0 -38
- package/lib/common-BlI5Gsw_.d.ts +0 -35
- package/lib/define-B9r20dK6.d.ts +0 -130
- package/lib/exports/config/array.d.ts +0 -1
- package/lib/exports/config/array.js +0 -7
- package/lib/exports/config/config.d.ts +0 -56
- package/lib/exports/config/config.js +0 -12
- package/lib/exports/database/database.d.ts +0 -30
- package/lib/exports/database/database.js +0 -22
- package/lib/exports/database/dbs/base.d.ts +0 -25
- package/lib/exports/database/dbs/base.js +0 -19
- package/lib/exports/database/dbs/index.d.ts +0 -4
- package/lib/exports/database/dbs/index.js +0 -29
- package/lib/exports/database/dbs/sqlite3.d.ts +0 -27
- package/lib/exports/database/dbs/sqlite3.js +0 -23
- package/lib/exports/database/dbs/table.d.ts +0 -20
- package/lib/exports/database/dbs/table.js +0 -25
- package/lib/exports/database/tables/index.d.ts +0 -9
- package/lib/exports/database/tables/index.js +0 -40
- package/lib/exports/database/tables/mysAccountInfo.d.ts +0 -9
- package/lib/exports/database/tables/mysAccountInfo.js +0 -27
- package/lib/exports/database/tables/mysDeviceInfo.d.ts +0 -9
- package/lib/exports/database/tables/mysDeviceInfo.js +0 -27
- package/lib/exports/database/tables/mysUserInfo.d.ts +0 -9
- package/lib/exports/database/tables/mysUserInfo.js +0 -27
- package/lib/exports/database/types/database.d.ts +0 -6
- package/lib/exports/database/types/database.js +0 -1
- package/lib/exports/database/types/dbs/base.js +0 -11
- package/lib/exports/database/types/dbs/index.d.ts +0 -2
- package/lib/exports/database/types/dbs/index.js +0 -12
- package/lib/exports/database/types/index.d.ts +0 -6
- package/lib/exports/database/types/index.js +0 -24
- package/lib/exports/database/types/tables/index.d.ts +0 -5
- package/lib/exports/database/types/tables/index.js +0 -13
- package/lib/exports/database/types/tables/mysAccountInfo.d.ts +0 -14
- package/lib/exports/database/types/tables/mysAccountInfo.js +0 -7
- package/lib/exports/database/types/tables/mysDeviceInfo.d.ts +0 -19
- package/lib/exports/database/types/tables/mysDeviceInfo.js +0 -1
- package/lib/exports/database/types/tables/mysUserInfo.d.ts +0 -32
- package/lib/exports/database/types/tables/mysUserInfo.js +0 -7
- package/lib/exports/mys/api/apis.d.ts +0 -82
- package/lib/exports/mys/api/apis.js +0 -56
- package/lib/exports/mys/api/app.d.ts +0 -60
- package/lib/exports/mys/api/app.js +0 -32
- package/lib/exports/mys/api/define.d.ts +0 -6
- package/lib/exports/mys/api/define.js +0 -42
- package/lib/exports/mys/api/index.d.ts +0 -11
- package/lib/exports/mys/api/index.js +0 -63
- package/lib/exports/mys/types/api/define.d.ts +0 -6
- package/lib/exports/mys/types/api/define.js +0 -1
- package/lib/exports/mys/types/api/index.d.ts +0 -6
- package/lib/exports/mys/types/api/index.js +0 -2
- package/lib/exports/mys/types/index.d.ts +0 -12
- package/lib/exports/mys/types/index.js +0 -6
- package/lib/exports/mys/types/user/game.d.ts +0 -23
- package/lib/exports/mys/types/user/game.js +0 -1
- package/lib/exports/mys/types/user/index.d.ts +0 -12
- package/lib/exports/mys/types/user/index.js +0 -3
- package/lib/exports/mys/types/user/userInfo.d.ts +0 -42
- package/lib/exports/mys/types/user/userInfo.js +0 -1
- package/lib/exports/mys/user/deviceInfo.d.ts +0 -11
- package/lib/exports/mys/user/deviceInfo.js +0 -30
- package/lib/exports/mys/user/game.d.ts +0 -40
- package/lib/exports/mys/user/game.js +0 -9
- package/lib/exports/mys/user/index.d.ts +0 -14
- package/lib/exports/mys/user/index.js +0 -52
- package/lib/exports/mys/user/userInfo.d.ts +0 -53
- package/lib/exports/mys/user/userInfo.js +0 -44
- package/lib/exports/render/render.d.ts +0 -38
- package/lib/exports/render/render.js +0 -12
- package/lib/exports/utils/common.d.ts +0 -1
- package/lib/exports/utils/common.js +0 -15
- package/lib/exports/utils/types/common.d.ts +0 -11
- package/lib/exports/utils/types/common.js +0 -1
- package/lib/exports/utils/types/index.d.ts +0 -1
- package/lib/exports/utils/types/index.js +0 -2
- package/resources/image/frame-logo.png +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-core-logo.png +0 -0
- package/resources/image/mys-logo.png +0 -0
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
DefaultLayoutComponent,
|
|
3
|
-
React
|
|
4
|
-
} from "./chunk-JT3SU5UU.js";
|
|
5
|
-
import {
|
|
3
|
+
React,
|
|
6
4
|
ReactRender
|
|
7
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-A5FZEOIN.js";
|
|
8
6
|
import {
|
|
7
|
+
MysGame,
|
|
9
8
|
UserInfo
|
|
10
|
-
} from "./chunk-
|
|
11
|
-
import {
|
|
12
|
-
MysGame
|
|
13
|
-
} from "./chunk-2BVJS5VE.js";
|
|
9
|
+
} from "./chunk-HTL64YH2.js";
|
|
14
10
|
import {
|
|
15
11
|
dir
|
|
16
12
|
} from "./chunk-SHLPPEAY.js";
|
|
@@ -21,11 +17,11 @@ var ShowBindAccountComponent = ({
|
|
|
21
17
|
AccountList
|
|
22
18
|
}) => {
|
|
23
19
|
const plugin = Render.plugin;
|
|
24
|
-
return /* @__PURE__ */ React.createElement(DefaultLayoutComponent, {
|
|
20
|
+
return /* @__PURE__ */ React.createElement(DefaultLayoutComponent, { bg: "bg-[#f6f0e6]", width: "w-[600px]" }, /* @__PURE__ */ React.createElement("div", { className: "w-full px-[18px] pb-9 pt-5" }, /* @__PURE__ */ React.createElement(
|
|
25
21
|
"div",
|
|
26
22
|
{
|
|
27
23
|
className: "absolute -top-2.5 right-0 z-[5] h-[72px] w-[150px] bg-contain bg-center bg-no-repeat opacity-50",
|
|
28
|
-
style: { backgroundImage: `url('${plugin.resources.default}/image/mys-logo.
|
|
24
|
+
style: { backgroundImage: `url('${plugin.resources.default}/image/mys-logo.webp')` }
|
|
29
25
|
}
|
|
30
26
|
), /* @__PURE__ */ React.createElement("div", { className: "mb-3 flex items-center gap-2.5" }, /* @__PURE__ */ React.createElement("img", { className: "h-10 w-10 flex-none rounded-full object-cover", src: User.avatar, alt: "avatar" }), /* @__PURE__ */ React.createElement("span", { className: "min-w-0 overflow-anywhere break-words text-sm text-[#222]" }, User.nickname, " (", User.userId, ")")), AccountList && AccountList.length > 0 ? AccountList.map((account, idx) => /* @__PURE__ */ React.createElement(
|
|
31
27
|
"div",
|
|
@@ -33,7 +29,7 @@ var ShowBindAccountComponent = ({
|
|
|
33
29
|
className: "mb-3 flex flex-col gap-1.5 rounded-lg border border-black/[0.06] bg-white p-3 shadow-[0_2px_6px_rgba(0,0,0,0.04)]",
|
|
34
30
|
key: account.ltuid
|
|
35
31
|
},
|
|
36
|
-
/* @__PURE__ */ React.createElement("div", { className: "relative flex items-center justify-between gap-2" }, /* @__PURE__ */ React.createElement("span", { className: "flex text-sm font-semibold text-[#3f7dd1]" }, "MYS UID (", idx + 1, ")\uFF1A", account.ltuid), /* @__PURE__ */ React.createElement("div", { className: "flex items-center gap-2" }, account.permission >= 1 && /* @__PURE__ */ React.createElement("span", { className: "inline-block rounded-xl bg-gradient-to-b from-[#34bc5b] to-[#2ea94b] px-2 py-1 text-xs font-semibold text-white shadow-[0_1px_0_rgba(0,0,0,0.06)_inset]" }, "cookie"), account.permission >= 2 && /* @__PURE__ */ React.createElement("span", { className: "inline-block rounded-xl bg-gradient-to-b from-[#f6d86a] to-[#f1c40f] px-2 py-1 text-xs font-semibold text-black/85" }, "stoken"))),
|
|
32
|
+
/* @__PURE__ */ React.createElement("div", { className: "relative flex items-center justify-between gap-2" }, /* @__PURE__ */ React.createElement("span", { className: "flex text-sm font-semibold text-[#3f7dd1]" }, "MYS UID ( ", idx + 1, " )\uFF1A", account.ltuid), /* @__PURE__ */ React.createElement("div", { className: "flex items-center gap-2" }, account.permission >= 1 && /* @__PURE__ */ React.createElement("span", { className: "inline-block rounded-xl bg-gradient-to-b from-[#34bc5b] to-[#2ea94b] px-2 py-1 text-xs font-semibold text-white shadow-[0_1px_0_rgba(0,0,0,0.06)_inset]" }, "cookie"), account.permission >= 2 && /* @__PURE__ */ React.createElement("span", { className: "inline-block rounded-xl bg-gradient-to-b from-[#f6d86a] to-[#f1c40f] px-2 py-1 text-xs font-semibold text-black/85" }, "stoken"))),
|
|
37
33
|
account.bindUids.map((bindUid, bindIdx) => /* @__PURE__ */ React.createElement(
|
|
38
34
|
"div",
|
|
39
35
|
{
|
|
@@ -44,7 +40,7 @@ var ShowBindAccountComponent = ({
|
|
|
44
40
|
"img",
|
|
45
41
|
{
|
|
46
42
|
className: "flex w-10 items-center justify-center rounded-[10px]",
|
|
47
|
-
src: `${plugin.resources.default}/image/launcher-icon/${bindUid.gameName}.
|
|
43
|
+
src: `${plugin.resources.default}/image/launcher-icon/${bindUid.gameName}.webp`,
|
|
48
44
|
alt: bindUid.gameName
|
|
49
45
|
}
|
|
50
46
|
),
|
|
@@ -52,7 +48,7 @@ var ShowBindAccountComponent = ({
|
|
|
52
48
|
"span",
|
|
53
49
|
{
|
|
54
50
|
key: info.uid,
|
|
55
|
-
className: `relative flex items-center justify-center overflow-visible break-all rounded-lg bg-black/[0.06] px-2 py-1.5 text-[13px] font-semibold text-[#
|
|
51
|
+
className: `relative flex items-center justify-center overflow-visible break-all rounded-lg bg-black/[0.06] px-2 py-1.5 text-[13px] font-semibold text-[#34bc5b] ${info.perm === 4 ? "text-black/60 after:absolute after:left-[8%] after:right-[8%] after:top-1/2 after:h-px after:rounded-sm after:bg-[#d32f2f] after:-translate-y-1/2" : ""}`
|
|
56
52
|
},
|
|
57
53
|
info.uid
|
|
58
54
|
)))
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import {
|
|
2
|
+
common_exports
|
|
3
|
+
} from "./chunk-RX4VMVAI.js";
|
|
4
|
+
|
|
5
|
+
// src/exports/config/array.ts
|
|
6
|
+
import { logger } from "node-karin";
|
|
7
|
+
import lodash from "node-karin/lodash";
|
|
8
|
+
var EnhancedArray = class _EnhancedArray extends Array {
|
|
9
|
+
#keyPath;
|
|
10
|
+
#cfg;
|
|
11
|
+
constructor(cfg, items, path2) {
|
|
12
|
+
super();
|
|
13
|
+
Object.setPrototypeOf(this, _EnhancedArray.prototype);
|
|
14
|
+
if (Array.isArray(items)) {
|
|
15
|
+
this.push(...items);
|
|
16
|
+
}
|
|
17
|
+
this.#cfg = cfg;
|
|
18
|
+
this.#keyPath = path2;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* @param element - string | number
|
|
22
|
+
* @returns
|
|
23
|
+
*/
|
|
24
|
+
has(element) {
|
|
25
|
+
return new Set(this).has(element);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* @param isEqual 是否不添加重复元素
|
|
29
|
+
* @param save 是否立即保存
|
|
30
|
+
*/
|
|
31
|
+
add(element, isEqual, save) {
|
|
32
|
+
if (isEqual) {
|
|
33
|
+
const existingSet = new Set(this.map((item) => JSON.stringify(item)));
|
|
34
|
+
if (existingSet.has(JSON.stringify(element))) return this;
|
|
35
|
+
}
|
|
36
|
+
this.push(element);
|
|
37
|
+
this.#cfg.set(this.#keyPath, this.slice(), save);
|
|
38
|
+
return this;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* @param isEqual 是否不添加重复元素
|
|
42
|
+
* @param save 是否立即保存
|
|
43
|
+
*/
|
|
44
|
+
addSome(elements, isEqual, save) {
|
|
45
|
+
if (isEqual) {
|
|
46
|
+
const existingSet = new Set(this.map((item) => JSON.stringify(item)));
|
|
47
|
+
elements = elements.filter((element) => !existingSet.has(JSON.stringify(element)));
|
|
48
|
+
if (elements.length === 0) return this;
|
|
49
|
+
}
|
|
50
|
+
this.push(...elements);
|
|
51
|
+
this.#cfg.set(this.#keyPath, this.slice(), save);
|
|
52
|
+
return this;
|
|
53
|
+
}
|
|
54
|
+
/** @description 删除指定索引 */
|
|
55
|
+
pullAt(idx, save) {
|
|
56
|
+
if (idx < 0 || idx >= this.length) {
|
|
57
|
+
logger.error(`\u7D22\u5F15 ${idx} \u8D85\u51FA\u8303\u56F4 [0, ${this.length - 1}]`);
|
|
58
|
+
return this;
|
|
59
|
+
}
|
|
60
|
+
lodash.pullAt(this, idx);
|
|
61
|
+
this.#cfg.set(this.#keyPath, this.slice(), save);
|
|
62
|
+
return this;
|
|
63
|
+
}
|
|
64
|
+
/** @description 删除指定元素 */
|
|
65
|
+
pullAll(elements, save) {
|
|
66
|
+
lodash.pullAll(this, elements);
|
|
67
|
+
this.#cfg.set(this.#keyPath, this.slice(), save);
|
|
68
|
+
return this;
|
|
69
|
+
}
|
|
70
|
+
/** @description 使用条件函数删除元素 */
|
|
71
|
+
remove(predicate, save) {
|
|
72
|
+
lodash.remove(this, predicate);
|
|
73
|
+
this.#cfg.set(this.#keyPath, this.slice(), save);
|
|
74
|
+
return this;
|
|
75
|
+
}
|
|
76
|
+
clear() {
|
|
77
|
+
this.length = 0;
|
|
78
|
+
return this;
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
// src/exports/config/config.ts
|
|
83
|
+
import { existsSync, existToMkdirSync, logger as logger2, requireFileSync, watch, writeJsonSync } from "node-karin";
|
|
84
|
+
import lodash2 from "node-karin/lodash";
|
|
85
|
+
import path from "path";
|
|
86
|
+
var Config = class {
|
|
87
|
+
#cfgName;
|
|
88
|
+
/**
|
|
89
|
+
* @description 配置缓存
|
|
90
|
+
*/
|
|
91
|
+
#ConfigCache = null;
|
|
92
|
+
/**
|
|
93
|
+
* @description 默认配置
|
|
94
|
+
*/
|
|
95
|
+
#DefaultConfig;
|
|
96
|
+
#DefineConfig;
|
|
97
|
+
/**
|
|
98
|
+
* @description 配置保存路径
|
|
99
|
+
*/
|
|
100
|
+
#ConfigPath;
|
|
101
|
+
/**
|
|
102
|
+
* @param name 插件名称:配置名称
|
|
103
|
+
*/
|
|
104
|
+
constructor(name, ConfigDir, DefaultConfig, DefineConfig) {
|
|
105
|
+
this.#cfgName = name;
|
|
106
|
+
const splitName = name.split(":");
|
|
107
|
+
if (!splitName[1]) {
|
|
108
|
+
throw new Error("\u914D\u7F6E\u540D\u79F0\u683C\u5F0F\u9519\u8BEF\uFF0C\u5E94\u4E3A \u63D2\u4EF6\u540D\u79F0:\u914D\u7F6E\u540D\u79F0");
|
|
109
|
+
}
|
|
110
|
+
this.#ConfigPath = path.join(ConfigDir, `${splitName[1]}.json`);
|
|
111
|
+
this.#DefaultConfig = DefaultConfig;
|
|
112
|
+
this.#DefineConfig = DefineConfig;
|
|
113
|
+
existToMkdirSync(ConfigDir);
|
|
114
|
+
!existsSync(this.#ConfigPath) && writeJsonSync(this.#ConfigPath, DefaultConfig, true);
|
|
115
|
+
this.loadConfig();
|
|
116
|
+
}
|
|
117
|
+
loadConfig() {
|
|
118
|
+
const config = requireFileSync(this.#ConfigPath);
|
|
119
|
+
const mergedConfig = this.mergeWithDefaults(config, this.#DefaultConfig, this.#DefineConfig);
|
|
120
|
+
this.#ConfigCache = mergedConfig;
|
|
121
|
+
return mergedConfig;
|
|
122
|
+
}
|
|
123
|
+
mergeWithDefaults(userConfig, defaultConfig, DefineConfig) {
|
|
124
|
+
const filteredUserConfig = common_exports.filterData(userConfig, defaultConfig, DefineConfig);
|
|
125
|
+
const result = lodash2.merge({}, defaultConfig, filteredUserConfig);
|
|
126
|
+
if (!lodash2.isEqual(result, userConfig)) {
|
|
127
|
+
try {
|
|
128
|
+
writeJsonSync(this.#ConfigPath, result);
|
|
129
|
+
} catch (err) {
|
|
130
|
+
logger2.error(err);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return result;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* @description 获取配置路径对应的默认配置
|
|
137
|
+
*/
|
|
138
|
+
getDef(path2) {
|
|
139
|
+
const defConfig = JSON.parse(JSON.stringify(this.#DefaultConfig));
|
|
140
|
+
return lodash2.get(defConfig, path2);
|
|
141
|
+
}
|
|
142
|
+
get(path2, isArray = false, def) {
|
|
143
|
+
const conf = JSON.parse(JSON.stringify(this.#ConfigCache));
|
|
144
|
+
const result = path2 ? lodash2.get(conf, path2, def) : conf;
|
|
145
|
+
if (isArray) {
|
|
146
|
+
if (!Array.isArray(result)) {
|
|
147
|
+
logger2.error(`\u914D\u7F6E\u8DEF\u5F84 ${path2} \u4E0D\u662F\u6570\u7EC4\u7C7B\u578B`);
|
|
148
|
+
return new EnhancedArray(this, [], path2);
|
|
149
|
+
}
|
|
150
|
+
return new EnhancedArray(this, result, path2);
|
|
151
|
+
}
|
|
152
|
+
return result;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* @param save 是否立即保存
|
|
156
|
+
*/
|
|
157
|
+
set(path2, value, save) {
|
|
158
|
+
lodash2.set(this.#ConfigCache, path2, value);
|
|
159
|
+
save && this.save();
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* @description 立即保存配置
|
|
163
|
+
*/
|
|
164
|
+
save() {
|
|
165
|
+
try {
|
|
166
|
+
logger2.debug(`[${this.#cfgName}] \u4FDD\u5B58\u914D\u7F6E`, this.#ConfigCache);
|
|
167
|
+
writeJsonSync(this.#ConfigPath, this.#ConfigCache);
|
|
168
|
+
} catch (err) {
|
|
169
|
+
logger2.error(err);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
watch(fnc) {
|
|
173
|
+
watch(this.#ConfigPath, async (oldData, newData) => {
|
|
174
|
+
fnc && await fnc(this, oldData, newData);
|
|
175
|
+
this.loadConfig();
|
|
176
|
+
});
|
|
177
|
+
return this;
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
export {
|
|
182
|
+
EnhancedArray,
|
|
183
|
+
Config
|
|
184
|
+
};
|
|
@@ -1 +1,56 @@
|
|
|
1
|
-
|
|
1
|
+
declare class Config<C extends Record<string, any>> {
|
|
2
|
+
#private;
|
|
3
|
+
/**
|
|
4
|
+
* @param name 插件名称:配置名称
|
|
5
|
+
*/
|
|
6
|
+
constructor(name: `${string}:${string}`, ConfigDir: string, DefaultConfig: C, DefineConfig: Record<string, any>);
|
|
7
|
+
loadConfig(): C;
|
|
8
|
+
mergeWithDefaults(userConfig: C, defaultConfig: C, DefineConfig: Record<string, any>): C;
|
|
9
|
+
/**
|
|
10
|
+
* @description 获取配置路径对应的默认配置
|
|
11
|
+
*/
|
|
12
|
+
getDef<T>(path: string): T;
|
|
13
|
+
/**
|
|
14
|
+
* @description 获取配置路径对应的配置
|
|
15
|
+
*/
|
|
16
|
+
get<T>(path: string, isArray?: false, def?: T): T;
|
|
17
|
+
get<T>(path: string, isArray: true, def?: T[]): EnhancedArray<T>;
|
|
18
|
+
/**
|
|
19
|
+
* @param save 是否立即保存
|
|
20
|
+
*/
|
|
21
|
+
set<T>(path: string, value: T, save: boolean): void;
|
|
22
|
+
/**
|
|
23
|
+
* @description 立即保存配置
|
|
24
|
+
*/
|
|
25
|
+
save(): void;
|
|
26
|
+
watch(fnc?: (self: Config<C>, oldData: C, newData: C) => Promise<void> | void): this;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
declare class EnhancedArray<T> extends Array<T> {
|
|
30
|
+
#private;
|
|
31
|
+
constructor(cfg: Config<any>, items: T[], path: string);
|
|
32
|
+
/**
|
|
33
|
+
* @param element - string | number
|
|
34
|
+
* @returns
|
|
35
|
+
*/
|
|
36
|
+
has(element: T & (string | number)): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* @param isEqual 是否不添加重复元素
|
|
39
|
+
* @param save 是否立即保存
|
|
40
|
+
*/
|
|
41
|
+
add(element: T, isEqual: boolean, save: boolean): this;
|
|
42
|
+
/**
|
|
43
|
+
* @param isEqual 是否不添加重复元素
|
|
44
|
+
* @param save 是否立即保存
|
|
45
|
+
*/
|
|
46
|
+
addSome(elements: T[], isEqual: boolean, save: boolean): this;
|
|
47
|
+
/** @description 删除指定索引 */
|
|
48
|
+
pullAt(idx: number, save: boolean): this;
|
|
49
|
+
/** @description 删除指定元素 */
|
|
50
|
+
pullAll(elements: T[], save: boolean): this;
|
|
51
|
+
/** @description 使用条件函数删除元素 */
|
|
52
|
+
remove(predicate: (item: T) => boolean, save: boolean): this;
|
|
53
|
+
clear(): this;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export { Config, EnhancedArray };
|
|
@@ -1,14 +1,8 @@
|
|
|
1
|
-
import "../../chunk-3ERB3ILC.js";
|
|
2
|
-
import {
|
|
3
|
-
Config
|
|
4
|
-
} from "../../chunk-TTN7NFCA.js";
|
|
5
|
-
import "../../chunk-ARLTXJFJ.js";
|
|
6
|
-
import "../../chunk-PYTECG57.js";
|
|
7
|
-
import "../../chunk-T7W4DXRM.js";
|
|
8
|
-
import "../../chunk-5DXIT7UB.js";
|
|
9
1
|
import {
|
|
2
|
+
Config,
|
|
10
3
|
EnhancedArray
|
|
11
|
-
} from "../../chunk-
|
|
4
|
+
} from "../../chunk-UIPRZFST.js";
|
|
5
|
+
import "../../chunk-RX4VMVAI.js";
|
|
12
6
|
import "../../chunk-MLKGABMK.js";
|
|
13
7
|
export {
|
|
14
8
|
Config,
|
|
@@ -1,12 +1,78 @@
|
|
|
1
|
-
|
|
2
|
-
export {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import { D as DatabaseType, a as DatabaseClassInstance, b as Dialect, c as DatabaseClassStatic, M as ModelAttributes, d as DatabaseReturn, e as MysAccountInfoTableType, f as MysDeviceInfoTableType, B as BaseUserInfoTableType, g as BaseGameUIDInfoTableType } from '../../mysUserInfo-BsyEENbc.js';
|
|
2
|
+
export { l as BindUidsItemType, h as DatabaseArray, i as MysAccountType, j as MysDeviceInfoDatabaseBaseType, k as MysDeviceInfoDatabaseIdFpType, U as UidPermission } from '../../mysUserInfo-BsyEENbc.js';
|
|
3
|
+
import { DataTypes, ModelAttributeColumnOptions, Model, ModelStatic } from 'sequelize';
|
|
4
|
+
|
|
5
|
+
type DatabaseFn = <T extends Record<string, any>, D extends DatabaseType>() => DatabaseClassInstance<T, D>;
|
|
6
|
+
|
|
7
|
+
declare const Database: {
|
|
8
|
+
"__#private@#defaultDialect": Dialect;
|
|
9
|
+
"__#private@#DatabaseMap": Map<Dialect, {
|
|
10
|
+
Database: DatabaseFn;
|
|
11
|
+
Static: DatabaseClassStatic;
|
|
12
|
+
}>;
|
|
13
|
+
default(dialect: Dialect): void;
|
|
14
|
+
/** @description 添加数据库 */
|
|
15
|
+
Add(Db: DatabaseFn, Static: DatabaseClassStatic): Promise<void>;
|
|
16
|
+
get Db(): {
|
|
17
|
+
Database: DatabaseFn;
|
|
18
|
+
Static: DatabaseClassStatic;
|
|
19
|
+
};
|
|
20
|
+
get details(): {
|
|
21
|
+
dialect: Dialect;
|
|
22
|
+
desc: string;
|
|
23
|
+
}[];
|
|
24
|
+
/** @description 获取当前使用的数据库 */
|
|
25
|
+
get<T extends Record<string, any>, D extends DatabaseType>(): DatabaseClassInstance<T, D>;
|
|
26
|
+
get PkColumn(): (type: keyof typeof DataTypes, option?: Partial<ModelAttributeColumnOptions<Model>>) => ModelAttributeColumnOptions<Model>;
|
|
27
|
+
get Column(): DatabaseClassStatic["Column"];
|
|
28
|
+
get ArrayColumn(): DatabaseClassStatic["ArrayColumn"];
|
|
29
|
+
get JsonColumn(): DatabaseClassStatic["JsonColumn"];
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
declare class DbBase<T extends Record<string, any>, D extends DatabaseType> {
|
|
33
|
+
primaryKey: keyof T | undefined;
|
|
34
|
+
model: ModelStatic<Model> | undefined;
|
|
35
|
+
databasePath: string;
|
|
36
|
+
databaseType: D;
|
|
37
|
+
modelName: string;
|
|
38
|
+
modelSchema: ModelAttributes<Model, T>;
|
|
39
|
+
modelSchemaDefine: Partial<Record<keyof T, any>>;
|
|
40
|
+
initBase(DataDir: string, modelName: string, modelSchema: ModelAttributes<Model, T>, modelSchemaDefine: Partial<Record<keyof T, any>>, type: D, primaryKey?: keyof T): void;
|
|
41
|
+
schemaToJSON(pk: string): T;
|
|
42
|
+
userPath(pk: string): string;
|
|
43
|
+
readSync(path: string, pk: string): DatabaseReturn<T>[DatabaseType.File];
|
|
44
|
+
readDirSync(pk: string): DatabaseReturn<T>[DatabaseType.Dir];
|
|
45
|
+
writeDirSync(pk: string, data: Record<string, any>): boolean;
|
|
46
|
+
saveFile(pk: string): (data: T) => Promise<DatabaseReturn<T>[DatabaseType.File]>;
|
|
47
|
+
saveDir(pk: string): (data: T) => Promise<DatabaseReturn<T>[DatabaseType.Dir]>;
|
|
48
|
+
destroyPath(pk: string): Promise<boolean>;
|
|
49
|
+
saveSql(model: Model<any, any>, pk: string): (data: Partial<T>) => Promise<DatabaseReturn<T>[DatabaseType.Db]>;
|
|
50
|
+
destroySql(pk: string): Promise<boolean>;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
declare class Table<TableType extends Record<string, any>, ExtraTableType extends Record<string, any> = {}, DBType extends DatabaseType = DatabaseType> {
|
|
54
|
+
#private;
|
|
55
|
+
initCache: DatabaseClassInstance<TableType, DBType>;
|
|
56
|
+
modelSchema: ModelAttributes<Model, TableType>;
|
|
57
|
+
modelSchemaDefine: Partial<Record<keyof TableType, any>>;
|
|
58
|
+
/**
|
|
59
|
+
* @param type Db: 直接保存在sqlite数据中、 File: 保存在单个json文件中、 Dir: 保存在多个json文件的目录中、Schema中除pk外每一个键值对应一个文件 e.g tableName/user/key.json
|
|
60
|
+
*/
|
|
61
|
+
constructor(DataDir: string, tableName: string, type: DBType, primaryKey?: keyof TableType);
|
|
62
|
+
init(Schema: ModelAttributes<Model, TableType>, SchemaDefine?: Partial<Record<keyof TableType, any>>): Promise<() => Promise<DatabaseClassInstance<TableType, DBType>>>;
|
|
63
|
+
addSchem<newTableType extends ExtraTableType>(newSchema: ModelAttributes<Model, newTableType>, SchemaDefine?: Partial<Record<keyof newTableType, any>>): Promise<() => Promise<DatabaseClassInstance<TableType & newTableType, DBType>>>;
|
|
64
|
+
}
|
|
65
|
+
declare function createTable<TableType extends Record<string, any>, ExtraTableType extends Record<string, any> = {}>(DataDir: string, tableName: string, type: DatabaseType.File, primaryKey: keyof TableType): Table<TableType, ExtraTableType, DatabaseType.File>;
|
|
66
|
+
declare function createTable<TableType extends Record<string, any>, ExtraTableType extends Record<string, any> = {}>(DataDir: string, tableName: string, type: DatabaseType.Dir, primaryKey: keyof TableType): Table<TableType, ExtraTableType, DatabaseType.Dir>;
|
|
67
|
+
declare function createTable<TableType extends Record<string, any>, ExtraTableType extends Record<string, any> = {}>(DataDir: string, tableName: string, type: DatabaseType.Db, primaryKey?: keyof TableType): Table<TableType, ExtraTableType, DatabaseType.Db>;
|
|
68
|
+
|
|
69
|
+
declare const MysAccountInfoTable: Table<MysAccountInfoTableType, {}, DatabaseType.Db>;
|
|
70
|
+
declare const MysAccountInfoDB: () => Promise<DatabaseClassInstance<MysAccountInfoTableType, DatabaseType.Db>>;
|
|
71
|
+
|
|
72
|
+
declare const MysDeviceInfoTable: Table<MysDeviceInfoTableType, {}, DatabaseType.Db>;
|
|
73
|
+
declare const MysDeviceInfoDB: () => Promise<DatabaseClassInstance<MysDeviceInfoTableType, DatabaseType.Db>>;
|
|
74
|
+
|
|
75
|
+
declare const MysUserInfoTable: Table<BaseUserInfoTableType, BaseGameUIDInfoTableType<string>, DatabaseType.Db>;
|
|
76
|
+
declare const MysUserInfoDB: () => Promise<DatabaseClassInstance<BaseUserInfoTableType, DatabaseType.Db>>;
|
|
77
|
+
|
|
78
|
+
export { BaseGameUIDInfoTableType, BaseUserInfoTableType, Database, DatabaseClassInstance, DatabaseClassStatic, type DatabaseFn, DatabaseReturn, DatabaseType, DbBase, Dialect, ModelAttributes, MysAccountInfoDB, MysAccountInfoTable, MysAccountInfoTableType, MysDeviceInfoDB, MysDeviceInfoTable, MysDeviceInfoTableType, MysUserInfoDB, MysUserInfoTable, Table, createTable };
|
|
@@ -1,50 +1,22 @@
|
|
|
1
|
-
import "../../chunk-W4DBT7AD.js";
|
|
2
|
-
import "../../chunk-Z5I6A73Y.js";
|
|
3
1
|
import {
|
|
2
|
+
Database,
|
|
3
|
+
DatabaseArray,
|
|
4
|
+
DatabaseType,
|
|
5
|
+
DbBase,
|
|
6
|
+
Dialect,
|
|
4
7
|
MysAccountInfoDB,
|
|
5
|
-
MysAccountInfoTable
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
+
MysAccountInfoTable,
|
|
9
|
+
MysAccountType,
|
|
8
10
|
MysDeviceInfoDB,
|
|
9
|
-
MysDeviceInfoTable
|
|
10
|
-
} from "../../chunk-ZTOR2DXG.js";
|
|
11
|
-
import {
|
|
11
|
+
MysDeviceInfoTable,
|
|
12
12
|
MysUserInfoDB,
|
|
13
|
-
MysUserInfoTable
|
|
14
|
-
} from "../../chunk-HJ6HX5HB.js";
|
|
15
|
-
import "../../chunk-SEWEEPJN.js";
|
|
16
|
-
import {
|
|
13
|
+
MysUserInfoTable,
|
|
17
14
|
Table,
|
|
15
|
+
UidPermission,
|
|
18
16
|
createTable
|
|
19
|
-
} from "../../chunk-
|
|
20
|
-
import {
|
|
21
|
-
Database
|
|
22
|
-
} from "../../chunk-DMJ5OQR6.js";
|
|
23
|
-
import "../../chunk-MPZP23EX.js";
|
|
24
|
-
import {
|
|
25
|
-
DbBase
|
|
26
|
-
} from "../../chunk-3JN5WYUN.js";
|
|
27
|
-
import "../../chunk-7KEG6SDX.js";
|
|
28
|
-
import "../../chunk-FBWSEBAW.js";
|
|
29
|
-
import {
|
|
30
|
-
DatabaseArray,
|
|
31
|
-
DatabaseType,
|
|
32
|
-
Dialect
|
|
33
|
-
} from "../../chunk-JVJQKRJ4.js";
|
|
34
|
-
import "../../chunk-LYTNREAI.js";
|
|
35
|
-
import {
|
|
36
|
-
MysAccountType
|
|
37
|
-
} from "../../chunk-SHW6FHIB.js";
|
|
38
|
-
import "../../chunk-K5U2O3HH.js";
|
|
39
|
-
import {
|
|
40
|
-
UidPermission
|
|
41
|
-
} from "../../chunk-I7XZONDN.js";
|
|
42
|
-
import "../../chunk-JRH4JC43.js";
|
|
17
|
+
} from "../../chunk-IASM5MM5.js";
|
|
43
18
|
import "../../chunk-SHLPPEAY.js";
|
|
44
|
-
import "../../chunk-
|
|
45
|
-
import "../../chunk-PYTECG57.js";
|
|
46
|
-
import "../../chunk-T7W4DXRM.js";
|
|
47
|
-
import "../../chunk-5DXIT7UB.js";
|
|
19
|
+
import "../../chunk-RX4VMVAI.js";
|
|
48
20
|
import "../../chunk-MLKGABMK.js";
|
|
49
21
|
export {
|
|
50
22
|
Database,
|