创建vue项目

This commit is contained in:
2026-02-06 20:19:09 +08:00
parent 3cb15575e6
commit 99c5c5089e
13 changed files with 1680 additions and 0 deletions

12
index.html Normal file
View File

@@ -0,0 +1,12 @@
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<title>Graduation Design WR</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
</body>
</html>

1346
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

18
package.json Normal file
View File

@@ -0,0 +1,18 @@
{
"name": "graduation-design-wr",
"version": "1.0.0",
"private": true,
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
},
"dependencies": {
"vue": "^3.5.0",
"vue-router": "^4.3.0"
},
"devDependencies": {
"@vitejs/plugin-vue": "^5.0.0",
"vite": "^6.0.0"
}
}

125
src/App.vue Normal file
View File

@@ -0,0 +1,125 @@
<template>
<div class="layout">
<aside class="sidebar">
<div class="logo">我的毕业设计</div>
<nav class="nav">
<RouterLink
v-for="item in menu"
:key="item.path"
:to="item.path"
class="nav-item"
active-class="nav-item-active"
>
{{ item.label }}
</RouterLink>
</nav>
</aside>
<main class="content">
<header class="content-header">
<h1>{{ currentTitle }}</h1>
</header>
<section class="content-body">
<RouterView />
</section>
</main>
</div>
</template>
<script setup lang="ts">
import { computed } from 'vue'
import { useRoute, RouterLink, RouterView } from 'vue-router'
const menu = [
{ path: '/', label: '首页', title: '首页' },
{ path: '/analysis', label: '数据分析', title: '数据分析' },
{ path: '/report', label: '报告中心', title: '报告中心' },
{ path: '/settings', label: '系统设置', title: '系统设置' }
]
const route = useRoute()
const currentTitle = computed(() => {
const found = menu.find((item) => item.path === route.path)
return found?.title ?? '页面'
})
</script>
<style scoped>
.layout {
display: flex;
min-height: 100vh;
background: #f5f7fb;
color: #1f2933;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui,
sans-serif;
}
.sidebar {
width: 240px;
background: linear-gradient(180deg, #1e3a8a, #0f172a);
color: #e5e7eb;
padding: 20px 16px;
display: flex;
flex-direction: column;
}
.logo {
font-size: 20px;
font-weight: 600;
margin-bottom: 24px;
}
.nav {
display: flex;
flex-direction: column;
gap: 8px;
}
.nav-item {
padding: 10px 12px;
border-radius: 8px;
color: #e5e7eb;
text-decoration: none;
font-size: 14px;
transition: background 0.2s ease, color 0.2s ease, transform 0.1s ease;
}
.nav-item:hover {
background: rgba(255, 255, 255, 0.08);
transform: translateX(2px);
}
.nav-item-active {
background: #f97316;
color: #111827;
}
.content {
flex: 1;
display: flex;
flex-direction: column;
padding: 24px 28px;
}
.content-header {
padding-bottom: 12px;
border-bottom: 1px solid #e5e7eb;
margin-bottom: 16px;
}
.content-header h1 {
margin: 0;
font-size: 22px;
font-weight: 600;
}
.content-body {
background: #ffffff;
border-radius: 16px;
padding: 20px 24px;
box-shadow: 0 10px 25px rgba(15, 23, 42, 0.08);
min-height: 400px;
}
</style>

10
src/main.ts Normal file
View File

@@ -0,0 +1,10 @@
import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import './style.css'
const app = createApp(App)
app.use(router)
app.mount('#app')

36
src/router/index.ts Normal file
View File

@@ -0,0 +1,36 @@
import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router'
import Home from '../views/Home.vue'
import Analysis from '../views/Analysis.vue'
import Report from '../views/Report.vue'
import Settings from '../views/Settings.vue'
const routes: RouteRecordRaw[] = [
{
path: '/',
name: 'Home',
component: Home
},
{
path: '/analysis',
name: 'Analysis',
component: Analysis
},
{
path: '/report',
name: 'Report',
component: Report
},
{
path: '/settings',
name: 'Settings',
component: Settings
}
]
const router = createRouter({
history: createWebHistory(),
routes
})
export default router

11
src/style.css Normal file
View File

@@ -0,0 +1,11 @@
*,
*::before,
*::after {
box-sizing: border-box;
}
body {
margin: 0;
background: #f5f7fb;
}

24
src/views/Analysis.vue Normal file
View File

@@ -0,0 +1,24 @@
<template>
<div class="page">
<h2>数据分析页</h2>
<p>后续可以在这里放图表统计数据等可视化内容</p>
</div>
</template>
<script setup lang="ts"></script>
<style scoped>
.page h2 {
margin-top: 0;
margin-bottom: 8px;
font-size: 18px;
font-weight: 600;
}
.page p {
margin: 0;
color: #4b5563;
font-size: 14px;
}
</style>

24
src/views/Home.vue Normal file
View File

@@ -0,0 +1,24 @@
<template>
<div class="page">
<h2>欢迎来到首页</h2>
<p>这里可以展示项目的总体介绍关键指标和快捷入口</p>
</div>
</template>
<script setup lang="ts"></script>
<style scoped>
.page h2 {
margin-top: 0;
margin-bottom: 8px;
font-size: 18px;
font-weight: 600;
}
.page p {
margin: 0;
color: #4b5563;
font-size: 14px;
}
</style>

24
src/views/Report.vue Normal file
View File

@@ -0,0 +1,24 @@
<template>
<div class="page">
<h2>报告中心</h2>
<p>在这里管理查看和导出各类报告</p>
</div>
</template>
<script setup lang="ts"></script>
<style scoped>
.page h2 {
margin-top: 0;
margin-bottom: 8px;
font-size: 18px;
font-weight: 600;
}
.page p {
margin: 0;
color: #4b5563;
font-size: 14px;
}
</style>

24
src/views/Settings.vue Normal file
View File

@@ -0,0 +1,24 @@
<template>
<div class="page">
<h2>系统设置</h2>
<p>这里可以配置系统参数主题用户等</p>
</div>
</template>
<script setup lang="ts"></script>
<style scoped>
.page h2 {
margin-top: 0;
margin-bottom: 8px;
font-size: 18px;
font-weight: 600;
}
.page p {
margin: 0;
color: #4b5563;
font-size: 14px;
}
</style>

17
tsconfig.json Normal file
View File

@@ -0,0 +1,17 @@
{
"compilerOptions": {
"target": "ESNext",
"useDefineForClassFields": true,
"module": "ESNext",
"moduleResolution": "bundler",
"strict": true,
"jsx": "preserve",
"resolveJsonModule": true,
"isolatedModules": true,
"esModuleInterop": true,
"lib": ["ESNext", "DOM"],
"skipLibCheck": true,
"types": ["vite/client"]
},
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"]
}

9
vite.config.mts Normal file
View File

@@ -0,0 +1,9 @@
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
export default defineConfig({
plugins: [vue()],
server: {
port: 5173,
}
})