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,12 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="zh-CN">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<title>省心推 · 运营后台</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="app"></div>
|
||||||
|
<script type="module" src="/src/main.ts"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
server_name _;
|
||||||
|
|
||||||
|
root /usr/share/nginx/html;
|
||||||
|
index index.html;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
try_files $uri $uri/ /index.html;
|
||||||
|
}
|
||||||
|
|
||||||
|
location /api {
|
||||||
|
proxy_pass http://ops-api:8090;
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
proxy_read_timeout 120s;
|
||||||
|
proxy_send_timeout 120s;
|
||||||
|
}
|
||||||
|
|
||||||
|
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff2?)$ {
|
||||||
|
expires 1y;
|
||||||
|
add_header Cache-Control "public, immutable";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
{
|
||||||
|
"name": "ops-web",
|
||||||
|
"version": "0.0.0",
|
||||||
|
"private": true,
|
||||||
|
"type": "module",
|
||||||
|
"scripts": {
|
||||||
|
"dev": "vite",
|
||||||
|
"build": "vue-tsc --noEmit && vite build",
|
||||||
|
"preview": "vite preview",
|
||||||
|
"typecheck": "vue-tsc --noEmit"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@ant-design/icons-vue": "^7.0.1",
|
||||||
|
"@tanstack/vue-query": "^5.96.0",
|
||||||
|
"@vueuse/core": "^14.2.1",
|
||||||
|
"ant-design-vue": "^4.2.6",
|
||||||
|
"axios": "^1.7.9",
|
||||||
|
"dayjs": "^1.11.20",
|
||||||
|
"pinia": "^3.0.4",
|
||||||
|
"vue": "^3.5.31",
|
||||||
|
"vue-router": "^4.5.1"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/node": "^24.0.0",
|
||||||
|
"@vitejs/plugin-vue": "^6.0.5",
|
||||||
|
"typescript": "^5.9.3",
|
||||||
|
"vite": "^7.3.2",
|
||||||
|
"vue-tsc": "^3.2.6"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<template>
|
||||||
|
<a-config-provider>
|
||||||
|
<a-app>
|
||||||
|
<router-view />
|
||||||
|
</a-app>
|
||||||
|
</a-config-provider>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { onMounted } from "vue";
|
||||||
|
|
||||||
|
import { useAuthStore } from "@/stores/auth";
|
||||||
|
|
||||||
|
const auth = useAuthStore();
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
if (!auth.initialized) auth.hydrate();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
Vendored
+7
@@ -0,0 +1,7 @@
|
|||||||
|
/// <reference types="vite/client" />
|
||||||
|
|
||||||
|
declare module "*.vue" {
|
||||||
|
import type { DefineComponent } from "vue";
|
||||||
|
const component: DefineComponent<Record<string, unknown>, Record<string, unknown>, unknown>;
|
||||||
|
export default component;
|
||||||
|
}
|
||||||
@@ -0,0 +1,168 @@
|
|||||||
|
<template>
|
||||||
|
<a-layout style="min-height: 100vh">
|
||||||
|
<a-layout-sider v-model:collapsed="collapsed" collapsible breakpoint="lg" :trigger="null">
|
||||||
|
<div class="ops-brand">
|
||||||
|
<span v-if="!collapsed">省心推 · 运营</span>
|
||||||
|
<span v-else>SXT</span>
|
||||||
|
</div>
|
||||||
|
<a-menu
|
||||||
|
theme="light"
|
||||||
|
mode="inline"
|
||||||
|
:selected-keys="selectedKeys"
|
||||||
|
:items="menuItems"
|
||||||
|
@click="onMenuClick"
|
||||||
|
/>
|
||||||
|
</a-layout-sider>
|
||||||
|
|
||||||
|
<a-layout>
|
||||||
|
<a-layout-header class="ops-header">
|
||||||
|
<a-button type="text" class="header-trigger" @click="collapsed = !collapsed">
|
||||||
|
{{ collapsed ? "›" : "‹" }}
|
||||||
|
</a-button>
|
||||||
|
<span style="flex: 1" />
|
||||||
|
<a-dropdown placement="bottomRight">
|
||||||
|
<div class="user-dropdown-btn" style="cursor: pointer;">
|
||||||
|
<div class="user-avatar">
|
||||||
|
{{ auth.operator?.display_name?.charAt(0) ?? "U" }}
|
||||||
|
</div>
|
||||||
|
<span>{{ auth.operator?.display_name ?? "未登录" }}</span>
|
||||||
|
</div>
|
||||||
|
<template #overlay>
|
||||||
|
<a-menu @click="onUserMenuClick">
|
||||||
|
<a-menu-item key="profile">个人资料</a-menu-item>
|
||||||
|
<a-menu-item key="logout">退出登录</a-menu-item>
|
||||||
|
</a-menu>
|
||||||
|
</template>
|
||||||
|
</a-dropdown>
|
||||||
|
</a-layout-header>
|
||||||
|
|
||||||
|
<a-layout-content class="ops-shell-content">
|
||||||
|
<router-view />
|
||||||
|
</a-layout-content>
|
||||||
|
</a-layout>
|
||||||
|
</a-layout>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { computed, onMounted, ref } from "vue";
|
||||||
|
import { useRoute, useRouter } from "vue-router";
|
||||||
|
|
||||||
|
import { useAuthStore } from "@/stores/auth";
|
||||||
|
|
||||||
|
interface MenuItem {
|
||||||
|
key: string;
|
||||||
|
label: string;
|
||||||
|
path: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const router = useRouter();
|
||||||
|
const route = useRoute();
|
||||||
|
const auth = useAuthStore();
|
||||||
|
|
||||||
|
const collapsed = ref(false);
|
||||||
|
|
||||||
|
const menuItems = computed<MenuItem[]>(() => [
|
||||||
|
{ key: "/accounts", label: "账号管理", path: "/accounts" },
|
||||||
|
{ key: "/audits", label: "审计日志", path: "/audits" },
|
||||||
|
]);
|
||||||
|
|
||||||
|
const selectedKeys = computed(() => [route.path]);
|
||||||
|
|
||||||
|
function onMenuClick(info: { key: string | number }) {
|
||||||
|
const item = menuItems.value.find((m) => m.key === info.key);
|
||||||
|
if (item) void router.push(item.path);
|
||||||
|
}
|
||||||
|
|
||||||
|
function onUserMenuClick(info: { key: string | number }) {
|
||||||
|
if (info.key === "logout") {
|
||||||
|
auth.logout();
|
||||||
|
void router.replace({ name: "login" });
|
||||||
|
} else if (info.key === "profile") {
|
||||||
|
void router.push({ name: "profile" });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
if (auth.isAuthenticated) {
|
||||||
|
void auth.refreshSelf();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
:deep(.ant-layout-sider) {
|
||||||
|
background: #fff !important;
|
||||||
|
border-right: 1px solid #f0f0f0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ops-brand {
|
||||||
|
height: 40px;
|
||||||
|
background: #f0f8ff;
|
||||||
|
border: 1px solid #bae0ff;
|
||||||
|
margin: 16px;
|
||||||
|
border-radius: 6px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
color: #1677ff;
|
||||||
|
font-weight: 800;
|
||||||
|
font-size: 16px;
|
||||||
|
letter-spacing: 0.05em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ops-header {
|
||||||
|
background: #fff;
|
||||||
|
padding: 0 24px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
height: 64px;
|
||||||
|
box-shadow: 0 1px 4px rgba(0, 21, 41, 0.08);
|
||||||
|
z-index: 1;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header-trigger {
|
||||||
|
font-size: 18px;
|
||||||
|
color: #8c8c8c;
|
||||||
|
width: 40px;
|
||||||
|
height: 40px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
border-radius: 8px;
|
||||||
|
transition: all 0.2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header-trigger:hover {
|
||||||
|
background-color: #f5f5f5;
|
||||||
|
color: #141414;
|
||||||
|
}
|
||||||
|
|
||||||
|
.user-dropdown-btn {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
color: #141414;
|
||||||
|
font-weight: 500;
|
||||||
|
border-radius: 6px;
|
||||||
|
padding: 4px 8px;
|
||||||
|
transition: all 0.2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.user-dropdown-btn:hover {
|
||||||
|
background-color: #f5f5f5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.user-avatar {
|
||||||
|
background-color: #1677ff;
|
||||||
|
color: #fff;
|
||||||
|
width: 28px;
|
||||||
|
height: 28px;
|
||||||
|
border-radius: 50%;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,97 @@
|
|||||||
|
import axios, { type AxiosError, type AxiosInstance } from "axios";
|
||||||
|
|
||||||
|
import { clearStoredSession, readStoredSession } from "@/lib/storage";
|
||||||
|
|
||||||
|
export class OpsApiError extends Error {
|
||||||
|
status?: number;
|
||||||
|
code: number;
|
||||||
|
detail?: string;
|
||||||
|
requestId?: string;
|
||||||
|
|
||||||
|
constructor(input: {
|
||||||
|
message: string;
|
||||||
|
code?: number;
|
||||||
|
status?: number;
|
||||||
|
detail?: string;
|
||||||
|
requestId?: string;
|
||||||
|
}) {
|
||||||
|
super(input.message);
|
||||||
|
this.name = "OpsApiError";
|
||||||
|
this.code = input.code ?? 50000;
|
||||||
|
this.status = input.status;
|
||||||
|
this.detail = input.detail;
|
||||||
|
this.requestId = input.requestId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ApiEnvelope<T> {
|
||||||
|
code: number;
|
||||||
|
message: string;
|
||||||
|
detail?: string;
|
||||||
|
data: T;
|
||||||
|
request_id?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
let onUnauthorized: (() => void) | null = null;
|
||||||
|
|
||||||
|
export function bindUnauthorizedHandler(handler: () => void): void {
|
||||||
|
onUnauthorized = handler;
|
||||||
|
}
|
||||||
|
|
||||||
|
const client: AxiosInstance = axios.create({
|
||||||
|
baseURL: "/api/ops",
|
||||||
|
timeout: 30000,
|
||||||
|
});
|
||||||
|
|
||||||
|
client.interceptors.request.use((config) => {
|
||||||
|
const session = readStoredSession();
|
||||||
|
if (session.accessToken) {
|
||||||
|
config.headers = config.headers ?? {};
|
||||||
|
config.headers["Authorization"] = `Bearer ${session.accessToken}`;
|
||||||
|
}
|
||||||
|
return config;
|
||||||
|
});
|
||||||
|
|
||||||
|
client.interceptors.response.use(
|
||||||
|
(response) => response,
|
||||||
|
(error: AxiosError<ApiEnvelope<unknown>>) => {
|
||||||
|
const status = error.response?.status;
|
||||||
|
const payload = error.response?.data;
|
||||||
|
|
||||||
|
if (status === 401) {
|
||||||
|
clearStoredSession();
|
||||||
|
onUnauthorized?.();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Promise.reject(
|
||||||
|
new OpsApiError({
|
||||||
|
message: payload?.message ?? error.message ?? "request_failed",
|
||||||
|
code: typeof payload?.code === "number" ? payload.code : undefined,
|
||||||
|
status,
|
||||||
|
detail: typeof payload?.detail === "string" ? payload.detail : undefined,
|
||||||
|
requestId: typeof payload?.request_id === "string" ? payload.request_id : undefined,
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
async function unwrap<T>(promise: Promise<{ data: ApiEnvelope<T> }>): Promise<T> {
|
||||||
|
const { data } = await promise;
|
||||||
|
if (data.code !== 0) {
|
||||||
|
throw new OpsApiError({
|
||||||
|
message: data.message,
|
||||||
|
code: data.code,
|
||||||
|
detail: data.detail,
|
||||||
|
requestId: data.request_id,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return data.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const http = {
|
||||||
|
get: <T>(url: string, params?: Record<string, unknown>) =>
|
||||||
|
unwrap<T>(client.get(url, { params })),
|
||||||
|
post: <T, B = unknown>(url: string, body?: B) => unwrap<T>(client.post(url, body)),
|
||||||
|
patch: <T, B = unknown>(url: string, body?: B) => unwrap<T>(client.patch(url, body)),
|
||||||
|
delete: <T>(url: string) => unwrap<T>(client.delete(url)),
|
||||||
|
};
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
const STORAGE_KEY = "geo.ops-web.session";
|
||||||
|
|
||||||
|
export interface OperatorView {
|
||||||
|
id: number;
|
||||||
|
username: string;
|
||||||
|
display_name: string;
|
||||||
|
email: string | null;
|
||||||
|
role: string;
|
||||||
|
status: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface OpsSession {
|
||||||
|
accessToken: string | null;
|
||||||
|
expiresAt: number | null;
|
||||||
|
operator: OperatorView | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function emptySession(): OpsSession {
|
||||||
|
return { accessToken: null, expiresAt: null, operator: null };
|
||||||
|
}
|
||||||
|
|
||||||
|
function hasStorage(): boolean {
|
||||||
|
return typeof window !== "undefined" && "localStorage" in window;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function readStoredSession(): OpsSession {
|
||||||
|
if (!hasStorage()) return emptySession();
|
||||||
|
try {
|
||||||
|
const raw = window.localStorage.getItem(STORAGE_KEY);
|
||||||
|
if (!raw) return emptySession();
|
||||||
|
const parsed = JSON.parse(raw) as Partial<OpsSession>;
|
||||||
|
return {
|
||||||
|
accessToken: typeof parsed.accessToken === "string" ? parsed.accessToken : null,
|
||||||
|
expiresAt: typeof parsed.expiresAt === "number" ? parsed.expiresAt : null,
|
||||||
|
operator:
|
||||||
|
parsed.operator && typeof parsed.operator === "object"
|
||||||
|
? (parsed.operator as OperatorView)
|
||||||
|
: null,
|
||||||
|
};
|
||||||
|
} catch {
|
||||||
|
return emptySession();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function writeStoredSession(session: OpsSession): void {
|
||||||
|
if (!hasStorage()) return;
|
||||||
|
try {
|
||||||
|
window.localStorage.setItem(STORAGE_KEY, JSON.stringify(session));
|
||||||
|
} catch {
|
||||||
|
// ignore quota / serialization errors
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function clearStoredSession(): void {
|
||||||
|
if (!hasStorage()) return;
|
||||||
|
try {
|
||||||
|
window.localStorage.removeItem(STORAGE_KEY);
|
||||||
|
} catch {
|
||||||
|
// noop
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,86 @@
|
|||||||
|
import { QueryClient, VueQueryPlugin } from "@tanstack/vue-query";
|
||||||
|
import {
|
||||||
|
App as AntApp,
|
||||||
|
Avatar,
|
||||||
|
Badge,
|
||||||
|
Button,
|
||||||
|
Card,
|
||||||
|
ConfigProvider,
|
||||||
|
DatePicker,
|
||||||
|
Descriptions,
|
||||||
|
Drawer,
|
||||||
|
Dropdown,
|
||||||
|
Empty,
|
||||||
|
Form,
|
||||||
|
Input,
|
||||||
|
Layout,
|
||||||
|
Menu,
|
||||||
|
Modal,
|
||||||
|
Pagination,
|
||||||
|
Popconfirm,
|
||||||
|
Result,
|
||||||
|
Select,
|
||||||
|
Space,
|
||||||
|
Spin,
|
||||||
|
Table,
|
||||||
|
Tag,
|
||||||
|
Tooltip,
|
||||||
|
message,
|
||||||
|
} from "ant-design-vue";
|
||||||
|
import { createApp } from "vue";
|
||||||
|
|
||||||
|
import App from "./App.vue";
|
||||||
|
import { bindUnauthorizedHandler } from "@/lib/http";
|
||||||
|
import { router } from "@/router";
|
||||||
|
import { pinia } from "@/stores/pinia";
|
||||||
|
import "./styles.css";
|
||||||
|
import "ant-design-vue/dist/reset.css";
|
||||||
|
|
||||||
|
const queryClient = new QueryClient({
|
||||||
|
defaultOptions: {
|
||||||
|
queries: {
|
||||||
|
staleTime: 30000,
|
||||||
|
refetchOnWindowFocus: false,
|
||||||
|
retry: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const app = createApp(App);
|
||||||
|
|
||||||
|
bindUnauthorizedHandler(() => {
|
||||||
|
void router.replace({ name: "login" });
|
||||||
|
message.warning("登录已过期,请重新登录");
|
||||||
|
});
|
||||||
|
|
||||||
|
[
|
||||||
|
AntApp,
|
||||||
|
Avatar,
|
||||||
|
Badge,
|
||||||
|
Button,
|
||||||
|
Card,
|
||||||
|
ConfigProvider,
|
||||||
|
DatePicker,
|
||||||
|
Descriptions,
|
||||||
|
Drawer,
|
||||||
|
Dropdown,
|
||||||
|
Empty,
|
||||||
|
Form,
|
||||||
|
Input,
|
||||||
|
Layout,
|
||||||
|
Menu,
|
||||||
|
Modal,
|
||||||
|
Pagination,
|
||||||
|
Popconfirm,
|
||||||
|
Result,
|
||||||
|
Select,
|
||||||
|
Space,
|
||||||
|
Spin,
|
||||||
|
Table,
|
||||||
|
Tag,
|
||||||
|
Tooltip,
|
||||||
|
].forEach((component) => {
|
||||||
|
app.use(component);
|
||||||
|
});
|
||||||
|
|
||||||
|
app.use(pinia).use(router).use(VueQueryPlugin, { queryClient }).mount("#app");
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
import { createRouter, createWebHistory } from "vue-router";
|
||||||
|
|
||||||
|
import { pinia } from "@/stores/pinia";
|
||||||
|
import { useAuthStore } from "@/stores/auth";
|
||||||
|
|
||||||
|
export const router = createRouter({
|
||||||
|
history: createWebHistory(),
|
||||||
|
routes: [
|
||||||
|
{
|
||||||
|
path: "/login",
|
||||||
|
name: "login",
|
||||||
|
component: () => import("@/views/LoginView.vue"),
|
||||||
|
meta: { title: "登录" },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "/",
|
||||||
|
component: () => import("@/layouts/AppShell.vue"),
|
||||||
|
meta: { requiresAuth: true },
|
||||||
|
children: [
|
||||||
|
{ path: "", redirect: "/accounts" },
|
||||||
|
{
|
||||||
|
path: "accounts",
|
||||||
|
name: "accounts",
|
||||||
|
component: () => import("@/views/AccountsView.vue"),
|
||||||
|
meta: { title: "账号管理" },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "audits",
|
||||||
|
name: "audits",
|
||||||
|
component: () => import("@/views/AuditLogsView.vue"),
|
||||||
|
meta: { title: "审计日志" },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "profile",
|
||||||
|
name: "profile",
|
||||||
|
component: () => import("@/views/ProfileView.vue"),
|
||||||
|
meta: { title: "个人资料" },
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "/:pathMatch(.*)*",
|
||||||
|
redirect: "/",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
router.beforeEach((to) => {
|
||||||
|
const auth = useAuthStore(pinia);
|
||||||
|
if (!auth.initialized) {
|
||||||
|
auth.hydrate();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (to.meta.requiresAuth && !auth.isAuthenticated) {
|
||||||
|
return {
|
||||||
|
name: "login",
|
||||||
|
query: to.fullPath !== "/" ? { redirect: to.fullPath } : undefined,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (to.name === "login" && auth.isAuthenticated) {
|
||||||
|
return { name: "accounts" };
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
|
router.afterEach((to) => {
|
||||||
|
if (typeof document !== "undefined") {
|
||||||
|
const t = (to.meta.title as string | undefined) ?? "运营后台";
|
||||||
|
document.title = `${t} · 省心推`;
|
||||||
|
}
|
||||||
|
});
|
||||||
@@ -0,0 +1,86 @@
|
|||||||
|
import { defineStore } from "pinia";
|
||||||
|
import { computed, ref } from "vue";
|
||||||
|
|
||||||
|
import { http } from "@/lib/http";
|
||||||
|
import {
|
||||||
|
type OperatorView,
|
||||||
|
clearStoredSession,
|
||||||
|
readStoredSession,
|
||||||
|
writeStoredSession,
|
||||||
|
} from "@/lib/storage";
|
||||||
|
|
||||||
|
interface LoginResponse {
|
||||||
|
access_token: string;
|
||||||
|
expires_at: number;
|
||||||
|
operator: OperatorView;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const useAuthStore = defineStore("ops-auth", () => {
|
||||||
|
const accessToken = ref<string | null>(null);
|
||||||
|
const expiresAt = ref<number | null>(null);
|
||||||
|
const operator = ref<OperatorView | null>(null);
|
||||||
|
const initialized = ref(false);
|
||||||
|
|
||||||
|
function hydrate(): void {
|
||||||
|
const stored = readStoredSession();
|
||||||
|
accessToken.value = stored.accessToken;
|
||||||
|
expiresAt.value = stored.expiresAt;
|
||||||
|
operator.value = stored.operator;
|
||||||
|
initialized.value = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function login(username: string, password: string): Promise<void> {
|
||||||
|
const result = await http.post<LoginResponse>("/auth/login", { username, password });
|
||||||
|
accessToken.value = result.access_token;
|
||||||
|
expiresAt.value = result.expires_at;
|
||||||
|
operator.value = result.operator;
|
||||||
|
writeStoredSession({
|
||||||
|
accessToken: result.access_token,
|
||||||
|
expiresAt: result.expires_at,
|
||||||
|
operator: result.operator,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async function refreshSelf(): Promise<void> {
|
||||||
|
if (!accessToken.value) return;
|
||||||
|
try {
|
||||||
|
const me = await http.get<OperatorView & { last_login_at: string | null }>("/auth/me");
|
||||||
|
operator.value = {
|
||||||
|
id: me.id,
|
||||||
|
username: me.username,
|
||||||
|
display_name: me.display_name,
|
||||||
|
email: me.email,
|
||||||
|
role: me.role,
|
||||||
|
status: me.status,
|
||||||
|
};
|
||||||
|
writeStoredSession({
|
||||||
|
accessToken: accessToken.value,
|
||||||
|
expiresAt: expiresAt.value,
|
||||||
|
operator: operator.value,
|
||||||
|
});
|
||||||
|
} catch {
|
||||||
|
logout();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function logout(): void {
|
||||||
|
accessToken.value = null;
|
||||||
|
expiresAt.value = null;
|
||||||
|
operator.value = null;
|
||||||
|
clearStoredSession();
|
||||||
|
}
|
||||||
|
|
||||||
|
const isAuthenticated = computed(() => !!accessToken.value);
|
||||||
|
|
||||||
|
return {
|
||||||
|
accessToken,
|
||||||
|
expiresAt,
|
||||||
|
operator,
|
||||||
|
initialized,
|
||||||
|
isAuthenticated,
|
||||||
|
hydrate,
|
||||||
|
login,
|
||||||
|
refreshSelf,
|
||||||
|
logout,
|
||||||
|
};
|
||||||
|
});
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
import { createPinia } from "pinia";
|
||||||
|
|
||||||
|
export const pinia = createPinia();
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
html,
|
||||||
|
body,
|
||||||
|
#app {
|
||||||
|
height: 100%;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
|
||||||
|
"Hiragino Sans GB", "Microsoft YaHei", sans-serif;
|
||||||
|
background-color: #f8fafc; /* Lighter, cooler gray */
|
||||||
|
color: #334155;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ops-shell-content {
|
||||||
|
padding: 24px 32px;
|
||||||
|
max-width: 1400px;
|
||||||
|
margin: 0 auto;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ops-page-title {
|
||||||
|
font-size: 24px;
|
||||||
|
font-weight: 700;
|
||||||
|
color: #0f172a;
|
||||||
|
margin: 0 0 24px;
|
||||||
|
letter-spacing: -0.5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ops-card {
|
||||||
|
background: #ffffff;
|
||||||
|
border-radius: 12px;
|
||||||
|
box-shadow: 0 1px 3px 0 rgba(15, 23, 42, 0.08), 0 1px 2px -1px rgba(15, 23, 42, 0.04);
|
||||||
|
padding: 24px;
|
||||||
|
border: 1px solid #f1f5f9;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ops-toolbar {
|
||||||
|
display: flex;
|
||||||
|
gap: 16px;
|
||||||
|
align-items: center;
|
||||||
|
margin-bottom: 24px;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Make Ant Table headers slightly more modern inside card */
|
||||||
|
.ops-card .ant-table-thead > tr > th {
|
||||||
|
background: #f8fafc;
|
||||||
|
color: #64748b;
|
||||||
|
font-weight: 600;
|
||||||
|
border-bottom: 1px solid #e2e8f0;
|
||||||
|
}
|
||||||
@@ -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>
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"extends": "../../packages/tsconfig/base.json",
|
||||||
|
"compilerOptions": {
|
||||||
|
"types": ["vite/client"],
|
||||||
|
"baseUrl": ".",
|
||||||
|
"paths": {
|
||||||
|
"@/*": ["src/*"]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"include": [
|
||||||
|
"src/**/*.ts",
|
||||||
|
"src/**/*.d.ts",
|
||||||
|
"src/**/*.vue",
|
||||||
|
"vite.config.ts"
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
import { fileURLToPath, URL } from "node:url";
|
||||||
|
|
||||||
|
import vue from "@vitejs/plugin-vue";
|
||||||
|
import { defineConfig, loadEnv } from "vite";
|
||||||
|
|
||||||
|
const r = (path: string) => fileURLToPath(new URL(path, import.meta.url));
|
||||||
|
|
||||||
|
export default defineConfig(({ mode }) => {
|
||||||
|
const env = loadEnv(mode, ".", "");
|
||||||
|
const isProd = mode === "production";
|
||||||
|
|
||||||
|
return {
|
||||||
|
plugins: [vue()],
|
||||||
|
resolve: {
|
||||||
|
alias: {
|
||||||
|
"@": r("./src"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
server: {
|
||||||
|
host: "0.0.0.0",
|
||||||
|
port: 5174,
|
||||||
|
proxy: {
|
||||||
|
"/api": {
|
||||||
|
target: env.VITE_OPS_API_PROXY_TARGET || "http://localhost:8090",
|
||||||
|
changeOrigin: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
esbuild: isProd ? { drop: ["console", "debugger"] } : undefined,
|
||||||
|
build: {
|
||||||
|
target: "es2022",
|
||||||
|
sourcemap: "hidden",
|
||||||
|
cssCodeSplit: true,
|
||||||
|
reportCompressedSize: false,
|
||||||
|
rollupOptions: {
|
||||||
|
output: {
|
||||||
|
entryFileNames: "assets/js/[name]-[hash].js",
|
||||||
|
chunkFileNames: "assets/js/[name]-[hash].js",
|
||||||
|
assetFileNames: "assets/[name]-[hash][extname]",
|
||||||
|
manualChunks(id) {
|
||||||
|
if (!id.includes("node_modules")) return undefined;
|
||||||
|
if (id.includes("/ant-design-vue/") || id.includes("/@ant-design/")) {
|
||||||
|
return "antd";
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
id.includes("/vue/") ||
|
||||||
|
id.includes("/@vue/") ||
|
||||||
|
id.includes("/vue-router/") ||
|
||||||
|
id.includes("/pinia/")
|
||||||
|
) {
|
||||||
|
return "vue-vendor";
|
||||||
|
}
|
||||||
|
return "vendor";
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
});
|
||||||
Generated
+53
-7
@@ -212,6 +212,52 @@ importers:
|
|||||||
specifier: ^3.2.6
|
specifier: ^3.2.6
|
||||||
version: 3.2.6(typescript@5.9.3)
|
version: 3.2.6(typescript@5.9.3)
|
||||||
|
|
||||||
|
apps/ops-web:
|
||||||
|
dependencies:
|
||||||
|
'@ant-design/icons-vue':
|
||||||
|
specifier: ^7.0.1
|
||||||
|
version: 7.0.1(vue@3.5.31(typescript@5.9.3))
|
||||||
|
'@tanstack/vue-query':
|
||||||
|
specifier: ^5.96.0
|
||||||
|
version: 5.96.0(vue@3.5.31(typescript@5.9.3))
|
||||||
|
'@vueuse/core':
|
||||||
|
specifier: ^14.2.1
|
||||||
|
version: 14.2.1(vue@3.5.31(typescript@5.9.3))
|
||||||
|
ant-design-vue:
|
||||||
|
specifier: ^4.2.6
|
||||||
|
version: 4.2.6(vue@3.5.31(typescript@5.9.3))
|
||||||
|
axios:
|
||||||
|
specifier: ^1.7.9
|
||||||
|
version: 1.14.0
|
||||||
|
dayjs:
|
||||||
|
specifier: ^1.11.20
|
||||||
|
version: 1.11.20
|
||||||
|
pinia:
|
||||||
|
specifier: ^3.0.4
|
||||||
|
version: 3.0.4(typescript@5.9.3)(vue@3.5.31(typescript@5.9.3))
|
||||||
|
vue:
|
||||||
|
specifier: ^3.5.31
|
||||||
|
version: 3.5.31(typescript@5.9.3)
|
||||||
|
vue-router:
|
||||||
|
specifier: ^4.5.1
|
||||||
|
version: 4.6.4(vue@3.5.31(typescript@5.9.3))
|
||||||
|
devDependencies:
|
||||||
|
'@types/node':
|
||||||
|
specifier: ^24.0.0
|
||||||
|
version: 24.12.0
|
||||||
|
'@vitejs/plugin-vue':
|
||||||
|
specifier: ^6.0.5
|
||||||
|
version: 6.0.6(vite@7.3.2(@types/node@24.12.0)(jiti@2.6.1)(lightningcss@1.32.0))(vue@3.5.31(typescript@5.9.3))
|
||||||
|
typescript:
|
||||||
|
specifier: ^5.9.3
|
||||||
|
version: 5.9.3
|
||||||
|
vite:
|
||||||
|
specifier: ^7.3.2
|
||||||
|
version: 7.3.2(@types/node@24.12.0)(jiti@2.6.1)(lightningcss@1.32.0)
|
||||||
|
vue-tsc:
|
||||||
|
specifier: ^3.2.6
|
||||||
|
version: 3.2.6(typescript@5.9.3)
|
||||||
|
|
||||||
packages/http-client:
|
packages/http-client:
|
||||||
dependencies:
|
dependencies:
|
||||||
'@geo/shared-types':
|
'@geo/shared-types':
|
||||||
@@ -6051,18 +6097,18 @@ snapshots:
|
|||||||
vite: 7.3.2(@types/node@24.12.0)(jiti@2.6.1)(lightningcss@1.32.0)
|
vite: 7.3.2(@types/node@24.12.0)(jiti@2.6.1)(lightningcss@1.32.0)
|
||||||
vue: 3.5.31(typescript@5.9.3)
|
vue: 3.5.31(typescript@5.9.3)
|
||||||
|
|
||||||
'@vitejs/plugin-vue@6.0.5(vite@8.0.3(@emnapi/core@1.9.1)(@emnapi/runtime@1.9.1)(@types/node@24.12.0)(esbuild@0.27.5)(jiti@2.6.1))(vue@3.5.31(typescript@5.9.3))':
|
|
||||||
dependencies:
|
|
||||||
'@rolldown/pluginutils': 1.0.0-rc.2
|
|
||||||
vite: 8.0.3(@emnapi/core@1.9.1)(@emnapi/runtime@1.9.1)(@types/node@24.12.0)(esbuild@0.27.5)(jiti@2.6.1)
|
|
||||||
vue: 3.5.31(typescript@5.9.3)
|
|
||||||
|
|
||||||
'@vitejs/plugin-vue@6.0.6(vite@7.3.2(@types/node@24.12.0)(jiti@2.6.1)(lightningcss@1.32.0))(vue@3.5.31(typescript@5.9.3))':
|
'@vitejs/plugin-vue@6.0.6(vite@7.3.2(@types/node@24.12.0)(jiti@2.6.1)(lightningcss@1.32.0))(vue@3.5.31(typescript@5.9.3))':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@rolldown/pluginutils': 1.0.0-rc.13
|
'@rolldown/pluginutils': 1.0.0-rc.13
|
||||||
vite: 7.3.2(@types/node@24.12.0)(jiti@2.6.1)(lightningcss@1.32.0)
|
vite: 7.3.2(@types/node@24.12.0)(jiti@2.6.1)(lightningcss@1.32.0)
|
||||||
vue: 3.5.31(typescript@5.9.3)
|
vue: 3.5.31(typescript@5.9.3)
|
||||||
|
|
||||||
|
'@vitejs/plugin-vue@6.0.6(vite@8.0.3(@emnapi/core@1.9.1)(@emnapi/runtime@1.9.1)(@types/node@24.12.0)(esbuild@0.27.5)(jiti@2.6.1))(vue@3.5.31(typescript@5.9.3))':
|
||||||
|
dependencies:
|
||||||
|
'@rolldown/pluginutils': 1.0.0-rc.13
|
||||||
|
vite: 8.0.3(@emnapi/core@1.9.1)(@emnapi/runtime@1.9.1)(@types/node@24.12.0)(esbuild@0.27.5)(jiti@2.6.1)
|
||||||
|
vue: 3.5.31(typescript@5.9.3)
|
||||||
|
|
||||||
'@vitest/expect@4.1.5':
|
'@vitest/expect@4.1.5':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@standard-schema/spec': 1.1.0
|
'@standard-schema/spec': 1.1.0
|
||||||
@@ -6230,7 +6276,7 @@ snapshots:
|
|||||||
|
|
||||||
'@wxt-dev/module-vue@1.0.3(vite@8.0.3(@emnapi/core@1.9.1)(@emnapi/runtime@1.9.1)(@types/node@24.12.0)(esbuild@0.27.5)(jiti@2.6.1))(vue@3.5.31(typescript@5.9.3))(wxt@0.20.20(@emnapi/core@1.9.1)(@emnapi/runtime@1.9.1)(@types/node@24.12.0)(jiti@2.6.1)(lightningcss@1.32.0)(rollup@4.60.2))':
|
'@wxt-dev/module-vue@1.0.3(vite@8.0.3(@emnapi/core@1.9.1)(@emnapi/runtime@1.9.1)(@types/node@24.12.0)(esbuild@0.27.5)(jiti@2.6.1))(vue@3.5.31(typescript@5.9.3))(wxt@0.20.20(@emnapi/core@1.9.1)(@emnapi/runtime@1.9.1)(@types/node@24.12.0)(jiti@2.6.1)(lightningcss@1.32.0)(rollup@4.60.2))':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@vitejs/plugin-vue': 6.0.5(vite@8.0.3(@emnapi/core@1.9.1)(@emnapi/runtime@1.9.1)(@types/node@24.12.0)(esbuild@0.27.5)(jiti@2.6.1))(vue@3.5.31(typescript@5.9.3))
|
'@vitejs/plugin-vue': 6.0.6(vite@8.0.3(@emnapi/core@1.9.1)(@emnapi/runtime@1.9.1)(@types/node@24.12.0)(esbuild@0.27.5)(jiti@2.6.1))(vue@3.5.31(typescript@5.9.3))
|
||||||
wxt: 0.20.20(@emnapi/core@1.9.1)(@emnapi/runtime@1.9.1)(@types/node@24.12.0)(jiti@2.6.1)(lightningcss@1.32.0)(rollup@4.60.2)
|
wxt: 0.20.20(@emnapi/core@1.9.1)(@emnapi/runtime@1.9.1)(@types/node@24.12.0)(jiti@2.6.1)(lightningcss@1.32.0)(rollup@4.60.2)
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- vite
|
- vite
|
||||||
|
|||||||
Reference in New Issue
Block a user