diff --git a/apps/character/ProfileList.js b/apps/character/ProfileList.js index 54ab7a6b..8c74b9a0 100644 --- a/apps/character/ProfileList.js +++ b/apps/character/ProfileList.js @@ -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) { diff --git a/components/Profile.js b/components/Profile.js index 912e477f..f369a732 100644 --- a/components/Profile.js +++ b/components/Profile.js @@ -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 = {} diff --git a/config/system/cfg_system.js b/config/system/cfg_system.js index d83a63c7..096d3659 100644 --- a/config/system/cfg_system.js +++ b/config/system/cfg_system.js @@ -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: '上传深渊', diff --git a/models/ProfileRank.js b/models/ProfileRank.js index dad3bd88..8f5e2074 100644 --- a/models/ProfileRank.js +++ b/models/ProfileRank.js @@ -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} + */ 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 diff --git a/resources/admin/index.css b/resources/admin/index.css index c72dbd9b..edf01540 100644 --- a/resources/admin/index.css +++ b/resources/admin/index.css @@ -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; diff --git a/resources/admin/index.less b/resources/admin/index.less index 0d0fe814..856e2bab 100644 --- a/resources/admin/index.less +++ b/resources/admin/index.less @@ -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 { diff --git a/resources/character/profile-list.html b/resources/character/profile-list.html index e4350665..9db746ac 100644 --- a/resources/character/profile-list.html +++ b/resources/character/profile-list.html @@ -17,7 +17,7 @@
- {{if !allowRank || true}} + {{if !allowRank}} 本面板暂未参与排名,参与要求:{{rankCfg.limitTxt}} {{else}}