Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions src/components/Button/LevelDiglog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ export default {
},
method: "GET",
});
if (!response.ok) throw new Error(`HTTP 错误!状态:${response.status}`);
if (!response.ok)
throw new Error(`HTTP 错误!状态:${response.status}`);
return await response.json();
} catch (error) {
console.error("获取关于页面数据失败:", error);
Expand All @@ -87,7 +88,8 @@ export default {
},
method: "GET",
});
if (!response.ok) throw new Error(`HTTP 错误!状态:${response.status}`);
if (!response.ok)
throw new Error(`HTTP 错误!状态:${response.status}`);
return await response.json();
} catch (error) {
console.error("获取用户数据失败:", error);
Expand Down Expand Up @@ -170,10 +172,13 @@ export default {
created() {
setInterval(() => {
if (!this.username) {
const src = $("#toggle-current-user img.avatar").attr("src");
const match = src.match(/\/user_avatar\/linux\.do\/([^\/]+)/);
if (match && match[1]) {
this.username = match[1];
const avatarImg = $("#toggle-current-user img.avatar");
const src = avatarImg.length ? avatarImg.attr("src") : null;
if (src) {
const match = src.match(/\/user_avatar\/linux\.do\/([^\/]+)/);
if (match && match[1]) {
this.username = match[1];
}
}
}
}, 1000);
Expand Down