手动初始化

This commit is contained in:
kura 2025-01-03 10:53:05 +08:00
parent c942b7673a
commit 09dc671216
2 changed files with 4 additions and 1 deletions

View File

@ -188,6 +188,7 @@ const handleReceive = async () => {
};
//
onMounted(() => {
peer.init();
peer.on("open", ((event: CustomEvent) => {
myId.value = event.detail;
const sign = getUrlParam("sign");

View File

@ -21,7 +21,9 @@ class Peer extends EventTarget {
constructor(sign: string) {
super()
this.sign = sign
this.peer = new PeerJs(sign2peerid(sign))
}
public init() {
this.peer = new PeerJs(sign2peerid(this.sign))
this.peer.on('open', (id) => {
console.log('peer open', id)
this.id = id