一些已知问题修复

This commit is contained in:
yoimiya-kokomi 2022-10-26 04:11:01 +08:00
parent 92419e1d73
commit 98282e3741
4 changed files with 14 additions and 19 deletions

View File

@ -396,15 +396,15 @@ async function uploadData (e) {
if (!Cfg.get('wiki.abyss', false) && !isMatch) {
return false
}
let mys = await MysApi.init(e)
if (!mys) {
let mys = await MysApi.init(e, { auth: 'cookie' })
if (!mys || !mys.uid) {
if (isMatch) {
e.reply(`请绑定ck后再使用${e.original_msg || e.msg}`)
}
return false
}
let ret = {}
let uid = e.selfUser.uid
let uid = mys.uid
let resDetail, resAbyss
try {
resAbyss = await mys.getSpiralAbyss(1)

View File

@ -56,7 +56,10 @@ let Profile = {
const userFile = `${userPath}/${uid}.json`
let userData = {}
if (fs.existsSync(userFile)) {
userData = JSON.parse(fs.readFileSync(userFile, 'utf8')) || {}
try {
userData = JSON.parse(fs.readFileSync(userFile, 'utf8')) || {}
} catch (e) {
}
}
if (userData && userData.chars) {
let char = Character.get(charId)

View File

@ -18,18 +18,11 @@ export default class MysApi {
cfg = { auth: cfg }
}
let { auth = 'all' } = cfg
let mys = await YzMysInfo.init(e, 'roleIndex')
let mys = await YzMysInfo.init(e, auth === 'cookie' ? 'detail' : 'roleIndex')
if (!mys) {
return false
}
let uid = mys.uid
/* 检查user ck */
if (auth === 'cookie') {
if (mys?.ckInfo?.uid * 1 !== uid * 1) {
e.reply('请绑定CK以使用此功能...')
return false
}
}
e._mys = new MysApi(e, uid, mys)
return e._mys
}

View File

@ -19,11 +19,6 @@ await init()
if (!YzMysInfo) {
// v2 MysInfo
const apiCfg = {
auth: 'all',
targetType: 'all',
cookieType: 'all'
}
YzMysInfo = class {
constructor (e, uid, cookieUser) {
if (e) {
@ -37,8 +32,12 @@ if (!YzMysInfo) {
}
}
static async init (e) {
let MysApi = await e.getMysApi(apiCfg) // V2兼容
static async init (e, api) {
let MysApi = await e.getMysApi({
auth: 'all',
targetType: 'all',
cookieType: api === 'detail' ? 'self:' : 'all'
}) // V2兼容
let { selfUser, targetUser, cookieUser } = MysApi
let mys = new YzMysInfo(e, targetUser.uid || selfUser.uid, cookieUser)
mys._MysApi = MysApi