新增:管理后台前端页面,以及openspec内容。
This commit is contained in:
24
admin-web/.gitignore
vendored
Normal file
24
admin-web/.gitignore
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
pnpm-debug.log*
|
||||
lerna-debug.log*
|
||||
|
||||
node_modules
|
||||
dist
|
||||
dist-ssr
|
||||
*.local
|
||||
|
||||
# Editor directories and files
|
||||
.vscode/*
|
||||
!.vscode/extensions.json
|
||||
.idea
|
||||
.DS_Store
|
||||
*.suo
|
||||
*.ntvs*
|
||||
*.njsproj
|
||||
*.sln
|
||||
*.sw?
|
||||
3
admin-web/.vscode/extensions.json
vendored
Normal file
3
admin-web/.vscode/extensions.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"recommendations": ["Vue.volar"]
|
||||
}
|
||||
5
admin-web/README.md
Normal file
5
admin-web/README.md
Normal file
@@ -0,0 +1,5 @@
|
||||
# Vue 3 + Vite
|
||||
|
||||
This template should help get you started developing with Vue 3 in Vite. The template uses Vue 3 `<script setup>` SFCs, check out the [script setup docs](https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup) to learn more.
|
||||
|
||||
Learn more about IDE Support for Vue in the [Vue Docs Scaling up Guide](https://vuejs.org/guide/scaling-up/tooling.html#ide-support).
|
||||
13
admin-web/index.html
Normal file
13
admin-web/index.html
Normal file
@@ -0,0 +1,13 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>admin-web</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script type="module" src="/src/main.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
2468
admin-web/package-lock.json
generated
Normal file
2468
admin-web/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
23
admin-web/package.json
Normal file
23
admin-web/package.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"name": "admin-web",
|
||||
"private": true,
|
||||
"version": "0.0.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "vite build",
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"axios": "^1.13.2",
|
||||
"element-plus": "^2.13.0",
|
||||
"pinia": "^3.0.4",
|
||||
"vue": "^3.5.24",
|
||||
"vue-router": "^4.6.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vitejs/plugin-vue": "^6.0.1",
|
||||
"sass": "^1.97.1",
|
||||
"vite": "^7.2.4"
|
||||
}
|
||||
}
|
||||
1
admin-web/public/vite.svg
Normal file
1
admin-web/public/vite.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
|
||||
|
After Width: | Height: | Size: 1.5 KiB |
18
admin-web/src/App.vue
Normal file
18
admin-web/src/App.vue
Normal file
@@ -0,0 +1,18 @@
|
||||
<template>
|
||||
<router-view />
|
||||
</template>
|
||||
|
||||
<style>
|
||||
/* 全局样式重置 */
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
html, body {
|
||||
height: 100%;
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
||||
}
|
||||
</style>
|
||||
|
||||
1
admin-web/src/assets/vue.svg
Normal file
1
admin-web/src/assets/vue.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="37.07" height="36" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 198"><path fill="#41B883" d="M204.8 0H256L128 220.8L0 0h97.92L128 51.2L157.44 0h47.36Z"></path><path fill="#41B883" d="m0 0l128 220.8L256 0h-51.2L128 132.48L50.56 0H0Z"></path><path fill="#35495E" d="M50.56 0L128 133.12L204.8 0h-47.36L128 51.2L97.92 0H50.56Z"></path></svg>
|
||||
|
After Width: | Height: | Size: 496 B |
43
admin-web/src/components/HelloWorld.vue
Normal file
43
admin-web/src/components/HelloWorld.vue
Normal file
@@ -0,0 +1,43 @@
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
|
||||
defineProps({
|
||||
msg: String,
|
||||
})
|
||||
|
||||
const count = ref(0)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<h1>{{ msg }}</h1>
|
||||
|
||||
<div class="card">
|
||||
<button type="button" @click="count++">count is {{ count }}</button>
|
||||
<p>
|
||||
Edit
|
||||
<code>components/HelloWorld.vue</code> to test HMR
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
Check out
|
||||
<a href="https://vuejs.org/guide/quick-start.html#local" target="_blank"
|
||||
>create-vue</a
|
||||
>, the official Vue + Vite starter
|
||||
</p>
|
||||
<p>
|
||||
Learn more about IDE Support for Vue in the
|
||||
<a
|
||||
href="https://vuejs.org/guide/scaling-up/tooling.html#ide-support"
|
||||
target="_blank"
|
||||
>Vue Docs Scaling up Guide</a
|
||||
>.
|
||||
</p>
|
||||
<p class="read-the-docs">Click on the Vite and Vue logos to learn more</p>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.read-the-docs {
|
||||
color: #888;
|
||||
}
|
||||
</style>
|
||||
156
admin-web/src/components/Layout/Header.vue
Normal file
156
admin-web/src/components/Layout/Header.vue
Normal file
@@ -0,0 +1,156 @@
|
||||
<template>
|
||||
<header class="header">
|
||||
<div class="header-left">
|
||||
<el-button
|
||||
v-if="isMobile"
|
||||
type="text"
|
||||
:icon="Menu"
|
||||
@click="toggleSidebar"
|
||||
></el-button>
|
||||
<div class="logo">
|
||||
<h1>后台管理</h1>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="header-right">
|
||||
<div class="header-actions">
|
||||
<!-- 主题切换组件 -->
|
||||
<!-- <ThemeSwitcher /> -->
|
||||
|
||||
<!-- 用户信息下拉菜单 -->
|
||||
<el-dropdown trigger="click">
|
||||
<span class="user-info">
|
||||
<el-avatar :size="32">
|
||||
{{ username.charAt(0).toUpperCase() }}
|
||||
</el-avatar>
|
||||
<span class="username">{{ username }}</span>
|
||||
<el-icon class="el-icon--right"><ArrowDown /></el-icon>
|
||||
</span>
|
||||
<template #dropdown>
|
||||
<el-dropdown-menu>
|
||||
<el-dropdown-item divided @click="handleLogout">
|
||||
<el-icon><SwitchButton /></el-icon>
|
||||
<span>退出登录</span>
|
||||
</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
</el-dropdown>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, computed, onMounted, onUnmounted } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { Menu, ArrowDown, SwitchButton } from '@element-plus/icons-vue'
|
||||
import { useAuthStore } from '../../store/auth'
|
||||
import ThemeSwitcher from '../ThemeSwitcher.vue'
|
||||
|
||||
// 路由实例
|
||||
const router = useRouter()
|
||||
|
||||
// 认证状态管理
|
||||
const authStore = useAuthStore()
|
||||
|
||||
// 用户名
|
||||
const username = computed(() => authStore.username)
|
||||
|
||||
// 侧边栏显示状态(手机端)
|
||||
const isSidebarOpen = ref(false)
|
||||
|
||||
// 响应式布局:判断是否为手机端
|
||||
const isMobile = ref(false)
|
||||
|
||||
// 监听窗口大小变化
|
||||
const handleResize = () => {
|
||||
isMobile.value = window.innerWidth < 768
|
||||
}
|
||||
|
||||
// 初始化响应式状态
|
||||
onMounted(() => {
|
||||
handleResize()
|
||||
window.addEventListener('resize', handleResize)
|
||||
})
|
||||
|
||||
// 清理事件监听
|
||||
onUnmounted(() => {
|
||||
window.removeEventListener('resize', handleResize)
|
||||
})
|
||||
|
||||
// 切换侧边栏显示(手机端)
|
||||
const toggleSidebar = () => {
|
||||
isSidebarOpen.value = !isSidebarOpen.value
|
||||
// 发送事件给父组件
|
||||
emit('toggleSidebar', isSidebarOpen.value)
|
||||
}
|
||||
|
||||
// 登出处理
|
||||
const handleLogout = () => {
|
||||
authStore.logout()
|
||||
router.push('/login')
|
||||
}
|
||||
|
||||
// 定义事件
|
||||
const emit = defineEmits(['toggleSidebar'])
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
height: 64px;
|
||||
padding: 0 24px;
|
||||
background-color: var(--background-color);
|
||||
border-bottom: 1px solid var(--border-color);
|
||||
box-shadow: var(--box-shadow);
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
z-index: 100;
|
||||
transition: all 0.3s;
|
||||
}
|
||||
|
||||
.logo {
|
||||
h1 {
|
||||
font-size: 20px;
|
||||
margin: 0;
|
||||
color: var(--text-color);
|
||||
}
|
||||
}
|
||||
|
||||
.header-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.user-info {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
cursor: pointer;
|
||||
color: var(--text-color);
|
||||
|
||||
.username {
|
||||
font-size: 14px;
|
||||
}
|
||||
}
|
||||
|
||||
/* 响应式样式 */
|
||||
@media (max-width: 767px) {
|
||||
.header {
|
||||
padding: 0 6px;
|
||||
}
|
||||
|
||||
.logo h1 {
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.username {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
94
admin-web/src/components/Layout/Layout.vue
Normal file
94
admin-web/src/components/Layout/Layout.vue
Normal file
@@ -0,0 +1,94 @@
|
||||
<template>
|
||||
<div class="layout-container">
|
||||
<!-- 顶部导航栏 -->
|
||||
<Header @toggle-sidebar="handleToggleSidebar" />
|
||||
|
||||
<!-- 侧边栏 -->
|
||||
<Sidebar
|
||||
:is-open="isSidebarOpen"
|
||||
@close-sidebar="handleCloseSidebar"
|
||||
/>
|
||||
|
||||
<!-- 主内容区域 -->
|
||||
<main class="main-content" :class="{ 'main-content--open': isSidebarOpen }">
|
||||
<div class="content-wrapper">
|
||||
<router-view />
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
import Header from './Header.vue'
|
||||
import Sidebar from './Sidebar.vue'
|
||||
|
||||
// 侧边栏显示状态(手机端)
|
||||
const isSidebarOpen = ref(false)
|
||||
|
||||
// 处理侧边栏切换事件(来自Header组件)
|
||||
const handleToggleSidebar = (isOpen) => {
|
||||
isSidebarOpen.value = isOpen
|
||||
}
|
||||
|
||||
// 处理侧边栏关闭事件(来自Sidebar组件)
|
||||
const handleCloseSidebar = () => {
|
||||
isSidebarOpen.value = false
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.layout-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100vh;
|
||||
background-color: var(--background-color);
|
||||
}
|
||||
|
||||
.main-content {
|
||||
flex: 1;
|
||||
margin-top: 64px;
|
||||
margin-left: 250px;
|
||||
padding: 24px;
|
||||
overflow-y: auto;
|
||||
transition: all 0.3s ease;
|
||||
|
||||
/* 响应式布局 */
|
||||
@media (max-width: 1023px) {
|
||||
margin-left: 200px;
|
||||
}
|
||||
|
||||
@media (max-width: 767px) {
|
||||
margin-left: 0;
|
||||
padding: 6px;
|
||||
}
|
||||
}
|
||||
|
||||
/* 手机端侧边栏打开时,主内容区域添加左侧边距 */
|
||||
.main-content--open {
|
||||
@media (max-width: 767px) {
|
||||
margin-left: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.content-wrapper {
|
||||
max-width: 1200px;
|
||||
margin: 0 auto;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
/* 平板端调整 */
|
||||
@media (min-width: 768px) and (max-width: 1023px) {
|
||||
.main-content {
|
||||
margin-left: 200px;
|
||||
}
|
||||
}
|
||||
|
||||
/* 手机端调整 */
|
||||
@media (max-width: 767px) {
|
||||
.main-content {
|
||||
margin-left: 0;
|
||||
padding: 6px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
192
admin-web/src/components/Layout/Sidebar.vue
Normal file
192
admin-web/src/components/Layout/Sidebar.vue
Normal file
@@ -0,0 +1,192 @@
|
||||
<template>
|
||||
<aside
|
||||
class="sidebar"
|
||||
:class="{ 'sidebar--open': isOpen }"
|
||||
>
|
||||
<nav class="sidebar-nav">
|
||||
<ul class="nav-list">
|
||||
<li class="nav-item" v-for="menu in menuList" :key="menu.path">
|
||||
<router-link
|
||||
:to="menu.path"
|
||||
class="nav-link"
|
||||
:class="{ 'is-active': $route.path === menu.path }"
|
||||
@click="handleMenuClick"
|
||||
>
|
||||
<el-icon class="nav-icon"><component :is="menu.icon" /></el-icon>
|
||||
<span class="nav-text">{{ menu.title }}</span>
|
||||
</router-link>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
|
||||
<!-- 遮罩层(手机端) -->
|
||||
<div
|
||||
v-if="isOpen && isMobile"
|
||||
class="sidebar-mask"
|
||||
@click="handleMaskClick"
|
||||
></div>
|
||||
</aside>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, computed, onMounted, onUnmounted } from 'vue'
|
||||
import { HomeFilled, Message, User } from '@element-plus/icons-vue'
|
||||
|
||||
// 菜单数据
|
||||
const menuList = [
|
||||
{
|
||||
path: '/',
|
||||
title: '首页',
|
||||
icon: HomeFilled
|
||||
},
|
||||
{
|
||||
path: '/conversations',
|
||||
title: '会话记录管理',
|
||||
icon: Message
|
||||
},
|
||||
{
|
||||
path: '/users',
|
||||
title: '用户管理',
|
||||
icon: User
|
||||
}
|
||||
]
|
||||
|
||||
// 侧边栏显示状态(手机端)
|
||||
const props = defineProps({
|
||||
isOpen: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
})
|
||||
|
||||
// 定义事件
|
||||
const emit = defineEmits(['closeSidebar'])
|
||||
|
||||
// 响应式布局:判断是否为手机端
|
||||
const isMobile = ref(false)
|
||||
|
||||
// 监听窗口大小变化
|
||||
const handleResize = () => {
|
||||
isMobile.value = window.innerWidth < 768
|
||||
// 如果不是手机端,关闭侧边栏
|
||||
if (!isMobile.value) {
|
||||
emit('closeSidebar')
|
||||
}
|
||||
}
|
||||
|
||||
// 初始化响应式状态
|
||||
onMounted(() => {
|
||||
handleResize()
|
||||
window.addEventListener('resize', handleResize)
|
||||
})
|
||||
|
||||
// 清理事件监听
|
||||
onUnmounted(() => {
|
||||
window.removeEventListener('resize', handleResize)
|
||||
})
|
||||
|
||||
// 菜单点击处理(手机端)
|
||||
const handleMenuClick = () => {
|
||||
if (isMobile.value) {
|
||||
emit('closeSidebar')
|
||||
}
|
||||
}
|
||||
|
||||
// 遮罩层点击处理(手机端)
|
||||
const handleMaskClick = () => {
|
||||
emit('closeSidebar')
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.sidebar {
|
||||
position: fixed;
|
||||
top: 64px;
|
||||
left: 0;
|
||||
bottom: 0;
|
||||
width: 250px;
|
||||
background-color: var(--background-color);
|
||||
border-right: 1px solid var(--border-color);
|
||||
transition: all 0.3s ease;
|
||||
z-index: 99;
|
||||
overflow-y: auto;
|
||||
|
||||
/* 桌面端默认显示,手机端默认隐藏 */
|
||||
@media (max-width: 767px) {
|
||||
transform: translateX(-100%);
|
||||
}
|
||||
}
|
||||
|
||||
/* 侧边栏打开状态(手机端) */
|
||||
.sidebar--open {
|
||||
@media (max-width: 767px) {
|
||||
transform: translateX(0);
|
||||
}
|
||||
}
|
||||
|
||||
.sidebar-nav {
|
||||
padding: 20px 0;
|
||||
}
|
||||
|
||||
.nav-list {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.nav-item {
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.nav-link {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 12px 24px;
|
||||
color: var(--text-color);
|
||||
text-decoration: none;
|
||||
transition: all 0.3s;
|
||||
|
||||
&:hover {
|
||||
background-color: var(--border-color-lighter);
|
||||
color: var(--primary-color);
|
||||
}
|
||||
|
||||
&.is-active {
|
||||
background-color: rgba(64, 158, 255, 0.1);
|
||||
color: var(--primary-color);
|
||||
border-right: 3px solid var(--primary-color);
|
||||
}
|
||||
}
|
||||
|
||||
.nav-icon {
|
||||
font-size: 18px;
|
||||
margin-right: 12px;
|
||||
width: 20px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.nav-text {
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
/* 遮罩层(手机端) */
|
||||
.sidebar-mask {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background-color: rgba(0, 0, 0, 0.5);
|
||||
z-index: 98;
|
||||
@media (min-width: 768px) {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
/* 平板端侧边栏宽度调整 */
|
||||
@media (min-width: 768px) and (max-width: 1023px) {
|
||||
.sidebar {
|
||||
width: 200px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
55
admin-web/src/components/ThemeSwitcher.vue
Normal file
55
admin-web/src/components/ThemeSwitcher.vue
Normal file
@@ -0,0 +1,55 @@
|
||||
<template>
|
||||
<el-dropdown trigger="click" @command="handleThemeChange">
|
||||
<el-button type="text" :icon="isDark ? 'MoonNight' : 'Sunny'" circle>
|
||||
</el-button>
|
||||
<template #dropdown>
|
||||
<el-dropdown-menu>
|
||||
<el-dropdown-item command="light">
|
||||
<el-icon><Sunny /></el-icon>
|
||||
<span>浅色模式</span>
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item command="dark">
|
||||
<el-icon><MoonNight /></el-icon>
|
||||
<span>深色模式</span>
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item command="auto">
|
||||
<el-icon><Monitor /></el-icon>
|
||||
<span>跟随系统</span>
|
||||
</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
</el-dropdown>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed } from 'vue'
|
||||
import { Sunny, MoonNight, Monitor } from '@element-plus/icons-vue'
|
||||
import { useThemeStore } from '../store/theme'
|
||||
|
||||
const themeStore = useThemeStore()
|
||||
|
||||
// 当前主题状态
|
||||
const isDark = computed(() => themeStore.isDark)
|
||||
|
||||
// 切换主题
|
||||
const handleThemeChange = (theme) => {
|
||||
if (theme === 'auto') {
|
||||
// 跟随系统主题
|
||||
const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches
|
||||
themeStore.isDark = prefersDark
|
||||
} else {
|
||||
// 手动设置主题
|
||||
themeStore.isDark = theme === 'dark'
|
||||
}
|
||||
|
||||
// 更新localStorage和document属性
|
||||
localStorage.setItem('theme', themeStore.isDark ? 'dark' : 'light')
|
||||
document.documentElement.setAttribute('data-theme', themeStore.isDark ? 'dark' : 'light')
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.el-dropdown {
|
||||
display: inline-block;
|
||||
}
|
||||
</style>
|
||||
32
admin-web/src/main.js
Normal file
32
admin-web/src/main.js
Normal file
@@ -0,0 +1,32 @@
|
||||
import { createApp } from 'vue'
|
||||
import ElementPlus from 'element-plus'
|
||||
import 'element-plus/dist/index.css'
|
||||
// 引入中文语言包
|
||||
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
|
||||
import router from './router'
|
||||
import { pinia, useThemeStore } from './store'
|
||||
import './styles/main.scss'
|
||||
import App from './App.vue'
|
||||
|
||||
// 创建应用实例
|
||||
const app = createApp(App)
|
||||
|
||||
// 使用Pinia - 必须先初始化Pinia,再使用store
|
||||
app.use(pinia)
|
||||
|
||||
// 初始化主题
|
||||
const themeStore = useThemeStore()
|
||||
themeStore.initTheme()
|
||||
|
||||
// 使用Element Plus,并配置中文语言
|
||||
app.use(ElementPlus, {
|
||||
locale: zhCn,
|
||||
// 配置主题切换
|
||||
dark: themeStore.isDark
|
||||
})
|
||||
|
||||
// 使用路由
|
||||
app.use(router)
|
||||
|
||||
// 挂载应用
|
||||
app.mount('#app')
|
||||
59
admin-web/src/router/index.js
Normal file
59
admin-web/src/router/index.js
Normal file
@@ -0,0 +1,59 @@
|
||||
import { createRouter, createWebHistory } from 'vue-router'
|
||||
import { useAuthStore } from '../store/auth'
|
||||
|
||||
// 定义路由
|
||||
const routes = [
|
||||
{
|
||||
path: '/login',
|
||||
name: 'Login',
|
||||
component: () => import('../views/Login.vue'),
|
||||
meta: { requiresAuth: false }
|
||||
},
|
||||
{
|
||||
path: '/',
|
||||
name: 'Layout',
|
||||
component: () => import('../components/Layout/Layout.vue'),
|
||||
meta: { requiresAuth: true },
|
||||
children: [
|
||||
{
|
||||
path: '',
|
||||
name: 'Home',
|
||||
component: () => import('../views/Home.vue')
|
||||
},
|
||||
{
|
||||
path: '/conversations',
|
||||
name: 'ConversationList',
|
||||
component: () => import('../views/ConversationList.vue')
|
||||
},
|
||||
{
|
||||
path: '/users',
|
||||
name: 'UserList',
|
||||
component: () => import('../views/UserList.vue')
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
path: '/:pathMatch(.*)*',
|
||||
redirect: '/'
|
||||
}
|
||||
]
|
||||
|
||||
// 创建路由实例
|
||||
const router = createRouter({
|
||||
history: createWebHistory(),
|
||||
routes
|
||||
})
|
||||
|
||||
// 路由守卫
|
||||
router.beforeEach((to, from, next) => {
|
||||
const authStore = useAuthStore()
|
||||
|
||||
if (to.meta.requiresAuth && !authStore.isLoggedIn) {
|
||||
// 未登录用户访问受保护页面,重定向到登录页
|
||||
next('/login')
|
||||
} else {
|
||||
next()
|
||||
}
|
||||
})
|
||||
|
||||
export default router
|
||||
22
admin-web/src/store/auth.js
Normal file
22
admin-web/src/store/auth.js
Normal file
@@ -0,0 +1,22 @@
|
||||
import { defineStore } from 'pinia'
|
||||
|
||||
export const useAuthStore = defineStore('auth', {
|
||||
state: () => ({
|
||||
isLoggedIn: false,
|
||||
username: ''
|
||||
}),
|
||||
actions: {
|
||||
login(username, password) {
|
||||
if (username === 'Admin' && password === 'Admin') {
|
||||
this.isLoggedIn = true
|
||||
this.username = username
|
||||
return true
|
||||
}
|
||||
return false
|
||||
},
|
||||
logout() {
|
||||
this.isLoggedIn = false
|
||||
this.username = ''
|
||||
}
|
||||
}
|
||||
})
|
||||
11
admin-web/src/store/index.js
Normal file
11
admin-web/src/store/index.js
Normal file
@@ -0,0 +1,11 @@
|
||||
import { createPinia } from 'pinia'
|
||||
import { useAuthStore } from './auth'
|
||||
import { useThemeStore } from './theme'
|
||||
|
||||
const pinia = createPinia()
|
||||
|
||||
export {
|
||||
pinia,
|
||||
useAuthStore,
|
||||
useThemeStore
|
||||
}
|
||||
31
admin-web/src/store/theme.js
Normal file
31
admin-web/src/store/theme.js
Normal file
@@ -0,0 +1,31 @@
|
||||
import { defineStore } from 'pinia'
|
||||
|
||||
export const useThemeStore = defineStore('theme', {
|
||||
state: () => ({
|
||||
isDark: localStorage.getItem('theme') === 'dark'
|
||||
}),
|
||||
actions: {
|
||||
toggleTheme() {
|
||||
this.isDark = !this.isDark
|
||||
localStorage.setItem('theme', this.isDark ? 'dark' : 'light')
|
||||
document.documentElement.setAttribute('data-theme', this.isDark ? 'dark' : 'light')
|
||||
// 控制 Element Plus 深色模式
|
||||
if (this.isDark) {
|
||||
document.documentElement.classList.add('dark')
|
||||
} else {
|
||||
document.documentElement.classList.remove('dark')
|
||||
}
|
||||
},
|
||||
initTheme() {
|
||||
const theme = localStorage.getItem('theme') || 'light'
|
||||
this.isDark = theme === 'dark'
|
||||
document.documentElement.setAttribute('data-theme', theme)
|
||||
// 初始化 Element Plus 深色模式
|
||||
if (this.isDark) {
|
||||
document.documentElement.classList.add('dark')
|
||||
} else {
|
||||
document.documentElement.classList.remove('dark')
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
79
admin-web/src/style.css
Normal file
79
admin-web/src/style.css
Normal file
@@ -0,0 +1,79 @@
|
||||
:root {
|
||||
font-family: system-ui, Avenir, Helvetica, Arial, sans-serif;
|
||||
line-height: 1.5;
|
||||
font-weight: 400;
|
||||
|
||||
color-scheme: light dark;
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
background-color: #242424;
|
||||
|
||||
font-synthesis: none;
|
||||
text-rendering: optimizeLegibility;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
|
||||
a {
|
||||
font-weight: 500;
|
||||
color: #646cff;
|
||||
text-decoration: inherit;
|
||||
}
|
||||
a:hover {
|
||||
color: #535bf2;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
display: flex;
|
||||
place-items: center;
|
||||
min-width: 320px;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 3.2em;
|
||||
line-height: 1.1;
|
||||
}
|
||||
|
||||
button {
|
||||
border-radius: 8px;
|
||||
border: 1px solid transparent;
|
||||
padding: 0.6em 1.2em;
|
||||
font-size: 1em;
|
||||
font-weight: 500;
|
||||
font-family: inherit;
|
||||
background-color: #1a1a1a;
|
||||
cursor: pointer;
|
||||
transition: border-color 0.25s;
|
||||
}
|
||||
button:hover {
|
||||
border-color: #646cff;
|
||||
}
|
||||
button:focus,
|
||||
button:focus-visible {
|
||||
outline: 4px auto -webkit-focus-ring-color;
|
||||
}
|
||||
|
||||
.card {
|
||||
padding: 2em;
|
||||
}
|
||||
|
||||
#app {
|
||||
max-width: 1280px;
|
||||
margin: 0 auto;
|
||||
padding: 2rem;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: light) {
|
||||
:root {
|
||||
color: #213547;
|
||||
background-color: #ffffff;
|
||||
}
|
||||
a:hover {
|
||||
color: #747bff;
|
||||
}
|
||||
button {
|
||||
background-color: #f9f9f9;
|
||||
}
|
||||
}
|
||||
236
admin-web/src/styles/main.scss
Normal file
236
admin-web/src/styles/main.scss
Normal file
@@ -0,0 +1,236 @@
|
||||
// 引入变量文件 - 使用 @use 替换 @import 以消除 Sass 3.0.0 弃用警告
|
||||
@use './variables.scss' as *;
|
||||
|
||||
// 引入响应式样式 - 使用 @use 替换 @import 以消除 Sass 3.0.0 弃用警告
|
||||
@use './responsive.scss' as *;
|
||||
|
||||
// 全局样式重置
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
html, body {
|
||||
height: 100%;
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
||||
font-size: 14px;
|
||||
line-height: 1.5;
|
||||
color: var(--text-color);
|
||||
background-color: var(--background-color);
|
||||
transition: background-color 0.3s, color 0.3s;
|
||||
}
|
||||
|
||||
// 链接样式
|
||||
a {
|
||||
color: var(--primary-color);
|
||||
text-decoration: none;
|
||||
|
||||
&:hover {
|
||||
color: #66b1ff;
|
||||
}
|
||||
}
|
||||
|
||||
// 容器样式
|
||||
.container {
|
||||
width: 100%;
|
||||
padding: 0 20px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
// 页面容器样式
|
||||
.page-container {
|
||||
padding: 20px;
|
||||
min-height: calc(100vh - 64px);
|
||||
|
||||
@media (max-width: $breakpoint-sm - 1px) {
|
||||
padding: 16px;
|
||||
}
|
||||
}
|
||||
|
||||
// 卡片样式
|
||||
.card {
|
||||
background-color: var(--background-color);
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: 4px;
|
||||
box-shadow: var(--box-shadow);
|
||||
padding: 20px;
|
||||
margin-bottom: 20px;
|
||||
transition: all 0.3s;
|
||||
|
||||
&:hover {
|
||||
box-shadow: var(--box-shadow-light);
|
||||
}
|
||||
}
|
||||
|
||||
// 标题样式
|
||||
h1, h2, h3, h4, h5, h6 {
|
||||
margin-bottom: 16px;
|
||||
font-weight: 600;
|
||||
color: var(--text-color);
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 24px;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
h3 {
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
// 按钮样式
|
||||
.btn {
|
||||
display: inline-block;
|
||||
padding: 8px 16px;
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: 4px;
|
||||
background-color: var(--background-color);
|
||||
color: var(--text-color);
|
||||
font-size: 14px;
|
||||
line-height: 1.5;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s;
|
||||
|
||||
&:hover {
|
||||
border-color: var(--primary-color);
|
||||
color: var(--primary-color);
|
||||
}
|
||||
|
||||
&.btn-primary {
|
||||
background-color: var(--primary-color);
|
||||
border-color: var(--primary-color);
|
||||
color: #ffffff;
|
||||
|
||||
&:hover {
|
||||
background-color: #66b1ff;
|
||||
border-color: #66b1ff;
|
||||
color: #ffffff;
|
||||
}
|
||||
}
|
||||
|
||||
&.btn-success {
|
||||
background-color: var(--success-color);
|
||||
border-color: var(--success-color);
|
||||
color: #ffffff;
|
||||
|
||||
&:hover {
|
||||
background-color: #85ce61;
|
||||
border-color: #85ce61;
|
||||
color: #ffffff;
|
||||
}
|
||||
}
|
||||
|
||||
&.btn-danger {
|
||||
background-color: var(--danger-color);
|
||||
border-color: var(--danger-color);
|
||||
color: #ffffff;
|
||||
|
||||
&:hover {
|
||||
background-color: #f78989;
|
||||
border-color: #f78989;
|
||||
color: #ffffff;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 表单样式
|
||||
.form-item {
|
||||
margin-bottom: 20px;
|
||||
|
||||
.form-label {
|
||||
display: block;
|
||||
margin-bottom: 8px;
|
||||
font-weight: 500;
|
||||
color: var(--text-color);
|
||||
}
|
||||
|
||||
.form-input {
|
||||
width: 100%;
|
||||
padding: 8px 12px;
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: 4px;
|
||||
background-color: var(--background-color);
|
||||
color: var(--text-color);
|
||||
font-size: 14px;
|
||||
transition: all 0.3s;
|
||||
|
||||
&:focus {
|
||||
outline: none;
|
||||
border-color: var(--primary-color);
|
||||
box-shadow: 0 0 0 2px rgba(64, 158, 255, 0.2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 表格样式
|
||||
.table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
|
||||
th, td {
|
||||
padding: 12px;
|
||||
text-align: left;
|
||||
border-bottom: 1px solid var(--border-color);
|
||||
}
|
||||
|
||||
th {
|
||||
background-color: var(--border-color-lighter);
|
||||
font-weight: 600;
|
||||
color: var(--text-color);
|
||||
}
|
||||
|
||||
tr {
|
||||
transition: background-color 0.3s;
|
||||
|
||||
&:hover {
|
||||
background-color: var(--border-color-lighter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 加载状态样式
|
||||
.loading {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
padding: 40px;
|
||||
|
||||
.loading-text {
|
||||
margin-left: 8px;
|
||||
color: var(--text-color-secondary);
|
||||
}
|
||||
}
|
||||
|
||||
// 空状态样式
|
||||
.empty {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
padding: 60px 20px;
|
||||
color: var(--text-color-secondary);
|
||||
|
||||
.empty-icon {
|
||||
font-size: 48px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
}
|
||||
|
||||
// 错误状态样式
|
||||
.error {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
padding: 60px 20px;
|
||||
color: var(--danger-color);
|
||||
|
||||
.error-icon {
|
||||
font-size: 48px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
}
|
||||
100
admin-web/src/styles/responsive.scss
Normal file
100
admin-web/src/styles/responsive.scss
Normal file
@@ -0,0 +1,100 @@
|
||||
// 响应式布局样式
|
||||
// 导入变量文件 - 使用 @use 替换 @import 以消除 Sass 3.0.0 弃用警告
|
||||
@use './variables.scss' as *;
|
||||
|
||||
// 手机端 (< 768px)
|
||||
@media (max-width: $breakpoint-sm - 1px) {
|
||||
.container {
|
||||
padding: 0 16px;
|
||||
}
|
||||
|
||||
.sidebar {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.main-content {
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
.header {
|
||||
padding: 0 16px;
|
||||
}
|
||||
}
|
||||
|
||||
// 平板端 (768px - 1023px)
|
||||
@media (min-width: $breakpoint-sm) and (max-width: $breakpoint-md - 1px) {
|
||||
.container {
|
||||
padding: 0 24px;
|
||||
}
|
||||
|
||||
.sidebar {
|
||||
width: 200px;
|
||||
}
|
||||
|
||||
.main-content {
|
||||
margin-left: 200px;
|
||||
}
|
||||
}
|
||||
|
||||
// 桌面端 (>= 1024px)
|
||||
@media (min-width: $breakpoint-md) {
|
||||
.container {
|
||||
padding: 0 32px;
|
||||
}
|
||||
|
||||
.sidebar {
|
||||
width: 250px;
|
||||
}
|
||||
|
||||
.main-content {
|
||||
margin-left: 250px;
|
||||
}
|
||||
}
|
||||
|
||||
// 大屏幕桌面端 (>= 1200px)
|
||||
@media (min-width: $breakpoint-lg) {
|
||||
.container {
|
||||
max-width: 1200px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
}
|
||||
|
||||
// 超大屏幕桌面端 (>= 1920px)
|
||||
@media (min-width: $breakpoint-xl) {
|
||||
.container {
|
||||
max-width: 1600px;
|
||||
}
|
||||
}
|
||||
|
||||
// 通用响应式工具类
|
||||
.text-center-sm {
|
||||
text-align: center;
|
||||
|
||||
@media (min-width: $breakpoint-sm) {
|
||||
text-align: left;
|
||||
}
|
||||
}
|
||||
|
||||
.display-block-sm {
|
||||
display: block;
|
||||
|
||||
@media (min-width: $breakpoint-sm) {
|
||||
display: inline-block;
|
||||
}
|
||||
}
|
||||
|
||||
.hidden-sm {
|
||||
display: none;
|
||||
|
||||
@media (min-width: $breakpoint-sm) {
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
|
||||
.visible-sm {
|
||||
display: block;
|
||||
|
||||
@media (min-width: $breakpoint-sm) {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
41
admin-web/src/styles/variables.scss
Normal file
41
admin-web/src/styles/variables.scss
Normal file
@@ -0,0 +1,41 @@
|
||||
// 浅色主题变量
|
||||
:root {
|
||||
--primary-color: #409eff;
|
||||
--success-color: #67c23a;
|
||||
--warning-color: #e6a23c;
|
||||
--danger-color: #f56c6c;
|
||||
--info-color: #909399;
|
||||
|
||||
--background-color: #ffffff;
|
||||
--text-color: #303133;
|
||||
--text-color-secondary: #606266;
|
||||
--border-color: #dcdfe6;
|
||||
--border-color-light: #e4e7ed;
|
||||
--border-color-lighter: #ebeef5;
|
||||
--box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12), 0 0 6px rgba(0, 0, 0, 0.04);
|
||||
--box-shadow-light: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
// 深色主题变量
|
||||
[data-theme="dark"] {
|
||||
--primary-color: #409eff;
|
||||
--success-color: #67c23a;
|
||||
--warning-color: #e6a23c;
|
||||
--danger-color: #f56c6c;
|
||||
--info-color: #909399;
|
||||
|
||||
--background-color: #1a1a1a;
|
||||
--text-color: #ffffff;
|
||||
--text-color-secondary: #aaaaaa;
|
||||
--border-color: #444444;
|
||||
--border-color-light: #333333;
|
||||
--border-color-lighter: #222222;
|
||||
--box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3), 0 0 6px rgba(0, 0, 0, 0.2);
|
||||
--box-shadow-light: 0 2px 12px 0 rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
|
||||
// 响应式断点
|
||||
$breakpoint-sm: 768px;
|
||||
$breakpoint-md: 1024px;
|
||||
$breakpoint-lg: 1200px;
|
||||
$breakpoint-xl: 1920px;
|
||||
25
admin-web/src/utils/formatters.js
Normal file
25
admin-web/src/utils/formatters.js
Normal file
@@ -0,0 +1,25 @@
|
||||
// 手机号脱敏处理
|
||||
export const formatPhoneNumber = (phoneNumber, showFull = false) => {
|
||||
if (!phoneNumber) return ''
|
||||
const phone = phoneNumber.toString()
|
||||
if (phone.length !== 11) return phone
|
||||
|
||||
if (showFull) {
|
||||
return phone
|
||||
} else {
|
||||
return phone.replace(/(\d{3})\d{4}(\d{4})/, '$1****$2')
|
||||
}
|
||||
}
|
||||
|
||||
// 时间格式转换,将T替换为空格
|
||||
export const formatDateTime = (dateTime) => {
|
||||
if (!dateTime) return ''
|
||||
return dateTime.toString().replace('T', ' ')
|
||||
}
|
||||
|
||||
// 时间戳转换为格式化日期
|
||||
export const formatTimestamp = (timestamp) => {
|
||||
if (!timestamp) return ''
|
||||
const date = new Date(timestamp)
|
||||
return date.toISOString().replace('T', ' ').slice(0, 19)
|
||||
}
|
||||
55
admin-web/src/utils/request.js
Normal file
55
admin-web/src/utils/request.js
Normal file
@@ -0,0 +1,55 @@
|
||||
import axios from 'axios'
|
||||
import { useAuthStore } from '../store/auth'
|
||||
|
||||
// 创建axios实例
|
||||
const request = axios.create({
|
||||
baseURL: 'https://wx-xcx-check.blv-oa.com:4433/api', // API根地址 - 使用vite代理
|
||||
timeout: 10000, // 请求超时时间
|
||||
headers: {
|
||||
'Content-Type': 'application/json' // 设置默认请求格式为JSON
|
||||
}
|
||||
})
|
||||
|
||||
// 请求拦截器
|
||||
request.interceptors.request.use(
|
||||
config => {
|
||||
// 从auth store获取token(如果有)
|
||||
const authStore = useAuthStore()
|
||||
if (authStore.isLoggedIn) {
|
||||
// 虽然当前是前端验证,但预留token位置以便后续扩展
|
||||
// config.headers.Authorization = `Bearer ${authStore.token}`
|
||||
}
|
||||
return config
|
||||
},
|
||||
error => {
|
||||
// 请求错误处理
|
||||
console.error('request error:', error)
|
||||
return Promise.reject(error)
|
||||
}
|
||||
)
|
||||
|
||||
// 响应拦截器
|
||||
request.interceptors.response.use(
|
||||
response => {
|
||||
// 直接返回响应数据
|
||||
return response.data
|
||||
},
|
||||
error => {
|
||||
// 响应错误处理
|
||||
console.error('response error:', error)
|
||||
|
||||
// 如果是401未授权,可以在这里处理登出逻辑
|
||||
if (error.response && error.response.status === 401) {
|
||||
const authStore = useAuthStore()
|
||||
authStore.logout()
|
||||
// 跳转到登录页
|
||||
window.location.href = '/login'
|
||||
}
|
||||
|
||||
// 格式化错误信息
|
||||
const errorMessage = error.response?.data?.message || error.message || '请求失败'
|
||||
return Promise.reject(new Error(errorMessage))
|
||||
}
|
||||
)
|
||||
|
||||
export default request
|
||||
412
admin-web/src/views/ConversationList.vue
Normal file
412
admin-web/src/views/ConversationList.vue
Normal file
@@ -0,0 +1,412 @@
|
||||
<template>
|
||||
<div class="conversation-list-container">
|
||||
<!-- 筛选表单折叠面板 -->
|
||||
<el-collapse v-model="activeCollapse" class="filter-collapse">
|
||||
<el-collapse-item name="filter">
|
||||
<template #title>
|
||||
<div class="collapse-header">
|
||||
<span class="collapse-title">筛选条件</span>
|
||||
<div class="header-buttons" @click.stop>
|
||||
<el-button type="primary" size="small" @click="handleQuery">查询</el-button>
|
||||
<el-button size="small" @click="handleReset">重置</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<el-form :model="filterForm" inline label-width="80px" size="small">
|
||||
<el-form-item label="时间范围">
|
||||
<el-date-picker v-model="filterForm.dateRange" type="daterange" range-separator="至" start-placeholder="开始日期"
|
||||
end-placeholder="结束日期" format="YYYY-MM-DD" value-format="YYYY-MM-DD" clearable></el-date-picker>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="用户">
|
||||
<el-select v-model="filterForm.userKey" placeholder="请选择用户" clearable filterable remote
|
||||
:remote-method="handleUserSearch" :loading="userLoading" style="width: 200px">
|
||||
<el-option v-for="user in userList" :key="user.userKey" :label="user.userName"
|
||||
:value="user.userKey"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="消息类型">
|
||||
<el-select v-model="filterForm.messageType" placeholder="请选择消息类型" clearable style="width: 150px">
|
||||
<el-option label="公有" :value="1"></el-option>
|
||||
<el-option label="私有" :value="2"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="部门">
|
||||
<el-select v-model="filterForm.department" placeholder="请选择部门" clearable style="width: 150px">
|
||||
<el-option v-for="dept in departmentList" :key="dept" :label="dept" :value="dept"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-collapse-item>
|
||||
</el-collapse>
|
||||
|
||||
<!-- 会话记录列表 -->
|
||||
<el-scrollbar :style="{ height: scrollbarHeight }" @scroll="handleScroll">
|
||||
<div v-loading="loading" class="descriptions-container">
|
||||
<div v-for="(item, index) in conversationList" :key="index" class="descriptions-item">
|
||||
<el-descriptions :column="1" size="small" label-width="0px">
|
||||
<el-descriptions-item label="">
|
||||
{{ formatDateTime(item.recordTime) }} | {{ item.userName }} | {{ item.department }}
|
||||
<el-tag :type="item.messageType === 1 ? 'success' : ''">
|
||||
{{ item.messageType === 1 ? '公有' : '私有' }}
|
||||
</el-tag>
|
||||
<el-tag :type="item.sendMethod === '文字' ? 'success' : ''">
|
||||
{{ item.sendMethod === 'text' ? '文字' : '语音' }}{{ item.speakingTime ? ' | ' + item.speakingTime + '秒' :
|
||||
''
|
||||
}}
|
||||
</el-tag>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="">
|
||||
{{ item.conversationContent }}
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</div>
|
||||
|
||||
<!-- 加载更多提示 -->
|
||||
<div v-if="loadingMore" class="loading-more">
|
||||
<el-icon class="is-loading">
|
||||
<Loading />
|
||||
</el-icon>
|
||||
<span>正在加载中...</span>
|
||||
</div>
|
||||
<div v-else-if="!hasMoreData" class="no-more-data">
|
||||
<span>已加载全部数据</span>
|
||||
</div>
|
||||
</div>
|
||||
</el-scrollbar>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, reactive, onMounted, computed, watch } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import request from '../utils/request'
|
||||
import { formatPhoneNumber, formatDateTime, formatTimestamp } from '../utils/formatters'
|
||||
import { Loading } from '@element-plus/icons-vue'
|
||||
|
||||
// 加载状态
|
||||
const loading = ref(false)
|
||||
const userLoading = ref(false)
|
||||
|
||||
// 折叠面板状态
|
||||
const activeCollapse = ref(['filter'])
|
||||
|
||||
// 计算滚动容器高度
|
||||
const scrollbarHeight = computed(() => {
|
||||
return activeCollapse.value.includes('filter') ? 'calc(100vh - 350px)' : 'calc(100vh - 160px)'
|
||||
})
|
||||
|
||||
// 分页数据
|
||||
const currentPage = ref(1)
|
||||
const pageSize = ref(20) // 固定分页大小为20条/页
|
||||
const total = ref(0)
|
||||
const loadingMore = ref(false)
|
||||
const hasMoreData = ref(true)
|
||||
|
||||
// 空状态文本
|
||||
const emptyText = computed(() => loading.value ? '加载中...' : '暂无数据')
|
||||
|
||||
// 筛选表单数据
|
||||
const filterForm = reactive({
|
||||
dateRange: [],
|
||||
userKey: '',
|
||||
messageType: '',
|
||||
department: ''
|
||||
})
|
||||
|
||||
// 会话记录列表
|
||||
const conversationList = ref([])
|
||||
|
||||
// 用户列表(用于筛选)
|
||||
const userList = ref([])
|
||||
|
||||
// 部门列表(用于筛选)
|
||||
const departmentList = ref([])
|
||||
|
||||
// 查询会话记录
|
||||
const handleQuery = () => {
|
||||
currentPage.value = 1
|
||||
fetchConversations()
|
||||
}
|
||||
|
||||
// 重置筛选条件
|
||||
const handleReset = () => {
|
||||
// 重置表单
|
||||
Object.keys(filterForm).forEach(key => {
|
||||
if (key === 'dateRange') {
|
||||
filterForm[key] = []
|
||||
} else {
|
||||
filterForm[key] = ''
|
||||
}
|
||||
})
|
||||
currentPage.value = 1
|
||||
fetchConversations()
|
||||
}
|
||||
|
||||
// 滚动处理
|
||||
const handleScroll = ({ scrollTop, scrollHeight, clientHeight }) => {
|
||||
// 当滚动到底部100px以内时加载下一页
|
||||
if (scrollHeight - scrollTop - clientHeight < 100 && !loadingMore.value && hasMoreData.value) {
|
||||
loadNextPage()
|
||||
}
|
||||
}
|
||||
|
||||
// 加载下一页数据
|
||||
const loadNextPage = () => {
|
||||
if (loadingMore.value || !hasMoreData.value) return
|
||||
|
||||
loadingMore.value = true
|
||||
currentPage.value++
|
||||
fetchConversations(true) // 传入true表示加载更多
|
||||
}
|
||||
|
||||
// 远程搜索用户
|
||||
const handleUserSearch = (query) => {
|
||||
if (query) {
|
||||
userLoading.value = true
|
||||
// 过滤用户列表
|
||||
setTimeout(() => {
|
||||
const allUsers = originalUserList.value
|
||||
userList.value = allUsers.filter(user =>
|
||||
user.userName.toLowerCase().includes(query.toLowerCase())
|
||||
)
|
||||
userLoading.value = false
|
||||
}, 200)
|
||||
} else {
|
||||
userList.value = [...originalUserList.value]
|
||||
}
|
||||
}
|
||||
|
||||
// 原始用户列表(用于搜索过滤)
|
||||
const originalUserList = ref([])
|
||||
|
||||
// 获取会话记录
|
||||
const fetchConversations = async (isLoadMore = false) => {
|
||||
if (isLoadMore) {
|
||||
loadingMore.value = true
|
||||
} else {
|
||||
loading.value = true
|
||||
conversationList.value = [] // 非加载更多时清空列表
|
||||
hasMoreData.value = true // 重置加载状态
|
||||
currentPage.value = 1 // 重置当前页
|
||||
}
|
||||
|
||||
try {
|
||||
// 构建请求参数
|
||||
const params = {
|
||||
startTime: filterForm.dateRange[0] ? new Date(filterForm.dateRange[0]).getTime() : null,
|
||||
endTime: filterForm.dateRange[1] ? new Date(filterForm.dateRange[1]).getTime() + 24 * 60 * 60 * 1000 - 1 : null,
|
||||
userKey: filterForm.userKey,
|
||||
messageType: filterForm.messageType ? Number(filterForm.messageType) : null,
|
||||
department: filterForm.department,
|
||||
page: currentPage.value,
|
||||
pageSize: pageSize.value
|
||||
}
|
||||
|
||||
// 调用API获取会话记录
|
||||
const data = await request.post('/Admin/QueryConversations', JSON.stringify(params))
|
||||
|
||||
// 检查返回数据格式,确保是数组
|
||||
const rawData = Array.isArray(data) ? data : data.data || []
|
||||
|
||||
// 按时间排序(最新的记录在前面)
|
||||
const sortedData = rawData.sort((a, b) => {
|
||||
return b.recordTimeUTCStamp - a.recordTimeUTCStamp
|
||||
})
|
||||
|
||||
// 如果是加载更多,则追加数据,否则替换数据
|
||||
if (isLoadMore) {
|
||||
conversationList.value = [...conversationList.value, ...sortedData]
|
||||
} else {
|
||||
conversationList.value = sortedData
|
||||
}
|
||||
|
||||
total.value = conversationList.value.length
|
||||
|
||||
// 判断是否已加载全部数据
|
||||
if (sortedData.length < pageSize.value) {
|
||||
hasMoreData.value = false
|
||||
}
|
||||
} catch (error) {
|
||||
ElMessage.error('获取会话记录失败:' + error.message)
|
||||
if (!isLoadMore) {
|
||||
conversationList.value = []
|
||||
total.value = 0
|
||||
}
|
||||
} finally {
|
||||
loading.value = false
|
||||
loadingMore.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 获取用户列表(用于筛选)
|
||||
const fetchUsers = async () => {
|
||||
try {
|
||||
// 调用API获取用户列表
|
||||
const data = await request.get('/Admin/QueryUsers')
|
||||
|
||||
// 检查返回数据格式,确保是数组
|
||||
const rawData = Array.isArray(data) ? data : data.data || []
|
||||
|
||||
// 转换数据格式,只取userName和userKey
|
||||
const users = rawData.map(item => ({
|
||||
userKey: item.userKey,
|
||||
userName: item.userName
|
||||
}))
|
||||
|
||||
userList.value = users
|
||||
originalUserList.value = [...users]
|
||||
|
||||
// 提取部门列表
|
||||
const depts = [...new Set(rawData.map(user => user.department))]
|
||||
departmentList.value = depts.filter(dept => dept)
|
||||
} catch (error) {
|
||||
ElMessage.error('获取用户列表失败:' + error.message)
|
||||
userList.value = []
|
||||
originalUserList.value = []
|
||||
departmentList.value = []
|
||||
}
|
||||
}
|
||||
|
||||
// 页面初始化
|
||||
onMounted(() => {
|
||||
fetchUsers()
|
||||
fetchConversations()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.conversation-list-container {
|
||||
padding: 20px 0;
|
||||
height: calc(100% - 64px);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
/* 折叠面板样式 */
|
||||
.filter-collapse {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.filter-collapse :deep(.el-collapse-item__header) {
|
||||
height: auto;
|
||||
padding: 12px 16px;
|
||||
line-height: normal;
|
||||
}
|
||||
|
||||
.collapse-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
padding-right: 20px;
|
||||
}
|
||||
|
||||
.collapse-title {
|
||||
font-size: 16px;
|
||||
font-weight: 500;
|
||||
color: #303133;
|
||||
}
|
||||
|
||||
.header-buttons {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.header-buttons .el-button {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.filter-card {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.table-card {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.pagination-container {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
/* 手机号样式 */
|
||||
.phone-number {
|
||||
cursor: pointer;
|
||||
color: #409eff;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.phone-number:hover {
|
||||
color: #66b1ff;
|
||||
}
|
||||
|
||||
/* 加载更多样式 */
|
||||
.loading-more,
|
||||
.no-more-data {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
padding: 16px;
|
||||
color: #909399;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.loading-more .el-icon {
|
||||
margin-right: 8px;
|
||||
}
|
||||
|
||||
/* Descriptions容器样式 */
|
||||
.descriptions-container {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
/* 每个Descriptions项的样式 */
|
||||
.descriptions-item {
|
||||
margin-bottom: 20px;
|
||||
border-radius: 4px;
|
||||
overflow: hidden;
|
||||
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
/* 会话内容样式 */
|
||||
.conversation-content {
|
||||
margin-top: 0px;
|
||||
}
|
||||
|
||||
/* 响应式样式 */
|
||||
@media (max-width: 767px) {
|
||||
.conversation-list-container {
|
||||
padding: 6px 0;
|
||||
}
|
||||
|
||||
.el-form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
}
|
||||
|
||||
.el-form-item {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.el-date-picker,
|
||||
.el-select {
|
||||
width: 100% !important;
|
||||
}
|
||||
|
||||
/* 响应式调整Descriptions列数 */
|
||||
.el-descriptions {
|
||||
:deep(.el-descriptions__table) {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
:deep(.el-descriptions__cell) {
|
||||
width: 50%;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
334
admin-web/src/views/Home.vue
Normal file
334
admin-web/src/views/Home.vue
Normal file
@@ -0,0 +1,334 @@
|
||||
<template>
|
||||
<div class="home-container">
|
||||
<h2>欢迎回来,{{ username }}</h2>
|
||||
|
||||
<!-- 系统统计卡片 -->
|
||||
<div class="stats-container">
|
||||
<el-card class="stat-card">
|
||||
<div class="stat-content">
|
||||
<div class="stat-icon user-icon">
|
||||
<el-icon><User /></el-icon>
|
||||
</div>
|
||||
<div class="stat-info">
|
||||
<h3>{{ userCount }}</h3>
|
||||
<p>活跃用户</p>
|
||||
</div>
|
||||
</div>
|
||||
</el-card>
|
||||
|
||||
<el-card class="stat-card">
|
||||
<div class="stat-content">
|
||||
<div class="stat-icon conversation-icon">
|
||||
<el-icon><Message /></el-icon>
|
||||
</div>
|
||||
<div class="stat-info">
|
||||
<h3>{{ conversationCount }}</h3>
|
||||
<p>会话记录</p>
|
||||
</div>
|
||||
</div>
|
||||
</el-card>
|
||||
|
||||
<el-card class="stat-card">
|
||||
<div class="stat-content">
|
||||
<div class="stat-icon department-icon">
|
||||
<el-icon><OfficeBuilding /></el-icon>
|
||||
</div>
|
||||
<div class="stat-info">
|
||||
<h3>{{ departmentCount }}</h3>
|
||||
<p>部门数量</p>
|
||||
</div>
|
||||
</div>
|
||||
</el-card>
|
||||
|
||||
<el-card class="stat-card">
|
||||
<div class="stat-content">
|
||||
<div class="stat-icon today-icon">
|
||||
<el-icon><Calendar /></el-icon>
|
||||
</div>
|
||||
<div class="stat-info">
|
||||
<h3>{{ todayCount }}</h3>
|
||||
<p>今日新增</p>
|
||||
</div>
|
||||
</div>
|
||||
</el-card>
|
||||
</div>
|
||||
|
||||
<!-- 最近会话记录 -->
|
||||
<el-card class="recent-conversations-card">
|
||||
<template #header>
|
||||
<div class="card-header">
|
||||
<span>最近会话记录</span>
|
||||
<router-link to="/conversations" class="view-all-link">
|
||||
查看全部
|
||||
<el-icon class="el-icon--right"><ArrowRight /></el-icon>
|
||||
</router-link>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<el-table
|
||||
:data="recentConversations"
|
||||
style="width: 100%"
|
||||
stripe
|
||||
size="small"
|
||||
:empty-text="'暂无会话记录'"
|
||||
max-height="300"
|
||||
>
|
||||
<el-table-column prop="recordTime" label="时间" width="160"></el-table-column>
|
||||
<el-table-column prop="userName" label="用户名" width="70"></el-table-column>
|
||||
<el-table-column prop="conversationContent" label="内容" min-width="300" show-overflow-tooltip></el-table-column>
|
||||
</el-table>
|
||||
</el-card>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, computed, onMounted } from 'vue'
|
||||
import { User, Message, OfficeBuilding, Calendar, ArrowRight } from '@element-plus/icons-vue'
|
||||
import { useAuthStore } from '../store/auth'
|
||||
import request from '../utils/request'
|
||||
import { ElMessage } from 'element-plus'
|
||||
|
||||
// 认证状态管理
|
||||
const authStore = useAuthStore()
|
||||
|
||||
// 用户名
|
||||
const username = computed(() => authStore.username)
|
||||
|
||||
// 统计数据
|
||||
const userCount = ref(0)
|
||||
const conversationCount = ref(0)
|
||||
const departmentCount = ref(0)
|
||||
const todayCount = ref(0)
|
||||
|
||||
// 最近会话记录
|
||||
const recentConversations = ref([])
|
||||
|
||||
// 数据转换:将后端返回的会话数据转换为前端所需格式
|
||||
const convertConversationData = (data) => {
|
||||
return data.map(item => ({
|
||||
id: item.Id,
|
||||
recordTime: new Date(item.RecordTime).toLocaleString('zh-CN'),
|
||||
recordTimeUTCStamp: item.RecordTimeUTCStamp,
|
||||
userName: item.UserName,
|
||||
conversationContent: item.ConversationContent,
|
||||
messageType: item.MessageType
|
||||
}))
|
||||
}
|
||||
|
||||
// 获取系统统计数据
|
||||
const fetchStats = async () => {
|
||||
try {
|
||||
// 获取用户列表数据,用于统计
|
||||
const usersData = await request.get('/Admin/QueryUsers')
|
||||
const users = Array.isArray(usersData) ? usersData : usersData.data || []
|
||||
|
||||
// 获取会话记录数据,用于统计
|
||||
const conversationsData = await request.post('/Admin/QueryConversations', {})
|
||||
const conversations = Array.isArray(conversationsData) ? conversationsData : conversationsData.data || []
|
||||
|
||||
// 计算统计数据
|
||||
userCount.value = users.length
|
||||
conversationCount.value = conversations.length
|
||||
|
||||
// 计算部门数量
|
||||
const departments = new Set(users.map(user => user.Department))
|
||||
departmentCount.value = departments.size
|
||||
|
||||
// 计算今日新增会话数
|
||||
const today = new Date().toDateString()
|
||||
const todayConversations = conversations.filter(conv => {
|
||||
return new Date(conv.RecordTime).toDateString() === today
|
||||
})
|
||||
todayCount.value = todayConversations.length
|
||||
|
||||
// 获取最近会话记录
|
||||
await fetchRecentConversations()
|
||||
} catch (error) {
|
||||
console.error('获取系统统计数据失败:', error)
|
||||
ElMessage.error('获取系统统计数据失败')
|
||||
}
|
||||
}
|
||||
|
||||
// 获取最近会话记录
|
||||
const fetchRecentConversations = async () => {
|
||||
try {
|
||||
// 调用API获取最近的5条会话记录
|
||||
const data = await request.post('/Admin/QueryConversations', {})
|
||||
|
||||
// 检查返回数据格式,确保是数组
|
||||
const rawData = Array.isArray(data) ? data : data.data || []
|
||||
|
||||
// 转换数据格式
|
||||
const convertedData = convertConversationData(rawData)
|
||||
|
||||
// 按时间排序(最新的记录在前面),并只显示最近5条
|
||||
recentConversations.value = convertedData
|
||||
.sort((a, b) => {
|
||||
return b.recordTimeUTCStamp - a.recordTimeUTCStamp
|
||||
})
|
||||
.slice(0, 5)
|
||||
} catch (error) {
|
||||
console.error('获取最近会话记录失败:', error)
|
||||
recentConversations.value = []
|
||||
}
|
||||
}
|
||||
|
||||
// 页面初始化
|
||||
onMounted(() => {
|
||||
fetchStats()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.home-container {
|
||||
padding: 20px 0;
|
||||
}
|
||||
|
||||
.stats-container {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
||||
gap: 20px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.stat-card {
|
||||
transition: all 0.3s;
|
||||
|
||||
&:hover {
|
||||
transform: translateY(-5px);
|
||||
box-shadow: var(--box-shadow-light);
|
||||
}
|
||||
}
|
||||
|
||||
.stat-content {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.stat-icon {
|
||||
width: 60px;
|
||||
height: 60px;
|
||||
border-radius: 50%;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
font-size: 24px;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.user-icon {
|
||||
background-color: var(--primary-color);
|
||||
}
|
||||
|
||||
.conversation-icon {
|
||||
background-color: var(--success-color);
|
||||
}
|
||||
|
||||
.department-icon {
|
||||
background-color: var(--warning-color);
|
||||
}
|
||||
|
||||
.today-icon {
|
||||
background-color: var(--danger-color);
|
||||
}
|
||||
|
||||
.stat-info h3 {
|
||||
font-size: 28px;
|
||||
font-weight: 600;
|
||||
margin: 0 0 4px 0;
|
||||
color: var(--text-color);
|
||||
}
|
||||
|
||||
.stat-info p {
|
||||
font-size: 14px;
|
||||
margin: 0;
|
||||
color: var(--text-color-secondary);
|
||||
}
|
||||
|
||||
.recent-conversations-card {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.card-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.view-all-link {
|
||||
color: var(--primary-color);
|
||||
text-decoration: none;
|
||||
font-size: 14px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
|
||||
&:hover {
|
||||
color: #66b1ff;
|
||||
}
|
||||
}
|
||||
|
||||
.system-status-container {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.status-list {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.status-item {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 12px 0;
|
||||
border-bottom: 1px solid var(--border-color-light);
|
||||
|
||||
&:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
}
|
||||
|
||||
.status-label {
|
||||
color: var(--text-color-secondary);
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.status-value {
|
||||
color: var(--text-color);
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
/* 响应式样式 */
|
||||
@media (max-width: 767px) {
|
||||
.home-container {
|
||||
padding: 6px 0;
|
||||
}
|
||||
|
||||
.stats-container {
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.stat-content {
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.stat-icon {
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
.stat-info h3 {
|
||||
font-size: 24px;
|
||||
}
|
||||
|
||||
.status-list {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
142
admin-web/src/views/Login.vue
Normal file
142
admin-web/src/views/Login.vue
Normal file
@@ -0,0 +1,142 @@
|
||||
<template>
|
||||
<div class="login-container">
|
||||
<div class="login-box">
|
||||
<h2 class="login-title">后台管理系统</h2>
|
||||
<el-form ref="loginFormRef" :model="loginForm" :rules="loginRules" label-width="80px">
|
||||
<el-form-item label="用户名" prop="username">
|
||||
<el-input
|
||||
v-model="loginForm.username"
|
||||
placeholder="请输入用户名"
|
||||
prefix-icon="User"
|
||||
clearable
|
||||
></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="密码" prop="password">
|
||||
<el-input
|
||||
v-model="loginForm.password"
|
||||
type="password"
|
||||
placeholder="请输入密码"
|
||||
prefix-icon="Lock"
|
||||
clearable
|
||||
show-password
|
||||
></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" class="login-btn" @click="handleLogin" :loading="loading">
|
||||
登录
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, reactive } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { useAuthStore } from '../store/auth'
|
||||
|
||||
// 表单引用
|
||||
const loginFormRef = ref()
|
||||
|
||||
// 加载状态
|
||||
const loading = ref(false)
|
||||
|
||||
// 登录表单数据
|
||||
const loginForm = reactive({
|
||||
username: '',
|
||||
password: ''
|
||||
})
|
||||
|
||||
// 登录表单验证规则
|
||||
const loginRules = {
|
||||
username: [
|
||||
{ required: true, message: '请输入用户名', trigger: 'blur' }
|
||||
],
|
||||
password: [
|
||||
{ required: true, message: '请输入密码', trigger: 'blur' }
|
||||
]
|
||||
}
|
||||
|
||||
// 路由实例
|
||||
const router = useRouter()
|
||||
|
||||
// 认证状态管理
|
||||
const authStore = useAuthStore()
|
||||
|
||||
// 登录处理
|
||||
const handleLogin = async () => {
|
||||
// 表单验证
|
||||
if (!loginFormRef.value) return
|
||||
|
||||
try {
|
||||
await loginFormRef.value.validate()
|
||||
loading.value = true
|
||||
|
||||
// 调用登录方法
|
||||
const success = authStore.login(loginForm.username, loginForm.password)
|
||||
|
||||
if (success) {
|
||||
// 登录成功,跳转到首页
|
||||
ElMessage.success('登录成功')
|
||||
router.push('/')
|
||||
} else {
|
||||
// 登录失败,显示错误消息
|
||||
ElMessage.error('用户名或密码错误')
|
||||
}
|
||||
} catch (error) {
|
||||
// 表单验证失败
|
||||
console.error('login form validate error:', error)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.login-container {
|
||||
width: 100%;
|
||||
height: 100vh;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
background-color: var(--background-color);
|
||||
transition: background-color 0.3s;
|
||||
}
|
||||
|
||||
.login-box {
|
||||
width: 100%;
|
||||
max-width: 400px;
|
||||
padding: 32px;
|
||||
background-color: var(--background-color);
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: 8px;
|
||||
box-shadow: var(--box-shadow-light);
|
||||
transition: all 0.3s;
|
||||
}
|
||||
|
||||
.login-title {
|
||||
text-align: center;
|
||||
margin-bottom: 24px;
|
||||
color: var(--text-color);
|
||||
}
|
||||
|
||||
.login-btn {
|
||||
width: 100%;
|
||||
margin-top: 16px;
|
||||
}
|
||||
|
||||
.login-footer {
|
||||
margin-top: 24px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/* 响应式样式 */
|
||||
@media (max-width: 767px) {
|
||||
.login-box {
|
||||
margin: 0 6px;
|
||||
padding: 10px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
280
admin-web/src/views/UserList.vue
Normal file
280
admin-web/src/views/UserList.vue
Normal file
@@ -0,0 +1,280 @@
|
||||
<template>
|
||||
<div class="user-list-container">
|
||||
<h2>用户管理</h2>
|
||||
|
||||
<!-- 筛选表单 -->
|
||||
<el-card class="filter-card">
|
||||
<el-form :model="filterForm" inline label-width="80px">
|
||||
<el-form-item label="用户名">
|
||||
<el-input
|
||||
v-model="filterForm.userName"
|
||||
placeholder="请输入用户名"
|
||||
clearable
|
||||
style="width: 200px"
|
||||
></el-input>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="手机号">
|
||||
<el-input
|
||||
v-model="filterForm.phoneNumber"
|
||||
placeholder="请输入手机号"
|
||||
clearable
|
||||
style="width: 200px"
|
||||
></el-input>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="部门">
|
||||
<el-select
|
||||
v-model="filterForm.department"
|
||||
placeholder="请选择部门"
|
||||
clearable
|
||||
style="width: 150px"
|
||||
>
|
||||
<el-option
|
||||
v-for="dept in departmentList"
|
||||
:key="dept"
|
||||
:label="dept"
|
||||
:value="dept"
|
||||
></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="handleQuery">查询</el-button>
|
||||
<el-button @click="handleReset">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
|
||||
<!-- 用户列表表格 -->
|
||||
<el-card class="table-card">
|
||||
<el-table
|
||||
v-loading="loading"
|
||||
:data="userList"
|
||||
style="width: 100%"
|
||||
stripe
|
||||
:empty-text="emptyText"
|
||||
>
|
||||
<el-table-column prop="userName" label="用户名" width="120"></el-table-column>
|
||||
<el-table-column prop="weChatName" label="微信名" width="120"></el-table-column>
|
||||
<el-table-column prop="phoneNumber" label="手机号" width="130">
|
||||
<template #default="scope">
|
||||
<span
|
||||
class="phone-number"
|
||||
@click="scope.row.showFullPhone = !scope.row.showFullPhone"
|
||||
:title="'点击' + (scope.row.showFullPhone ? '隐藏' : '显示') + '完整号码'"
|
||||
>
|
||||
{{ formatPhoneNumber(scope.row.phoneNumber, scope.row.showFullPhone) }}
|
||||
</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="department" label="部门" width="120"></el-table-column>
|
||||
<el-table-column prop="firstLoginTime" label="首次登录时间" width="180">
|
||||
<template #default="scope">
|
||||
{{ formatDateTime(scope.row.firstLoginTime) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column prop="updateTime" label="更新时间" width="180">
|
||||
<template #default="scope">
|
||||
{{ formatDateTime(scope.row.updateTime) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="isDisabled" label="状态" width="100">
|
||||
<template #default="scope">
|
||||
<el-tag :type="scope.row.isDisabled ? 'danger' : 'success'">
|
||||
{{ scope.row.isDisabled ? '禁用' : '启用' }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<!-- 移除分页控件 -->
|
||||
</el-card>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, reactive, onMounted, computed } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import request from '../utils/request'
|
||||
import { formatPhoneNumber, formatDateTime } from '../utils/formatters'
|
||||
|
||||
// 加载状态
|
||||
const loading = ref(false)
|
||||
|
||||
// 移除分页数据
|
||||
// const currentPage = ref(1)
|
||||
// const pageSize = ref(10)
|
||||
// const total = ref(0)
|
||||
|
||||
// 空状态文本
|
||||
const emptyText = computed(() => loading.value ? '加载中...' : '暂无数据')
|
||||
|
||||
// 筛选表单数据
|
||||
const filterForm = reactive({
|
||||
userName: '',
|
||||
phoneNumber: '',
|
||||
department: ''
|
||||
})
|
||||
|
||||
// 用户列表
|
||||
const userList = ref([])
|
||||
|
||||
// 部门列表(用于筛选)
|
||||
const departmentList = ref([])
|
||||
|
||||
// 查询用户列表
|
||||
const handleQuery = () => {
|
||||
fetchUsers()
|
||||
}
|
||||
|
||||
// 重置筛选条件
|
||||
const handleReset = () => {
|
||||
// 重置表单
|
||||
Object.keys(filterForm).forEach(key => {
|
||||
filterForm[key] = ''
|
||||
})
|
||||
fetchUsers()
|
||||
}
|
||||
|
||||
// 移除分页变化处理
|
||||
// const handlePageChange = (page) => {
|
||||
// currentPage.value = page
|
||||
// fetchUsers()
|
||||
// }
|
||||
|
||||
// 切换用户状态(启用/禁用)
|
||||
const handleToggleStatus = (user) => {
|
||||
ElMessage.confirm(
|
||||
`确定要${user.isDisabled ? '启用' : '禁用'}用户「${user.userName}」吗?`,
|
||||
'状态切换',
|
||||
{
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}
|
||||
)
|
||||
.then(() => {
|
||||
// 这里可以调用API切换用户状态
|
||||
// 模拟API调用
|
||||
user.isDisabled = !user.isDisabled
|
||||
ElMessage.success(`${user.isDisabled ? '禁用' : '启用'}成功`)
|
||||
})
|
||||
.catch(() => {
|
||||
// 取消操作
|
||||
})
|
||||
}
|
||||
|
||||
// 获取用户列表
|
||||
const fetchUsers = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
// 构建请求参数
|
||||
// const params = {
|
||||
// userName: filterForm.userName,
|
||||
// phoneNumber: filterForm.phoneNumber,
|
||||
// department: filterForm.department
|
||||
// }
|
||||
|
||||
// 调用API获取用户列表
|
||||
const data = await request.get('/Admin/QueryUsers')//, { params })
|
||||
|
||||
// 检查返回数据格式,确保是数组
|
||||
const rawData = Array.isArray(data) ? data : data.data || []
|
||||
|
||||
// 按首次登录时间排序(最新的用户在前面)
|
||||
userList.value = rawData.sort((a, b) => {
|
||||
// 使用时间戳进行比较,确保正确排序
|
||||
const timeA = new Date(a.firstLoginTime).getTime()
|
||||
const timeB = new Date(b.firstLoginTime).getTime()
|
||||
return timeB - timeA // 降序排列,最新的用户在前面
|
||||
})
|
||||
|
||||
// 提取部门列表
|
||||
const depts = [...new Set(userList.value.map(user => user.department))]
|
||||
departmentList.value = depts.filter(dept => dept)
|
||||
|
||||
// 移除分页逻辑
|
||||
// total.value = userList.value.length
|
||||
} catch (error) {
|
||||
ElMessage.error('获取用户列表失败:' + error.message)
|
||||
userList.value = []
|
||||
// total.value = 0
|
||||
departmentList.value = []
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 页面初始化
|
||||
onMounted(() => {
|
||||
fetchUsers()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.user-list-container {
|
||||
padding: 20px 0;
|
||||
}
|
||||
|
||||
.filter-card {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.table-card {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.pagination-container {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
/* 手机号样式 */
|
||||
.phone-number {
|
||||
cursor: pointer;
|
||||
color: #409eff;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.phone-number:hover {
|
||||
color: #66b1ff;
|
||||
}
|
||||
|
||||
/* 响应式样式 */
|
||||
@media (max-width: 767px) {
|
||||
.user-list-container {
|
||||
padding: 6px 0;
|
||||
}
|
||||
|
||||
.el-form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
}
|
||||
|
||||
.el-form-item {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.el-input,
|
||||
.el-select {
|
||||
width: 100% !important;
|
||||
}
|
||||
|
||||
.el-table {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.el-table-column {
|
||||
padding: 8px 0;
|
||||
}
|
||||
|
||||
.el-button {
|
||||
padding: 6px 12px;
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
17
admin-web/vite.config.js
Normal file
17
admin-web/vite.config.js
Normal file
@@ -0,0 +1,17 @@
|
||||
import { defineConfig } from 'vite'
|
||||
import vue from '@vitejs/plugin-vue'
|
||||
|
||||
// https://vite.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [vue()],
|
||||
server: {
|
||||
proxy: {
|
||||
'/api': {
|
||||
target: 'https://wx-xcx-check.blv-oa.com:4433',
|
||||
changeOrigin: true,
|
||||
secure: true,
|
||||
rewrite: (path) => path.replace(/^\/api/, '')
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user