update: 米游接口

This commit is contained in:
ningmengchongshui 2024-06-09 12:42:45 +08:00
parent d2a6da4461
commit 88944bcc95
4 changed files with 36 additions and 12 deletions

View File

@ -3,11 +3,20 @@
*/ */
import MysUtil from './MysUtil.js' import MysUtil from './MysUtil.js'
let cacheMap = {} const cacheMap = {}
let reFn = {} const reFn = {}
export default class BaseModel { export default class BaseModel {
_uuid = null
/**
*
* @returns
*/
constructor() { constructor() {
/**
* ????
*/
return this return this
} }

View File

@ -14,13 +14,15 @@ const redisKeyRoot = 'Yz:cache:'
* *
*/ */
export default class DailyCache extends BaseModel { export default class DailyCache extends BaseModel {
keyPre = null
/** /**
* *
* @param uid * @param uid
* @param game * @param game
* @returns * @returns
*/ */
constructor(uid, game = 'config') { constructor(uid: string | number, game = 'config') {
super() super()
const storeKey = DailyCache.getStoreKey(uid, game) const storeKey = DailyCache.getStoreKey(uid, game)
// 检查实例缓存 // 检查实例缓存

View File

@ -5,11 +5,13 @@ import MysUtil from './MysUtil.js'
import { UserDB } from '../db/index.js' import { UserDB } from '../db/index.js'
import { Data } from '../local.js' import { Data } from '../local.js'
/** /**
* *******************
* Bot实际User用户类 * Bot实际User用户类
* QQ * QQ
* *
* User可以注册UID getRegUid / setRegUid * User可以注册UID getRegUid / setRegUid
* User可以绑定多个MysUser CKMysUser * User可以绑定多个MysUser CKMysUser
* *******************
*/ */
export default class NoteUser extends BaseModel { export default class NoteUser extends BaseModel {
/** /**
@ -32,12 +34,17 @@ export default class NoteUser extends BaseModel {
* OLD Func {{ * OLD Func {{
*/ */
/**
*
*/
get uid() { get uid() {
console.warn('NoteUser.uid 默认返回原神UID可更改为 user.getUid(game)') console.warn('NoteUser.uid 默认返回原神UID可更改为 user.getUid(game)')
return this.getUid() return this.getUid()
} }
// 获取绑定CK的UID列表如未绑定CK则返回空数组 /**
* CK的UID列表CK则返回空数组
*/
get ckUids() { get ckUids() {
console.warn( console.warn(
'NoteUser.ckUids 默认返回原神UID可更改为 user.getCkUidList(game)' 'NoteUser.ckUids 默认返回原神UID可更改为 user.getCkUidList(game)'

View File

@ -5,21 +5,27 @@ import { randomRange } from './mysApi.js'
* *
*/ */
export default class apiTool { export default class apiTool {
uid = null
isSr = false
server = null
game = 'genshin'
/** /**
* *
* @param {uid} uid * @param {uid} uid
* @param {} server * @param {} server
* @param {? type(bool or string)} isSr * @param {? type(bool or string)} isSr
*/ */
constructor(uid, server, isSr = false) { constructor(uid: string | null, server, isSr: boolean = false) {
this.uid = uid uid && (this.uid = uid)
this.isSr = isSr typeof isSr != 'undefined' && (this.uid = uid)
this.server = server server && (this.server = server)
// init
this.game = 'genshin' this.game = 'genshin'
if (isSr) this.game = 'honkaisr' if (isSr) this.game = 'honkaisr'
if (typeof isSr !== 'boolean') { if (typeof isSr !== 'boolean') this.game = isSr
this.game = isSr
}
} }
/** /**
@ -27,7 +33,7 @@ export default class apiTool {
* @param data * @param data
* @returns * @returns
*/ */
getUrlMap = (data = {}) => { getUrlMap = (data: any = {}) => {
let host, hostRecord, hostPublicData let host, hostRecord, hostPublicData
if ( if (
['cn_gf01', 'cn_qd01', 'prod_gf_cn', 'prod_qd_cn'].includes(this.server) ['cn_gf01', 'cn_qd01', 'prod_gf_cn', 'prod_qd_cn'].includes(this.server)