新增片刻删除提示框、动画;修复异常;深度优化
This commit is contained in:
@@ -143,9 +143,10 @@ login_loginBtn.addEventListener('click', async () => {
|
||||
if (finalUrl.includes('/uc')) {
|
||||
cocoMessage.success('署名成功,正在跳转...');
|
||||
login_loginBtn.textContent = '跳转中...';
|
||||
setTimeout(() => {
|
||||
window.location.reload();
|
||||
}, 800);
|
||||
const currentScrollTop = window.scrollY || document.documentElement.scrollTop;
|
||||
$.cookie('scrollParam', currentScrollTop, { path: '/', domain: 'anian.cc' });
|
||||
$.cookie('load_type', 'login', { path: '/', domain: 'anian.cc' });
|
||||
window.location.reload();
|
||||
} else if (finalUrl.includes('error=invalid-credential')) {
|
||||
cocoMessage.warning('署名人与心上锁不匹配');
|
||||
fetchCSRFToken();
|
||||
@@ -181,6 +182,8 @@ document.addEventListener("keydown", function (e) {
|
||||
|
||||
// 退出登录
|
||||
async function customLogout() {
|
||||
$('.pixar-notice-btn-confirm, .pixar-notice-btn-close').prop('disabled', true);
|
||||
let closeLoading = cocoMessage.loading('退出登录中...');
|
||||
try {
|
||||
const getResponse = await fetch('/logout', { credentials: 'include' });
|
||||
const htmlText = await getResponse.text();
|
||||
@@ -189,6 +192,8 @@ async function customLogout() {
|
||||
const logoutCsrfToken = doc.querySelector('input[name="_csrf"]')?.value;
|
||||
if (!logoutCsrfToken) {
|
||||
cocoMessage.error('页面未找到 CSRF 令牌');
|
||||
$('.pixar-notice-btn-confirm, .pixar-notice-btn-close').prop('disabled', false);
|
||||
closeLoading();
|
||||
return;
|
||||
}
|
||||
const postResponse = await fetch('/logout', {
|
||||
@@ -202,14 +207,20 @@ async function customLogout() {
|
||||
})
|
||||
});
|
||||
if (postResponse.ok) {
|
||||
closeLoading();
|
||||
cocoMessage.success('您已成功退出登录');
|
||||
setTimeout(() => {
|
||||
window.location.reload();
|
||||
}, 800);
|
||||
const currentScrollTop = window.scrollY || document.documentElement.scrollTop;
|
||||
$.cookie('scrollParam', currentScrollTop, { path: '/', domain: 'anian.cc' });
|
||||
$.cookie('load_type', 'logout', { path: '/', domain: 'anian.cc' });
|
||||
window.location.reload();
|
||||
} else {
|
||||
closeLoading();
|
||||
$('.pixar-notice-btn-confirm, .pixar-notice-btn-close').prop('disabled', false);
|
||||
throw new Error('退出请求被拒绝');
|
||||
}
|
||||
} catch (err) {
|
||||
closeLoading();
|
||||
$('.pixar-notice-btn-confirm, .pixar-notice-btn-close').prop('disabled', false);
|
||||
console.error('Logout Error:', err);
|
||||
cocoMessage.error('退出失败,请手动刷新页面');
|
||||
}
|
||||
@@ -229,7 +240,16 @@ function confirmPixarAction() {
|
||||
customLogout();
|
||||
}
|
||||
|
||||
|
||||
// 打开确认模态框
|
||||
function openModal(title, msg, type) {
|
||||
var modal = $('#momentsDeleteModal');
|
||||
var card = modal.find('.moments-card-widget');
|
||||
modal.find('.moments-title-text').text(title);
|
||||
modal.find('.moments-message-text').text(msg);
|
||||
card.removeClass('theme-red theme-yellow theme-green').addClass('theme-' + type);
|
||||
$('.moments-btn-cancel, .moments-btn-confirm').prop('disabled', false);
|
||||
modal.fadeIn(200);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user