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 @@