refactor: 移除调试日志并优化代码结构

- 删除多个组件中的console.log调试语句
- 优化axios错误处理中的可选链操作
- 重构wechat-btn组件的事件监听逻辑
- 清理ai.vue中的冗余代码和注释
- 改进页面可见性变化的处理逻辑
This commit is contained in:
DESKTOP-RQ919RC\Pc
2025-08-25 18:53:18 +08:00
parent 411494dd1b
commit 5fd6f68a7c
6 changed files with 44 additions and 49 deletions

View File

@@ -5,7 +5,6 @@
</div>
<div class="circle-pop flexacenter" v-if="circleState">
<img class="close-icon" src="@/assets/img/publicImage/circle-close.png" alt="" @click.stop="circleState = !circleState" />
<!-- <img class="circle-bj" src="@/assets/img/publicImage/circle-pop-bj.svg"> -->
<img class="circle-bj-green" src="@/assets/img/publicImage/wechat-pop-green.svg" />
<div class="circle-title flexacenter">
欢迎联系 <b>{{ wechat["nickname"] }}</b> 咨询公寓
@@ -19,12 +18,43 @@
</template>
<script setup>
import { ref, toRefs } from "vue";
import { useStore } from "vuex";
const store = useStore();
const { wechat } = toRefs(store.state);
import { reactive, onMounted, ref, toRefs, nextTick, onBeforeUnmount, watch, getCurrentInstance, onUnmounted } from "vue";
let circleState = ref(false);
// 定义点击事件处理函数
const handleDocumentClick = (e) => {
// 点击关闭按钮关闭
if (e.target.classList.contains("close-icon")) {
circleState.value = false;
return;
}
// 点击其他地方且弹窗显示时关闭
if (circleState.value) {
circleState.value = false;
}
};
// 监听 circleState 变化,状态为 true 时开始监听,为 false 时停止监听
watch(circleState, (newVal) => {
if (newVal) {
setTimeout(() => {
document.addEventListener("click", handleDocumentClick);
}, 1000);
} else {
setTimeout(() => {
document.removeEventListener("click", handleDocumentClick);
}, 1000);
}
});
// 组件卸载时移除事件监听,避免内存泄漏
onUnmounted(() => {
document.removeEventListener("click", handleDocumentClick);
});
</script>
<style lang="less" scoped>
@@ -77,7 +107,7 @@ let circleState = ref(false);
.circle-pop {
position: absolute;
bottom: 45px;
bottom: 40px;
// right: 65px;
width: 300px;
height: 300px;