我将使用Element Plus组件库美化您的页面,添加布局容器、导航菜单、错误提示和页脚样式。以下是优化后的代码:
<template>
<el-container id="app" direction="vertical">
<el-header class="app-header">
<div class="header-content">
<h1 class="app-title">简易地理信息标注平台</h1>
<el-menu
mode="horizontal"
:default-active="$route.path"
background-color="#409EFF"
text-color="#fff"
active-text-color="#ffd04b"
router
>
<el-menu-item index="/">首页</el-menu-item>
<!-- 可以在此处添加更多导航项 -->
</el-menu>
</div>
</el-header>
<el-main class="app-main">
<el-alert
v-if="hasError"
:title="errorMessage"
type="error"
show-icon
class="error-alert"
:closable="false"
/>
<router-view />
</el-main>
<el-footer class="app-footer">
<div class="footer-content">
<p>© 2024 地理信息标注平台</p>
<div class="footer-links">
<el-link type="info" href="#" :underline="false">关于我们</el-link>
<el-divider direction="vertical" />
<el-link type="info" href="#" :underline="false">帮助中心</el-link>
<el-divider direction="vertical" />
<el-link type="info" href="#" :underline="false">联系我们</el-link>
</div>
</div>
</el-footer>
</el-container>
</template>
<script>
import { ref } from 'vue';
export default {
name: 'App',
setup() {
const hasError = ref(false);
const errorMessage = ref('示例错误信息:数据加载失败');
return {
hasError,
errorMessage,
};
},
};
</script>
<style scoped>
#app {
min-height: 100vh;
font-family: 'Helvetica Neue', Helvetica, 'PingFang SC', 'Hiragino Sans GB', Arial, sans-serif;
}
.app-header {
background: linear-gradient(135deg, #409EFF, #337ecc);
color: white;
padding: 0;
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
z-index: 1000;
}
.header-content {
display: flex;
justify-content: space-between;
align-items: center;
width: 100%;
max-width: 1200px;
margin: 0 auto;
padding: 0 20px;
}
.app-title {
font-size: 1.5rem;
margin: 0;
font-weight: 600;
text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
}
.app-main {
max-width: 1200px;
margin: 0 auto;
padding: 20px;
width: 100%;
}
.error-alert {
margin-bottom: 20px;
}
.app-footer {
background-color: #f5f7fa;
color: #606266;
padding: 20px 0;
box-shadow: 0 -2px 4px rgba(0, 0, 0, 0.05);
}
.footer-content {
max-width: 1200px;
margin: 0 auto;
text-align: center;
}
.footer-links {
margin-top: 10px;
display: flex;
justify-content: center;
align-items: center;
}
@media (max-width: 768px) {
.header-content {
flex-direction: column;
padding: 10px;
}
.app-title {
margin-bottom: 10px;
}
.el-menu {
width: 100%;
}
}
</style>
主要改进:
-
布局优化:
- 使用
el-container 容器组件构建整体布局
- 响应式设计,适配移动设备
- 添加最大宽度限制(1200px)保持内容居中
-
头部美化:
- 渐变蓝色背景 (
linear-gradient(135deg, #409EFF, #337ecc))
- Element Plus 导航菜单 (支持未来扩展)
- 响应式布局(小屏幕时垂直排列)
-
错误提示:
- 使用
el-alert 组件替代普通错误提示
- 添加错误图标和醒目样式
-
页脚改进:
- 添加链接区域(关于我们、帮助中心、联系我们)
- 使用分隔线美化链接
- 浅色背景配合柔和阴影
-
视觉增强:
- 添加阴影效果提升层次感
- 使用 Element Plus 的配色方案
- 优化字体和间距
-
响应式设计:
- 移动设备适配(小屏幕时标题和菜单垂直排列)
- 内容区域自动调整内边距
这个设计保持了原有的功能,同时通过Element Plus组件库提供了更现代、专业的UI界面,并增强了用户体验。