mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/learning-system-portal.git
synced 2025-12-17 14:56:44 +08:00
fix(lan): 修复局域网服务检测逻辑与显示控制
- 将 `v-if` 替换为 `v-show` 以避免组件重复创建 - 使用 `.sync` 修饰符替代 `value` 事件进行双向绑定 - 调整检测超时逻辑,超时后设置为检测成功 - 网络响应失败时正确同步状态值 - 移除模板中冗余的条件渲染包装元素
This commit is contained in:
@@ -20,7 +20,7 @@ export default {
|
||||
methods: {
|
||||
syncValue(val) {
|
||||
this.loading = false
|
||||
this.$emit('value', val)
|
||||
this.$emit('update:value', val)
|
||||
},
|
||||
/**局域网检测*/
|
||||
lanServiceCheck() {
|
||||
@@ -30,7 +30,7 @@ export default {
|
||||
const controller = new AbortController();
|
||||
const timeoutId = setTimeout(() => {
|
||||
controller.abort();
|
||||
this.syncValue(false);
|
||||
this.syncValue(true);
|
||||
}, 1000);
|
||||
|
||||
// 拼接随机参数(时间戳+随机数,确保URL唯一,防止缓存)
|
||||
@@ -43,7 +43,7 @@ export default {
|
||||
})
|
||||
.then(response => {
|
||||
clearTimeout(timeoutId);
|
||||
response.ok ? this.syncValue(true) : this.syncValue(false);
|
||||
this.syncValue(!response.ok)
|
||||
})
|
||||
.catch(error => {
|
||||
clearTimeout(timeoutId);
|
||||
@@ -58,14 +58,12 @@ export default {
|
||||
|
||||
<template>
|
||||
<div class="lan-checker-container">
|
||||
<div v-if="value">
|
||||
<div>
|
||||
<span>{{ errorMsg }}</span>
|
||||
</div>
|
||||
<div class="check-btn" @click="lanServiceCheck">
|
||||
<el-button v-loading="loading" type="primary">重新检测</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user