mirror of
https://github.com/yoimiya-kokomi/miao-plugin.git
synced 2024-11-25 01:21:55 +00:00
面板排名支持限制是否绑定CK
This commit is contained in:
parent
34a0e1f0f3
commit
7e519fdfe3
@ -8,8 +8,12 @@ export async function profileList (e) {
|
||||
if (!uid) {
|
||||
return true
|
||||
}
|
||||
let isSelfUid = false
|
||||
if (e.runtime) {
|
||||
let uids = e.runtime?.user?.ckUids || []
|
||||
isSelfUid = uids.join(',').split(',').includes(uid + '')
|
||||
}
|
||||
let rank = false
|
||||
|
||||
let servName = Profile.getServName(uid)
|
||||
let hasNew = false
|
||||
let newCount = 0
|
||||
@ -25,7 +29,7 @@ export async function profileList (e) {
|
||||
// 获取面板数据
|
||||
let profiles = Profile.getAll(uid)
|
||||
// 检测标志位
|
||||
await ProfileRank.setRankLimit(uid, profiles)
|
||||
await ProfileRank.setRankLimit(uid, profiles, isSelfUid)
|
||||
|
||||
let groupId = e.group_id
|
||||
if (groupId) {
|
||||
|
@ -36,7 +36,11 @@ let Profile = {
|
||||
let userData = {}
|
||||
const userFile = `${userPath}/${uid}.json`
|
||||
if (fs.existsSync(userFile)) {
|
||||
userData = JSON.parse(fs.readFileSync(userFile, 'utf8')) || {}
|
||||
try {
|
||||
userData = JSON.parse(fs.readFileSync(userFile, 'utf8')) || {}
|
||||
} catch (e) {
|
||||
userData = {}
|
||||
}
|
||||
}
|
||||
lodash.assignIn(userData, lodash.pick(data, 'uid,name,lv,avatar'.split(',')))
|
||||
userData.chars = userData.chars || {}
|
||||
@ -93,7 +97,11 @@ let Profile = {
|
||||
const userFile = `${userPath}/${uid}.json`
|
||||
let userData = {}
|
||||
if (fs.existsSync(userFile)) {
|
||||
userData = JSON.parse(fs.readFileSync(userFile, 'utf8')) || {}
|
||||
try {
|
||||
userData = JSON.parse(fs.readFileSync(userFile, 'utf8')) || {}
|
||||
} catch (e) {
|
||||
userData = {}
|
||||
}
|
||||
}
|
||||
if (userData && userData.chars) {
|
||||
let ret = {}
|
||||
|
@ -27,7 +27,7 @@ export const cfgSchema = {
|
||||
key: '限制',
|
||||
def: 1,
|
||||
type: 'num',
|
||||
desc: '参与排名的限制条件:1:无限制 2:有16个角色 3:有御三家(安柏&凯亚&丽莎) 4:有16个角色+御三家。若改变设置请根据情况决定是否需要【#重置排名】'
|
||||
desc: '参与排名的限制条件:1:无限制 2:有CK 3:有16个角色或有CK 4:有御三家(安柏&凯亚&丽莎)或有CK 5:有16个角色+御三家或有CK。 若改变设置请根据情况决定是否需要【#重置排名】'
|
||||
},
|
||||
uploadAbyssData: {
|
||||
title: '上传深渊',
|
||||
|
@ -151,14 +151,14 @@ export default class ProfileRank {
|
||||
static async getGroupCfg (groupId) {
|
||||
const rankLimitTxt = {
|
||||
1: '无限制',
|
||||
2: '面板列表中至少有16个角色的数据',
|
||||
3: '面板列表中有 安柏&凯亚&丽莎 的数据',
|
||||
4: '面板列表至少有16个角色数据,且包含安柏&凯亚&丽莎'
|
||||
2: '绑定有CK的用户',
|
||||
3: '绑定CK,或列表有16个角色数据',
|
||||
4: '绑定CK,或列表有安柏&凯亚&丽莎的数据',
|
||||
5: '绑定CK,或列表有16个角色数据且包含安柏&凯亚&丽莎'
|
||||
}
|
||||
let rankLimit = Common.cfg('groupRankLimit') * 1 || 1
|
||||
let ret = {
|
||||
timestamp: (new Date()) * 1,
|
||||
limitTxt: rankLimitTxt[rankLimit],
|
||||
status: 0
|
||||
}
|
||||
try {
|
||||
@ -170,11 +170,12 @@ export default class ProfileRank {
|
||||
}
|
||||
} catch (e) {
|
||||
}
|
||||
ret.limitTxt = rankLimitTxt[rankLimit]
|
||||
ret.time = moment(new Date(ret.timestamp)).format('MM-DD HH:mm')
|
||||
return ret
|
||||
}
|
||||
|
||||
static async setRankLimit (uid, profiles) {
|
||||
static async setRankLimit (uid, profiles, isSelfUid = false) {
|
||||
if (!uid) {
|
||||
return false
|
||||
}
|
||||
@ -190,12 +191,31 @@ export default class ProfileRank {
|
||||
}
|
||||
totalCount++
|
||||
}
|
||||
let data = {}
|
||||
try {
|
||||
data = await redis.get(`miao:rank:uid-info:${uid}`)
|
||||
if (data) {
|
||||
data = JSON.parse(data)
|
||||
}
|
||||
} catch (e) {
|
||||
data = {}
|
||||
}
|
||||
await redis.set(`miao:rank:uid-info:${uid}`, JSON.stringify({
|
||||
totalCount,
|
||||
basicCount
|
||||
basicCount,
|
||||
isSelfUid: !!(isSelfUid || data.isSelfUid)
|
||||
}), { EX: 3600 * 24 * 365 })
|
||||
}
|
||||
|
||||
/**
|
||||
* 1: '无限制',
|
||||
* 2: '绑定有CK的用户',
|
||||
* 3: '面板列表有16个角色数据,或绑定CK',
|
||||
* 4: '面板列表有安柏&凯亚&丽莎的数据,或绑定CK',
|
||||
* 5: '面板列表有16个角色数据且包含安柏&凯亚&丽莎,或绑定CK'
|
||||
* @param uid
|
||||
* @returns {Promise<boolean>}
|
||||
*/
|
||||
static async checkRankLimit (uid) {
|
||||
if (!uid) {
|
||||
return false
|
||||
@ -207,10 +227,16 @@ export default class ProfileRank {
|
||||
}
|
||||
let data = await redis.get(`miao:rank:uid-info:${uid}`)
|
||||
data = JSON.parse(data)
|
||||
if ((data.totalCount || 0) < 16 && [2, 4].includes(rankLimit)) {
|
||||
if (data.isSelfUid) {
|
||||
return true
|
||||
}
|
||||
if (rankLimit === 2) {
|
||||
return false
|
||||
}
|
||||
if ((data.basicCount || 0) < 3 && [3, 4].includes(rankLimit)) {
|
||||
if ((data.totalCount || 0) < 16 && [3, 5].includes(rankLimit)) {
|
||||
return false
|
||||
}
|
||||
if ((data.basicCount || 0) < 3 && [4, 5].includes(rankLimit)) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
|
@ -1,11 +1,11 @@
|
||||
body {
|
||||
transform: scale(1);
|
||||
width: 520px;
|
||||
width: 700px;
|
||||
}
|
||||
.container {
|
||||
background: url("./imgs/bg.png") #000144 left top no-repeat;
|
||||
background-size: 520px auto;
|
||||
width: 520px;
|
||||
background-size: 700px auto;
|
||||
width: 700px;
|
||||
}
|
||||
.head-box {
|
||||
margin: 0 0 80px 0;
|
||||
|
@ -1,12 +1,12 @@
|
||||
body {
|
||||
transform: scale(1);
|
||||
width: 520px;
|
||||
width: 700px;
|
||||
}
|
||||
|
||||
.container {
|
||||
background: url("./imgs/bg.png") #000144 left top no-repeat;
|
||||
background-size: 520px auto;
|
||||
width:520px;
|
||||
background-size: 700px auto;
|
||||
width:700px;
|
||||
}
|
||||
|
||||
.head-box {
|
||||
|
@ -17,7 +17,7 @@
|
||||
</div>
|
||||
<div class="cont group-rank-tip {{groupRank?'has-rank':'no-rank'}}">
|
||||
<div class="cont-title">
|
||||
{{if !allowRank || true}}
|
||||
{{if !allowRank}}
|
||||
<span> <i class="group-rank-icon dmg-icon"></i>本面板暂未参与排名,参与要求:{{rankCfg.limitTxt}} </span>
|
||||
{{else}}
|
||||
<span>
|
||||
|
Loading…
Reference in New Issue
Block a user