Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Add socket to widget
- Loading branch information
1 parent
7593d69
commit 0873d73
Showing
8 changed files
with
63 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| <template> | ||
| <div class="chat-widget"> | ||
| Chat-widget says hi! | ||
| <div>From the store: {{ mainStore.hello }}</div> | ||
| </div> | ||
| </template> | ||
|
|
||
| <script setup lang="ts"> | ||
| import io from 'socket.io-client'; | ||
| import { onUnmounted } from 'vue'; | ||
| import { useMainStore } from './stores/main'; | ||
| const URL = 'http://localhost:5000'; | ||
| const socket = io(URL); | ||
| const mainStore = useMainStore(); | ||
| socket.on('connect_error', (err) => { | ||
| console.log('connection error', err); | ||
| }); | ||
| socket.onAny((event, ...args) => { | ||
| console.log(event, args); | ||
| }); | ||
| onUnmounted(() => { | ||
| socket.off('connect_error'); | ||
| }); | ||
| </script> | ||
|
|
||
| <style lang="scss"> | ||
| .chat-widget { | ||
| background-color: red; | ||
| color: white; | ||
| } | ||
| </style> |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,11 @@ | ||
| import { defineCustomElement } from 'vue'; | ||
| import myTwoButtons from './components/MyTwoButtons.ce.vue'; | ||
| import App from './App.vue'; | ||
| import { createPinia } from 'pinia'; | ||
| import { defineCustomElement, createApp } from 'vue'; | ||
|
|
||
| const myBtnsComponent = defineCustomElement(myTwoButtons); | ||
| const app = createApp(App); | ||
|
|
||
| customElements.define('mytwo-buttons', myBtnsComponent); | ||
| app.use(createPinia()); | ||
|
|
||
| const chatWidget = defineCustomElement(App); | ||
|
|
||
| customElements.define('chat-widget', chatWidget); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import { defineStore } from 'pinia'; | ||
|
|
||
| export const useMainStore = defineStore('main', { | ||
| state: () => ({ | ||
| hello: 'Hi there!', | ||
| }), | ||
| getters: { | ||
| // | ||
| }, | ||
| actions: { | ||
| // | ||
| }, | ||
| }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters