Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add login box component #4

Merged
merged 10 commits into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions src/components/BlockSlideLoginBox.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<template>
<div class="login">
<div class="bg-box">
<div class="rotate-box"></div>
</div>
<div class="form">
<slot></slot>
</div>
</div>
</template>

<style>
.login {
width: 100%;
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
}
.bg-box {
overflow: hidden;
width: 310px;
height: 310px;
position: relative;
border: 1px solid #c4edde;
}
.rotate-box {
position: absolute;
margin-left: 155px;
margin-top: 155px;
width: 600px;
height: 50px;
transform-origin: 0px 0px;
background: linear-gradient(to left, #c4edde, #7ac7c4, #f73859, #384259 80%);
animation: Rotating 2s linear infinite;
}
@keyframes Rotating {
100% {
transform: rotate(360deg);
}
}
</style>
51 changes: 51 additions & 0 deletions src/components/LinearColorLoginBox.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<template>
<div class="login">
<div class="bg-box" :style="style">
<div
class="rotate-box"
></div>
</div>
<div class="form">
<slot></slot>
</div>
</div>
</template>

<style>
.login {
width: 100%;
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
}
.bg-box {
overflow: hidden;
position: relative;
border: 1px solid #c4edde;
}
.rotate-box {
position: absolute;
left: -120px;
top: -120px;
width: 600px;
height: 600px;
background: linear-gradient(to left, #c4edde, #7ac7c4, #f73859, #384259 80%);
animation: Rotating 2s linear infinite;
}
@keyframes Rotating {
100% {
transform: rotate(360deg);
}
}
</style>

<script setup lang="ts">
// import { defineComponent } from 'vue'
defineProps({
style: {
type: Object as () => Record<string, string>, // 使用 Record<string, string> 类型来传递样式
required: true,
}
})
</script>
78 changes: 22 additions & 56 deletions src/views/LoginView.vue
Original file line number Diff line number Diff line change
@@ -1,33 +1,21 @@
<template>
<div class="login">
<div class="bg-box">
<div class="rotate-box"></div>
</div>
<div class="form">
<el-form :model="form" label-width="auto" style="max-width: 600px">
<el-form-item label="Name">
<el-input v-model="form.name" />
</el-form-item>
<el-form-item label="Password">
<el-input type="password" v-model="form.password" show-password style="width: 200px" />
</el-form-item>
<el-form-item>
<el-button type="primary" @click="onSubmit">Submit</el-button>
<el-button>Cancel</el-button>
</el-form-item>
</el-form>
</div>
</div>
<LinearColorLoginBox :style="dynamicStyle">
<el-form :model="form" label-width="auto" style="max-width: 600px">
<el-form-item label="Name">
<el-input v-model="form.name" />
</el-form-item>
<el-form-item label="Password">
<el-input type="password" v-model="form.password" show-password style="width: 200px" />
</el-form-item>
<el-form-item>
<el-button type="primary" @click="onSubmit">Submit</el-button>
<el-button>Cancel</el-button>
</el-form-item>
</el-form>
</LinearColorLoginBox>
</template>

<style>
.login {
width: 100%;
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
}
.form {
display: flex;
justify-content: center;
Expand All @@ -37,50 +25,28 @@
background: white;
position: absolute;
}
.bg-box {
overflow: hidden;
width: 310px;
height: 310px;
position: relative;
border: 1px solid #c4edde;
/* border: 1px solid #f73859; */
/* box-shadow: -3px -3px #384259,
3px 3px #384259; */
}
.rotate-box {
position: absolute;
/* top: -100px;
left: -100px; */
margin-left: 155px;
margin-top: 155px;
width: 600px;
height: 50px;
transform-origin: 0px 0px;
background: linear-gradient(to left, #c4edde, #7ac7c4, #f73859, #384259 80%);
animation: Rotating 2s linear infinite;
}
@keyframes Rotating {
100% {
transform: rotate(360deg);
}
}
</style>

<script lang="ts" setup>
import router from '@/router'
import { reactive } from 'vue'
import { reactive, ref } from 'vue'
import LinearColorLoginBox from '@/components/LinearColorLoginBox.vue';

// do not use same name with ref
const form = reactive({
name: '',
password: '',
})

const dynamicStyle = ref<Record<string, string>>({
width: "310px",
height: "310px",
});

const onSubmit = () => {
if (form.name === 'admin' && form.password === '123456') {
router.push('home')
} else {
alert('What Happen???')
alert('What Happen ??? sb')
}
}
</script>