From 1f83a25410c23105f56e1f7960a0e849738a6c5d Mon Sep 17 00:00:00 2001 From: yoimiya-kokomi <592981798@qq.com> Date: Tue, 20 Sep 2022 20:16:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DMysApi=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E6=97=B6=E7=9A=84=E4=B8=80=E4=BA=9B=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- adapter/index.js | 2 +- apps/character/profile-common.js | 2 +- models/MysApi.js | 2 +- models/mys-lib/MysInfo.js | 22 ++++++++++++++++------ 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/adapter/index.js b/adapter/index.js index 1a28ebd1..e95b6b92 100644 --- a/adapter/index.js +++ b/adapter/index.js @@ -12,7 +12,7 @@ const importV3 = async function (file, def, key = 'default') { let MysInfo = await importV3('/plugins/genshin/model/mys/mysInfo.js', {}) let plugin = await importV3('lib/plugins/plugin.js', _plugin) -let puppeteer = _puppeteer +let puppeteer = await importV3('lib/plugins/plugin.js', _puppeteer) export { plugin, MysInfo, diff --git a/apps/character/profile-common.js b/apps/character/profile-common.js index 192ccee6..8591c03f 100644 --- a/apps/character/profile-common.js +++ b/apps/character/profile-common.js @@ -5,7 +5,7 @@ import lodash from 'lodash' import { segment } from 'oicq' import { profileList } from './profile-list.js' import { Profile, Version } from '../../components/index.js' -import { Character } from '../../models/index.js' +import { Character, MysApi } from '../../models/index.js' /* * 获取面板查询的 目标uid diff --git a/models/MysApi.js b/models/MysApi.js index 518ee039..c1ed9385 100644 --- a/models/MysApi.js +++ b/models/MysApi.js @@ -124,4 +124,4 @@ export default class MysApi { async getAvatarSkill (id) { return await this.getData('avatarSkill', { avatar_id: id }) } -} \ No newline at end of file +} diff --git a/models/mys-lib/MysInfo.js b/models/mys-lib/MysInfo.js index 8e362342..07e3762a 100644 --- a/models/mys-lib/MysInfo.js +++ b/models/mys-lib/MysInfo.js @@ -1,11 +1,17 @@ -import { Data } from '../../components/index.js' +import { Data, Version } from '../../components/index.js' let MysInfo = false +let MysUser = false async function init () { let mys = await Data.importModule('plugins/genshin/model/mys/mysInfo.js', 'root') if (mys && mys.default) { MysInfo = mys.default + } else { + let module = await Data.importModule('lib/components/models/MysUser.js', 'root') + if (module && module.default) { + MysUser = module.default + } } } @@ -33,22 +39,26 @@ if (!MysInfo) { static async init (e) { let MysApi = await e.getMysApi(apiCfg) // V2兼容 - let { targetUser, cookieUser } = MysApi - let mys = new MysInfo(e, targetUser.id, cookieUser) + let { selfUser, targetUser, cookieUser } = MysApi + let mys = new MysInfo(e, targetUser.uid || selfUser.uid, cookieUser) mys._MysApi = MysApi return mys } // 检查当前UID是否有CK绑定 static async checkUidBing (uid) { - + let user = await MysUser.get(uid) + return user.cookie } static async getUid (e) { - + let user = await e.checkAuth({ + auth: 'all' + }) + return user ? user.uid : false } - static async getData (e, api, data) { + static async get (e, api, data) { let MysApi = await e.getMysApi(apiCfg) // V2兼容 let ret = await MysApi.getData(api, data) if (ret) {