feat: 精简部署工作空间并接入真实助手
- 项目首页保留部署状态与日志入口,发布和管理功能收进更多菜单。 - 统一记录步骤与日志,限制轮询、日志渲染和助手短会话开销。 - 接入只读 Agent 问答、来源与个人历史,补充权限和并发回归。
This commit is contained in:
+67
-135
@@ -9,18 +9,15 @@ import { useRoute, useRouter } from 'vue-router'
|
||||
import { devopsApi } from '../services/devopsApi'
|
||||
import { useSessionStore } from '../stores/session'
|
||||
|
||||
type LoginRole = 'super_admin' | 'member'
|
||||
|
||||
const SUPER_ADMIN_ACCOUNT = 'zhanxi'
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const session = useSessionStore()
|
||||
const loading = ref(false)
|
||||
const forgotPasswordLoading = ref(false)
|
||||
const loginRole = ref<LoginRole>('super_admin')
|
||||
|
||||
const loginForm = reactive({
|
||||
account: SUPER_ADMIN_ACCOUNT,
|
||||
account: '',
|
||||
password: '',
|
||||
})
|
||||
|
||||
@@ -30,34 +27,23 @@ const passwordForm = reactive({
|
||||
confirmPassword: '',
|
||||
})
|
||||
|
||||
const redirect = computed(() =>
|
||||
typeof route.query.redirect === 'string' ? route.query.redirect : '/overview',
|
||||
)
|
||||
const roleHint = computed(() =>
|
||||
loginRole.value === 'super_admin'
|
||||
? '超级管理员不提供忘记密码入口,请通过服务器运维方式重置。'
|
||||
: '普通成员首次登录或重置密码后,必须先修改临时密码。',
|
||||
)
|
||||
const isSuperAdminLogin = computed(() => loginRole.value === 'super_admin')
|
||||
|
||||
function switchLoginRole(role: LoginRole) {
|
||||
loginRole.value = role
|
||||
loginForm.account = role === 'super_admin' ? SUPER_ADMIN_ACCOUNT : ''
|
||||
loginForm.password = ''
|
||||
}
|
||||
|
||||
function handleLoginRoleChange(value: unknown) {
|
||||
if (value === 'super_admin' || value === 'member') {
|
||||
switchLoginRole(value)
|
||||
}
|
||||
}
|
||||
const redirect = computed(() => {
|
||||
const value = route.query.redirect
|
||||
return typeof value === 'string' && value.startsWith('/') && !value.startsWith('//')
|
||||
? value
|
||||
: '/overview'
|
||||
})
|
||||
const isSuperAdminLogin = computed(() => loginForm.account.trim() === SUPER_ADMIN_ACCOUNT)
|
||||
const loginError = ref('')
|
||||
|
||||
async function submitLogin() {
|
||||
if (loading.value) return
|
||||
loginError.value = ''
|
||||
loading.value = true
|
||||
|
||||
try {
|
||||
const user = await session.login({
|
||||
account: isSuperAdminLogin.value ? SUPER_ADMIN_ACCOUNT : loginForm.account.trim(),
|
||||
account: loginForm.account.trim(),
|
||||
password: loginForm.password,
|
||||
})
|
||||
passwordForm.currentPassword = loginForm.password
|
||||
@@ -69,7 +55,7 @@ async function submitLogin() {
|
||||
|
||||
await router.push(redirect.value)
|
||||
} catch (error) {
|
||||
ElMessage.error(error instanceof Error ? error.message : '登录失败')
|
||||
loginError.value = error instanceof Error ? error.message : '登录失败,请重试'
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
@@ -88,15 +74,11 @@ async function requestPasswordReset() {
|
||||
}
|
||||
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
`确认向超级管理员发送账号 ${account} 的密码重置请求?`,
|
||||
'忘记密码',
|
||||
{
|
||||
confirmButtonText: '发送请求',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
},
|
||||
)
|
||||
await ElMessageBox.confirm(`确认向超级管理员发送账号 ${account} 的密码重置请求?`, '忘记密码', {
|
||||
confirmButtonText: '发送请求',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
})
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
@@ -162,28 +144,20 @@ function accountLabel() {
|
||||
<section class="login-panel">
|
||||
<div class="login-copy">
|
||||
<ElIcon><Monitor /></ElIcon>
|
||||
<h1>DevOps 运维平台</h1>
|
||||
<p>使用平台账号进入控制台。</p>
|
||||
<h1>登录 DevOps</h1>
|
||||
<p>项目发布,简单有序。</p>
|
||||
</div>
|
||||
<ElForm class="login-form" label-position="top" @submit.prevent="submit">
|
||||
<template v-if="!session.mustChangePassword">
|
||||
<div class="role-switch">
|
||||
<ElRadioGroup
|
||||
:model-value="loginRole"
|
||||
size="large"
|
||||
@change="handleLoginRoleChange"
|
||||
>
|
||||
<ElRadioButton value="super_admin">超级管理员</ElRadioButton>
|
||||
<ElRadioButton value="member">普通成员</ElRadioButton>
|
||||
</ElRadioGroup>
|
||||
<p>{{ roleHint }}</p>
|
||||
</div>
|
||||
<ElFormItem label="账号">
|
||||
<ElInput
|
||||
v-model="loginForm.account"
|
||||
size="large"
|
||||
autocomplete="username"
|
||||
:readonly="isSuperAdminLogin"
|
||||
name="username"
|
||||
required
|
||||
:spellcheck="false"
|
||||
placeholder="输入平台账号…"
|
||||
/>
|
||||
</ElFormItem>
|
||||
<ElFormItem label="密码">
|
||||
@@ -192,9 +166,11 @@ function accountLabel() {
|
||||
size="large"
|
||||
type="password"
|
||||
autocomplete="current-password"
|
||||
required
|
||||
show-password
|
||||
/>
|
||||
</ElFormItem>
|
||||
<p v-if="loginError" class="login-error" role="alert">{{ loginError }}</p>
|
||||
<ElButton
|
||||
type="primary"
|
||||
size="large"
|
||||
@@ -270,111 +246,67 @@ function accountLabel() {
|
||||
display: grid;
|
||||
min-height: 100vh;
|
||||
place-items: center;
|
||||
padding: 24px;
|
||||
background: #eef2f7;
|
||||
padding: 28px 20px;
|
||||
background: #f8f9fb;
|
||||
}
|
||||
|
||||
.login-panel {
|
||||
display: grid;
|
||||
width: min(860px, 100%);
|
||||
grid-template-columns: 1fr 360px;
|
||||
overflow: hidden;
|
||||
border: 1px solid #dfe6f0;
|
||||
border-radius: 8px;
|
||||
background: #ffffff;
|
||||
box-shadow: 0 18px 50px rgb(15 23 42 / 10%);
|
||||
width: min(410px, 100%);
|
||||
padding: 38px;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 12px;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.login-copy {
|
||||
padding: 44px;
|
||||
border-right: 1px solid #e6ebf3;
|
||||
background: #f8fafc;
|
||||
margin-bottom: 32px;
|
||||
}
|
||||
|
||||
.login-copy .el-icon {
|
||||
color: #1d5fd0;
|
||||
font-size: 34px;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
width: 38px;
|
||||
height: 38px;
|
||||
margin-bottom: 24px;
|
||||
border-radius: 9px;
|
||||
background: #272d3a;
|
||||
color: #fff;
|
||||
font-size: 23px;
|
||||
}
|
||||
|
||||
.login-copy h1 {
|
||||
margin: 18px 0 10px;
|
||||
color: #111827;
|
||||
font-size: 28px;
|
||||
letter-spacing: 0;
|
||||
}
|
||||
|
||||
.login-copy p {
|
||||
max-width: 420px;
|
||||
color: #697386;
|
||||
font-size: 14px;
|
||||
line-height: 1.8;
|
||||
}
|
||||
|
||||
.login-form {
|
||||
padding: 44px 36px;
|
||||
}
|
||||
|
||||
.role-switch {
|
||||
display: grid;
|
||||
gap: 10px;
|
||||
margin-bottom: 22px;
|
||||
}
|
||||
|
||||
.role-switch :deep(.el-radio-group) {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.role-switch :deep(.el-radio-button__inner) {
|
||||
width: 100%;
|
||||
letter-spacing: 0;
|
||||
}
|
||||
|
||||
.role-switch p {
|
||||
min-height: 20px;
|
||||
margin: 0;
|
||||
color: #697386;
|
||||
font-size: 13px;
|
||||
line-height: 1.6;
|
||||
color: var(--text);
|
||||
font-size: 23px;
|
||||
font-weight: 600;
|
||||
letter-spacing: -0.5px;
|
||||
}
|
||||
.login-copy p {
|
||||
margin: 10px 0 0;
|
||||
color: var(--text-muted);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.login-form .el-button {
|
||||
width: 100%;
|
||||
margin-top: 8px;
|
||||
margin: 8px 0 0;
|
||||
}
|
||||
|
||||
.forgot-password {
|
||||
width: 100%;
|
||||
margin-top: 10px;
|
||||
.login-error {
|
||||
padding: 10px 12px;
|
||||
border-radius: 5px;
|
||||
background: #fff4f4;
|
||||
color: #b04747;
|
||||
font-size: 12px;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.change-title {
|
||||
display: grid;
|
||||
gap: 4px;
|
||||
margin-bottom: 18px;
|
||||
color: #111827;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.change-title span {
|
||||
color: #697386;
|
||||
gap: 6px;
|
||||
margin-bottom: 22px;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.switch-account {
|
||||
width: 100%;
|
||||
margin-top: 10px;
|
||||
.change-title span {
|
||||
color: var(--text-muted);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
@media (max-width: 780px) {
|
||||
@media (max-width: 480px) {
|
||||
.login-panel {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.login-copy {
|
||||
border-right: 0;
|
||||
border-bottom: 1px solid #e6ebf3;
|
||||
padding: 30px 24px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user