-
Notifications
You must be signed in to change notification settings - Fork 11.3k
优化: 任务日志查询速度并显示用户详情 #2905
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
优化: 任务日志查询速度并显示用户详情 #2905
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -72,6 +72,10 @@ export const useTaskLogsData = () => { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const [isVideoModalOpen, setIsVideoModalOpen] = useState(false); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const [videoUrl, setVideoUrl] = useState(''); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // User info modal state | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const [showUserInfo, setShowUserInfoModal] = useState(false); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const [userInfoData, setUserInfoData] = useState(null); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Form state | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const [formApi, setFormApi] = useState(null); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let now = new Date(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -273,6 +277,21 @@ export const useTaskLogsData = () => { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| setIsVideoModalOpen(true); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // User info function | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const showUserInfoFunc = async (userId) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!isAdminUser) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const res = await API.get(`/api/user/${userId}`); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const { success, message, data } = res.data; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (success) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| setUserInfoData(data); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| setShowUserInfoModal(true); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| showError(message); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+280
to
+293
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing error handling for network failures.
Proposed fix const showUserInfoFunc = async (userId) => {
if (!isAdminUser) {
return;
}
- const res = await API.get(`/api/user/${userId}`);
- const { success, message, data } = res.data;
- if (success) {
- setUserInfoData(data);
- setShowUserInfoModal(true);
- } else {
- showError(message);
+ try {
+ const res = await API.get(`/api/user/${userId}`);
+ const { success, message, data } = res.data;
+ if (success) {
+ setUserInfoData(data);
+ setShowUserInfoModal(true);
+ } else {
+ showError(message);
+ }
+ } catch (error) {
+ showError(error);
}
};📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Initialize data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| useEffect(() => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const localPageSize = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -319,6 +338,12 @@ export const useTaskLogsData = () => { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| compactMode, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| setCompactMode, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // User info modal | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| showUserInfo, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| setShowUserInfoModal, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| userInfoData, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| showUserInfoFunc, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Functions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| loadLogs, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| handlePageChange, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.