mirror of
https://github.com/yoimiya-kokomi/miao-plugin.git
synced 2024-11-16 04:35:42 +00:00
47 lines
947 B
JavaScript
47 lines
947 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)
|
|
}
|
|
|
|
_getCache (uuid = '', time = 10 * 60) {
|
|
if (uuid && cacheMap[uuid]) {
|
|
return cacheMap[uuid]._setCache(time)
|
|
}
|
|
this._uuid = uuid
|
|
}
|
|
|
|
_setCache (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) => {
|
|
|
|
}
|