mirror of
https://github.com/go-shiori/shiori.git
synced 2024-11-17 06:34:55 +08:00
120 lines
No EOL
4.8 KiB
HTML
120 lines
No EOL
4.8 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
|
<link rel="stylesheet" href="/css/stylesheet.css">
|
|
<link rel="stylesheet" href="/css/fontawesome.css">
|
|
<link rel="stylesheet" href="/css/source-sans-pro.css">
|
|
<script src="/js/vue.js"></script>
|
|
<script src="/js/axios.js"></script>
|
|
<script src="/js/js-cookie.js"></script>
|
|
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="/res/apple-touch-icon-144x144.png" />
|
|
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="/res/apple-touch-icon-152x152.png" />
|
|
<link rel="icon" type="image/png" href="/res/favicon-32x32.png" sizes="32x32" />
|
|
<link rel="icon" type="image/png" href="/res/favicon-16x16.png" sizes="16x16" />
|
|
<title>Login - Shiori - Bookmarks Manager</title>
|
|
</head>
|
|
|
|
<body>
|
|
<div id="login-page" :class="{night: nightMode}">
|
|
<p class="error-message" v-if="error !== ''">{{error}}</p>
|
|
<div id="login-box">
|
|
<div id="logo-area">
|
|
<p id="logo">
|
|
<span>栞</span>shiori
|
|
</p>
|
|
<p id="tagline">simple bookmark manager</p>
|
|
</div>
|
|
<div id="input-area">
|
|
<div class="input-field">
|
|
<p>Username: </p>
|
|
<input type="text" name="username" v-model.trim="username" placeholder="Username" tabindex="1">
|
|
</div>
|
|
<div class="input-field">
|
|
<p>Password: </p>
|
|
<input type="password" name="password" v-model.trim="password" placeholder="Password" tabindex="2" @keyup.enter="login">
|
|
</div>
|
|
<div class="input-field">
|
|
<a @click="toggleRemember" @keyup.enter="toggleRemember" tabindex="3">
|
|
<i class="fa-fw" :class="rememberMe ? 'fas fa-check-square' : 'far fa-square'"></i>Remember me
|
|
</a>
|
|
</div>
|
|
</div>
|
|
<div id="button-area">
|
|
<a v-if="loading">
|
|
<i class="fas fa-fw fa-spinner fa-spin"></i>
|
|
</a>
|
|
<a v-else class="button" tabindex="4" @click="login" @keyup.enter="login">Login</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<script>
|
|
var app = new Vue({
|
|
el: '#login-page',
|
|
data: {
|
|
error: '',
|
|
loading: false,
|
|
username: '',
|
|
password: '',
|
|
rememberMe: false,
|
|
nightMode: false,
|
|
},
|
|
methods: {
|
|
toggleRemember: function () {
|
|
this.rememberMe = !this.rememberMe;
|
|
},
|
|
login: function () {
|
|
// Validate input
|
|
if (this.username === '') {
|
|
this.error = 'Username must not empty';
|
|
return;
|
|
}
|
|
|
|
// Send request
|
|
this.loading = true;
|
|
axios.post('/api/login', {
|
|
username: this.username,
|
|
password: this.password,
|
|
remember: this.rememberMe
|
|
}, {
|
|
timeout: 10000
|
|
})
|
|
.then(function (response) {
|
|
// Save token
|
|
var token = response.data;
|
|
Cookies.set('token', token, {
|
|
expires: this.rememberMe ? 7 : 1
|
|
});
|
|
|
|
// Set destination URL
|
|
var rx = /[&?]dst=([^&]+)(&|$)/g,
|
|
match = rx.exec(location.href);
|
|
|
|
if (match == null) {
|
|
location.href = '/';
|
|
} else {
|
|
var dst = match[1];
|
|
location.href = decodeURIComponent(dst);
|
|
}
|
|
})
|
|
.catch(function (error) {
|
|
var errorMsg = (error.response ? error.response.data : error.message).trim();
|
|
app.password = '';
|
|
app.loading = false;
|
|
app.error = errorMsg;
|
|
});
|
|
}
|
|
},
|
|
mounted() {
|
|
// Read config from local storage
|
|
var nightMode = localStorage.getItem('shiori-night-mode');
|
|
this.nightMode = nightMode === '1';
|
|
}
|
|
});
|
|
</script>
|
|
</body>
|
|
|
|
</html> |