front/src/composables/useOperationScanFeedback.ts
zzh 6a7f8f1bcb feat: 用户扩展、Nana双Tab、仓库与客服入口优化
扩展用户管理字段与组织编码生成,顶部改为仓库下拉;Nana 分 AI 与专属顾问 Tab,仓库页移除客服字段,并完善扫描语音与订单相关页面。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-09 11:23:54 +08:00

52 lines
1.3 KiB
TypeScript

import { ref } from 'vue';
import { useOperationVoiceBroadcast } from './useOperationVoiceBroadcast';
export type ScanFeedbackType = 'idle' | 'success' | 'error' | 'warning';
/**
* 扫描页左侧反馈区 + 语音播报。
*/
export function useOperationScanFeedback(pageKey: string) {
const { voiceEnabled, speak, stopSpeak } = useOperationVoiceBroadcast(pageKey);
const feedbackType = ref<ScanFeedbackType>('idle');
const feedbackMessage = ref('');
function clearFeedback() {
feedbackType.value = 'idle';
feedbackMessage.value = '';
}
function showFeedback(type: ScanFeedbackType, message: string, withVoice = true) {
feedbackType.value = type;
feedbackMessage.value = message;
if (withVoice && (type === 'error' || type === 'success' || type === 'warning')) {
speak(message);
}
}
function showError(message: string, withVoice = true) {
showFeedback('error', message, withVoice);
}
function showSuccess(message: string, withVoice = true) {
showFeedback('success', message, withVoice);
}
function showWarning(message: string, withVoice = true) {
showFeedback('warning', message, withVoice);
}
return {
voiceEnabled,
feedbackType,
feedbackMessage,
speak,
stopSpeak,
clearFeedback,
showFeedback,
showError,
showSuccess,
showWarning,
};
}