修复练习不能分享的问题

This commit is contained in:
kron
2025-11-11 10:13:14 +08:00
parent 81ab085e48
commit dfc62c7e3f
9 changed files with 60 additions and 128 deletions

View File

@@ -71,22 +71,16 @@ export default defineStore("store", {
},
async updateUser(user = {}) {
this.user = { ...defaultUser, ...user };
if (user.avatar) {
// 先保存到本地,分享只能用本地图片
const imageInfo = await uni.getImageInfo({ src: user.avatar });
this.user.avatar = imageInfo.path;
}
if (this.user.rankLvl !== undefined) {
this.user.lvlName = getLvlName(
this.user.rankLvl,
this.config.randInfos
);
}
const lvlImage = getLvlImage(this.user.rankLvl, this.config.randInfos);
if (lvlImage) {
const imageInfo = await uni.getImageInfo({ src: lvlImage });
this.user.lvlImage = imageInfo.path;
}
this.user.lvlImage = getLvlImage(
this.user.rankLvl,
this.config.randInfos
);
},
updateDevice(deviceId, deviceName) {
this.device.deviceId = deviceId;
@@ -95,13 +89,15 @@ export default defineStore("store", {
async updateConfig(config) {
this.config = config;
if (this.user.scores !== undefined) {
this.user.lvlName = getLvlName(this.user.scores, this.config.randInfos);
}
const lvlImage = getLvlImage(this.user.rankLvl, this.config.randInfos);
if (lvlImage) {
const imageInfo = await uni.getImageInfo({ src: lvlImage });
this.user.lvlImage = imageInfo.path;
this.user.lvlName = getLvlName(
this.user.rankLvl,
this.config.randInfos
);
}
this.user.lvlImage = getLvlImage(
this.user.rankLvl,
this.config.randInfos
);
},
},