Files
gongxue-base/apps/admin/src/hooks/useViewSensitive.ts
wangziqi 42d3f0e27f feat: DingTalk attendance import + integration config + expense types + UI polish
Server:
- Add DingTalk attendance import service with SSE progress streaming
- Add IntegrationConfig entity & module for multi-tenant DingTalk setup
- Add ExpenseType entity & ExpenseTypesModule
- Add SeedModule for DB initialization
- Add UserDingMapping entity for DingTalk user linkage
- Attendance service: import flow with dedup & student auto-mapping
- Rooms service: time-range overlap queries
- Sync controller/service: DingTalk integration wiring
- Permission guard: refactor to pure re-export
- Campus scope middleware: tenant-aware filtering

Admin UI:
- Attendance page: import UI with progress & result summary
- All pages: tableStyle/tablePagination standardization
- Login page: responsive styling
- Sensitive data: useViewSensitive hook for masked viewing
- Vite config: path aliases, build optimization
- Test infra: vitest config, test utilities

Docs: PRD DingTalk batch 1 & 2 design docs
2026-07-09 09:11:56 +08:00

44 lines
1.3 KiB
TypeScript

import { useCallback } from 'react';
import { Modal, message } from 'antd';
import api from '../api';
/**
* Shared hook for viewing sensitive student info (phone / ID number).
* Logs an audit entry before revealing the unmasked value.
*
* @param studentId - The student whose data is being viewed
* @param module - Audit module label (e.g. '学生管理', '学生档案')
*/
export function useViewSensitive(studentId: number, module: string) {
return useCallback(
(field: string, value: string) => {
Modal.confirm({
title: '查看敏感信息',
content: `您即将查看 "${field}" 的完整信息。此操作将被记录。`,
okText: '确认查看',
cancelText: '取消',
onOk: async () => {
try {
await api.post('/operation-logs/audit', {
module,
action: '查看敏感信息',
targetId: studentId,
targetType: 'student',
detail: `查看${field}`,
});
} catch {
message.error('操作日志记录失败,请稍后重试');
return;
}
Modal.info({
title: field,
content: value,
okText: '关闭',
});
},
});
},
[studentId, module],
);
}