Spaces:
Running
Running
File size: 1,269 Bytes
18ffd74 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | import os
with open('/Users/liruojuan/Library/CloudStorage/OneDrive-个人/Code/Python/Flask App/成绩查询/templates/login.html', 'r', encoding='utf-8') as f:
text = f.read()
text = text.replace(
'if (data.has_qr) {',
'''window.lastQrUpdate = window.lastQrUpdate || 0;
if (data.has_qr && data.status === 'waiting_login') {'''
)
text = text.replace(
'''qrImg.src = `/static/dingtalk_qr.png?t=${Date.now()}`;''',
'''if (!qrImg.src || qrImg.src.indexOf('static/dingtalk_qr.png') === -1 || (Date.now() - window.lastQrUpdate > 3000)) {
qrImg.src = `/static/dingtalk_qr.png?t=${Date.now()}`;
window.lastQrUpdate = Date.now();
}'''
)
text = text.replace(
'''qrPlaceholder.style.display = 'none';\n }''',
'''qrPlaceholder.style.display = 'none';
} else {
qrImg.style.display = 'none';
qrImg.src = '';
qrPlaceholder.style.display = 'flex';
qrPlaceholder.innerHTML = '<span>' + (data.status === "done" ? "登录已完成" : (isError ? "抓取异常" : "暂无二维码")) + '</span>';
}'''
)
with open('/Users/liruojuan/Library/CloudStorage/OneDrive-个人/Code/Python/Flask App/成绩查询/templates/login.html', 'w', encoding='utf-8') as f:
f.write(text)
|