重构消息通知弹窗

This commit is contained in:
dengqichen 2025-11-14 14:45:45 +08:00
parent 3a7492ac91
commit 46f23104f9
5 changed files with 37 additions and 36 deletions

View File

@ -80,7 +80,7 @@ export const ApplicationCard: React.FC<ApplicationCardProps> = ({
{app.branch ? ( {app.branch ? (
<code className="truncate font-mono">{app.branch}</code> <code className="truncate font-mono">{app.branch}</code>
) : ( ) : (
<Skeleton className="h-3 w-16" /> <span className="text-amber-600 italic font-medium"></span>
)} )}
</div> </div>

View File

@ -59,7 +59,7 @@ const DeploymentFormModal: React.FC<DeploymentFormModalProps> = ({
environmentCode: environment.environmentCode || '', environmentCode: environment.environmentCode || '',
environmentName: environment.environmentName || '', environmentName: environment.environmentName || '',
// 任务编号(自动生成) // 任务编号(自动生成)
taskNo: '', deployRemark: '',
// 审批信息 // 审批信息
approval: { approval: {
required: environment.requiresApproval ? 'true' : 'false', required: environment.requiresApproval ? 'true' : 'false',

View File

@ -104,7 +104,7 @@ export const EnvironmentTabs: React.FC<EnvironmentTabsProps> = React.memo(({
</CardContent> </CardContent>
</Card> </Card>
) : ( ) : (
<div className="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 xl:grid-cols-4 gap-4"> <div className="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-5 gap-4">
{env.applications.map((app) => ( {env.applications.map((app) => (
<ApplicationCard <ApplicationCard
key={app.teamApplicationId} key={app.teamApplicationId}

View File

@ -34,7 +34,7 @@ import {
createTemplate, createTemplate,
updateTemplate, updateTemplate,
getTemplateById, getTemplateById,
checkTemplateCodeUnique, // checkTemplateCodeUnique, // 暂时注释掉,后端没有这个接口
renderTemplate, renderTemplate,
} from '../service'; } from '../service';
import { TemplateEditor, TemplateRender } from './'; import { TemplateEditor, TemplateRender } from './';
@ -112,31 +112,31 @@ export const NotificationTemplateDialog: React.FC<NotificationTemplateDialogProp
const watchedTemplate = watch('contentTemplate'); const watchedTemplate = watch('contentTemplate');
const watchedTemplateConfig = watch('templateConfig'); const watchedTemplateConfig = watch('templateConfig');
// 验证编码唯一性 // 验证编码唯一性 - 暂时注释掉,后端没有这个接口
const validateCodeUnique = async (code: string) => { // const validateCodeUnique = async (code: string) => {
if (!code || code.length < 1) return; // if (!code || code.length < 1) return;
//
try { // try {
const isUnique = await checkTemplateCodeUnique(code, editId); // const isUnique = await checkTemplateCodeUnique(code, editId);
if (!isUnique) { // if (!isUnique) {
setError('code', { message: '模板编码已存在' }); // setError('code', { message: '模板编码已存在' });
} else { // } else {
clearErrors('code'); // clearErrors('code');
} // }
} catch (error) { // } catch (error) {
console.error('Failed to check code uniqueness:', error); // console.error('Failed to check code uniqueness:', error);
} // }
}; // };
// 监听编码变化进行唯一性验证 // 监听编码变化进行唯一性验证 - 暂时注释掉,后端没有这个接口
useEffect(() => { // useEffect(() => {
if (watchedCode && mode === 'create') { // if (watchedCode && mode === 'create') {
const timer = setTimeout(() => { // const timer = setTimeout(() => {
validateCodeUnique(watchedCode); // validateCodeUnique(watchedCode);
}, 500); // }, 500);
return () => clearTimeout(timer); // return () => clearTimeout(timer);
} // }
}, [watchedCode, mode]); // }, [watchedCode, mode]);
// 加载编辑数据 // 加载编辑数据
useEffect(() => { useEffect(() => {

View File

@ -126,15 +126,16 @@ export const batchDisableTemplates = async (ids: number[]): Promise<void> => {
/** /**
* *
*
*/ */
export const checkTemplateCodeUnique = async ( // export const checkTemplateCodeUnique = async (
code: string, // code: string,
excludeId?: number // excludeId?: number
): Promise<boolean> => { // ): Promise<boolean> => {
return request.get(`${API_PREFIX}/check-code`, { // return request.get(`${API_PREFIX}/check-code`, {
params: { code, excludeId }, // params: { code, excludeId },
}); // });
}; // };
/** /**
* *