first
This commit is contained in:
40
src/components/HelloWorld.vue
Normal file
40
src/components/HelloWorld.vue
Normal file
@@ -0,0 +1,40 @@
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
|
||||
defineProps({
|
||||
msg: String
|
||||
})
|
||||
|
||||
const count = ref(0)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<h1>{{ msg }}</h1>
|
||||
|
||||
<p>
|
||||
Recommended IDE setup:
|
||||
<a href="https://code.visualstudio.com/" target="_blank">VS Code</a>
|
||||
+
|
||||
<a href="https://github.com/johnsoncodehk/volar" target="_blank">Volar</a>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<a href="https://vitejs.dev/guide/features.html" target="_blank">
|
||||
Vite Documentation
|
||||
</a>
|
||||
|
|
||||
<a href="https://v3.vuejs.org/" target="_blank">Vue 3 Documentation</a>
|
||||
</p>
|
||||
|
||||
<button type="button" @click="count++">count is: {{ count }}</button>
|
||||
<p>
|
||||
Edit
|
||||
<code>components/HelloWorld.vue</code> to test hot module replacement.
|
||||
</p>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
a {
|
||||
color: #42b983;
|
||||
}
|
||||
</style>
|
116
src/components/Login.vue
Normal file
116
src/components/Login.vue
Normal file
@@ -0,0 +1,116 @@
|
||||
<template>
|
||||
<div class="login">
|
||||
<div class="loin_form">
|
||||
<p>Welcome to SNCTF</p>
|
||||
<el-tabs v-model="activeNames" >
|
||||
<el-tab-pane label="登录" name="first">
|
||||
<el-form
|
||||
:model="loginForm"
|
||||
:rules="loginRules"
|
||||
ref="loginForm">
|
||||
<el-form-item label="" prop="username" class="elItem">
|
||||
<el-input
|
||||
type="text"
|
||||
autocomplete="off"
|
||||
v-model="loginForm.username"
|
||||
prefix-icon="el-icon-user-solid"
|
||||
placeholder="请输入用户名"
|
||||
></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="" prop="password">
|
||||
<el-input
|
||||
type="password"
|
||||
autocomplete="off"
|
||||
v-model="loginForm.password"
|
||||
prefix-icon="el-icon-lock"
|
||||
placeholder="请输入密码"
|
||||
></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item class="btns">
|
||||
<el-button type="primary" @click="goToLogin">登录</el-button>
|
||||
<!-- <el-button @click="resetLoginForm">重置</el-button>-->
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="注册" name="second">
|
||||
<!-- 引用注册组件-->
|
||||
<register></register>
|
||||
</el-tab-pane>
|
||||
|
||||
</el-tabs>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import Register from "./register.vue";
|
||||
import axios from "axios";
|
||||
import { ElNotification } from 'element-plus';
|
||||
|
||||
export default {
|
||||
data(){
|
||||
return{
|
||||
loginForm:{
|
||||
username:'',
|
||||
password:'',
|
||||
},
|
||||
activeNames: 'first',
|
||||
loginRules:{
|
||||
username: [
|
||||
{ required: true, message: '请输入用户名', trigger: 'blur' },
|
||||
{ min: 3, max: 10, message: '长度在 3 到 10 个字符', trigger: 'blur' }
|
||||
],
|
||||
password: [
|
||||
{ required: true, message: '请输入密码', trigger: 'blur' },
|
||||
{ min: 6, max: 20, message: '长度在 6 到 20 个字符', trigger: 'blur' }
|
||||
]
|
||||
},
|
||||
|
||||
}
|
||||
},
|
||||
methods:{
|
||||
goToLogin(){
|
||||
axios({
|
||||
method:'post',
|
||||
url:'/api/v1/login',
|
||||
headers:{
|
||||
'Content-Type':'application/json;charset=UTF-8'
|
||||
},
|
||||
data:{
|
||||
username:this.loginForm.username,
|
||||
password:this.loginForm.password
|
||||
}
|
||||
}).then(res=>{
|
||||
console.log(res.data);
|
||||
if(res.data.code===200){
|
||||
this.$router.push('/home')
|
||||
ElNotification({
|
||||
title: '登录成功',
|
||||
message: '欢迎回来',
|
||||
type: 'success',
|
||||
duration: 3000,
|
||||
|
||||
});
|
||||
}else{
|
||||
ElNotification({
|
||||
title: '登录失败',
|
||||
message: '用户名或密码错误',
|
||||
type: 'error',
|
||||
duration: 3000,
|
||||
|
||||
});
|
||||
}
|
||||
}).catch(err=>{
|
||||
ElNotification({
|
||||
title: '登录失败',
|
||||
message: '用户访问错误',
|
||||
type: 'error',
|
||||
duration: 3000,
|
||||
|
||||
});
|
||||
console.log(err)
|
||||
})
|
||||
}
|
||||
},
|
||||
components: {Register}
|
||||
}
|
||||
</script>
|
51
src/components/Navbar.vue
Normal file
51
src/components/Navbar.vue
Normal file
@@ -0,0 +1,51 @@
|
||||
<template>
|
||||
|
||||
<el-menu
|
||||
router
|
||||
:default-active="$route.path"
|
||||
class="el-menu-demo"
|
||||
mode="horizontal"
|
||||
background-color="#2d3039"
|
||||
text-color="#fff"
|
||||
active-text-color="#ffd04b"
|
||||
|
||||
>
|
||||
|
||||
<el-menu-item index="0">
|
||||
<a href="/home"><img style = "height:50px;width:auto" src="../assets/logo.png" alt="logo"></a>
|
||||
</el-menu-item>
|
||||
|
||||
<el-menu-item index="/home">Home</el-menu-item>
|
||||
<el-menu-item index="/scoreboard">Scoreboard</el-menu-item>
|
||||
<el-menu-item index="/users">Users</el-menu-item>
|
||||
<el-menu-item index="/notification">Notification</el-menu-item>
|
||||
<el-menu-item index="/challenges">Challenges</el-menu-item>
|
||||
|
||||
<el-button type="primary" class="login" @click="login">登录/注册</el-button>
|
||||
|
||||
</el-menu>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
methods:{
|
||||
login(){
|
||||
this.$router.push('/login')
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
<style lang="less" scoped>
|
||||
|
||||
.login{
|
||||
margin-top: 12px;
|
||||
margin-left: auto;
|
||||
margin-right: 30px;
|
||||
float:right;
|
||||
}
|
||||
|
||||
|
||||
|
||||
</style>
|
34
src/components/index/Index.vue
Normal file
34
src/components/index/Index.vue
Normal file
@@ -0,0 +1,34 @@
|
||||
<template>
|
||||
<div class="index">
|
||||
<div class="title">
|
||||
Welcome to SNCTF
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.index {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: auto;
|
||||
/* 首页 */
|
||||
position: absolute;
|
||||
left: 0px;
|
||||
top: 80px;
|
||||
width: 100%;
|
||||
height: auto;
|
||||
background: #2D3039;
|
||||
.title{
|
||||
/* Welcome To SNCTF */
|
||||
|
||||
position: absolute;
|
||||
font-family: MiSans-Regular;
|
||||
font-size: 50px;
|
||||
font-weight: normal;
|
||||
margin-top: 10%;
|
||||
color: #FFFFFF;
|
||||
}
|
||||
}
|
||||
</style>
|
0
src/components/register.vue
Normal file
0
src/components/register.vue
Normal file
Reference in New Issue
Block a user