From 1b6497147ae8f90943853fc390a65ec4ecb8f7a7 Mon Sep 17 00:00:00 2001 From: skmcj <2604597248@qq.com> Date: Mon, 28 Apr 2025 16:37:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=9F=90=E4=BA=9B?= =?UTF-8?q?=E6=83=85=E5=86=B5=E4=B8=8B=E8=BE=93=E5=85=A5=E6=A1=86=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E8=BE=93=E5=85=A5=E7=9A=84BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/ConnectInput.vue | 17 +++++++++++++---- src/views/IndexView.vue | 34 +++++++++++++++++++++------------ 2 files changed, 35 insertions(+), 16 deletions(-) diff --git a/src/components/ConnectInput.vue b/src/components/ConnectInput.vue index 9fea69c..f955872 100644 --- a/src/components/ConnectInput.vue +++ b/src/components/ConnectInput.vue @@ -55,7 +55,7 @@ const inputDisabled = ref(false); /** 按钮状态 */ const btnDisabled = ref(false); /** 连接状态 */ -const connectStatus = defineModel('status'); +const connectStatus = ref(false); /** 验证提示 */ const testTip = ref(void 0); /** event */ @@ -111,20 +111,25 @@ const handleChange = (e: Event) => { emits('change', e); }; -/** 监听连接状态 */ -watch(connectStatus, flag => { +/** + * 设置连接状态 + * @param flag + */ +const setStatus = function (flag?: boolean) { if (flag) { // 连接成功 // 锁定输入框,防止再次输入 inputDisabled.value = true; + connectStatus.value = true; } else { // 连接失败 // 解锁输入框 inputDisabled.value = false; + connectStatus.value = false; } // 还原按钮状态 btnDisabled.value = false; -}); +}; /** 初始化数据 */ const initData = function () { @@ -134,6 +139,10 @@ const initData = function () { onMounted(() => { initData(); }); + +defineExpose({ + setStatus +});