编写页头组件

This commit is contained in:
bicey 2024-05-16 22:47:12 +08:00
parent f2e5df0e5e
commit b9ce5813fd
14 changed files with 818 additions and 354 deletions

View File

@ -7,10 +7,60 @@
# 开发进度
- [ ] 项目基本框架
- [ ] 基本组件设计header、aside、main
- [ ] 基本组件布局
......
- [ ] 页面路由
- [ ] 数据请求
## 登录界面
- [x] 基本组件布局
- [x] 基本方法
- [ ] 对接后端
- [ ] 优化界面样式
## 主页
### header
- [x] 基本界面
- [x] 基本方法
- [ ] 优化界面样式
### aside
- [ ] 基本界面
- [ ] 基本方法
- [ ] 优化界面样式
### footer
- [ ] 基本界面
- [ ] 基本方法
- [ ] 优化界面样式
### main
- [ ] 基本界面
- [ ] 基本方法
- [ ] 优化界面样式
## 内容页面
### 管理员
- [ ] 数据展示
- [ ] 基本功能
- [ ] 基本方法
- [ ] 接入后端
### 饲养员
- [ ] 数据展示
- [ ] 基本功能
- [ ] 基本方法
- [ ] 接入后端
### 兽医
- [ ] 数据展示
- [ ] 基本功能
- [ ] 基本方法
- [ ] 接入后端

View File

@ -1,13 +1,13 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<head>
<meta charset="UTF-8">
<link rel="icon" href="/favicon.ico">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Vite App</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.js"></script>
</body>
<title>动物信息管理系统</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.js"></script>
</body>
</html>

686
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -9,7 +9,10 @@
"preview": "vite preview"
},
"dependencies": {
"@element-plus/icons-vue": "^2.3.1",
"element-plus": "^2.7.3",
"unplugin-icons": "^0.19.0",
"vite-plugin-inspect": "^0.8.4",
"vue": "^3.4.21",
"vue-router": "^4.3.2"
},

View File

@ -1,44 +0,0 @@
<script setup>
defineProps({
msg: {
type: String,
required: true
}
})
</script>
<template>
<div class="greetings">
<h1 class="green">{{ msg }}</h1>
<h3>
Youve successfully created a project with
<a href="https://vitejs.dev/" target="_blank" rel="noopener">Vite</a> +
<a href="https://vuejs.org/" target="_blank" rel="noopener">Vue 3</a>.
</h3>
</div>
</template>
<style scoped>
h1 {
font-weight: 500;
font-size: 2.6rem;
position: relative;
top: -10px;
}
h3 {
font-size: 1.2rem;
}
.greetings h1,
.greetings h3 {
text-align: center;
}
@media (min-width: 1024px) {
.greetings h1,
.greetings h3 {
text-align: left;
}
}
</style>

View File

@ -1,88 +0,0 @@
<script setup>
import WelcomeItem from './WelcomeItem.vue'
import DocumentationIcon from './icons/IconDocumentation.vue'
import ToolingIcon from './icons/IconTooling.vue'
import EcosystemIcon from './icons/IconEcosystem.vue'
import CommunityIcon from './icons/IconCommunity.vue'
import SupportIcon from './icons/IconSupport.vue'
</script>
<template>
<WelcomeItem>
<template #icon>
<DocumentationIcon />
</template>
<template #heading>Documentation</template>
Vues
<a href="https://vuejs.org/" target="_blank" rel="noopener">official documentation</a>
provides you with all information you need to get started.
</WelcomeItem>
<WelcomeItem>
<template #icon>
<ToolingIcon />
</template>
<template #heading>Tooling</template>
This project is served and bundled with
<a href="https://vitejs.dev/guide/features.html" target="_blank" rel="noopener">Vite</a>. The
recommended IDE setup is
<a href="https://code.visualstudio.com/" target="_blank" rel="noopener">VSCode</a> +
<a href="https://github.com/johnsoncodehk/volar" target="_blank" rel="noopener">Volar</a>. If
you need to test your components and web pages, check out
<a href="https://www.cypress.io/" target="_blank" rel="noopener">Cypress</a> and
<a href="https://on.cypress.io/component" target="_blank" rel="noopener"
>Cypress Component Testing</a
>.
<br />
More instructions are available in <code>README.md</code>.
</WelcomeItem>
<WelcomeItem>
<template #icon>
<EcosystemIcon />
</template>
<template #heading>Ecosystem</template>
Get official tools and libraries for your project:
<a href="https://pinia.vuejs.org/" target="_blank" rel="noopener">Pinia</a>,
<a href="https://router.vuejs.org/" target="_blank" rel="noopener">Vue Router</a>,
<a href="https://test-utils.vuejs.org/" target="_blank" rel="noopener">Vue Test Utils</a>, and
<a href="https://github.com/vuejs/devtools" target="_blank" rel="noopener">Vue Dev Tools</a>. If
you need more resources, we suggest paying
<a href="https://github.com/vuejs/awesome-vue" target="_blank" rel="noopener">Awesome Vue</a>
a visit.
</WelcomeItem>
<WelcomeItem>
<template #icon>
<CommunityIcon />
</template>
<template #heading>Community</template>
Got stuck? Ask your question on
<a href="https://chat.vuejs.org" target="_blank" rel="noopener">Vue Land</a>, our official
Discord server, or
<a href="https://stackoverflow.com/questions/tagged/vue.js" target="_blank" rel="noopener"
>StackOverflow</a
>. You should also subscribe to
<a href="https://news.vuejs.org" target="_blank" rel="noopener">our mailing list</a> and follow
the official
<a href="https://twitter.com/vuejs" target="_blank" rel="noopener">@vuejs</a>
twitter account for latest news in the Vue world.
</WelcomeItem>
<WelcomeItem>
<template #icon>
<SupportIcon />
</template>
<template #heading>Support Vue</template>
As an independent project, Vue relies on community backing for its sustainability. You can help
us by
<a href="https://vuejs.org/sponsor/" target="_blank" rel="noopener">becoming a sponsor</a>.
</WelcomeItem>
</template>

View File

@ -1,87 +0,0 @@
<template>
<div class="item">
<i>
<slot name="icon"></slot>
</i>
<div class="details">
<h3>
<slot name="heading"></slot>
</h3>
<slot></slot>
</div>
</div>
</template>
<style scoped>
.item {
margin-top: 2rem;
display: flex;
position: relative;
}
.details {
flex: 1;
margin-left: 1rem;
}
i {
display: flex;
place-items: center;
place-content: center;
width: 32px;
height: 32px;
color: var(--color-text);
}
h3 {
font-size: 1.2rem;
font-weight: 500;
margin-bottom: 0.4rem;
color: var(--color-heading);
}
@media (min-width: 1024px) {
.item {
margin-top: 0;
padding: 0.4rem 0 1rem calc(var(--section-gap) / 2);
}
i {
top: calc(50% - 25px);
left: -26px;
position: absolute;
border: 1px solid var(--color-border);
background: var(--color-background);
border-radius: 8px;
width: 50px;
height: 50px;
}
.item:before {
content: ' ';
border-left: 1px solid var(--color-border);
position: absolute;
left: 0;
bottom: calc(50% + 25px);
height: calc(50% - 25px);
}
.item:after {
content: ' ';
border-left: 1px solid var(--color-border);
position: absolute;
left: 0;
top: calc(50% + 25px);
height: calc(50% - 25px);
}
.item:first-of-type:before {
display: none;
}
.item:last-of-type:after {
display: none;
}
}
</style>

View File

@ -1,16 +1,68 @@
<script>
import {HomeFilled, SwitchButton} from "@element-plus/icons-vue";
export default {
name: "ZooHeader"
name: "ZooHeader",
computed: {
HomeFilled() {
return HomeFilled
},
SwitchButton() {
return SwitchButton
}
},
data() {
return {
visible: false,
}
},
methods: {
// 退
logout() {
console.log("logout");
sessionStorage.removeItem('isLogin')
this.$router.push('/login');
}
}
}
</script>
<template>
<div id="header">
<slot>我是头部插槽</slot>
<div class="to-home left">
<el-button :icon="HomeFilled" size="large" @click="$router.push('/panel/home')">返回首页</el-button>
</div>
动物信息管理系统
<div class="logout right">
<el-popover :visible="visible" placement="top" :width="160" trigger="click">
<p>是否退出登录</p>
<div style="text-align: right; margin: 0">
<el-button size="small" text @click="visible = false">取消</el-button>
<el-button size="small" type="primary" @click="visible = false;logout()">确认</el-button>
</div>
<template #reference>
<el-button :icon="SwitchButton" size="large" @click="visible = true">退出登录</el-button>
</template>
</el-popover>
</div>
</div>
</template>
<style scoped>
#header {
text-align: center;
font-size: 32px;
line-height: 60px;
background-color: whitesmoke;
}
.to-home {
margin-left: 20px;
}
.logout {
margin-right: 20px;
}
</style>

View File

@ -1,10 +1,16 @@
import './assets/main.css'
import './assets/common.css'
import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
const app = createApp(App)
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
app.component(key, component)
}
app.use(router)
app.mount('#app')

View File

@ -1,6 +1,15 @@
<script>
export default {
name: "ZooHome"
name: "ZooHome",
data() {
return {
}
},
methods: {
}
}
</script>

View File

@ -1,8 +1,10 @@
<script>
export default {
name: "ZooContainer",
data() {
return {
tip: '',
form: {
name: '张三',
password: '123456'
@ -11,42 +13,60 @@ export default {
},
methods: {
onSubmit() {
console.log('点击了按钮')
this.$router.push({
path: '/panel/home',
})
}
}
console.log('点击了登录按钮')
if (!this.form.name || !this.form.password) {
//
return ElMessage({
message: '用户名和密码不能为空',
type: 'warning',
})
} else {
//
sessionStorage.setItem('isLogin', 'isLogin');
this.$router.push('/panel/home')
}
},
reset() {
this.form = {}
},
},
}
</script>
<template>
<div class="root center">
<el-card style="width: 480px" shadow="always">
<el-form :model="form" label-width="auto" style="max-width: 600px">
<el-form-item label="用户名">
<el-input v-model="form.name" style="width: 240px" placeholder="请输入用户名"/>
</el-form-item>
<el-form-item label="密码">
<el-input
v-model="form.password"
style="width: 240px"
type="password"
placeholder="请输入密码"
show-password
/>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="onSubmit">登录</el-button>
<el-button>重置</el-button>
</el-form-item>
</el-form>
</el-card>
<div class="root">
<div class="center">
<el-card style="width: 480px" shadow="always" header="登录">
<el-form :model="form" label-width="auto" style="max-width: 600px">
<el-form-item label="用户名">
<el-input v-model="form.name" style="width: 240px" placeholder="请输入用户名"/>
</el-form-item>
<el-form-item label="密码">
<el-input
v-model="form.password"
style="width: 240px"
type="password"
placeholder="请输入密码"
show-password
/>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="onSubmit">登录</el-button>
<el-button @click="reset">重置</el-button>
</el-form-item>
</el-form>
</el-card>
</div>
</div>
</template>
<style scoped>
.root {
width: 100%;
height: 700px;
background-color: skyblue;
}
</style>

View File

@ -1,27 +1,23 @@
<script>
// import {
// Document,
// Menu as IconMenu,
// Location,
// Setting,
// } from '@element-plus/icons-vue'
import ZooHeader from "@/components/ZooHeader.vue";
import ZooAside from "@/components/ZooAside.vue";
import ZooMain from "@/components/ZooMain.vue";
import ZooFooter from "@/components/ZooFooter.vue";
import {SwitchButton} from "@element-plus/icons-vue";
export default {
name: "ZooPanel",
computed: {
SwitchButton() {
return SwitchButton
}
},
data() {
return {
}
},
components: {
// Document,
// IconMenu,
// Location,
// Setting
ZooHeader,
ZooAside,
ZooMain,
@ -44,7 +40,7 @@ export default {
.root {
width: 1300px;
height: 700px;
background-color: pink;
/*background-color: pink;*/
}
.aside {
width: 200px;

View File

@ -20,10 +20,12 @@ const router = createRouter({
{
path: '/panel',
component:ZooPanel,
meta:{isAuth: true},//需要权限
children:[
{
path: 'home',
component: ZooHome
component: ZooHome,
meta:{isAuth: true},//需要权限
},
]
},
@ -34,4 +36,19 @@ const router = createRouter({
]
})
router.beforeEach((to, from, next) => {
//判断页面是否需要登录权限才可进入
if (to.meta.isAuth) {
if (!sessionStorage.getItem('isLogin')) {
router.replace({
path: '/login',
})
} else {
next()
}
} else {
next()
}
})
export default router