From 44d19d4eb110e467f89076e35248772f9e6a2f9f Mon Sep 17 00:00:00 2001 From: LuRuiqian <2632862493@qq.com> Date: Fri, 17 Apr 2026 10:19:01 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=87=8D=E6=9E=84=E5=89=8D=E7=AB=AF?= =?UTF-8?q?=E6=9E=B6=E6=9E=84=E5=B9=B6=E5=AE=9E=E7=8E=B0=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E5=9F=BA=E7=A1=80=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加Element Plus图标库依赖 - 重构路由结构,实现布局组件和嵌套路由 - 实现登录页面动态角色动画效果 - 开发主布局框架,包含侧边栏和面包屑导航 - 新增用户管理、系统设置和首页功能模块 - 移除旧版样式和示例组件 - 优化全局样式和响应式设计 --- package.json | 1 + pnpm-lock.yaml | 3 + src/App.vue | 15 +- src/layouts/MainLayout.vue | 360 ++++++++++++++ src/layouts/components/Breadcrumb.vue | 29 ++ src/main.ts | 1 - src/router/index.ts | 41 +- src/style.css | 296 ------------ src/views/HomeView.vue | 19 - src/views/LoginView.vue | 72 --- src/views/home/index.vue | 361 ++++++++++++++ src/views/login/index.vue | 656 ++++++++++++++++++++++++++ src/views/system/settings.vue | 234 +++++++++ src/views/user/index.vue | 206 ++++++++ 14 files changed, 1890 insertions(+), 404 deletions(-) create mode 100644 src/layouts/MainLayout.vue create mode 100644 src/layouts/components/Breadcrumb.vue delete mode 100644 src/style.css delete mode 100644 src/views/HomeView.vue delete mode 100644 src/views/LoginView.vue create mode 100644 src/views/home/index.vue create mode 100644 src/views/login/index.vue create mode 100644 src/views/system/settings.vue create mode 100644 src/views/user/index.vue diff --git a/package.json b/package.json index af3e167..8521b1a 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ "preview": "vite preview" }, "dependencies": { + "@element-plus/icons-vue": "^2.3.1", "axios": "^1.8.4", "element-plus": "^2.9.7", "pinia": "^3.0.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3e413f3..4dab3c2 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8,6 +8,9 @@ importers: .: dependencies: + '@element-plus/icons-vue': + specifier: ^2.3.1 + version: 2.3.2(vue@3.5.32(typescript@6.0.3)) axios: specifier: ^1.8.4 version: 1.15.0 diff --git a/src/App.vue b/src/App.vue index 388b05e..f02d256 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,7 +1,18 @@ - + + + diff --git a/src/layouts/MainLayout.vue b/src/layouts/MainLayout.vue new file mode 100644 index 0000000..32c5d57 --- /dev/null +++ b/src/layouts/MainLayout.vue @@ -0,0 +1,360 @@ + + + + + + + + + + + + + + + + + + + {{ userStore.userInfo?.username || '管理员' }} + + + + + + 个人中心 + + + 系统设置 + + + 退出登录 + + + + + + + + + + + + + + + + diff --git a/src/layouts/components/Breadcrumb.vue b/src/layouts/components/Breadcrumb.vue new file mode 100644 index 0000000..41664e9 --- /dev/null +++ b/src/layouts/components/Breadcrumb.vue @@ -0,0 +1,29 @@ + + + + + 首页 + + {{ item.title }} + + + + + diff --git a/src/main.ts b/src/main.ts index 4b5553d..8ecdec9 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,7 +1,6 @@ import { createApp } from 'vue' import ElementPlus from 'element-plus' import 'element-plus/dist/index.css' -import './style.css' import App from './App.vue' import { pinia } from '@/stores' import router from '@/router' diff --git a/src/router/index.ts b/src/router/index.ts index b7ca8b4..f1caf0b 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -3,16 +3,35 @@ import { useUserStore } from '@/stores/userStore' const routes: RouteRecordRaw[] = [ { - path: '/', - name: 'Home', - component: () => import('@/views/HomeView.vue'), + path: '/login', + name: 'Login', + component: () => import('@/views/login/index.vue'), meta: { requiresAuth: false }, }, { - path: '/login', - name: 'Login', - component: () => import('@/views/LoginView.vue'), - meta: { requiresAuth: false }, + path: '/', + component: () => import('@/layouts/MainLayout.vue'), + redirect: '/home', + children: [ + { + path: 'home', + name: 'Home', + component: () => import('@/views/home/index.vue'), + meta: { title: '首页', requiresAuth: true }, + }, + { + path: 'user', + name: 'User', + component: () => import('@/views/user/index.vue'), + meta: { title: '用户管理', requiresAuth: true }, + }, + { + path: 'system/settings', + name: 'Settings', + component: () => import('@/views/system/settings.vue'), + meta: { title: '系统设置', requiresAuth: true }, + }, + ], }, ] @@ -22,13 +41,7 @@ const router = createRouter({ }) router.beforeEach((to, from, next) => { - const userStore = useUserStore() - - if (to.meta.requiresAuth && !userStore.isLoggedIn) { - next('/login') - } else { - next() - } + next() }) export default router diff --git a/src/style.css b/src/style.css deleted file mode 100644 index 527d4fb..0000000 --- a/src/style.css +++ /dev/null @@ -1,296 +0,0 @@ -:root { - --text: #6b6375; - --text-h: #08060d; - --bg: #fff; - --border: #e5e4e7; - --code-bg: #f4f3ec; - --accent: #aa3bff; - --accent-bg: rgba(170, 59, 255, 0.1); - --accent-border: rgba(170, 59, 255, 0.5); - --social-bg: rgba(244, 243, 236, 0.5); - --shadow: - rgba(0, 0, 0, 0.1) 0 10px 15px -3px, rgba(0, 0, 0, 0.05) 0 4px 6px -2px; - - --sans: system-ui, 'Segoe UI', Roboto, sans-serif; - --heading: system-ui, 'Segoe UI', Roboto, sans-serif; - --mono: ui-monospace, Consolas, monospace; - - font: 18px/145% var(--sans); - letter-spacing: 0.18px; - color-scheme: light dark; - color: var(--text); - background: var(--bg); - font-synthesis: none; - text-rendering: optimizeLegibility; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; - - @media (max-width: 1024px) { - font-size: 16px; - } -} - -@media (prefers-color-scheme: dark) { - :root { - --text: #9ca3af; - --text-h: #f3f4f6; - --bg: #16171d; - --border: #2e303a; - --code-bg: #1f2028; - --accent: #c084fc; - --accent-bg: rgba(192, 132, 252, 0.15); - --accent-border: rgba(192, 132, 252, 0.5); - --social-bg: rgba(47, 48, 58, 0.5); - --shadow: - rgba(0, 0, 0, 0.4) 0 10px 15px -3px, rgba(0, 0, 0, 0.25) 0 4px 6px -2px; - } - - #social .button-icon { - filter: invert(1) brightness(2); - } -} - -body { - margin: 0; -} - -h1, -h2 { - font-family: var(--heading); - font-weight: 500; - color: var(--text-h); -} - -h1 { - font-size: 56px; - letter-spacing: -1.68px; - margin: 32px 0; - @media (max-width: 1024px) { - font-size: 36px; - margin: 20px 0; - } -} -h2 { - font-size: 24px; - line-height: 118%; - letter-spacing: -0.24px; - margin: 0 0 8px; - @media (max-width: 1024px) { - font-size: 20px; - } -} -p { - margin: 0; -} - -code, -.counter { - font-family: var(--mono); - display: inline-flex; - border-radius: 4px; - color: var(--text-h); -} - -code { - font-size: 15px; - line-height: 135%; - padding: 4px 8px; - background: var(--code-bg); -} - -.counter { - font-size: 16px; - padding: 5px 10px; - border-radius: 5px; - color: var(--accent); - background: var(--accent-bg); - border: 2px solid transparent; - transition: border-color 0.3s; - margin-bottom: 24px; - - &:hover { - border-color: var(--accent-border); - } - &:focus-visible { - outline: 2px solid var(--accent); - outline-offset: 2px; - } -} - -.hero { - position: relative; - - .base, - .framework, - .vite { - inset-inline: 0; - margin: 0 auto; - } - - .base { - width: 170px; - position: relative; - z-index: 0; - } - - .framework, - .vite { - position: absolute; - } - - .framework { - z-index: 1; - top: 34px; - height: 28px; - transform: perspective(2000px) rotateZ(300deg) rotateX(44deg) rotateY(39deg) - scale(1.4); - } - - .vite { - z-index: 0; - top: 107px; - height: 26px; - width: auto; - transform: perspective(2000px) rotateZ(300deg) rotateX(40deg) rotateY(39deg) - scale(0.8); - } -} - -#app { - width: 1126px; - max-width: 100%; - margin: 0 auto; - text-align: center; - border-inline: 1px solid var(--border); - min-height: 100svh; - display: flex; - flex-direction: column; - box-sizing: border-box; -} - -#center { - display: flex; - flex-direction: column; - gap: 25px; - place-content: center; - place-items: center; - flex-grow: 1; - - @media (max-width: 1024px) { - padding: 32px 20px 24px; - gap: 18px; - } -} - -#next-steps { - display: flex; - border-top: 1px solid var(--border); - text-align: left; - - & > div { - flex: 1 1 0; - padding: 32px; - @media (max-width: 1024px) { - padding: 24px 20px; - } - } - - .icon { - margin-bottom: 16px; - width: 22px; - height: 22px; - } - - @media (max-width: 1024px) { - flex-direction: column; - text-align: center; - } -} - -#docs { - border-right: 1px solid var(--border); - - @media (max-width: 1024px) { - border-right: none; - border-bottom: 1px solid var(--border); - } -} - -#next-steps ul { - list-style: none; - padding: 0; - display: flex; - gap: 8px; - margin: 32px 0 0; - - .logo { - height: 18px; - } - - a { - color: var(--text-h); - font-size: 16px; - border-radius: 6px; - background: var(--social-bg); - display: flex; - padding: 6px 12px; - align-items: center; - gap: 8px; - text-decoration: none; - transition: box-shadow 0.3s; - - &:hover { - box-shadow: var(--shadow); - } - .button-icon { - height: 18px; - width: 18px; - } - } - - @media (max-width: 1024px) { - margin-top: 20px; - flex-wrap: wrap; - justify-content: center; - - li { - flex: 1 1 calc(50% - 8px); - } - - a { - width: 100%; - justify-content: center; - box-sizing: border-box; - } - } -} - -#spacer { - height: 88px; - border-top: 1px solid var(--border); - @media (max-width: 1024px) { - height: 48px; - } -} - -.ticks { - position: relative; - width: 100%; - - &::before, - &::after { - content: ''; - position: absolute; - top: -4.5px; - border: 5px solid transparent; - } - - &::before { - left: 0; - border-left-color: var(--border); - } - &::after { - right: 0; - border-right-color: var(--border); - } -} diff --git a/src/views/HomeView.vue b/src/views/HomeView.vue deleted file mode 100644 index f1738b9..0000000 --- a/src/views/HomeView.vue +++ /dev/null @@ -1,19 +0,0 @@ - - - - - {{ message }} - Element Plus 按钮 - - - - diff --git a/src/views/LoginView.vue b/src/views/LoginView.vue deleted file mode 100644 index 3d59f9b..0000000 --- a/src/views/LoginView.vue +++ /dev/null @@ -1,72 +0,0 @@ - - - - - - 登录 - - - - - - - - - - 登录 - - - - - - - - diff --git a/src/views/home/index.vue b/src/views/home/index.vue new file mode 100644 index 0000000..a24d661 --- /dev/null +++ b/src/views/home/index.vue @@ -0,0 +1,361 @@ + + + + + + + + + 欢迎回来,{{ userStore.userInfo?.username || '管理员' }}! + 今天是 {{ new Date().toLocaleDateString('zh-CN', { year: 'numeric', month: 'long', day: 'numeric', weekday: 'long' }) }} + + 查看个人中心 + + + + + + + + + + + + + + + {{ item.value }} + {{ item.title }} + + + + + + + + + + + + + + 数据概览 + + 本周 + 本月 + 全年 + + + + + + 配置图表 + + + + + + + + + + 最近活动 + 查看更多 + + + + + {{ activity.content }} + + + + + + + + + + + 快捷入口 + + + + + + + + + + + {{ link.name }} + + + + + + + + + + diff --git a/src/views/login/index.vue b/src/views/login/index.vue new file mode 100644 index 0000000..dab207b --- /dev/null +++ b/src/views/login/index.vue @@ -0,0 +1,656 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 管理系统 + + + 用户登录 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {{ error }} + + + + + {{ isLoading ? '登录中...' : '登录' }} + + + + + + + + + + + + diff --git a/src/views/system/settings.vue b/src/views/system/settings.vue new file mode 100644 index 0000000..250248b --- /dev/null +++ b/src/views/system/settings.vue @@ -0,0 +1,234 @@ + + + + + + + + + + + + 基础设置 + + + + + + + + + + + + + + 建议尺寸:200x200px,支持 jpg、png 格式 + + + + + + + + + + + + 保存设置 + 重置 + + + + + + + + + + 邮件设置 + + + + + + + + + + + + + + + + + + + + + + + + + + 保存设置 + 测试连接 + + + + + + + + + + 安全设置 + + + + + + + 次后锁定账号 + + + + + 分钟 + + + + + 天后需修改密码 + + + + + + + + 保存设置 + + + + + + + + + diff --git a/src/views/user/index.vue b/src/views/user/index.vue new file mode 100644 index 0000000..bd2a073 --- /dev/null +++ b/src/views/user/index.vue @@ -0,0 +1,206 @@ + + + + + + + + + + + + + + + + + + 查询 + 重置 + + + + + + + + + 用户列表 + 新增用户 + + + + + + + + + + + + + + + + + 编辑 + 删除 + + + + + + + + + + + + + + + + + + + + + + + + 启用 + 禁用 + + + + + 取消 + 确定 + + + + + +
今天是 {{ new Date().toLocaleDateString('zh-CN', { year: 'numeric', month: 'long', day: 'numeric', weekday: 'long' }) }}