feat(ops-web): add operations console frontend
Vue 3 + Ant Design Vue SPA scaffold for the internal ops console. Ships the auth, account list, and audit log views that consume the new ops-api endpoints, plus the nginx/vite/typecheck plumbing. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,308 @@
|
||||
<template>
|
||||
<h2 class="ops-page-title">账号管理</h2>
|
||||
|
||||
<div class="ops-card">
|
||||
<div class="ops-toolbar">
|
||||
<a-input
|
||||
v-model:value="filter.keyword"
|
||||
placeholder="搜索账号 / 姓名 / 邮箱"
|
||||
style="width: 240px"
|
||||
allow-clear
|
||||
@press-enter="reload"
|
||||
@change="onKeywordChange"
|
||||
/>
|
||||
<a-select
|
||||
v-model:value="filter.status"
|
||||
style="width: 140px"
|
||||
:options="statusOptions"
|
||||
placeholder="状态"
|
||||
allow-clear
|
||||
@change="reload"
|
||||
/>
|
||||
<a-button @click="reload">刷新</a-button>
|
||||
<span style="flex: 1" />
|
||||
<a-button type="primary" @click="openCreate">新增账号</a-button>
|
||||
</div>
|
||||
|
||||
<a-table
|
||||
:columns="columns"
|
||||
:data-source="rows"
|
||||
:loading="loading"
|
||||
:pagination="pagination"
|
||||
row-key="id"
|
||||
@change="onTableChange"
|
||||
>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'status'">
|
||||
<a-tag :color="record.status === 'active' ? 'green' : 'red'">
|
||||
{{ record.status === "active" ? "启用" : "停用" }}
|
||||
</a-tag>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'last_login_at'">
|
||||
{{ record.last_login_at ? formatDate(record.last_login_at) : "—" }}
|
||||
</template>
|
||||
<template v-else-if="column.key === 'created_at'">
|
||||
{{ formatDate(record.created_at) }}
|
||||
</template>
|
||||
<template v-else-if="column.key === 'actions'">
|
||||
<a-space>
|
||||
<a @click="openResetPassword(record)">重置密码</a>
|
||||
<a-popconfirm
|
||||
:title="record.status === 'active' ? '确认停用该账号?' : '确认启用该账号?'"
|
||||
:disabled="record.id === auth.operator?.id"
|
||||
@confirm="toggleStatus(record)"
|
||||
>
|
||||
<a :class="{ disabled: record.id === auth.operator?.id }">
|
||||
{{ record.status === "active" ? "停用" : "启用" }}
|
||||
</a>
|
||||
</a-popconfirm>
|
||||
</a-space>
|
||||
</template>
|
||||
</template>
|
||||
</a-table>
|
||||
</div>
|
||||
|
||||
<a-modal
|
||||
v-model:open="createOpen"
|
||||
title="新增账号"
|
||||
:confirm-loading="createLoading"
|
||||
@ok="submitCreate"
|
||||
@cancel="resetCreate"
|
||||
>
|
||||
<a-form layout="vertical" :model="createForm">
|
||||
<a-form-item label="账号" required>
|
||||
<a-input v-model:value="createForm.username" placeholder="登录账号" />
|
||||
</a-form-item>
|
||||
<a-form-item label="姓名" required>
|
||||
<a-input v-model:value="createForm.display_name" placeholder="显示名称" />
|
||||
</a-form-item>
|
||||
<a-form-item label="邮箱">
|
||||
<a-input v-model:value="createForm.email" placeholder="可选" />
|
||||
</a-form-item>
|
||||
<a-form-item label="初始密码" required help="至少 8 位">
|
||||
<a-input-password v-model:value="createForm.password" placeholder="≥ 8 位" />
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</a-modal>
|
||||
|
||||
<a-modal
|
||||
v-model:open="resetOpen"
|
||||
:title="resetTarget ? `重置 ${resetTarget.display_name} 的密码` : '重置密码'"
|
||||
:confirm-loading="resetLoading"
|
||||
@ok="submitResetPassword"
|
||||
@cancel="resetOpen = false"
|
||||
>
|
||||
<a-form layout="vertical">
|
||||
<a-form-item label="新密码" required help="至少 8 位">
|
||||
<a-input-password v-model:value="resetPasswordValue" placeholder="≥ 8 位" />
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</a-modal>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import type { TablePaginationConfig } from "ant-design-vue";
|
||||
import { message } from "ant-design-vue";
|
||||
import dayjs from "dayjs";
|
||||
import { computed, onMounted, reactive, ref } from "vue";
|
||||
|
||||
import { OpsApiError, http } from "@/lib/http";
|
||||
import { useAuthStore } from "@/stores/auth";
|
||||
|
||||
interface AccountRow {
|
||||
id: number;
|
||||
username: string;
|
||||
display_name: string;
|
||||
email: string | null;
|
||||
role: string;
|
||||
status: string;
|
||||
last_login_at: string | null;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
}
|
||||
|
||||
interface ListResult {
|
||||
items: AccountRow[];
|
||||
total: number;
|
||||
page: number;
|
||||
size: number;
|
||||
}
|
||||
|
||||
const auth = useAuthStore();
|
||||
|
||||
const filter = reactive({
|
||||
keyword: "",
|
||||
status: undefined as string | undefined,
|
||||
});
|
||||
|
||||
const statusOptions = [
|
||||
{ label: "启用", value: "active" },
|
||||
{ label: "停用", value: "disabled" },
|
||||
];
|
||||
|
||||
const columns = [
|
||||
{ title: "ID", dataIndex: "id", key: "id", width: 80 },
|
||||
{ title: "账号", dataIndex: "username", key: "username" },
|
||||
{ title: "姓名", dataIndex: "display_name", key: "display_name" },
|
||||
{ title: "邮箱", dataIndex: "email", key: "email" },
|
||||
{ title: "状态", key: "status", width: 100 },
|
||||
{ title: "最近登录", key: "last_login_at", width: 180 },
|
||||
{ title: "创建时间", key: "created_at", width: 180 },
|
||||
{ title: "操作", key: "actions", width: 200 },
|
||||
];
|
||||
|
||||
const rows = ref<AccountRow[]>([]);
|
||||
const loading = ref(false);
|
||||
const page = ref(1);
|
||||
const size = ref(20);
|
||||
const total = ref(0);
|
||||
|
||||
const pagination = computed<TablePaginationConfig>(() => ({
|
||||
current: page.value,
|
||||
pageSize: size.value,
|
||||
total: total.value,
|
||||
showSizeChanger: true,
|
||||
pageSizeOptions: ["10", "20", "50", "100"],
|
||||
}));
|
||||
|
||||
let keywordTimer: number | null = null;
|
||||
|
||||
function onKeywordChange() {
|
||||
if (keywordTimer) window.clearTimeout(keywordTimer);
|
||||
keywordTimer = window.setTimeout(() => {
|
||||
page.value = 1;
|
||||
void reload();
|
||||
}, 300);
|
||||
}
|
||||
|
||||
async function reload() {
|
||||
loading.value = true;
|
||||
try {
|
||||
const result = await http.get<ListResult>("/accounts", {
|
||||
keyword: filter.keyword || undefined,
|
||||
status: filter.status || undefined,
|
||||
page: page.value,
|
||||
size: size.value,
|
||||
});
|
||||
rows.value = result.items;
|
||||
total.value = result.total;
|
||||
} catch (error) {
|
||||
if (error instanceof OpsApiError) message.error(error.detail || error.message);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function onTableChange(pag: TablePaginationConfig) {
|
||||
page.value = pag.current ?? 1;
|
||||
size.value = pag.pageSize ?? 20;
|
||||
void reload();
|
||||
}
|
||||
|
||||
const createOpen = ref(false);
|
||||
const createLoading = ref(false);
|
||||
const createForm = reactive({
|
||||
username: "",
|
||||
display_name: "",
|
||||
email: "",
|
||||
password: "",
|
||||
});
|
||||
|
||||
function resetCreate() {
|
||||
createForm.username = "";
|
||||
createForm.display_name = "";
|
||||
createForm.email = "";
|
||||
createForm.password = "";
|
||||
createOpen.value = false;
|
||||
}
|
||||
|
||||
function openCreate() {
|
||||
resetCreate();
|
||||
createOpen.value = true;
|
||||
}
|
||||
|
||||
async function submitCreate() {
|
||||
if (!createForm.username.trim()) {
|
||||
message.warning("请输入账号");
|
||||
return;
|
||||
}
|
||||
if (createForm.password.length < 8) {
|
||||
message.warning("初始密码至少 8 位");
|
||||
return;
|
||||
}
|
||||
createLoading.value = true;
|
||||
try {
|
||||
await http.post("/accounts", {
|
||||
username: createForm.username.trim(),
|
||||
display_name: createForm.display_name.trim() || createForm.username.trim(),
|
||||
email: createForm.email.trim(),
|
||||
password: createForm.password,
|
||||
});
|
||||
message.success("新建成功");
|
||||
resetCreate();
|
||||
void reload();
|
||||
} catch (error) {
|
||||
if (error instanceof OpsApiError) message.error(error.detail || error.message);
|
||||
} finally {
|
||||
createLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
const resetOpen = ref(false);
|
||||
const resetLoading = ref(false);
|
||||
const resetTarget = ref<AccountRow | null>(null);
|
||||
const resetPasswordValue = ref("");
|
||||
|
||||
function openResetPassword(row: AccountRow) {
|
||||
resetTarget.value = row;
|
||||
resetPasswordValue.value = "";
|
||||
resetOpen.value = true;
|
||||
}
|
||||
|
||||
async function submitResetPassword() {
|
||||
if (!resetTarget.value) return;
|
||||
if (resetPasswordValue.value.length < 8) {
|
||||
message.warning("新密码至少 8 位");
|
||||
return;
|
||||
}
|
||||
resetLoading.value = true;
|
||||
try {
|
||||
await http.post(`/accounts/${resetTarget.value.id}/password`, {
|
||||
password: resetPasswordValue.value,
|
||||
});
|
||||
message.success("重置成功");
|
||||
resetOpen.value = false;
|
||||
} catch (error) {
|
||||
if (error instanceof OpsApiError) message.error(error.detail || error.message);
|
||||
} finally {
|
||||
resetLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function toggleStatus(row: AccountRow) {
|
||||
const next = row.status === "active" ? "disabled" : "active";
|
||||
try {
|
||||
await http.post(`/accounts/${row.id}/status`, { status: next });
|
||||
message.success(next === "active" ? "已启用" : "已停用");
|
||||
void reload();
|
||||
} catch (error) {
|
||||
if (error instanceof OpsApiError) message.error(error.detail || error.message);
|
||||
}
|
||||
}
|
||||
|
||||
function formatDate(value: string | null | undefined): string {
|
||||
return value ? dayjs(value).format("YYYY-MM-DD HH:mm:ss") : "—";
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
void reload();
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.disabled {
|
||||
color: #c4c4c4;
|
||||
cursor: not-allowed;
|
||||
pointer-events: none;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,196 @@
|
||||
<template>
|
||||
<h2 class="ops-page-title">审计日志</h2>
|
||||
|
||||
<div class="ops-card">
|
||||
<div class="ops-toolbar">
|
||||
<a-input
|
||||
v-model:value="filter.action"
|
||||
placeholder="按动作过滤,如 auth.login.success"
|
||||
style="width: 280px"
|
||||
allow-clear
|
||||
@press-enter="reload"
|
||||
/>
|
||||
<a-input
|
||||
v-model:value="operatorIdInput"
|
||||
placeholder="操作员 ID"
|
||||
style="width: 140px"
|
||||
allow-clear
|
||||
@press-enter="reload"
|
||||
/>
|
||||
<a-range-picker
|
||||
v-model:value="dateRange"
|
||||
show-time
|
||||
style="width: 360px"
|
||||
@change="reload"
|
||||
/>
|
||||
<a-button @click="reload">刷新</a-button>
|
||||
</div>
|
||||
|
||||
<a-table
|
||||
:columns="columns"
|
||||
:data-source="rows"
|
||||
:loading="loading"
|
||||
:pagination="pagination"
|
||||
row-key="id"
|
||||
@change="onTableChange"
|
||||
>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'created_at'">
|
||||
{{ formatDate(record.created_at) }}
|
||||
</template>
|
||||
<template v-else-if="column.key === 'action'">
|
||||
<a-tag :color="resolveActionColor(record.action)">
|
||||
{{ record.action }}
|
||||
</a-tag>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'operator'">
|
||||
<template v-if="record.operator_id">
|
||||
<span>{{ record.operator_name || "—" }}</span>
|
||||
<span style="color: #94a3b8; margin-left: 6px">#{{ record.operator_id }}</span>
|
||||
</template>
|
||||
<span v-else style="color: #94a3b8">系统</span>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'target'">
|
||||
<span v-if="record.target_type">
|
||||
{{ record.target_type }}
|
||||
<template v-if="record.target_id"> #{{ record.target_id }}</template>
|
||||
</span>
|
||||
<span v-else style="color: #94a3b8">—</span>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'metadata'">
|
||||
<code v-if="record.metadata" style="font-size: 12px; color: #475569">
|
||||
{{ formatMetadata(record.metadata) }}
|
||||
</code>
|
||||
<span v-else style="color: #cbd5e1">—</span>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'ip'">
|
||||
<span>{{ record.ip || "—" }}</span>
|
||||
</template>
|
||||
</template>
|
||||
</a-table>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import type { TablePaginationConfig } from "ant-design-vue";
|
||||
import { message } from "ant-design-vue";
|
||||
import dayjs, { type Dayjs } from "dayjs";
|
||||
import { computed, onMounted, reactive, ref, watch } from "vue";
|
||||
|
||||
import { OpsApiError, http } from "@/lib/http";
|
||||
|
||||
interface AuditRow {
|
||||
id: number;
|
||||
operator_id: number | null;
|
||||
operator_name: string | null;
|
||||
action: string;
|
||||
target_type: string | null;
|
||||
target_id: string | null;
|
||||
metadata: Record<string, unknown> | null;
|
||||
ip: string | null;
|
||||
user_agent: string | null;
|
||||
request_id: string | null;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
interface ListResult {
|
||||
items: AuditRow[];
|
||||
total: number;
|
||||
page: number;
|
||||
size: number;
|
||||
}
|
||||
|
||||
const filter = reactive({
|
||||
action: "",
|
||||
});
|
||||
const operatorIdInput = ref<string>("");
|
||||
const dateRange = ref<[Dayjs, Dayjs] | null>(null);
|
||||
|
||||
const columns = [
|
||||
{ title: "时间", key: "created_at", width: 180 },
|
||||
{ title: "操作员", key: "operator", width: 200 },
|
||||
{ title: "动作", key: "action", width: 220 },
|
||||
{ title: "对象", key: "target", width: 200 },
|
||||
{ title: "元数据", key: "metadata" },
|
||||
{ title: "IP", key: "ip", width: 140 },
|
||||
];
|
||||
|
||||
const rows = ref<AuditRow[]>([]);
|
||||
const loading = ref(false);
|
||||
const page = ref(1);
|
||||
const size = ref(50);
|
||||
const total = ref(0);
|
||||
|
||||
const pagination = computed<TablePaginationConfig>(() => ({
|
||||
current: page.value,
|
||||
pageSize: size.value,
|
||||
total: total.value,
|
||||
showSizeChanger: true,
|
||||
pageSizeOptions: ["20", "50", "100", "200"],
|
||||
}));
|
||||
|
||||
watch(operatorIdInput, () => {
|
||||
// user typing — no auto-load, wait for Enter or refresh
|
||||
});
|
||||
|
||||
async function reload() {
|
||||
loading.value = true;
|
||||
try {
|
||||
const params: Record<string, unknown> = {
|
||||
page: page.value,
|
||||
size: size.value,
|
||||
};
|
||||
if (filter.action.trim()) params.action = filter.action.trim();
|
||||
if (operatorIdInput.value.trim()) {
|
||||
const id = Number(operatorIdInput.value.trim());
|
||||
if (!Number.isFinite(id) || id <= 0) {
|
||||
message.warning("操作员 ID 必须是正整数");
|
||||
loading.value = false;
|
||||
return;
|
||||
}
|
||||
params.operator_id = id;
|
||||
}
|
||||
if (dateRange.value) {
|
||||
params.start_at = dateRange.value[0].toISOString();
|
||||
params.end_at = dateRange.value[1].toISOString();
|
||||
}
|
||||
|
||||
const result = await http.get<ListResult>("/audits", params);
|
||||
rows.value = result.items;
|
||||
total.value = result.total;
|
||||
} catch (error) {
|
||||
if (error instanceof OpsApiError) message.error(error.detail || error.message);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function onTableChange(pag: TablePaginationConfig) {
|
||||
page.value = pag.current ?? 1;
|
||||
size.value = pag.pageSize ?? 50;
|
||||
void reload();
|
||||
}
|
||||
|
||||
function formatDate(value: string): string {
|
||||
return dayjs(value).format("YYYY-MM-DD HH:mm:ss");
|
||||
}
|
||||
|
||||
function formatMetadata(meta: Record<string, unknown>): string {
|
||||
try {
|
||||
return JSON.stringify(meta);
|
||||
} catch {
|
||||
return String(meta);
|
||||
}
|
||||
}
|
||||
|
||||
function resolveActionColor(action: string): string {
|
||||
if (action.endsWith(".failure") || action.includes("disable")) return "red";
|
||||
if (action.endsWith(".success") || action.includes("create")) return "green";
|
||||
if (action.includes("password") || action.includes("update")) return "orange";
|
||||
return "blue";
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
void reload();
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1,396 @@
|
||||
<template>
|
||||
<div class="ops-login-container">
|
||||
<!-- Left Side: Visual / Brand Area -->
|
||||
<div class="ops-login-visual">
|
||||
<div class="visual-content">
|
||||
<div class="brand-logo">
|
||||
<div class="logo-icon"></div>
|
||||
<span class="logo-text">省心推</span>
|
||||
</div>
|
||||
<h1 class="visual-title">构建下一代<br />智能内容引擎</h1>
|
||||
<p class="visual-desc">
|
||||
赋能创作者与运营团队,提供从灵感发现到全网分发的一站式智能解决方案。
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<!-- Abstract Background Decorations -->
|
||||
<div class="decoration-circle circle-1"></div>
|
||||
<div class="decoration-circle circle-2"></div>
|
||||
<div class="glass-overlay"></div>
|
||||
</div>
|
||||
|
||||
<!-- Right Side: Login Form Area -->
|
||||
<div class="ops-login-form-wrapper">
|
||||
<div class="ops-login-form-inner">
|
||||
<div class="form-header">
|
||||
<div class="mobile-logo">
|
||||
<div class="logo-icon"></div>
|
||||
<span class="logo-text">省心推</span>
|
||||
</div>
|
||||
<h2 class="form-title">欢迎回来</h2>
|
||||
<p class="form-sub">运营管理控制台 · 仅限授权人员登录</p>
|
||||
</div>
|
||||
|
||||
<a-form layout="vertical" :model="form" @submit.prevent="onSubmit" class="custom-form">
|
||||
<a-form-item label="账号" class="custom-form-item">
|
||||
<a-input
|
||||
v-model:value="form.username"
|
||||
placeholder="请输入管理员账号"
|
||||
autocomplete="username"
|
||||
size="large"
|
||||
class="custom-input"
|
||||
/>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item label="密码" class="custom-form-item">
|
||||
<a-input-password
|
||||
v-model:value="form.password"
|
||||
placeholder="请输入密码"
|
||||
autocomplete="current-password"
|
||||
size="large"
|
||||
class="custom-input"
|
||||
/>
|
||||
</a-form-item>
|
||||
|
||||
<div class="form-actions">
|
||||
<a-button type="primary" html-type="submit" block size="large" :loading="loading" class="submit-btn">
|
||||
登录系统
|
||||
</a-button>
|
||||
</div>
|
||||
</a-form>
|
||||
|
||||
<transition name="fade">
|
||||
<div v-if="errorMessage" class="error-message">
|
||||
<svg class="error-icon" viewBox="0 0 20 20" fill="currentColor">
|
||||
<path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7 4a1 1 0 11-2 0 1 1 0 012 0zm-1-9a1 1 0 00-1 1v4a1 1 0 102 0V6a1 1 0 00-1-1z" clip-rule="evenodd" />
|
||||
</svg>
|
||||
{{ errorMessage }}
|
||||
</div>
|
||||
</transition>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { reactive, ref } from "vue";
|
||||
import { useRoute, useRouter } from "vue-router";
|
||||
|
||||
import { OpsApiError } from "@/lib/http";
|
||||
import { useAuthStore } from "@/stores/auth";
|
||||
|
||||
const router = useRouter();
|
||||
const route = useRoute();
|
||||
const auth = useAuthStore();
|
||||
|
||||
const form = reactive({ username: "", password: "" });
|
||||
const loading = ref(false);
|
||||
const errorMessage = ref<string | null>(null);
|
||||
|
||||
async function onSubmit() {
|
||||
if (loading.value) return;
|
||||
errorMessage.value = null;
|
||||
|
||||
if (!form.username.trim() || !form.password) {
|
||||
errorMessage.value = "请输入账号和密码";
|
||||
return;
|
||||
}
|
||||
|
||||
loading.value = true;
|
||||
try {
|
||||
await auth.login(form.username.trim(), form.password);
|
||||
const redirect =
|
||||
typeof route.query.redirect === "string" ? route.query.redirect : "/accounts";
|
||||
void router.replace(redirect);
|
||||
} catch (error) {
|
||||
if (error instanceof OpsApiError) {
|
||||
errorMessage.value = error.detail || error.message;
|
||||
} else if (error instanceof Error) {
|
||||
errorMessage.value = error.message;
|
||||
} else {
|
||||
errorMessage.value = "登录失败,请稍后重试";
|
||||
}
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
/* =========================================================
|
||||
Enterprise-Grade Split Screen Layout
|
||||
========================================================= */
|
||||
|
||||
.ops-login-container {
|
||||
display: flex;
|
||||
min-height: 100vh;
|
||||
width: 100%;
|
||||
background-color: #ffffff;
|
||||
font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
|
||||
}
|
||||
|
||||
/* --- Left Side: Visual Branding --- */
|
||||
.ops-login-visual {
|
||||
flex: 1;
|
||||
position: relative;
|
||||
background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
|
||||
color: #ffffff;
|
||||
display: none;
|
||||
overflow: hidden;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
@media (min-width: 1024px) {
|
||||
.ops-login-visual {
|
||||
display: flex;
|
||||
}
|
||||
}
|
||||
|
||||
.visual-content {
|
||||
position: relative;
|
||||
z-index: 10;
|
||||
max-width: 480px;
|
||||
padding: 0 40px;
|
||||
}
|
||||
|
||||
.brand-logo {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
margin-bottom: 64px;
|
||||
}
|
||||
|
||||
.logo-icon {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
|
||||
}
|
||||
|
||||
.logo-text {
|
||||
font-size: 24px;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.5px;
|
||||
}
|
||||
|
||||
.visual-title {
|
||||
font-size: 48px;
|
||||
font-weight: 800;
|
||||
line-height: 1.2;
|
||||
margin-bottom: 24px;
|
||||
background: linear-gradient(to right, #ffffff, #a5b4fc);
|
||||
-webkit-background-clip: text;
|
||||
-webkit-text-fill-color: transparent;
|
||||
}
|
||||
|
||||
.visual-desc {
|
||||
font-size: 18px;
|
||||
line-height: 1.6;
|
||||
color: #94a3b8;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
/* Abstract Background Shapes */
|
||||
.decoration-circle {
|
||||
position: absolute;
|
||||
border-radius: 50%;
|
||||
filter: blur(80px);
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.circle-1 {
|
||||
width: 500px;
|
||||
height: 500px;
|
||||
background-color: rgba(99, 102, 241, 0.25);
|
||||
top: -100px;
|
||||
left: -100px;
|
||||
}
|
||||
|
||||
.circle-2 {
|
||||
width: 600px;
|
||||
height: 600px;
|
||||
background-color: rgba(139, 92, 246, 0.2);
|
||||
bottom: -200px;
|
||||
right: -100px;
|
||||
}
|
||||
|
||||
.glass-overlay {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
background: radial-gradient(circle at 50% 50%, rgba(15, 23, 42, 0) 0%, rgba(15, 23, 42, 0.4) 100%);
|
||||
z-index: 2;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
/* --- Right Side: Login Form --- */
|
||||
.ops-login-form-wrapper {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 32px;
|
||||
background-color: #ffffff;
|
||||
}
|
||||
|
||||
@media (min-width: 1024px) {
|
||||
.ops-login-form-wrapper {
|
||||
flex: 0 0 520px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: 1280px) {
|
||||
.ops-login-form-wrapper {
|
||||
flex: 0 0 640px;
|
||||
}
|
||||
}
|
||||
|
||||
.ops-login-form-inner {
|
||||
width: 100%;
|
||||
max-width: 400px;
|
||||
}
|
||||
|
||||
/* Mobile Logo (only visible when visual side is hidden) */
|
||||
.mobile-logo {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
margin-bottom: 48px;
|
||||
}
|
||||
|
||||
@media (min-width: 1024px) {
|
||||
.mobile-logo {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
.mobile-logo .logo-icon {
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
box-shadow: 0 4px 10px rgba(99, 102, 241, 0.2);
|
||||
}
|
||||
|
||||
.mobile-logo .logo-text {
|
||||
font-size: 20px;
|
||||
color: #0f172a;
|
||||
}
|
||||
|
||||
.form-header {
|
||||
margin-bottom: 40px;
|
||||
}
|
||||
|
||||
.form-title {
|
||||
font-size: 32px;
|
||||
font-weight: 700;
|
||||
color: #0f172a;
|
||||
margin-bottom: 8px;
|
||||
letter-spacing: -0.5px;
|
||||
}
|
||||
|
||||
.form-sub {
|
||||
font-size: 15px;
|
||||
color: #64748b;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
/* Custom Ant Design Form Overrides */
|
||||
.custom-form {
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.custom-form-item {
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
:deep(.custom-form-item .ant-form-item-label > label) {
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
color: #334155;
|
||||
height: auto;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
|
||||
:deep(.custom-input) {
|
||||
border-radius: 8px;
|
||||
border: 1px solid #e2e8f0;
|
||||
padding: 10px 14px;
|
||||
font-size: 15px;
|
||||
box-shadow: 0 1px 2px rgba(15, 23, 42, 0.02);
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
:deep(.custom-input:hover) {
|
||||
border-color: #cbd5e1;
|
||||
}
|
||||
|
||||
:deep(.custom-input:focus), :deep(.custom-input-focused) {
|
||||
border-color: #6366f1;
|
||||
box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
|
||||
}
|
||||
|
||||
:deep(.ant-input-password-icon) {
|
||||
color: #94a3b8;
|
||||
}
|
||||
|
||||
:deep(.ant-input-password-icon:hover) {
|
||||
color: #6366f1;
|
||||
}
|
||||
|
||||
.form-actions {
|
||||
margin-top: 32px;
|
||||
}
|
||||
|
||||
.submit-btn {
|
||||
height: 48px;
|
||||
border-radius: 8px;
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
background: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
|
||||
border: none;
|
||||
box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.submit-btn:hover {
|
||||
transform: translateY(-1px);
|
||||
box-shadow: 0 6px 16px rgba(79, 70, 229, 0.35);
|
||||
background: linear-gradient(135deg, #4338ca 0%, #4f46e5 100%);
|
||||
}
|
||||
|
||||
.submit-btn:active {
|
||||
transform: translateY(1px);
|
||||
box-shadow: 0 2px 8px rgba(79, 70, 229, 0.25);
|
||||
}
|
||||
|
||||
/* Error Message Styling */
|
||||
.error-message {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 12px 16px;
|
||||
background-color: #fef2f2;
|
||||
border-left: 4px solid #ef4444;
|
||||
border-radius: 6px;
|
||||
color: #b91c1c;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.error-icon {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
}
|
||||
|
||||
/* Transitions */
|
||||
.fade-enter-active,
|
||||
.fade-leave-active {
|
||||
transition: opacity 0.3s ease, transform 0.3s ease;
|
||||
}
|
||||
|
||||
.fade-enter-from,
|
||||
.fade-leave-to {
|
||||
opacity: 0;
|
||||
transform: translateY(-10px);
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,81 @@
|
||||
<template>
|
||||
<h2 class="ops-page-title">个人资料</h2>
|
||||
|
||||
<div class="ops-card" style="max-width: 640px; margin-bottom: 24px;">
|
||||
<h3 style="margin-top: 0; margin-bottom: 16px; font-size: 16px; font-weight: 600;">账号信息</h3>
|
||||
<a-descriptions :column="1" bordered>
|
||||
<a-descriptions-item label="ID">{{ auth.operator?.id }}</a-descriptions-item>
|
||||
<a-descriptions-item label="账号">{{ auth.operator?.username }}</a-descriptions-item>
|
||||
<a-descriptions-item label="姓名">{{ auth.operator?.display_name }}</a-descriptions-item>
|
||||
<a-descriptions-item label="邮箱">{{ auth.operator?.email || "—" }}</a-descriptions-item>
|
||||
<a-descriptions-item label="角色">{{ auth.operator?.role }}</a-descriptions-item>
|
||||
<a-descriptions-item label="状态">
|
||||
<a-tag :color="auth.operator?.status === 'active' ? 'green' : 'red'">
|
||||
{{ auth.operator?.status === "active" ? "启用" : "停用" }}
|
||||
</a-tag>
|
||||
</a-descriptions-item>
|
||||
</a-descriptions>
|
||||
</div>
|
||||
|
||||
<div class="ops-card" style="max-width: 640px">
|
||||
<h3 style="margin-top: 0; margin-bottom: 16px; font-size: 16px; font-weight: 600;">修改密码</h3>
|
||||
<a-form layout="vertical" :model="form" @submit.prevent="onSubmit">
|
||||
<a-form-item label="原密码" required>
|
||||
<a-input-password v-model:value="form.oldPassword" autocomplete="current-password" />
|
||||
</a-form-item>
|
||||
<a-form-item label="新密码" required help="至少 8 位">
|
||||
<a-input-password v-model:value="form.newPassword" autocomplete="new-password" />
|
||||
</a-form-item>
|
||||
<a-form-item label="确认新密码" required>
|
||||
<a-input-password v-model:value="form.confirmPassword" autocomplete="new-password" />
|
||||
</a-form-item>
|
||||
<a-button type="primary" html-type="submit" :loading="loading">提交</a-button>
|
||||
</a-form>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { message } from "ant-design-vue";
|
||||
import { reactive, ref } from "vue";
|
||||
|
||||
import { OpsApiError, http } from "@/lib/http";
|
||||
import { useAuthStore } from "@/stores/auth";
|
||||
|
||||
const auth = useAuthStore();
|
||||
|
||||
const form = reactive({
|
||||
oldPassword: "",
|
||||
newPassword: "",
|
||||
confirmPassword: "",
|
||||
});
|
||||
|
||||
const loading = ref(false);
|
||||
|
||||
async function onSubmit() {
|
||||
if (!form.oldPassword || form.newPassword.length < 8) {
|
||||
message.warning("请输入原密码,并将新密码设为至少 8 位");
|
||||
return;
|
||||
}
|
||||
if (form.newPassword !== form.confirmPassword) {
|
||||
message.warning("两次输入的新密码不一致");
|
||||
return;
|
||||
}
|
||||
loading.value = true;
|
||||
try {
|
||||
await http.post("/auth/password", {
|
||||
old_password: form.oldPassword,
|
||||
new_password: form.newPassword,
|
||||
});
|
||||
message.success("密码已更新,请使用新密码重新登录");
|
||||
auth.logout();
|
||||
// router redirect handled by 401 interceptor or next route guard
|
||||
if (typeof window !== "undefined") window.location.href = "/login";
|
||||
} catch (error) {
|
||||
if (error instanceof OpsApiError) {
|
||||
message.error(error.detail || error.message);
|
||||
}
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user