2026-01-02 22:57:33 +08:00
|
|
|
<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"
|
2026-01-02 23:04:49 +08:00
|
|
|
placeholder="请输入访问密码"
|
2026-01-02 22:57:33 +08:00
|
|
|
prefix-icon="Lock"
|
|
|
|
|
size="large"
|
2026-01-02 23:04:49 +08:00
|
|
|
show-password
|
2026-01-02 22:57:33 +08:00
|
|
|
@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 = {
|
2026-01-02 23:04:49 +08:00
|
|
|
password: [{ required: true, message: '请输入访问密码', trigger: 'blur' }],
|
2026-01-02 22:57:33 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const handleLogin = async () => {
|
|
|
|
|
if (!formRef.value) return;
|
|
|
|
|
|
|
|
|
|
await formRef.value.validate(async (valid) => {
|
|
|
|
|
if (!valid) return;
|
|
|
|
|
|
|
|
|
|
loading.value = true;
|
|
|
|
|
try {
|
2026-01-02 23:04:49 +08:00
|
|
|
await authStore.verifyPassword(loginForm.password);
|
2026-01-02 22:57:33 +08:00
|
|
|
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>
|