mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-06-16 03:05:11 -04:00
ADD:use token for check permission
This commit is contained in:
parent
07eea0f484
commit
11be4d032c
5 changed files with 145 additions and 1 deletions
120
src/pages/Login.vue
Normal file
120
src/pages/Login.vue
Normal file
|
@ -0,0 +1,120 @@
|
|||
<script setup lang="ts">
|
||||
import { ref } from 'vue';
|
||||
import { config } from '@/config';
|
||||
|
||||
const token = ref('');
|
||||
|
||||
async function handleLogin() {
|
||||
if (config.app.token === token.value) {
|
||||
localStorage.setItem('isLoggedIn', 'true');
|
||||
window.location.href = `${window.location.protocol}//${window.location.host}/`;
|
||||
} else {
|
||||
alert('Invalid Token');
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="login-container">
|
||||
<div class="login-card">
|
||||
<h1 class="login-title">Login</h1>
|
||||
<form @submit.prevent="handleLogin" class="login-form">
|
||||
<div class="form-group">
|
||||
<label for="token" class="form-label">Token:</label>
|
||||
<input
|
||||
id="token"
|
||||
v-model="token"
|
||||
type="text"
|
||||
required
|
||||
class="form-input"
|
||||
placeholder="Enter your access token"
|
||||
/>
|
||||
</div>
|
||||
<button type="submit" class="login-button">Login</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.login-container {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
min-height: 100vh;
|
||||
background-color: #f5f5f5; /* 浅灰色背景,与截图一致 */
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.login-card {
|
||||
background: white;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
|
||||
padding: 40px;
|
||||
width: 100%;
|
||||
max-width: 400px;
|
||||
}
|
||||
|
||||
.login-title {
|
||||
color: #2c3e50;
|
||||
text-align: center;
|
||||
margin-bottom: 30px;
|
||||
font-size: 24px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.login-form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 20px;
|
||||
}
|
||||
|
||||
.form-group {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.form-label {
|
||||
color: #2c3e50;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.form-input {
|
||||
padding: 12px 16px;
|
||||
border: 1px solid #e0e0e0;
|
||||
border-radius: 6px;
|
||||
font-size: 14px;
|
||||
transition: border-color 0.3s;
|
||||
}
|
||||
|
||||
.form-input:focus {
|
||||
outline: none;
|
||||
border-color: #4CAF50; /* 深绿色,与导航栏渐变一致 */
|
||||
box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.2);
|
||||
}
|
||||
|
||||
.login-button {
|
||||
background: linear-gradient(135deg, #4CAF50, #81C784); /* 与导航栏相似的渐变 */
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 6px;
|
||||
padding: 12px;
|
||||
font-size: 16px;
|
||||
font-weight: 500;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.login-button:hover {
|
||||
background: linear-gradient(135deg, #3e8e41, #66BB6A);
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.login-button:active {
|
||||
transform: translateY(0);
|
||||
}
|
||||
</style>
|
Loading…
Add table
Add a link
Reference in a new issue