refactor: 优化认证系统和组件类型安全性

- 新增 safeLocalStorage 工具函数增强本地存储安全性
- 简化认证流程,重构用户数据结构和 token 管理
- 修复多个模块的 TypeScript 类型错误和导入问题
- 优化状态管理,重构各模块 store 结构
- 清理冗余代码,移除未使用的组件和函数
- 改进错误处理和边界情况处理
- 更新配置文件以支持最新的类型检查

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-13 14:52:52 +08:00
parent dfc29ce01f
commit 68d9d97142
29 changed files with 1122 additions and 3001 deletions

View File

@@ -62,19 +62,6 @@ export default function MessageTemplatePage() {
updatedAt: '2024-01-01T00:00:00',
createdBy: 'admin',
},
{
id: 'tpl-2',
code: 'EQUIPMENT_WARNING',
name: '设备预警通知',
type: 'sms',
content: '【智慧农业】设备预警:{{equipmentName}}检测到异常,{{warningType}},请及时处理。',
variables: ['equipmentName', 'warningType'],
isActive: true,
description: '设备出现异常时发送短信通知',
createdAt: '2024-01-01T00:00:00',
updatedAt: '2024-01-01T00:00:00',
createdBy: 'admin',
},
{
id: 'tpl-3',
code: 'MAINTENANCE_REMINDER',
@@ -200,7 +187,7 @@ export default function MessageTemplatePage() {
}
// 检查变量是否都填写了
const emptyVars = Object.entries(testData.variables).filter(([k, v]) => !v.trim());
const emptyVars = Object.entries(testData.variables).filter(([k, v]) => !(v as string).trim());
if (emptyVars.length > 0) {
toast.error('请填写变量:' + emptyVars.map(([k]) => k).join(', '));
return;

View File

@@ -38,6 +38,7 @@ export interface LoginLogsQueryParams {
ip_address?: string;
sort_order?: 'asc' | 'desc';
order_by?: string;
keyword?:string;
}
// 分页状态接口
@@ -83,13 +84,11 @@ export const fetchLoginLogs = async (params: LoginLogsQueryParams = {}) => {
query: {
page: params.page || 1,
size: params.size || 10,
username: params.username,
keyword: params.keyword,
status: params.status,
start_time: params.start_time,
end_time: params.end_time,
ip_address: params.ip_address,
sort_order: params.sort_order || 'desc',
order_by: params.order_by || 'created_at',
}
});

View File

@@ -19,7 +19,6 @@ import {
LoginLog,
PaginationState,
LoginLogsQueryParams,
fetchLoginStatistics,
exportLoginLogs
} from './components/loginLogApi';
@@ -39,7 +38,6 @@ export default function LoginLogPage() {
search: '',
status: 'all'
});
const isFirstLoad = useRef(true);
// 搜索字段配置
const searchFields: SearchFieldConfig[] = [

View File

@@ -519,7 +519,6 @@ useEffect(() => {
onPageChange: handlePageChange,
onSizeChange: handleSizeChange,
onSearch: handleSearch,
onSort: handleSort,
emptyIcon: <FileText className="w-12 h-12 mx-auto mb-4 opacity-20" />,
emptyText: "暂无审核记录",
sizeOptions: [10, 20, 50, 100]

View File

@@ -516,12 +516,9 @@ export default function EnterpriseAuditPage() {
loading={state.loading}
error={state.error}
pagination={state.pagination}
sortBy={state.sortBy}
sortOrder={state.sortOrder}
onPageChange={handlePageChange}
onSizeChange={handleSizeChange}
onSearch={handleSearch}
onSort={handleSort}
emptyIcon={<Building2 className="w-12 h-12" />}
emptyText="暂无企业审核数据"
showSizeSelector={true}

View File

@@ -602,7 +602,6 @@ export default function EnterpriseManagement() {
onPageChange={handlePageChange}
onSizeChange={handleSizeChange}
onSearch={handleSearch}
onSort={handleSort}
emptyIcon={<Building2 className="w-12 h-12 mx-auto mb-4 opacity-20" />}
emptyText="暂无企业数据"
/>

View File

@@ -622,12 +622,9 @@ export default function TenantUserManagementPage() {
loading={state.loading}
error={state.error}
pagination={state.pagination}
sortBy={state.sortBy}
sortOrder={state.sortOrder}
onPageChange={handlePageChange}
onSizeChange={handleSizeChange}
onSearch={handleSearch}
onSort={handleSort}
emptyText="暂无用户数据"
sizeOptions={[10, 20, 50, 100]}
/>