修复MysApi查询时的一些问题

This commit is contained in:
yoimiya-kokomi 2022-09-20 20:16:19 +08:00
parent 78f87c9c45
commit 1f83a25410
4 changed files with 19 additions and 9 deletions

View File

@ -12,7 +12,7 @@ const importV3 = async function (file, def, key = 'default') {
let MysInfo = await importV3('/plugins/genshin/model/mys/mysInfo.js', {}) let MysInfo = await importV3('/plugins/genshin/model/mys/mysInfo.js', {})
let plugin = await importV3('lib/plugins/plugin.js', _plugin) let plugin = await importV3('lib/plugins/plugin.js', _plugin)
let puppeteer = _puppeteer let puppeteer = await importV3('lib/plugins/plugin.js', _puppeteer)
export { export {
plugin, plugin,
MysInfo, MysInfo,

View File

@ -5,7 +5,7 @@ import lodash from 'lodash'
import { segment } from 'oicq' import { segment } from 'oicq'
import { profileList } from './profile-list.js' import { profileList } from './profile-list.js'
import { Profile, Version } from '../../components/index.js' import { Profile, Version } from '../../components/index.js'
import { Character } from '../../models/index.js' import { Character, MysApi } from '../../models/index.js'
/* /*
* 获取面板查询的 目标uid * 获取面板查询的 目标uid

View File

@ -124,4 +124,4 @@ export default class MysApi {
async getAvatarSkill (id) { async getAvatarSkill (id) {
return await this.getData('avatarSkill', { avatar_id: id }) return await this.getData('avatarSkill', { avatar_id: id })
} }
} }

View File

@ -1,11 +1,17 @@
import { Data } from '../../components/index.js' import { Data, Version } from '../../components/index.js'
let MysInfo = false let MysInfo = false
let MysUser = false
async function init () { async function init () {
let mys = await Data.importModule('plugins/genshin/model/mys/mysInfo.js', 'root') let mys = await Data.importModule('plugins/genshin/model/mys/mysInfo.js', 'root')
if (mys && mys.default) { if (mys && mys.default) {
MysInfo = 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) { static async init (e) {
let MysApi = await e.getMysApi(apiCfg) // V2兼容 let MysApi = await e.getMysApi(apiCfg) // V2兼容
let { targetUser, cookieUser } = MysApi let { selfUser, targetUser, cookieUser } = MysApi
let mys = new MysInfo(e, targetUser.id, cookieUser) let mys = new MysInfo(e, targetUser.uid || selfUser.uid, cookieUser)
mys._MysApi = MysApi mys._MysApi = MysApi
return mys return mys
} }
// 检查当前UID是否有CK绑定 // 检查当前UID是否有CK绑定
static async checkUidBing (uid) { static async checkUidBing (uid) {
let user = await MysUser.get(uid)
return user.cookie
} }
static async getUid (e) { 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 MysApi = await e.getMysApi(apiCfg) // V2兼容
let ret = await MysApi.getData(api, data) let ret = await MysApi.getData(api, data)
if (ret) { if (ret) {