login.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. <script setup lang="ts">
  2. import { computed, ref, watch } from 'vue'
  3. const name = ref('')
  4. const roomID = ref('')
  5. const props = defineProps<{ modelValue: string }>()
  6. const err = computed(() => props.modelValue)
  7. const emit = defineEmits<{(evt: 'update:modelValue', value: string): void
  8. (evt: 'loginBack', value: { name: string, roomID: string }): void
  9. }>()
  10. function login() {
  11. if (name.value && roomID.value) emit('loginBack', { name: name.value, roomID: roomID.value })
  12. }
  13. function titleEvent(type: string) {
  14. window.$electron?.send(type)
  15. }
  16. watch([ name, roomID ], () => {
  17. if (name.value && roomID.value) emit('update:modelValue', '')
  18. })
  19. </script>
  20. <template>
  21. <div class="login">
  22. <div class="login-title">
  23. <Icon
  24. name="close"
  25. :size="15"
  26. color="#fff"
  27. @click="titleEvent('closeWin')"
  28. />
  29. </div>
  30. <div class="login-content">
  31. <div class="login-content-left" />
  32. <div
  33. class="login-content-right"
  34. @keydown.enter="login"
  35. >
  36. <p>Hello, 欢迎登录</p>
  37. <div>
  38. <Icon
  39. name="username"
  40. :size="25"
  41. />
  42. <input
  43. v-model="roomID"
  44. type="text"
  45. placeholder="请输入房间"
  46. maxlength="20"
  47. >
  48. </div>
  49. <div>
  50. <Icon
  51. name="password"
  52. :size="25"
  53. />
  54. <input
  55. v-model="name"
  56. type="text"
  57. placeholder="请输入名称"
  58. maxlength="20"
  59. >
  60. </div>
  61. <span>{{ err }}</span>
  62. <div>
  63. <button
  64. :disabled="!name && !roomID"
  65. :class="{ resetStyle: name && roomID }"
  66. @click="login"
  67. >
  68. 加入
  69. </button>
  70. </div>
  71. </div>
  72. </div>
  73. </div>
  74. </template>
  75. <style scoped lang="scss">
  76. .login {
  77. width: 100%;
  78. height: 100%;
  79. font-size: 0.15rem;
  80. display: flex;
  81. justify-content: center;
  82. align-items: center;
  83. background: url(../assets/img/bg.png) center center no-repeat;
  84. background-size: 100% 100%;
  85. -webkit-app-region: drag;
  86. position: relative;
  87. &-title {
  88. position: absolute;
  89. right: 0.15rem;
  90. top: 0.12rem;
  91. cursor: pointer;
  92. -webkit-app-region: no-drag;
  93. }
  94. &-content {
  95. width: 8rem;
  96. height: 4rem;
  97. background: white;
  98. border-radius: 0.2rem;
  99. display: flex;
  100. overflow: hidden;
  101. &-left {
  102. width: 5rem;
  103. background: url(../assets/img/login-left.png) center center no-repeat;
  104. background-size: 100% 100%;
  105. -webkit-app-region: drag;
  106. }
  107. &-right {
  108. width: 3rem;
  109. padding: 0 0.3rem;
  110. -webkit-app-region: no-drag;
  111. overflow: hidden;
  112. &>p {
  113. font-size: 0.3rem;
  114. color: #5970C6;
  115. text-align: left;
  116. font-weight: 400;
  117. text-align: center;
  118. margin-top: 0.5rem;
  119. margin-bottom: 0.5rem;
  120. }
  121. &>div {
  122. padding: 0.1rem 0;
  123. display: flex;
  124. align-items: center;
  125. margin: 0.1rem 0;
  126. &:not(:last-child) {
  127. border-bottom: solid 1px #D2D6E7;
  128. }
  129. input {
  130. border: none;
  131. margin-left: 0.05rem;
  132. outline: none;
  133. width: 100%;
  134. font-size: 0.15rem;
  135. color: #333;
  136. &::placeholder {
  137. color: #9DA1A8;
  138. font-size: 0.15rem;
  139. }
  140. }
  141. button {
  142. background: #79b8fa;
  143. border: none;
  144. outline: none;
  145. color: white;
  146. font-size: 0.16rem;
  147. font-weight: 500;
  148. border-radius: 1rem;
  149. margin-top: 0.4rem;
  150. margin-left: auto;
  151. line-height: 0.35rem;
  152. padding: 0 0.35rem;
  153. cursor: not-allowed;
  154. }
  155. }
  156. &>span {
  157. height: 0.17rem;
  158. color: red;
  159. font-size: 0.12rem;
  160. overflow: hidden;
  161. display: block;
  162. text-overflow: ellipsis;
  163. }
  164. .resetStyle {
  165. background: #2d8cf0;
  166. cursor: pointer;
  167. }
  168. }
  169. }
  170. }
  171. </style>