mirror of
https://github.com/yoimiya-kokomi/miao-plugin.git
synced 2024-11-21 14:38:30 +00:00
增加Data.forEach,以支持新版Miao-Yunzai功能
This commit is contained in:
parent
8602bd6943
commit
f4648510fd
@ -239,6 +239,30 @@ let Data = {
|
||||
}
|
||||
},
|
||||
|
||||
async forEach (data, fn) {
|
||||
if (lodash.isArray(data)) {
|
||||
for (let idx = 0; idx < data.length; idx++) {
|
||||
let ret = fn(data[idx], idx)
|
||||
if (ret instanceof Promise) {
|
||||
ret = await ret
|
||||
}
|
||||
if (ret === false) {
|
||||
break
|
||||
}
|
||||
}
|
||||
} else if (lodash.isPlainObject(data)) {
|
||||
for (const idx in data) {
|
||||
let ret = fn(data[idx], idx)
|
||||
if (ret instanceof Promise) {
|
||||
ret = await ret
|
||||
}
|
||||
if (ret === false) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// 循环字符串回调
|
||||
eachStr: (arr, fn) => {
|
||||
if (lodash.isString(arr)) {
|
||||
|
@ -6,6 +6,7 @@ export default class MysApi {
|
||||
this.e = e
|
||||
this.mysInfo = mysInfo
|
||||
this.ckInfo = mysInfo.ckInfo
|
||||
this.ckUser = mysInfo.ckUser
|
||||
this.uid = uid
|
||||
e.targetUser = this.targetUser
|
||||
e.selfUser = this.selfUser
|
||||
|
Loading…
Reference in New Issue
Block a user