From 7ec7a8942efcd528c4ffafa4b62d9607ae5e89f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=94=B0=E5=B2=A9?= Date: Tue, 3 Mar 2026 09:46:44 +0800 Subject: [PATCH] =?UTF-8?q?JLBA202505130001=5F=E5=85=B3=E4=BA=8E=E5=90=89?= =?UTF-8?q?=E6=9E=97=E9=93=B6=E8=A1=8C=E6=96=B0=E5=BB=BAAI=E6=99=BA?= =?UTF-8?q?=E8=83=BD=E5=9F=B9=E8=AE=AD=E7=B3=BB=E7=BB=9F=E7=9A=84=E9=9C=80?= =?UTF-8?q?=E6=B1=82=5F=E7=BB=A7=E7=BB=AD=E5=BC=80=E5=8F=91=E8=AF=AD?= =?UTF-8?q?=E9=9F=B3=E5=BD=95=E5=88=B6=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.development | 4 +-- src/components/touch-btn/touch-btn.ts | 30 ++++++++++++++------ src/components/touch-btn/touch-btn.types.ts | 27 ++++++++++++++---- src/components/touch-btn/touch-btn.vue | 31 ++++++++------------- 4 files changed, 57 insertions(+), 35 deletions(-) diff --git a/.env.development b/.env.development index 1af6108b..6e7704c3 100644 --- a/.env.development +++ b/.env.development @@ -4,10 +4,10 @@ ENV = 'development' -VITE_APP_BASE_API_Url = 'https://aits.jlbank.com.cn:7001' +#VITE_APP_BASE_API_Url = 'https://aits.jlbank.com.cn:7001' -#VITE_APP_BASE_API_Url = 'https://aitstest.jlbank.com.cn:7001' +VITE_APP_BASE_API_Url = 'https://aitstest.jlbank.com.cn:7001' # VITE_APP_BASE_API_Url = 'https://aitstest.jlbank.com.cn:7002' # VITE_APP_BASE_API_Url = 'http://192.168.247.200' diff --git a/src/components/touch-btn/touch-btn.ts b/src/components/touch-btn/touch-btn.ts index f5a04e0d..94387d3c 100644 --- a/src/components/touch-btn/touch-btn.ts +++ b/src/components/touch-btn/touch-btn.ts @@ -1,3 +1,4 @@ +import { ErrorCode, ShowErrorTipOptions } from './touch-btn.types'; import { get_base_url } from '@/api/request.js'; import { getToken } from '@/common/common.js'; // const url = '/trapractice/voiceCallSocket/voiceCall' @@ -70,13 +71,26 @@ export const initWebSocket = (wsUrl: string): Promise => { }); }; +/** + * 错误提示统一处理函数(极简版) + * @param errorCode 错误码(枚举类型,直接对应提示文本) + * @param options 可选参数:延迟显示时间 + * @returns 固定返回false(保持原有返回值类型) + */ +export function showErrorTip( + errorCode: ErrorCode, + options: ShowErrorTipOptions = {} +): boolean { + // 解构可选参数,设置默认延迟时间为200ms + const { delayTime = 200 } = options; + // 延迟显示对应的错误提示 + setTimeout(() => { + uni.showToast({ + title: errorCode, // 直接使用枚举值作为提示文本 + icon: 'none' + }); + }, delayTime); // 使用传入的延迟时间(或默认200ms) -// 方式2:Promise.then/catch 调用 -// initWebSocket('wss://your-real-ws-url.com') -// .then((socketTask) => { -// console.log('WS连接成功', socketTask); -// }) -// .catch((error) => { -// console.error('WS连接失败', error); -// }); \ No newline at end of file + return false; +} \ No newline at end of file diff --git a/src/components/touch-btn/touch-btn.types.ts b/src/components/touch-btn/touch-btn.types.ts index ae6be108..a32303e4 100644 --- a/src/components/touch-btn/touch-btn.types.ts +++ b/src/components/touch-btn/touch-btn.types.ts @@ -11,9 +11,24 @@ export type StatusType = 'default' | 'voice_recording' | 'text_input' | 'voice_t /** * 语音转文字的子状态(仅当主状态为 voice_to_text 时生效) */ -export type VoiceToTextSubStatus = - | '' // 纯空 - | 'init' // 初始化(刚进入语音转文字页面) - | 'loading' // 转换中(正在处理语音→文字) - | 'success' // 转换完成(成功得到文字结果) - | 'failed'; // 转换失败(网络/识别错误等) \ No newline at end of file +export type VoiceToTextSubStatus = + | '' // 纯空 + | 'init' // 初始化(刚进入语音转文字页面) + | 'loading' // 转换中(正在处理语音→文字) + | 'success' // 转换完成(成功得到文字结果) + | 'failed'; // 转换失败(网络/识别错误等) + + +/** 错误码枚举 - 直接映射提示文本 */ +export enum ErrorCode { + // 网络错误提示 + NetworkError = '网络连接失败,请稍后再试!', + // 录音时长过短提示 + ShortRecord = '说话时间太短,没有听清!' +} + +/** 错误提示函数的可选参数类型 */ +export interface ShowErrorTipOptions { + // 提示框延迟显示时间(毫秒),默认200ms + delayTime?: number; +} \ No newline at end of file diff --git a/src/components/touch-btn/touch-btn.vue b/src/components/touch-btn/touch-btn.vue index 62f84a05..316c6797 100644 --- a/src/components/touch-btn/touch-btn.vue +++ b/src/components/touch-btn/touch-btn.vue @@ -71,8 +71,8 @@