feat(schedule): 新增平台任务参数契约与动态选项支持

This commit is contained in:
hugo committed 2026-07-09 13:19:36 +08:00
1 parent 2ce1aca023
commit 8b5b0b49bf
76 files changed
+7103 -1203

No files matched your search

@@ -1,15 +1,25 @@
/**
* 对话页:删除确认弹窗、消息反馈弹窗状态。
* features/chat/page/useChatPageDialogs.ts
* 用途:对话页删除确认、发货「重试所有失败」确认、反馈弹窗与轻量 toast 状态。
* 依赖:vue computed/ref、chat.types。
* 逻辑:由 useChatPage 组装;ChatViewOverlays 绑定 DeleteConfirmDialog 与 toast 条。
*/
import { computed, ref } from 'vue';
import { computed, onBeforeUnmount, ref } from 'vue';
import type { ChatMessage } from '../types/chat.types';
import type { Ref } from 'vue';
const SHIPPING_TOAST_AUTO_CLOSE_MS = 3200;
export function useChatPageDialogs(messages: Ref<ChatMessage[]>) {
const showDeleteConfirmDialog = ref(false);
const deleteConfirmMessage = ref('');
let pendingDeleteAction: (() => Promise<void> | void) | null = null;
/**
* 打开删除确认弹窗,并在确认时执行待执行动作。
* @param message - 确认说明文案
* @param onConfirm - 用户确认后执行的回调
*/
const openDeleteConfirmDialog = (
message: string,
onConfirm: () => Promise<void> | void,
@@ -19,21 +29,93 @@ export function useChatPageDialogs(messages: Ref<ChatMessage[]>) {
showDeleteConfirmDialog.value = true;
};
/** 关闭删除确认弹窗并清空待执行动作。 */
const closeDeleteConfirmDialog = () => {
showDeleteConfirmDialog.value = false;
deleteConfirmMessage.value = '';
pendingDeleteAction = null;
};
/** 执行删除确认回调后关闭弹窗。 */
const handleDeleteConfirm = async () => {
if (!pendingDeleteAction) return;
await pendingDeleteAction();
closeDeleteConfirmDialog();
};
const showRetryFailedConfirmDialog = ref(false);
let pendingRetryFailedAction: (() => Promise<void> | void) | null = null;
/**
* 打开「重试所有失败」确认弹窗。
* 核心逻辑:仅登记确认后要执行的动作,实际请求由调用方注入。
* @param onConfirm - 用户点「确认重试」后执行的回调
*/
const openRetryFailedConfirm = (onConfirm: () => Promise<void> | void) => {
pendingRetryFailedAction = onConfirm;
showRetryFailedConfirmDialog.value = true;
};
/** 关闭重试确认弹窗并清空待执行动作。 */
const closeRetryFailedConfirm = () => {
showRetryFailedConfirmDialog.value = false;
pendingRetryFailedAction = null;
};
/**
* 用户确认后执行重试动作;弹窗由 DeleteConfirmDialog 自行关闭。
* 核心逻辑:取出并清空 pending,再 await 执行,避免重复确认。
*/
const handleRetryFailedConfirm = async () => {
const action = pendingRetryFailedAction;
pendingRetryFailedAction = null;
showRetryFailedConfirmDialog.value = false;
if (!action) return;
await action();
};
const shippingToastMessage = ref('');
let shippingToastTimer: ReturnType<typeof setTimeout> | null = null;
/** 清除 toast 自动关闭计时器。 */
const clearShippingToastTimer = () => {
if (!shippingToastTimer) return;
clearTimeout(shippingToastTimer);
shippingToastTimer = null;
};
/**
* 展示非阻塞顶部 toast(用于发货批量重试等轻量成功反馈)。
* @param message - toast 正文;空字符串视为关闭
*/
const showShippingToast = (message: string) => {
clearShippingToastTimer();
const next = String(message || '').trim();
shippingToastMessage.value = next;
if (!next) return;
shippingToastTimer = setTimeout(() => {
shippingToastMessage.value = '';
shippingToastTimer = null;
}, SHIPPING_TOAST_AUTO_CLOSE_MS);
};
/** 手动关闭发货 toast。 */
const clearShippingToast = () => {
clearShippingToastTimer();
shippingToastMessage.value = '';
};
onBeforeUnmount(() => {
clearShippingToastTimer();
});
const showGeneralFeedbackDialog = ref(false);
const activeFeedbackMessageIndex = ref<number | null>(null);
/**
* 打开消息反馈弹窗并记录当前消息下标。
* @param index - messages 数组下标
*/
const handleOpenFeedback = (index: number) => {
activeFeedbackMessageIndex.value = index;
showGeneralFeedbackDialog.value = true;
@@ -61,6 +143,13 @@ export function useChatPageDialogs(messages: Ref<ChatMessage[]>) {
openDeleteConfirmDialog,
closeDeleteConfirmDialog,
handleDeleteConfirm,
showRetryFailedConfirmDialog,
openRetryFailedConfirm,
closeRetryFailedConfirm,
handleRetryFailedConfirm,
shippingToastMessage,
showShippingToast,
clearShippingToast,
showGeneralFeedbackDialog,
activeFeedbackMessageIndex,
handleOpenFeedback,