diff --git a/common/common.css b/common/common.css index 4f59602..a127092 100644 --- a/common/common.css +++ b/common/common.css @@ -451,6 +451,14 @@ .no-login, .login-in { margin-left: 20px; + display: flex; + align-items: center; +} + +.no-login .btn-normal { + display: flex; + align-items: center; + justify-content: center; } .jr-tabs .title { diff --git a/common/common.js b/common/common.js index 3568cb6..c127b4b 100644 --- a/common/common.js +++ b/common/common.js @@ -44,8 +44,11 @@ $(function () { success: function (res) { if (res.status === 200) { const obj = res.data.account; - $(".no-login").attr("style", "display:none"); - $(".login-in").attr("style", "display:flex"); + // 只在桌面端显示登录状态 + if (window.innerWidth > 767) { + $(".no-login").attr("style", "display:none"); + $(".login-in").attr("style", "display:flex"); + } $("#username").text(res.data.account.username); const reg = /^[a-zA-Z]+$/; if (reg.test(res.data.account.username.substring(0, 1))) { @@ -73,8 +76,11 @@ $(function () { } sessionStorage.accountInfo = JSON.stringify(obj); } else { - $(".login-in").attr("style", "display:none"); - $(".no-login").attr("style", "display:block"); + // 只在桌面端显示未登录状态 + if (window.innerWidth > 767) { + $(".login-in").attr("style", "display:none"); + $(".no-login").attr("style", "display:block"); + } } }, }); @@ -96,14 +102,20 @@ $(function () { sessionStorage.is_certification = false; } } else { - $(".login-in").attr("style", "display:none"); - $(".no-login").attr("style", "display:block"); + // 只在桌面端显示未登录状态 + if (window.innerWidth > 767) { + $(".login-in").attr("style", "display:none"); + $(".no-login").attr("style", "display:block"); + } } }, }); } else { - $(".login-in").attr("style", "display:none"); - $(".no-login").attr("style", "display:block"); + // 只在桌面端显示未登录状态 + if (window.innerWidth > 767) { + $(".login-in").attr("style", "display:none"); + $(".no-login").attr("style", "display:block"); + } } }; // 设置通用信息相关的点击跳转(云服务器/物理机 CTA 等),来源于 SSR 注入的 window.__themeCommon @@ -174,8 +186,11 @@ $(function () { if (localStorage.jwt) { if (sessionStorage.accountInfo) { const obj = JSON.parse(sessionStorage.accountInfo); - $(".no-login").attr("style", "display:none"); - $(".login-in").attr("style", "display:flex"); + // 只在桌面端显示登录状态 + if (window.innerWidth > 767) { + $(".no-login").attr("style", "display:none"); + $(".login-in").attr("style", "display:flex"); + } $("#username").text(obj.username); $("#headImg").text(obj.firstName); $("#headImg").attr("style", `background:${sessionStorage.headBgc}`); @@ -189,8 +204,11 @@ $(function () { } initData(); } else { - $(".login-in").attr("style", "display:none"); - $(".no-login").attr("style", "display:block"); + // 只在桌面端显示未登录状态 + if (window.innerWidth > 767) { + $(".login-in").attr("style", "display:none"); + $(".no-login").attr("style", "display:block"); + } } // 退出登录 $("#logout").click(function () {