| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187 |
- <script setup lang="ts">
- import { computed, ref, watch } from 'vue'
- const name = ref('')
- const roomID = ref('')
- const props = defineProps<{ modelValue: string }>()
- const err = computed(() => props.modelValue)
- const emit = defineEmits<{(evt: 'update:modelValue', value: string): void
- (evt: 'loginBack', value: { name: string, roomID: string }): void
- }>()
- function login() {
- if (name.value && roomID.value) emit('loginBack', { name: name.value, roomID: roomID.value })
- }
- function titleEvent(type: string) {
- window.$electron?.send(type)
- }
- watch([ name, roomID ], () => {
- if (name.value && roomID.value) emit('update:modelValue', '')
- })
- </script>
- <template>
- <div class="login">
- <div class="login-title">
- <Icon
- name="close"
- :size="15"
- color="#fff"
- @click="titleEvent('closeWin')"
- />
- </div>
- <div class="login-content">
- <div class="login-content-left" />
- <div
- class="login-content-right"
- @keydown.enter="login"
- >
- <p>Hello, 欢迎登录</p>
- <div>
- <Icon
- name="username"
- :size="25"
- />
- <input
- v-model="roomID"
- type="text"
- placeholder="请输入房间"
- maxlength="20"
- >
- </div>
- <div>
- <Icon
- name="password"
- :size="25"
- />
- <input
- v-model="name"
- type="text"
- placeholder="请输入名称"
- maxlength="20"
- >
- </div>
- <span>{{ err }}</span>
- <div>
- <button
- :disabled="!name && !roomID"
- :class="{ resetStyle: name && roomID }"
- @click="login"
- >
- 加入
- </button>
- </div>
- </div>
- </div>
- </div>
- </template>
- <style scoped lang="scss">
- .login {
- width: 100%;
- height: 100%;
- font-size: 0.15rem;
- display: flex;
- justify-content: center;
- align-items: center;
- background: url(../assets/img/bg.png) center center no-repeat;
- background-size: 100% 100%;
- -webkit-app-region: drag;
- position: relative;
- &-title {
- position: absolute;
- right: 0.15rem;
- top: 0.12rem;
- cursor: pointer;
- -webkit-app-region: no-drag;
- }
- &-content {
- width: 8rem;
- height: 4rem;
- background: white;
- border-radius: 0.2rem;
- display: flex;
- overflow: hidden;
- &-left {
- width: 5rem;
- background: url(../assets/img/login-left.png) center center no-repeat;
- background-size: 100% 100%;
- -webkit-app-region: drag;
- }
- &-right {
- width: 3rem;
- padding: 0 0.3rem;
- -webkit-app-region: no-drag;
- overflow: hidden;
- &>p {
- font-size: 0.3rem;
- color: #5970C6;
- text-align: left;
- font-weight: 400;
- text-align: center;
- margin-top: 0.5rem;
- margin-bottom: 0.5rem;
- }
- &>div {
- padding: 0.1rem 0;
- display: flex;
- align-items: center;
- margin: 0.1rem 0;
- &:not(:last-child) {
- border-bottom: solid 1px #D2D6E7;
- }
- input {
- border: none;
- margin-left: 0.05rem;
- outline: none;
- width: 100%;
- font-size: 0.15rem;
- color: #333;
- &::placeholder {
- color: #9DA1A8;
- font-size: 0.15rem;
- }
- }
- button {
- background: #79b8fa;
- border: none;
- outline: none;
- color: white;
- font-size: 0.16rem;
- font-weight: 500;
- border-radius: 1rem;
- margin-top: 0.4rem;
- margin-left: auto;
- line-height: 0.35rem;
- padding: 0 0.35rem;
- cursor: not-allowed;
- }
- }
- &>span {
- height: 0.17rem;
- color: red;
- font-size: 0.12rem;
- overflow: hidden;
- display: block;
- text-overflow: ellipsis;
- }
- .resetStyle {
- background: #2d8cf0;
- cursor: pointer;
- }
- }
- }
- }
- </style>
|