fix(ui): 修复登录与并发请求并统一表格、主题和页面展示
验证:868 项单测、ESLint、Prettier、UI 依赖审计和差异检查通过。
This commit is contained in:
@@ -198,12 +198,20 @@ const PageLayout = () => {
|
||||
return;
|
||||
}
|
||||
|
||||
const sessionAPI = API;
|
||||
const isCurrentSession = () => {
|
||||
const currentUser = getUserData();
|
||||
return (
|
||||
sessionAPI === API && currentUser?.id === cachedUser.id && !!currentUser
|
||||
);
|
||||
};
|
||||
userDispatch({ type: 'auth_start' });
|
||||
try {
|
||||
const res = await API.get('/api/user/self', {
|
||||
const res = await sessionAPI.get('/api/user/self', {
|
||||
skipErrorHandler: true,
|
||||
disableDuplicate: true,
|
||||
});
|
||||
if (!isCurrentSession()) return;
|
||||
const { success, data } = res.data;
|
||||
if (success && data) {
|
||||
setUserData(data);
|
||||
@@ -213,6 +221,7 @@ const PageLayout = () => {
|
||||
userDispatch({ type: 'logout' });
|
||||
}
|
||||
} catch (error) {
|
||||
if (!isCurrentSession()) return;
|
||||
if (error?.response?.status === 401 || error?.response?.status === 403) {
|
||||
clearUserData();
|
||||
userDispatch({ type: 'logout' });
|
||||
|
||||
@@ -146,7 +146,10 @@ const ActionButtons = ({
|
||||
<div className='ui-header-actions flex items-center shrink-0'>
|
||||
{/* Tutorial Button - 新手教程按钮 (桌面端显示) */}
|
||||
{isLoggedIn && isButtonVisible('tutorial') && (
|
||||
<Link to='/tutorial' className='hidden sm:block'>
|
||||
<Link
|
||||
to='/tutorial'
|
||||
className='ui-header-action-link ui-header-desktop-action'
|
||||
>
|
||||
<AntButton icon={actionIcon(BookOpen)}>
|
||||
{!isMobile && t('新手教程')}
|
||||
</AntButton>
|
||||
@@ -157,7 +160,7 @@ const ActionButtons = ({
|
||||
{isLoggedIn && isButtonVisible('pricing') && (
|
||||
<AntButton
|
||||
icon={actionIcon(Share2)}
|
||||
className='hidden sm:!inline-flex'
|
||||
className='ui-header-desktop-action'
|
||||
onClick={() => setPromotionVisible(true)}
|
||||
>
|
||||
{!isMobile && t('推广')}
|
||||
@@ -169,7 +172,7 @@ const ActionButtons = ({
|
||||
<Tooltip title={t('下载 WeyAi')}>
|
||||
<Link
|
||||
to='/weyai/download'
|
||||
className='hidden sm:block'
|
||||
className='ui-header-action-link ui-header-desktop-action'
|
||||
aria-label={t('下载 WeyAi 桌面端')}
|
||||
>
|
||||
<AntButton
|
||||
@@ -185,7 +188,7 @@ const ActionButtons = ({
|
||||
|
||||
{/* Recharge Button - 充值按钮 */}
|
||||
{isButtonVisible('recharge') && !isMiniProgramWebView() && (
|
||||
<Link to='/recharge'>
|
||||
<Link to='/recharge' className='ui-header-action-link'>
|
||||
<AntButton
|
||||
icon={actionIcon(Wallet)}
|
||||
aria-label={isMobile ? t('充值') : undefined}
|
||||
|
||||
Reference in New Issue
Block a user