2022-08-05 22:12:57 +00:00
|
|
|
import lodash from 'lodash'
|
|
|
|
import { autoRefresh, getTargetUid } from './profile-common.js'
|
|
|
|
import { Common, Profile } from '../../components/index.js'
|
2022-08-06 22:36:05 +00:00
|
|
|
import { Character } from '../../components/models.js'
|
2022-08-05 22:12:57 +00:00
|
|
|
|
|
|
|
export async function profileList (e, { render }) {
|
|
|
|
let uid = await getTargetUid(e)
|
|
|
|
if (!uid) {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
let profiles = Profile.getAll(uid) || {}
|
2022-08-08 21:16:37 +00:00
|
|
|
let servName = Profile.getServName(uid)
|
|
|
|
let hasNew = false
|
|
|
|
let newCount = 0
|
2022-08-05 22:12:57 +00:00
|
|
|
|
|
|
|
let chars = []
|
|
|
|
let msg = ''
|
|
|
|
let newChar = {}
|
|
|
|
if (e.newChar) {
|
|
|
|
msg = '获取角色面板数据成功'
|
|
|
|
newChar = e.newChar
|
|
|
|
}
|
|
|
|
lodash.forEach(profiles || [], (ds) => {
|
2022-08-16 20:04:12 +00:00
|
|
|
if (!['enka', 'input2', 'miao'].includes(ds.dataSource)) {
|
2022-08-05 22:12:57 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
let { id } = ds
|
|
|
|
let char = Character.get(id)
|
|
|
|
let tmp = char.getData('id,name,abbr,element,star')
|
2022-08-06 22:36:05 +00:00
|
|
|
if (tmp.name === '荧' || tmp.name === '空') {
|
|
|
|
return
|
|
|
|
}
|
2022-08-05 22:12:57 +00:00
|
|
|
tmp.source = ds.dataSource
|
|
|
|
tmp.level = ds.lv || 1
|
2022-08-10 18:12:48 +00:00
|
|
|
tmp.isNew = 0
|
2022-08-08 21:16:37 +00:00
|
|
|
if (newChar[char.name]) {
|
|
|
|
tmp.isNew = 1
|
|
|
|
newCount++
|
|
|
|
}
|
2022-08-05 22:12:57 +00:00
|
|
|
chars.push(tmp)
|
|
|
|
})
|
|
|
|
|
|
|
|
if (chars.length === 0) {
|
|
|
|
if (await autoRefresh(e)) {
|
|
|
|
await profileList(e, { render })
|
|
|
|
return true
|
|
|
|
} else {
|
|
|
|
e.reply('尚未获取任何角色数据')
|
|
|
|
}
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2022-08-08 21:16:37 +00:00
|
|
|
if (newCount > 0) {
|
|
|
|
hasNew = newCount <= 8
|
|
|
|
}
|
|
|
|
|
2022-08-05 22:12:57 +00:00
|
|
|
chars = lodash.sortBy(chars, ['isNew', 'star', 'level', 'id'])
|
|
|
|
chars = chars.reverse()
|
|
|
|
|
|
|
|
// 渲染图像
|
|
|
|
return await Common.render('character/profile-list', {
|
|
|
|
save_id: uid,
|
|
|
|
uid,
|
|
|
|
chars,
|
2022-08-08 21:16:37 +00:00
|
|
|
servName,
|
|
|
|
hasNew,
|
2022-08-05 22:12:57 +00:00
|
|
|
msg
|
|
|
|
}, { e, render, scale: 1.6 })
|
|
|
|
}
|