Options.vue 790 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <template>
  2. <main>
  3. <h1>Options</h1>
  4. <hr/>
  5. <br/>
  6. <div class="control">
  7. <label for="passcode">Passcode: </label>
  8. <input type="password" id="passcode" v-model="passcode"/>
  9. </div>
  10. <button class="button" @click="save()">Save</button>
  11. </main>
  12. </template>
  13. <script>
  14. import io from "../../io.js";
  15. export default {
  16. components: { },
  17. data: () => {
  18. return {
  19. passcode: ""
  20. }
  21. },
  22. computed: {
  23. },
  24. methods: {
  25. save() {
  26. localStorage.setItem("passcode", this.passcode);
  27. this.socket.disconnect();
  28. this.socket.io.opts.query = `passcode=${this.passcode}`;
  29. this.socket.connect();
  30. }
  31. },
  32. mounted() {
  33. io.getSocket(socket => {
  34. this.socket = socket;
  35. });
  36. this.passcode = localStorage.getItem("passcode");
  37. }
  38. };
  39. </script>
  40. <style lang="scss" scoped>
  41. </style>