简化认证流程,移除用户名,只需要输入访问密码: ## 后端更改 - 移除 JWT_SECRET、ADMIN_USERNAME、ADMIN_PASSWORD 配置 - 添加 ACCESS_PASSWORD 配置 - 更新认证接口:POST /api/auth/verify-password - 简化 JWT payload,只包含认证状态和时间戳 - 移除用户管理相关代码 - 更新认证中间件 ## 前端更改 - 登录页面只显示密码输入框 - 移除用户名输入和相关状态 - 更新 Pinia store 为 verifyPassword 方法 - 移除 User 类型定义 - 更新布局和设置页面 ## 文档更改 - 更新 README.md 说明新的认证方式 - 更新 DEVELOPMENT_GUIDE.md 环境变量配置 - 更新 API.md 认证接口文档 - 更新 .env.example 配置模板 ## 安全改进 - 使用 ACCESS_PASSWORD 作为 JWT 签名密钥 - 自动清理过期会话(7天) - 简化配置,更易于部署 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
105 lines
2.3 KiB
Vue
105 lines
2.3 KiB
Vue
<template>
|
|
<div class="login-container">
|
|
<el-card class="login-card">
|
|
<template #header>
|
|
<div class="card-header">
|
|
<h2>CC Cloud</h2>
|
|
<p>Claude Code 管理平台</p>
|
|
</div>
|
|
</template>
|
|
|
|
<el-form :model="loginForm" :rules="rules" ref="formRef" @submit.prevent="handleLogin">
|
|
<el-form-item prop="password">
|
|
<el-input
|
|
v-model="loginForm.password"
|
|
type="password"
|
|
placeholder="请输入访问密码"
|
|
prefix-icon="Lock"
|
|
size="large"
|
|
show-password
|
|
@keyup.enter="handleLogin"
|
|
/>
|
|
</el-form-item>
|
|
|
|
<el-form-item>
|
|
<el-button type="primary" size="large" style="width: 100%" :loading="loading" @click="handleLogin">
|
|
登录
|
|
</el-button>
|
|
</el-form-item>
|
|
</el-form>
|
|
</el-card>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { reactive, ref } from 'vue';
|
|
import { useRouter } from 'vue-router';
|
|
import { ElMessage } from 'element-plus';
|
|
import type { FormInstance, FormRules } from 'element-plus';
|
|
import { useAuthStore } from '@/stores/auth';
|
|
|
|
const router = useRouter();
|
|
const authStore = useAuthStore();
|
|
|
|
const formRef = ref<FormInstance>();
|
|
const loading = ref(false);
|
|
|
|
const loginForm = reactive({
|
|
password: '',
|
|
});
|
|
|
|
const rules: FormRules = {
|
|
password: [{ required: true, message: '请输入访问密码', trigger: 'blur' }],
|
|
};
|
|
|
|
const handleLogin = async () => {
|
|
if (!formRef.value) return;
|
|
|
|
await formRef.value.validate(async (valid) => {
|
|
if (!valid) return;
|
|
|
|
loading.value = true;
|
|
try {
|
|
await authStore.verifyPassword(loginForm.password);
|
|
ElMessage.success('登录成功');
|
|
router.push('/');
|
|
} catch (error: any) {
|
|
ElMessage.error(error.message || '登录失败');
|
|
} finally {
|
|
loading.value = false;
|
|
}
|
|
});
|
|
};
|
|
</script>
|
|
|
|
<style scoped>
|
|
.login-container {
|
|
display: flex;
|
|
justify-content: center;
|
|
align-items: center;
|
|
width: 100%;
|
|
height: 100vh;
|
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
}
|
|
|
|
.login-card {
|
|
width: 400px;
|
|
}
|
|
|
|
.card-header {
|
|
text-align: center;
|
|
}
|
|
|
|
.card-header h2 {
|
|
margin: 0;
|
|
font-size: 24px;
|
|
color: #303133;
|
|
}
|
|
|
|
.card-header p {
|
|
margin: 8px 0 0;
|
|
font-size: 14px;
|
|
color: #909399;
|
|
}
|
|
</style>
|