重构消息通知弹窗
This commit is contained in:
parent
96517b809e
commit
f108781983
@ -1,4 +1,6 @@
|
||||
import React, {useRef, useEffect, useState} from 'react';
|
||||
import {useSelector} from 'react-redux';
|
||||
import type {RootState} from '@/store';
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
@ -38,6 +40,9 @@ const DeploymentFormModal: React.FC<DeploymentFormModalProps> = ({
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [submitLoading, setSubmitLoading] = useState(false);
|
||||
|
||||
// 获取当前登录用户
|
||||
const currentUser = useSelector((state: RootState) => state.user.userInfo);
|
||||
|
||||
// ✅ 使用 useMemo 缓存预填充数据,避免每次渲染都创建新对象
|
||||
const prefillData = React.useMemo(() => {
|
||||
return {
|
||||
@ -60,6 +65,8 @@ const DeploymentFormModal: React.FC<DeploymentFormModalProps> = ({
|
||||
environmentName: environment.environmentName || '',
|
||||
// 任务编号(自动生成)
|
||||
deployRemark: '',
|
||||
// 部署人(当前登录用户的 username)
|
||||
deployUser: currentUser?.username || '',
|
||||
// 审批信息
|
||||
approval: {
|
||||
required: environment.requiresApproval ? 'true' : 'false',
|
||||
@ -76,7 +83,7 @@ const DeploymentFormModal: React.FC<DeploymentFormModalProps> = ({
|
||||
buildFailureNotificationTemplateId: environment.notificationConfig?.buildFailureNotificationTemplateId,
|
||||
},
|
||||
};
|
||||
}, [app, environment, teamId]); // 只在这些依赖变化时重新生成
|
||||
}, [app, environment, teamId, currentUser]); // 只在这些依赖变化时重新生成
|
||||
|
||||
// 🎯 1. 加载表单定义 (ID=2)
|
||||
useEffect(() => {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user