mirror of
https://github.com/yoimiya-kokomi/miao-plugin.git
synced 2024-11-16 04:35:42 +00:00
b5c1daf472
角色面板支持旅行者,暂未支持伤害计算 `#雷主天赋`、`#草主命座`功能升级
42 lines
855 B
JavaScript
42 lines
855 B
JavaScript
import { Data } from '../components/index.js'
|
|
|
|
let cacheMap = {}
|
|
let reFn = {}
|
|
|
|
export default class Base {
|
|
|
|
toString () {
|
|
return this?.name || ''
|
|
}
|
|
|
|
getData (arrList = '', cfg = {}) {
|
|
arrList = arrList || this._dataKey || ''
|
|
return Data.getData(this, arrList, cfg)
|
|
}
|
|
|
|
// 获取指定值数据,支持通过
|
|
getVal (key, defaultValue) {
|
|
return Data.getVal(this, key, defaultValue)
|
|
}
|
|
|
|
_expire (time = 10 * 60) {
|
|
let id = this._uuid
|
|
if (id) {
|
|
reFn[id] && clearTimeout(reFn[id])
|
|
delete reFn[id]
|
|
reFn[id] = setTimeout(() => {
|
|
reFn[id] && clearTimeout(reFn[id])
|
|
delete reFn[id]
|
|
delete cacheMap[id]
|
|
}, time * 1000)
|
|
cacheMap[id] = this
|
|
}
|
|
return this
|
|
}
|
|
}
|
|
Base.get = (id, time = 10 * 60) => {
|
|
if (cacheMap[id]) {
|
|
return cacheMap[id]._expire(time)
|
|
}
|
|
}
|