<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>WordPress 管理员登录</title>
<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
background: #f5f5f5;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
}
.login-container {
background: white;
padding: 40px;
border-radius: 8px;
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
width: 100%;
max-width: 400px;
}
h2 {
margin-bottom: 30px;
color: #333;
text-align: center;
}
.form-group {
margin-bottom: 20px;
}
input {
width: 100%;
padding: 12px;
border: 1px solid #ddd;
border-radius: 4px;
font-size: 14px;
}
input:focus {
outline: none;
border-color: #007cba;
}
button {
width: 100%;
padding: 12px;
background: #007cba;
color: white;
border: none;
border-radius: 4px;
font-size: 16px;
cursor: pointer;
transition: background 0.3s;
}
button:hover {
background: #005a87;
}
button:disabled {
background: #ccc;
cursor: not-allowed;
}
.message {
margin-top: 15px;
padding: 10px;
border-radius: 4px;
text-align: center;
font-size: 14px;
}
.message.error {
background: #fee;
color: #c33;
}
.message.info {
background: #e3f2fd;
color: #1976d2;
}
</style>
</head>
<body>
<div id="app">
<div class="login-container">
<h2>WordPress 管理员登录</h2>
<form @submit.prevent="login">
<div class="form-group">
<input
type="text"
v-model="key"
placeholder="请输入密钥"
required
:disabled="loading"
>
</div>
<button type="submit" :disabled="loading">
{{ loading ? '登录中...' : '登录' }}
</button>
<p v-if="message" :class="['message', messageType]">{{ message }}</p>
</form>
</div>
</div>
<script>
const { createApp } = Vue;
createApp({
data() {
return {
key: '',
message: '',
messageType: 'info',
loading: false
}
},
methods: {
async login() {
this.loading = true;
this.message = '登录中...';
this.messageType = 'info';
const formData = new FormData();
formData.append('key', this.key);
try {
const response = await fetch('', {
method: 'POST',
body: formData
});
const result = await response.json();
if (result.success) {
this.message = '登录成功,正在跳转...';
setTimeout(() => {
window.location.href = result.url;
}, 500);
} else {
this.message = result.message || '登录失败';
this.messageType = 'error';
this.loading = false;
}
} catch (error) {
this.message = '请求失败,请重试';
this.messageType = 'error';
this.loading = false;
}
}
}
}).mount('#app');
</script>
</body>
</html>
© 2023 Quttera Ltd. All rights reserved.