karin-plugin-mys-core 1.0.14 → 1.0.19

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.
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  ShowBindAccountCmdFunc
3
- } from "../chunk-KJAYW3SO.js";
4
- import "../chunk-A5FZEOIN.js";
3
+ } from "../chunk-I3VGZG6L.js";
4
+ import "../chunk-S3ALDDWH.js";
5
5
  import {
6
6
  UserInfo,
7
7
  fetchQRcode,
@@ -9,14 +9,15 @@ import {
9
9
  getTokenByGameToken,
10
10
  getUserFullInfo,
11
11
  queryQRcode
12
- } from "../chunk-V2MCX7HT.js";
13
- import "../chunk-IASM5MM5.js";
14
- import "../chunk-YFMJTWDG.js";
15
- import "../chunk-SHLPPEAY.js";
16
- import "../chunk-UIPRZFST.js";
12
+ } from "../chunk-JYQZZKAO.js";
13
+ import "../chunk-5LRGHP36.js";
14
+ import "../chunk-PX6NFB3F.js";
15
+ import "../chunk-F7ZAG53H.js";
16
+ import "../chunk-ER4WMJJ6.js";
17
17
  import {
18
18
  common_exports
19
19
  } from "../chunk-RX4VMVAI.js";
20
+ import "../chunk-SHLPPEAY.js";
20
21
  import "../chunk-MLKGABMK.js";
21
22
 
22
23
  // src/apps/MiHoYoLogin.ts
@@ -226,6 +227,7 @@ var BindCookie = async (userId, cookieObj, perm, Serv) => {
226
227
  return {
227
228
  Serv: Serv || "mihoyo" /* cn */,
228
229
  uids: [],
230
+ mains: [],
229
231
  message: errMsg.pop() || ""
230
232
  };
231
233
  })();
@@ -249,6 +251,10 @@ var BindCookie = async (userId, cookieObj, perm, Serv) => {
249
251
  acc[cur.columnKey] = cur.data;
250
252
  return acc;
251
253
  }, {}),
254
+ ...uidList.mains.reduce((acc, cur) => {
255
+ acc[cur.columnKey] = cur.data;
256
+ return acc;
257
+ }, {}),
252
258
  ltuids: userInfo.ltuids.add(cookieParams.ltuid, true)
253
259
  });
254
260
  await userInfo.saveMysAccountInfo(cookieParams.ltuid, {
@@ -1,12 +1,13 @@
1
1
  import {
2
2
  DeviceInfo,
3
3
  UserInfo
4
- } from "../chunk-V2MCX7HT.js";
5
- import "../chunk-IASM5MM5.js";
6
- import "../chunk-YFMJTWDG.js";
7
- import "../chunk-SHLPPEAY.js";
8
- import "../chunk-UIPRZFST.js";
4
+ } from "../chunk-JYQZZKAO.js";
5
+ import "../chunk-5LRGHP36.js";
6
+ import "../chunk-PX6NFB3F.js";
7
+ import "../chunk-F7ZAG53H.js";
8
+ import "../chunk-ER4WMJJ6.js";
9
9
  import "../chunk-RX4VMVAI.js";
10
+ import "../chunk-SHLPPEAY.js";
10
11
  import "../chunk-MLKGABMK.js";
11
12
 
12
13
  // src/apps/MysDevice.ts
@@ -19,13 +20,13 @@ var BindMysDevice = karin.command(
19
20
  const cnLtuidInfoList = ltuidInfoList.filter((info) => info.type === "mihoyo" /* cn */);
20
21
  if (cnLtuidInfoList.length === 0) {
21
22
  if (ltuidInfoList.length === 0) {
22
- e.reply("\u6682\u672A\u7ED1\u5B9A\u56FD\u670D\u7C73\u6E38\u793E\u8D26\u53F7\uFF0C\u8BF7\u5148\u201C#\u7C73\u6E38\u793E\u7ED1\u5B9A\u201D\u8FDB\u884C\u7ED1\u5B9A\uFF01", { at: true });
23
+ e.reply("\u6682\u672A\u7ED1\u5B9A\u56FD\u670D\u7C73\u6E38\u793E\u8D26\u53F7\uFF0C\u8BF7\u5148\u4F7F\u7528 \u201C#\u7C73\u6E38\u793E\u767B\u5F55\u201D \u8FDB\u884C\u7ED1\u5B9A\uFF01", { at: true });
23
24
  } else {
24
25
  e.reply("\u56FD\u9645\u670D\u6682\u4E0D\u9700\u8981\u7ED1\u5B9A\u8BBE\u5907\u3002", { at: true });
25
26
  }
26
27
  return true;
27
28
  }
28
- e.reply("\u8BF7\u53D1\u9001\u8BBE\u5907\u4FE1\u606F(\u5EFA\u8BAE\u79C1\u804A\u53D1\u9001)\uFF0C\u6216\u8005\u53D1\u9001\u201C\u53D6\u6D88\u201D\u53D6\u6D88\u7ED1\u5B9A", { at: true });
29
+ e.reply("\u8BF7\u53D1\u9001\u8BBE\u5907\u4FE1\u606F(\u5EFA\u8BAE\u79C1\u804A\u53D1\u9001)\uFF0C\u6216\u8005\u53D1\u9001 \u201C\u53D6\u6D88\u201D \u53D6\u6D88\u7ED1\u5B9A", { at: true });
29
30
  const ctx = await karin.ctx(e);
30
31
  if (/^#?取消(绑定)?/.test(ctx.msg)) {
31
32
  e.reply("\u5DF2\u53D6\u6D88\u7ED1\u5B9A", { at: true });
@@ -1,20 +1,23 @@
1
1
  import {
2
2
  BindUID,
3
+ ChangeMainUID,
3
4
  ShowBindAccount,
4
5
  ShowBindAccountCmdFunc,
5
6
  UnbindAccount,
6
7
  UnbindUID
7
- } from "../chunk-KJAYW3SO.js";
8
- import "../chunk-A5FZEOIN.js";
9
- import "../chunk-V2MCX7HT.js";
10
- import "../chunk-IASM5MM5.js";
11
- import "../chunk-YFMJTWDG.js";
12
- import "../chunk-SHLPPEAY.js";
13
- import "../chunk-UIPRZFST.js";
8
+ } from "../chunk-I3VGZG6L.js";
9
+ import "../chunk-S3ALDDWH.js";
10
+ import "../chunk-JYQZZKAO.js";
11
+ import "../chunk-5LRGHP36.js";
12
+ import "../chunk-PX6NFB3F.js";
13
+ import "../chunk-F7ZAG53H.js";
14
+ import "../chunk-ER4WMJJ6.js";
14
15
  import "../chunk-RX4VMVAI.js";
16
+ import "../chunk-SHLPPEAY.js";
15
17
  import "../chunk-MLKGABMK.js";
16
18
  export {
17
19
  BindUID,
20
+ ChangeMainUID,
18
21
  ShowBindAccount,
19
22
  ShowBindAccountCmdFunc,
20
23
  UnbindAccount,
File without changes
@@ -132,30 +132,25 @@ var Config = class {
132
132
  }
133
133
  return result;
134
134
  }
135
- /**
136
- * @description 获取配置路径对应的默认配置
137
- */
138
135
  getDef(path2) {
139
136
  const defConfig = JSON.parse(JSON.stringify(this.#DefaultConfig));
140
137
  return lodash2.get(defConfig, path2);
141
138
  }
142
139
  get(path2, isArray = false, def) {
143
140
  const conf = JSON.parse(JSON.stringify(this.#ConfigCache));
144
- const result = path2 ? lodash2.get(conf, path2, def) : conf;
141
+ const pathStr = String(path2);
142
+ const result = pathStr ? lodash2.get(conf, pathStr, def) : conf;
145
143
  if (isArray) {
146
144
  if (!Array.isArray(result)) {
147
- logger2.error(`\u914D\u7F6E\u8DEF\u5F84 ${path2} \u4E0D\u662F\u6570\u7EC4\u7C7B\u578B`);
148
- return new EnhancedArray(this, [], path2);
145
+ logger2.error(`\u914D\u7F6E\u8DEF\u5F84 ${pathStr} \u4E0D\u662F\u6570\u7EC4\u7C7B\u578B`);
146
+ return new EnhancedArray(this, [], pathStr);
149
147
  }
150
- return new EnhancedArray(this, result, path2);
148
+ return new EnhancedArray(this, result, pathStr);
151
149
  }
152
150
  return result;
153
151
  }
154
- /**
155
- * @param save 是否立即保存
156
- */
157
152
  set(path2, value, save) {
158
- lodash2.set(this.#ConfigCache, path2, value);
153
+ lodash2.set(this.#ConfigCache, String(path2), value);
159
154
  save && this.save();
160
155
  }
161
156
  /**
@@ -2,11 +2,11 @@ import {
2
2
  DefaultLayoutComponent,
3
3
  React,
4
4
  ReactRender
5
- } from "./chunk-A5FZEOIN.js";
5
+ } from "./chunk-S3ALDDWH.js";
6
6
  import {
7
7
  MysGame,
8
8
  UserInfo
9
- } from "./chunk-V2MCX7HT.js";
9
+ } from "./chunk-JYQZZKAO.js";
10
10
  import {
11
11
  dir
12
12
  } from "./chunk-SHLPPEAY.js";
@@ -78,19 +78,13 @@ var BindUID = karin.command(
78
78
  bindUids[uid] = { perm: 0 /* BIND */, ltuid: "" };
79
79
  }
80
80
  await userInfo.saveUserInfo({
81
- [Game.game + "-main"]: uid,
82
- [Game.game + "-uids"]: bindUids
81
+ [Game.columnKey.main]: uid,
82
+ [Game.columnKey.uids]: bindUids
83
83
  });
84
84
  await handler.call(`MYS.${Game.game}.ShowUID`, { e });
85
85
  return true;
86
86
  }
87
87
  );
88
- var getMainUid = (uid, mainUid, bindUids) => {
89
- if (mainUid !== uid) return mainUid;
90
- const filterUids = Object.entries(bindUids).filter((value) => value[1].perm !== 4 /* DEL */);
91
- if (filterUids.length > 0) return filterUids[0][0];
92
- return "";
93
- };
94
88
  var UnbindUID = karin.command(
95
89
  /^#?(.*?)(删除|解绑)uid(?:\s*(.+))?$/i,
96
90
  async (e, next) => {
@@ -124,10 +118,49 @@ var UnbindUID = karin.command(
124
118
  e.reply("UID\u672A\u7ED1\u5B9A\uFF0C\u8BF7\u68C0\u67E5\u540E\u91CD\u65B0\u8F93\u5165\uFF01", { at: true });
125
119
  return "break";
126
120
  }
121
+ const getMainUid = (uid2, mainUid2, bindUids2) => {
122
+ if (mainUid2 !== uid2) return mainUid2;
123
+ const filterUids = Object.entries(bindUids2).filter((value) => value[1].perm !== 4 /* DEL */);
124
+ if (filterUids.length > 0) return filterUids[0][0];
125
+ return "";
126
+ };
127
127
  const mainUid = getMainUid(delUid, userInfo.main_uid, bindUids);
128
128
  await userInfo.saveUserInfo({
129
- [Game.game + "-main"]: mainUid,
130
- [Game.game + "-uids"]: bindUids
129
+ [Game.columnKey.main]: mainUid,
130
+ [Game.columnKey.uids]: bindUids
131
+ });
132
+ await handler.call(`MYS.${Game.game}.ShowUID`, { e });
133
+ return true;
134
+ }
135
+ );
136
+ var ChangeMainUID = karin.command(
137
+ /^#?(.*?)(切换|更改)uid(?:\s*(.+))?$/i,
138
+ async (e, next) => {
139
+ const msgMatch = e.msg.match(/^#?(?<prefix>.*?)(切换|更改)uid(?:\s*(?<idx>.+))?$/i)?.groups;
140
+ const Game = MysGame.match(msgMatch.prefix?.trim() || "");
141
+ if (!Game) return next();
142
+ const uid = msgMatch.idx?.trim();
143
+ const idx = +uid.split(".")[0];
144
+ if (isNaN(idx)) {
145
+ e.reply("\u8BF7\u6B63\u786E\u63D0\u4F9B\u8981\u5207\u6362\u7684\u6E38\u620FUID\u6216\u5E8F\u53F7\uFF01", { at: true });
146
+ return true;
147
+ }
148
+ const userInfo = await Game.UserInfo.create(e.userId);
149
+ let mainUid = uid;
150
+ const bindUids = userInfo.bind_uids;
151
+ if (idx <= 1e4) {
152
+ const filterUids = Object.entries(bindUids).filter((value) => value[1].perm !== 4 /* DEL */);
153
+ if (idx > filterUids.length || idx <= 0) {
154
+ e.reply("UID\u5E8F\u53F7\u4E0D\u5B58\u5728\uFF0C\u8BF7\u68C0\u67E5\u540E\u91CD\u65B0\u8F93\u5165\uFF01", { at: true });
155
+ return true;
156
+ }
157
+ mainUid = filterUids[idx - 1][0];
158
+ } else if (!bindUids[mainUid] || bindUids[mainUid].perm === 4 /* DEL */) {
159
+ e.reply("UID\u672A\u7ED1\u5B9A\uFF0C\u8BF7\u68C0\u67E5\u540E\u91CD\u65B0\u8F93\u5165\uFF01", { at: true });
160
+ return true;
161
+ }
162
+ await userInfo.saveUserInfo({
163
+ [Game.columnKey.main]: mainUid
131
164
  });
132
165
  await handler.call(`MYS.${Game.game}.ShowUID`, { e });
133
166
  return true;
@@ -161,10 +194,7 @@ var ShowBindAccountCmdFunc = async (e) => {
161
194
  const gameUserInfo = await Game.UserInfo.create(e.userId);
162
195
  data.bindUids.push({
163
196
  gameName: Game.name,
164
- uids: Object.entries(gameUserInfo.bind_uids).filter(([, info]) => info.ltuid === ltuidInfo.ltuid).map(([uid, info]) => ({
165
- uid,
166
- perm: info.perm
167
- }))
197
+ uids: Object.entries(gameUserInfo.bind_uids).filter(([, info]) => info.ltuid === ltuidInfo.ltuid).map(([uid, info]) => ({ uid, perm: info.perm }))
168
198
  });
169
199
  });
170
200
  renderData.AccountList.push(data);
@@ -228,6 +258,7 @@ var UnbindAccount = karin.command(
228
258
  export {
229
259
  BindUID,
230
260
  UnbindUID,
261
+ ChangeMainUID,
231
262
  ShowBindAccountCmdFunc,
232
263
  ShowBindAccount,
233
264
  UnbindAccount
@@ -1,17 +1,17 @@
1
+ import {
2
+ DeviceCfg
3
+ } from "./chunk-PX6NFB3F.js";
1
4
  import {
2
5
  MysAccountInfoDB,
3
6
  MysDeviceInfoDB,
4
7
  MysUserInfoDB
5
- } from "./chunk-IASM5MM5.js";
8
+ } from "./chunk-ER4WMJJ6.js";
6
9
  import {
7
- DeviceCfg
8
- } from "./chunk-YFMJTWDG.js";
10
+ common_exports
11
+ } from "./chunk-RX4VMVAI.js";
9
12
  import {
10
13
  dir
11
14
  } from "./chunk-SHLPPEAY.js";
12
- import {
13
- common_exports
14
- } from "./chunk-RX4VMVAI.js";
15
15
 
16
16
  // src/exports/mys/api/apis.ts
17
17
  import lodash2 from "node-karin/lodash";
@@ -119,7 +119,7 @@ var MysGame = new class MysGame2 {
119
119
  return void 0;
120
120
  }
121
121
  RegisterGame(Game) {
122
- this.#games.set(Game.columnKey, Game);
122
+ this.#games.set(Game.game, Game);
123
123
  }
124
124
  async forEachGame(fn) {
125
125
  if (this.num === 0) return;
@@ -130,7 +130,6 @@ var MysGame = new class MysGame2 {
130
130
  }();
131
131
  var RegisterGameBase = class {
132
132
  game;
133
- columnKey;
134
133
  /** @description 游戏名称 */
135
134
  name;
136
135
  /** @description 指令前缀 */
@@ -139,12 +138,17 @@ var RegisterGameBase = class {
139
138
  UserInfo;
140
139
  constructor(game, name, prefixs, userInfo, refreshFuc) {
141
140
  this.game = game;
142
- this.columnKey = `${game}-uids`;
143
141
  this.name = name;
144
142
  this.prefixs = prefixs;
145
143
  this.UserInfo = userInfo;
146
144
  this.refresh = refreshFuc;
147
145
  }
146
+ get columnKey() {
147
+ return {
148
+ uids: `${this.game}-uids`,
149
+ main: `${this.game}-main`
150
+ };
151
+ }
148
152
  get prefix() {
149
153
  return new RegExp(`^(${this.prefixs.join("|")})$`, "i");
150
154
  }
@@ -219,6 +223,7 @@ var UserInfo = class _UserInfo extends BaseUserInfo {
219
223
  static async refreshUid(options, perm) {
220
224
  let message = "";
221
225
  const uids = [];
226
+ const mains = [];
222
227
  if (MysGame.num > 0) {
223
228
  const res = (await (await getUserGameRolesByCookie.initDevice(options)).request(null)).data;
224
229
  if (res?.retcode === 0) {
@@ -244,9 +249,16 @@ var UserInfo = class _UserInfo extends BaseUserInfo {
244
249
  });
245
250
  uids.push({
246
251
  name: Game.name,
247
- columnKey: Game.columnKey,
252
+ columnKey: Game.columnKey.uids,
248
253
  data: bindUids
249
254
  });
255
+ if (!userInfo.main_uid || !bindUids[userInfo.main_uid]) {
256
+ mains.push({
257
+ name: Game.name,
258
+ columnKey: Game.columnKey.main,
259
+ data: Array.from(uidList)[0] || ""
260
+ });
261
+ }
250
262
  });
251
263
  } else if (res?.retcode === -100) {
252
264
  message = "Cookie\u5DF2\u5931\u6548\uFF0C\u8BF7\u91CD\u65B0#\u626B\u7801\u767B\u5F55\u6216#\u5237\u65B0Cookie\uFF01";
@@ -257,6 +269,7 @@ var UserInfo = class _UserInfo extends BaseUserInfo {
257
269
  return {
258
270
  Serv: options.type,
259
271
  uids,
272
+ mains,
260
273
  message
261
274
  };
262
275
  }
@@ -1,13 +1,16 @@
1
+ import {
2
+ Config
3
+ } from "./chunk-F7ZAG53H.js";
1
4
  import {
2
5
  dir
3
6
  } from "./chunk-SHLPPEAY.js";
4
- import {
5
- Config
6
- } from "./chunk-UIPRZFST.js";
7
7
 
8
8
  // src/core/config/config.ts
9
9
  var defaultConfig = {
10
- githubProxyUrl: "https://gh-proxy.org"
10
+ proxy: {
11
+ github: "https://gh-proxy.org",
12
+ ["hoyolab" /* os */]: ""
13
+ }
11
14
  };
12
15
  var defaultConfigDefine = {};
13
16
  var CoreCfg = new Config(`${dir.name}:config`, dir.ConfigDir, defaultConfig, defaultConfigDefine).watch();
@@ -1,7 +1,11 @@
1
1
  import { Config } from '../exports/config/index.js';
2
+ import { M as MysAccountType } from '../mysAccountInfo-B7u5Sl8f.js';
2
3
 
3
4
  interface DefaultCoreConfigType {
4
- githubProxyUrl: string;
5
+ proxy: {
6
+ github: string;
7
+ [MysAccountType.os]: string;
8
+ };
5
9
  }
6
10
  interface DefaultCoreConfigDefineType {
7
11
  }
package/lib/core/index.js CHANGED
@@ -1,10 +1,12 @@
1
+ import "../chunk-5LRGHP36.js";
1
2
  import {
2
3
  CoreCfg,
3
4
  DeviceCfg
4
- } from "../chunk-YFMJTWDG.js";
5
- import "../chunk-SHLPPEAY.js";
6
- import "../chunk-UIPRZFST.js";
5
+ } from "../chunk-PX6NFB3F.js";
6
+ import "../chunk-F7ZAG53H.js";
7
+ import "../chunk-ER4WMJJ6.js";
7
8
  import "../chunk-RX4VMVAI.js";
9
+ import "../chunk-SHLPPEAY.js";
8
10
  import "../chunk-MLKGABMK.js";
9
11
  export {
10
12
  CoreCfg,
@@ -1,24 +1,39 @@
1
- declare class Config<C extends Record<string, any>> {
1
+ type PathImpl<T, Key extends keyof T> = Key extends string ? T[Key] extends Record<string, any> ? T[Key] extends ArrayLike<any> ? Key | `${Key}.${PathImpl<T[Key], Exclude<keyof T[Key], keyof any[]>>}` : Key | `${Key}.${PathImpl<T[Key], keyof T[Key]>}` : Key : never;
2
+ type Path<T> = PathImpl<T, keyof T> | keyof T;
3
+ type PathValue<T, P extends Path<T>> = P extends `${infer Key}.${infer Rest}` ? Key extends keyof T ? Rest extends Path<T[Key]> ? PathValue<T[Key], Rest> : never : never : P extends keyof T ? T[P] : never;
4
+ declare class Config<C extends {
5
+ [key: string]: any;
6
+ }> {
2
7
  #private;
3
8
  /**
4
9
  * @param name 插件名称:配置名称
5
10
  */
6
- constructor(name: `${string}:${string}`, ConfigDir: string, DefaultConfig: C, DefineConfig: Record<string, any>);
11
+ constructor(name: `${string}:${string}`, ConfigDir: string, DefaultConfig: C, DefineConfig: {
12
+ [key: string]: any;
13
+ });
7
14
  loadConfig(): C;
8
15
  mergeWithDefaults(userConfig: C, defaultConfig: C, DefineConfig: Record<string, any>): C;
9
16
  /**
10
17
  * @description 获取配置路径对应的默认配置
11
18
  */
12
- getDef<T>(path: string): T;
19
+ getDef(path: ''): C;
13
20
  /**
14
21
  * @description 获取配置路径对应的配置
22
+ * @param path 配置路径,支持任意深度的嵌套路径,返回值类型会根据路径自动推断
23
+ * @param isArray 是否返回 EnhancedArray 类型
24
+ * @param def 默认值
15
25
  */
16
- get<T>(path: string, isArray?: false, def?: T): T;
17
- get<T>(path: string, isArray: true, def?: T[]): EnhancedArray<T>;
26
+ get(path: '', isArray?: false, def?: C): C;
27
+ get<P extends Path<C>>(path: P, isArray?: false, def?: PathValue<C, P>): PathValue<C, P>;
28
+ get<P extends Path<C>, T = PathValue<C, P>>(path: P, isArray: true, def?: T[]): EnhancedArray<T extends any[] ? T[number] : T, C>;
18
29
  /**
30
+ * @description 设置配置项的值
31
+ * @param path 配置路径,支持任意深度的嵌套路径
32
+ * @param value 要设置的值,类型会根据路径自动推断
19
33
  * @param save 是否立即保存
20
34
  */
21
- set<T>(path: string, value: T, save: boolean): void;
35
+ set(path: '', value: C, save: boolean): void;
36
+ set<P extends Path<C>>(path: P, value: PathValue<C, P>, save: boolean): void;
22
37
  /**
23
38
  * @description 立即保存配置
24
39
  */
@@ -26,9 +41,11 @@ declare class Config<C extends Record<string, any>> {
26
41
  watch(fnc?: (self: Config<C>, oldData: C, newData: C) => Promise<void> | void): this;
27
42
  }
28
43
 
29
- declare class EnhancedArray<T> extends Array<T> {
44
+ declare class EnhancedArray<T, C extends {
45
+ [key: string]: any;
46
+ }> extends Array<T> {
30
47
  #private;
31
- constructor(cfg: Config<any>, items: T[], path: string);
48
+ constructor(cfg: Config<C>, items: T[], path: string);
32
49
  /**
33
50
  * @param element - string | number
34
51
  * @returns
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  Config,
3
3
  EnhancedArray
4
- } from "../../chunk-UIPRZFST.js";
4
+ } from "../../chunk-F7ZAG53H.js";
5
5
  import "../../chunk-RX4VMVAI.js";
6
6
  import "../../chunk-MLKGABMK.js";
7
7
  export {
@@ -1,6 +1,8 @@
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';
1
+ import { D as DatabaseType, a as DatabaseClassInstance, b as Dialect, c as DatabaseClassStatic, M as ModelAttributes, d as DatabaseReturn, e as MysDeviceInfoTableType, B as BaseUserInfoTableType, f as BaseGameUIDInfoTableType } from '../../mysUserInfo-CPIjniyl.js';
2
+ export { j as BindUidsItemType, g as DatabaseArray, h as MysDeviceInfoDatabaseBaseType, i as MysDeviceInfoDatabaseIdFpType, U as UidPermission } from '../../mysUserInfo-CPIjniyl.js';
3
3
  import { DataTypes, ModelAttributeColumnOptions, Model, ModelStatic } from 'sequelize';
4
+ import { a as MysAccountInfoTableType } from '../../mysAccountInfo-B7u5Sl8f.js';
5
+ export { M as MysAccountType } from '../../mysAccountInfo-B7u5Sl8f.js';
4
6
 
5
7
  type DatabaseFn = <T extends Record<string, any>, D extends DatabaseType>() => DatabaseClassInstance<T, D>;
6
8
 
@@ -14,9 +14,9 @@ import {
14
14
  Table,
15
15
  UidPermission,
16
16
  createTable
17
- } from "../../chunk-IASM5MM5.js";
18
- import "../../chunk-SHLPPEAY.js";
17
+ } from "../../chunk-ER4WMJJ6.js";
19
18
  import "../../chunk-RX4VMVAI.js";
19
+ import "../../chunk-SHLPPEAY.js";
20
20
  import "../../chunk-MLKGABMK.js";
21
21
  export {
22
22
  Database,
@@ -1,6 +1,7 @@
1
- import { j as MysDeviceInfoDatabaseBaseType, k as MysDeviceInfoDatabaseIdFpType, i as MysAccountType, f as MysDeviceInfoTableType, B as BaseUserInfoTableType, e as MysAccountInfoTableType, d as DatabaseReturn, D as DatabaseType, h as DatabaseArray, U as UidPermission, g as BaseGameUIDInfoTableType } from '../../mysUserInfo-BsyEENbc.js';
1
+ import { M as MysAccountType, a as MysAccountInfoTableType } from '../../mysAccountInfo-B7u5Sl8f.js';
2
2
  import { SendMessage } from 'node-karin';
3
3
  import { AxiosRequestConfig, AxiosResponse } from 'node-karin/axios';
4
+ import { h as MysDeviceInfoDatabaseBaseType, i as MysDeviceInfoDatabaseIdFpType, e as MysDeviceInfoTableType, B as BaseUserInfoTableType, d as DatabaseReturn, D as DatabaseType, g as DatabaseArray, U as UidPermission, f as BaseGameUIDInfoTableType } from '../../mysUserInfo-CPIjniyl.js';
4
5
  import 'sequelize';
5
6
 
6
7
  declare const MysApp: Readonly<{
@@ -272,7 +273,6 @@ declare const MysGame: {
272
273
  };
273
274
  declare class RegisterGameBase<GameUserInfoTableType extends BaseUserInfoTableType> {
274
275
  game: string;
275
- columnKey: `${string}-uids`;
276
276
  /** @description 游戏名称 */
277
277
  name: gameName;
278
278
  /** @description 指令前缀 */
@@ -286,6 +286,10 @@ declare class RegisterGameBase<GameUserInfoTableType extends BaseUserInfoTableTy
286
286
  userId: string;
287
287
  cookie: string;
288
288
  } & BaseltuidInfoType) => Promise<string[]>);
289
+ get columnKey(): {
290
+ uids: `${string}-uids`;
291
+ main: `${string}-main`;
292
+ };
289
293
  get prefix(): RegExp;
290
294
  }
291
295
 
@@ -374,6 +378,11 @@ interface RefreshUidResultType {
374
378
  columnKey: `${string}-uids`;
375
379
  data: BaseGameUIDInfoTableType<string>[`${string}-uids`];
376
380
  }[];
381
+ mains: {
382
+ name: string;
383
+ columnKey: `${string}-main`;
384
+ data: string;
385
+ }[];
377
386
  message: string;
378
387
  }
379
388
 
@@ -15,12 +15,13 @@ import {
15
15
  getUserFullInfo,
16
16
  getUserGameRolesByCookie,
17
17
  queryQRcode
18
- } from "../../chunk-V2MCX7HT.js";
19
- import "../../chunk-IASM5MM5.js";
20
- import "../../chunk-YFMJTWDG.js";
21
- import "../../chunk-SHLPPEAY.js";
22
- import "../../chunk-UIPRZFST.js";
18
+ } from "../../chunk-JYQZZKAO.js";
19
+ import "../../chunk-5LRGHP36.js";
20
+ import "../../chunk-PX6NFB3F.js";
21
+ import "../../chunk-F7ZAG53H.js";
22
+ import "../../chunk-ER4WMJJ6.js";
23
23
  import "../../chunk-RX4VMVAI.js";
24
+ import "../../chunk-SHLPPEAY.js";
24
25
  import "../../chunk-MLKGABMK.js";
25
26
  export {
26
27
  BaseUserInfo,
@@ -2,9 +2,9 @@ import {
2
2
  DefaultLayoutComponent,
3
3
  React,
4
4
  ReactRender
5
- } from "../../chunk-A5FZEOIN.js";
6
- import "../../chunk-SHLPPEAY.js";
5
+ } from "../../chunk-S3ALDDWH.js";
7
6
  import "../../chunk-RX4VMVAI.js";
7
+ import "../../chunk-SHLPPEAY.js";
8
8
  import "../../chunk-MLKGABMK.js";
9
9
  export {
10
10
  DefaultLayoutComponent,
@@ -0,0 +1,14 @@
1
+ declare const enum MysAccountType {
2
+ cn = "mihoyo",
3
+ os = "hoyolab"
4
+ }
5
+ interface MysAccountInfoTableType {
6
+ ltuid: string;
7
+ type: MysAccountType;
8
+ cookie: string;
9
+ stoken: string;
10
+ /** 绑定的设备md5 */
11
+ deviceMd5: string;
12
+ }
13
+
14
+ export { MysAccountType as M, type MysAccountInfoTableType as a };
@@ -122,19 +122,6 @@ declare class DatabaseArray<T> extends Array<T> {
122
122
  clear(): this;
123
123
  }
124
124
 
125
- declare const enum MysAccountType {
126
- cn = "mihoyo",
127
- os = "hoyolab"
128
- }
129
- interface MysAccountInfoTableType {
130
- ltuid: string;
131
- type: MysAccountType;
132
- cookie: string;
133
- stoken: string;
134
- /** 绑定的设备md5 */
135
- deviceMd5: string;
136
- }
137
-
138
125
  interface MysDeviceInfoDatabaseBaseType {
139
126
  name: string;
140
127
  board: string;
@@ -181,4 +168,4 @@ type BaseGameUIDInfoTableType<Game extends string> = {
181
168
  [P in `${Game}-uids`]: Partial<Record<string, BindUidsItemType>>;
182
169
  };
183
170
 
184
- export { type BaseUserInfoTableType as B, DatabaseType as D, type ModelAttributes as M, UidPermission as U, type DatabaseClassInstance as a, Dialect as b, type DatabaseClassStatic as c, type DatabaseReturn as d, type MysAccountInfoTableType as e, type MysDeviceInfoTableType as f, type BaseGameUIDInfoTableType as g, DatabaseArray as h, MysAccountType as i, type MysDeviceInfoDatabaseBaseType as j, type MysDeviceInfoDatabaseIdFpType as k, type BindUidsItemType as l };
171
+ export { type BaseUserInfoTableType as B, DatabaseType as D, type ModelAttributes as M, UidPermission as U, type DatabaseClassInstance as a, Dialect as b, type DatabaseClassStatic as c, type DatabaseReturn as d, type MysDeviceInfoTableType as e, type BaseGameUIDInfoTableType as f, DatabaseArray as g, type MysDeviceInfoDatabaseBaseType as h, type MysDeviceInfoDatabaseIdFpType as i, type BindUidsItemType as j };
@@ -0,0 +1,10 @@
1
+ import * as node_karin from 'node-karin';
2
+
3
+ type ConfigSaveEntry = {
4
+ githubProxyUrl: string;
5
+ };
6
+ declare const _default: node_karin.DefineConfig<{
7
+ "accordion-config-key": ConfigSaveEntry[];
8
+ }>;
9
+
10
+ export { _default as default };
@@ -0,0 +1,155 @@
1
+ import {
2
+ CoreCfg,
3
+ DeviceCfg
4
+ } from "./chunk-PX6NFB3F.js";
5
+ import "./chunk-F7ZAG53H.js";
6
+ import "./chunk-ER4WMJJ6.js";
7
+ import "./chunk-RX4VMVAI.js";
8
+ import {
9
+ dir
10
+ } from "./chunk-SHLPPEAY.js";
11
+ import "./chunk-MLKGABMK.js";
12
+
13
+ // src/web.config.ts
14
+ import { components, defineConfig, logger } from "node-karin";
15
+ import lodash from "node-karin/lodash";
16
+ var FormatValue = (key, value) => {
17
+ const { format } = key.match(/=(?<format>.*)$/)?.groups || {};
18
+ switch (format) {
19
+ case "int":
20
+ return { key: key.replace(/=(.*)$/, "").replace(/-/g, "."), value: parseInt(value) };
21
+ case "float":
22
+ return { key: key.replace(/=(.*)$/, "").replace(/-/g, "."), value: parseFloat(value) };
23
+ default:
24
+ return { key: key.replace(/-/g, "."), value };
25
+ }
26
+ };
27
+ var web_config_default = defineConfig({
28
+ /** 插件信息配置 */
29
+ info: {
30
+ id: dir.name,
31
+ name: "Mys-Core",
32
+ version: dir.version,
33
+ description: dir.pkg.description,
34
+ author: [
35
+ {
36
+ name: dir.pkg.author,
37
+ avatar: "https://github.com/babanbang.png"
38
+ }
39
+ ]
40
+ },
41
+ /** 动态渲染的组件 */
42
+ components: () => [
43
+ components.accordion.create("accordion-config-key" /* Config */, {
44
+ label: "\u57FA\u7840\u8BBE\u7F6E",
45
+ children: [
46
+ components.accordion.createItem("accordion-proxy-item-key", {
47
+ title: "\u4EE3\u7406\u8BBE\u7F6E",
48
+ subtitle: "\u7528\u4E8E\u4E0B\u8F7D\u63D2\u4EF6\u8D44\u6E90\u6216api\u8BF7\u6C42",
49
+ children: [
50
+ components.input.url("proxy-github", {
51
+ label: "GitHub \u4EE3\u7406\u5730\u5740",
52
+ defaultValue: CoreCfg.get("proxy.github")
53
+ }),
54
+ components.input.url(`proxy-${"hoyolab" /* os */}`, {
55
+ label: "Hoyolab \u7C73\u6E38\u793E API \u4EE3\u7406",
56
+ defaultValue: CoreCfg.get(`proxy.${"hoyolab" /* os */}`)
57
+ })
58
+ ]
59
+ })
60
+ ]
61
+ }),
62
+ components.divider.horizontal("divider-config-end"),
63
+ components.accordion.create("accordion-device-key" /* Device */, {
64
+ label: "\u7C73\u6E38\u793E\u8BBE\u5907\u4FE1\u606F\u8BBE\u7F6E",
65
+ children: [
66
+ components.accordion.createItem("accordion-device-item-key", {
67
+ title: "\u5982\u679C\u4E0D\u77E5\u9053\u8FD9\u662F\u4EC0\u4E48\u8BF7\u52FF\u4FEE\u6539",
68
+ subtitle: "-- \u9ED8\u8BA4\u8BBE\u5907\u4FE1\u606F --",
69
+ className: "ml-4 mr-4",
70
+ children: [
71
+ components.input.number("version=int", {
72
+ defaultValue: DeviceCfg.get("version") + "",
73
+ label: "androidVersion",
74
+ rules: [
75
+ { max: 15, min: 10 }
76
+ ],
77
+ isRequired: true
78
+ }),
79
+ components.input.string("name", {
80
+ defaultValue: DeviceCfg.get("name"),
81
+ label: "deviceName",
82
+ isRequired: true
83
+ }),
84
+ components.input.string("board", {
85
+ defaultValue: DeviceCfg.get("board"),
86
+ label: "deviceBoard",
87
+ isRequired: true
88
+ }),
89
+ components.input.string("model", {
90
+ defaultValue: DeviceCfg.get("model"),
91
+ label: "deviceModel",
92
+ isRequired: true
93
+ }),
94
+ components.input.string("product", {
95
+ defaultValue: DeviceCfg.get("product"),
96
+ label: "deviceProduct",
97
+ isRequired: true
98
+ }),
99
+ components.input.string("fingerprint", {
100
+ defaultValue: DeviceCfg.get("fingerprint"),
101
+ label: "deviceFingerprint",
102
+ className: "w-full",
103
+ isRequired: true
104
+ })
105
+ ]
106
+ })
107
+ ]
108
+ })
109
+ ],
110
+ /** 前端点击保存之后调用的方法 */
111
+ save: (changeConfig) => {
112
+ const CfgMap = {
113
+ ["accordion-config-key" /* Config */]: CoreCfg,
114
+ ["accordion-device-key" /* Device */]: DeviceCfg
115
+ };
116
+ try {
117
+ lodash.forEach(changeConfig, (childrenValue, accordionKey) => {
118
+ switch (accordionKey) {
119
+ case "accordion-config-key" /* Config */: {
120
+ childrenValue.forEach((children) => {
121
+ lodash.forEach(children, (value, childrenKey) => {
122
+ const { key, value: formatValue } = FormatValue(childrenKey, value);
123
+ CfgMap[accordionKey].set(key, formatValue, false);
124
+ });
125
+ });
126
+ break;
127
+ }
128
+ case "accordion-device-key" /* Device */: {
129
+ childrenValue.forEach((children) => {
130
+ lodash.forEach(children, (value, childrenKey) => {
131
+ const { key, value: formatValue } = FormatValue(childrenKey, value);
132
+ CfgMap[accordionKey].set(key, formatValue, false);
133
+ });
134
+ });
135
+ break;
136
+ }
137
+ }
138
+ });
139
+ Object.values(CfgMap).forEach((cfg) => cfg.save());
140
+ } catch (err) {
141
+ logger.error(err);
142
+ return {
143
+ success: false,
144
+ message: "\u4FDD\u5B58\u5931\u8D25\uFF1A" + err.message
145
+ };
146
+ }
147
+ return {
148
+ success: true,
149
+ message: "\u4FDD\u5B58\u6210\u529F"
150
+ };
151
+ }
152
+ });
153
+ export {
154
+ web_config_default as default
155
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "karin-plugin-mys-core",
3
- "version": "1.0.14",
3
+ "version": "1.0.19",
4
4
  "author": "babanbang",
5
5
  "type": "module",
6
6
  "description": "karin-plugin-mys-core",
@@ -107,7 +107,7 @@
107
107
  }
108
108
 
109
109
  /*
110
- ! tailwindcss v3.4.18 | MIT License | https://tailwindcss.com
110
+ ! tailwindcss v3.4.19 | MIT License | https://tailwindcss.com
111
111
  */
112
112
 
113
113
  /*
@@ -1,9 +1,9 @@
1
- import {
2
- dir
3
- } from "./chunk-SHLPPEAY.js";
4
1
  import {
5
2
  common_exports
6
3
  } from "./chunk-RX4VMVAI.js";
4
+ import {
5
+ dir
6
+ } from "./chunk-SHLPPEAY.js";
7
7
 
8
8
  // src/exports/database/database.ts
9
9
  import { logger as logger4 } from "node-karin";
@@ -1,9 +1,9 @@
1
- import {
2
- dir
3
- } from "./chunk-SHLPPEAY.js";
4
1
  import {
5
2
  common_exports
6
3
  } from "./chunk-RX4VMVAI.js";
4
+ import {
5
+ dir
6
+ } from "./chunk-SHLPPEAY.js";
7
7
 
8
8
  // src/exports/render/index.ts
9
9
  import React3 from "react";