首页统计
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import logo from '@/assets/logo.png';
|
||||
|
||||
import logo from '@/assets/logo.png';
|
||||
import React, { useEffect, useRef, useState } from 'react';
|
||||
import { LoginForm, ProFormText, ProFormCaptcha, ProFormCheckbox } from '@ant-design/pro-components';
|
||||
import { AppstoreOutlined, LockOutlined, UserOutlined } from '@ant-design/icons';
|
||||
@@ -26,14 +27,25 @@ const LoginPage: React.FC = () => {
|
||||
if (loading) return;
|
||||
setLoading(true);
|
||||
try {
|
||||
const res = await login({ ...values, deviceId: uuid });
|
||||
const res = await login({ ...values, clientId: 'webApp', deviceId: uuid });
|
||||
|
||||
// 检查多种可能的token字段位置
|
||||
const accessToken = res?.access_token || res?.data?.access_token || res?.accessToken;
|
||||
|
||||
if (accessToken) {
|
||||
sessionStorage.setItem('access_token', accessToken);
|
||||
localStorage.setItem('tenant_client_id', String(values.clientId ?? ''));
|
||||
// 登录后预热可访问租户树缓存,便于各页快速使用
|
||||
try {
|
||||
const { ensureTenantCacheTokenGuard, setTenantTreeCache } = await import('@/utils/tenantCache');
|
||||
const { tenantApi } = await import('@/services/tenant');
|
||||
ensureTenantCacheTokenGuard();
|
||||
const treeRes: any = await tenantApi.getAccessibleTenants();
|
||||
let list: any[] = [];
|
||||
if (typeof treeRes?.success !== 'undefined') list = treeRes.success ? (treeRes.data || []) : [];
|
||||
else if (Array.isArray(treeRes)) list = treeRes as any[];
|
||||
if (list && list.length) setTenantTreeCache(list);
|
||||
} catch {}
|
||||
localStorage.setItem('tenant_client_id', 'webApp');
|
||||
message.success('登录成功,正在跳转...');
|
||||
|
||||
// 使用umi的history进行路由跳转
|
||||
@@ -84,6 +96,8 @@ const LoginPage: React.FC = () => {
|
||||
>
|
||||
<ProFormText
|
||||
name="clientId"
|
||||
initialValue="webApp"
|
||||
disabled
|
||||
fieldProps={{ size: 'large', prefix: <AppstoreOutlined /> }}
|
||||
placeholder="请输入租户标识"
|
||||
rules={[{ required: true, message: '请输入租户标识' }]}
|
||||
|
||||
Reference in New Issue
Block a user