From a6078584ee038c8030cd789bbea43e8ddf1fc17c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=9C=E6=99=93=E6=B5=A9?= <1923911906@qq.com> Date: Fri, 31 May 2024 21:58:44 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=BF=9E=E6=8E=A5=E6=9C=AC=E5=9C=B0?= =?UTF-8?q?=E5=85=A8=E5=8A=9F=E8=83=BD=E8=8A=82=E7=82=B9=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/web-chat-x-vue/src/classes/Libp2pManager.ts | 9 +++++++-- packages/web-chat-x-vue/src/components.d.ts | 1 + .../src/components/SetAdvancedComponent.vue | 12 +++++++++--- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/packages/web-chat-x-vue/src/classes/Libp2pManager.ts b/packages/web-chat-x-vue/src/classes/Libp2pManager.ts index ac0d330..c4a0dda 100644 --- a/packages/web-chat-x-vue/src/classes/Libp2pManager.ts +++ b/packages/web-chat-x-vue/src/classes/Libp2pManager.ts @@ -153,7 +153,7 @@ export class Libp2pManager { timeIntervalStart(); this.handleListenEvent(); this.cyclicQuery(); - // this.getLibp2pKadDHTDiscovery(); + this.getLibp2pKadDHTDiscovery(); } catch (error) { reject(error); } @@ -162,6 +162,9 @@ export class Libp2pManager { getLibp2pKadDHTDiscoveryTime?: NodeJS.Timeout; getLibp2pKadDHTDiscovery = async () => { if (!this.enableLocalNode) { + this.getLibp2pKadDHTDiscoveryTime = setTimeout(() => { + this.getLibp2pKadDHTDiscovery(); + }, 10000); return; } try { @@ -181,7 +184,9 @@ export class Libp2pManager { } catch (error) { ElMessage({ type: "error", - message: "连接本地全功能节点失败,请启动本地节点", + message: + "连接本地全功能节点失败,请启动本地节点,否则请在设置->高级中取消连接功能或刷新应用重置状态", + center: true, }); console.log("error getLibp2pKadDHTDiscovery", error); } diff --git a/packages/web-chat-x-vue/src/components.d.ts b/packages/web-chat-x-vue/src/components.d.ts index 87c36b7..3087a61 100644 --- a/packages/web-chat-x-vue/src/components.d.ts +++ b/packages/web-chat-x-vue/src/components.d.ts @@ -30,6 +30,7 @@ declare module 'vue' { ElRow: typeof import('element-plus/es')['ElRow'] ElSelect: typeof import('element-plus/es')['ElSelect'] ElSubMenu: typeof import('element-plus/es')['ElSubMenu'] + ElSwitch: typeof import('element-plus/es')['ElSwitch'] ElTable: typeof import('element-plus/es')['ElTable'] ElTableColumn: typeof import('element-plus/es')['ElTableColumn'] ElTooltip: typeof import('element-plus/es')['ElTooltip'] diff --git a/packages/web-chat-x-vue/src/components/SetAdvancedComponent.vue b/packages/web-chat-x-vue/src/components/SetAdvancedComponent.vue index 84f53e2..98da61e 100644 --- a/packages/web-chat-x-vue/src/components/SetAdvancedComponent.vue +++ b/packages/web-chat-x-vue/src/components/SetAdvancedComponent.vue @@ -23,9 +23,9 @@ 退出登录 - + + + @@ -39,6 +39,12 @@ import { useRouter } from "vue-router"; const router = useRouter(); // import { multiaddr } from "@multiformats/multiaddr"; const { databaseManager } = useDexie(); +const { libp2pManager } = useLibp2p(); +const enableLocalNode = ref(libp2pManager.enableLocalNode); +watchEffect(() => { + libp2pManager.enableLocalNode = enableLocalNode.value; +}); + // const user = ref( // (await databaseManager.activatedUserDb.info.limit(1).first())! // );