Skip to content

Commit

Permalink
fix: 连接本地全功能节点控制
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaohaodu committed May 31, 2024
1 parent 68e56ce commit a607858
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
9 changes: 7 additions & 2 deletions packages/web-chat-x-vue/src/classes/Libp2pManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export class Libp2pManager {
timeIntervalStart();
this.handleListenEvent();
this.cyclicQuery();
// this.getLibp2pKadDHTDiscovery();
this.getLibp2pKadDHTDiscovery();
} catch (error) {
reject(error);
}
Expand All @@ -162,6 +162,9 @@ export class Libp2pManager {
getLibp2pKadDHTDiscoveryTime?: NodeJS.Timeout;
getLibp2pKadDHTDiscovery = async () => {
if (!this.enableLocalNode) {
this.getLibp2pKadDHTDiscoveryTime = setTimeout(() => {
this.getLibp2pKadDHTDiscovery();
}, 10000);
return;
}
try {
Expand All @@ -181,7 +184,9 @@ export class Libp2pManager {
} catch (error) {
ElMessage({
type: "error",
message: "连接本地全功能节点失败,请启动本地节点",
message:
"连接本地全功能节点失败,请启动本地节点,否则请在设置->高级中取消连接功能或刷新应用重置状态",
center: true,
});
console.log("error getLibp2pKadDHTDiscovery", error);
}
Expand Down
1 change: 1 addition & 0 deletions packages/web-chat-x-vue/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down
12 changes: 9 additions & 3 deletions packages/web-chat-x-vue/src/components/SetAdvancedComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
<span class="icon-[dashicons--exit]"></span>退出登录</el-button
>
</el-form-item>
<!-- <el-form-item>
<el-button type="primary" @click="save()">保存</el-button>
</el-form-item> -->
<el-form-item label="连接本地全功能节点">
<el-switch v-model="enableLocalNode"></el-switch>
</el-form-item>
</el-form>
</el-card>
<a ref="refA" v-show="false"></a>
Expand All @@ -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())!
// );
Expand Down

0 comments on commit a607858

Please sign in to comment.