等级显示优化
This commit is contained in:
32
src/store.js
32
src/store.js
@@ -29,7 +29,22 @@ export default defineStore("store", {
|
||||
// 方法
|
||||
actions: {
|
||||
updateUser(user) {
|
||||
this.user = user || defaultUser;
|
||||
this.user = { ...defaultUser, ...user };
|
||||
const rankInfos = this.config.randInfos || [];
|
||||
let lvlName = "";
|
||||
if (this.user.scores) {
|
||||
rankInfos.some((r, index) => {
|
||||
lvlName = rankInfos[index].name;
|
||||
if (r.upgrade_scores > this.user.scores) {
|
||||
if (rankInfos[index - 1]) {
|
||||
lvlName = rankInfos[index - 1].name;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
this.user.lvlName = lvlName;
|
||||
},
|
||||
updateDevice(deviceId, deviceName) {
|
||||
this.device.deviceId = deviceId;
|
||||
@@ -37,6 +52,21 @@ export default defineStore("store", {
|
||||
},
|
||||
updateConfig(config) {
|
||||
this.config = config;
|
||||
const rankInfos = config.randInfos || [];
|
||||
let lvlName = "";
|
||||
if (this.user.scores) {
|
||||
rankInfos.some((r, index) => {
|
||||
lvlName = rankInfos[index].name;
|
||||
if (r.upgrade_scores > this.user.scores) {
|
||||
if (rankInfos[index - 1]) {
|
||||
lvlName = rankInfos[index - 1].name;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
this.user.lvlName = lvlName;
|
||||
},
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user