Skip to content

Commit 169d158

Browse files
committed
更新文档
1 parent 5304e8f commit 169d158

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

docs/.vuepress/public/js/gitee.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,36 @@ if (typeof window !== 'undefined') {
102102
return
103103
}
104104
let user = getUserInfo()
105+
106+
//浮层遮挡,提示授权检测中
107+
// 创建一个遮罩层元素
108+
const mask = document.createElement('div');
109+
mask.style.position = 'fixed';
110+
mask.style.top = '0';
111+
mask.style.left = '0';
112+
mask.style.width = '100%';
113+
mask.style.height = '100%';
114+
mask.style.backgroundColor = 'rgba(0, 0, 0, 0.5)'; // 半透明黑色背景
115+
mask.style.zIndex = '9999'; // 确保遮罩层在最上层
116+
117+
// 创建一个提示框元素
118+
const promptBox = document.createElement('div');
119+
promptBox.style.position = 'fixed';
120+
promptBox.style.top = '50%';
121+
promptBox.style.left = '50%';
122+
promptBox.style.transform = 'translate(-50%, -50%)';
123+
promptBox.style.padding = '20px';
124+
promptBox.style.backgroundColor = '#fff';
125+
promptBox.style.borderRadius = '5px';
126+
promptBox.style.boxShadow = '0 0 10px rgba(0, 0, 0, 0.3)';
127+
promptBox.style.zIndex = '10000'; // 确保提示框在遮罩层之上
128+
129+
// 设置提示框内容
130+
promptBox.innerHTML = '<p>授权检测中,请稍候...</p>';
131+
// 将遮罩层和提示框添加到页面中
132+
document.body.appendChild(mask);
133+
document.body.appendChild(promptBox);
134+
105135
fetch("https://gitee.com/api/v5/repos/" + owner + "/" + repo + "/contents/" + file + "?access_token=" + access_token, {
106136
method: "GET"
107137
})
@@ -121,6 +151,9 @@ if (typeof window !== 'undefined') {
121151
let json = JSON.parse(content)
122152
if (json[user?.login] != null) {
123153
console.log("check result", "ok");
154+
// 授权检测完成后,移除遮罩层和提示框
155+
document.body.removeChild(mask);
156+
document.body.removeChild(promptBox);
124157
} else {
125158
if(failCallback!= null){
126159
failCallback()

0 commit comments

Comments
 (0)