增加Data.forEach,以支持新版Miao-Yunzai功能

This commit is contained in:
Kokomi 2023-05-09 11:00:37 +08:00
parent 8602bd6943
commit f4648510fd
2 changed files with 25 additions and 0 deletions

View File

@ -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) => { eachStr: (arr, fn) => {
if (lodash.isString(arr)) { if (lodash.isString(arr)) {

View File

@ -6,6 +6,7 @@ export default class MysApi {
this.e = e this.e = e
this.mysInfo = mysInfo this.mysInfo = mysInfo
this.ckInfo = mysInfo.ckInfo this.ckInfo = mysInfo.ckInfo
this.ckUser = mysInfo.ckUser
this.uid = uid this.uid = uid
e.targetUser = this.targetUser e.targetUser = this.targetUser
e.selfUser = this.selfUser e.selfUser = this.selfUser