Skip to content

Commit e79fe46

Browse files
author
clb
committed
小修改
1 parent 14fba12 commit e79fe46

File tree

6 files changed

+351
-240
lines changed

6 files changed

+351
-240
lines changed

index.html

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
<!DOCTYPE html>
22
<html lang="en">
3-
<head>
4-
<meta charset="UTF-8">
5-
<link rel="icon" href="/favicon.ico">
6-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7-
<title>Vite App</title>
8-
</head>
9-
<body>
10-
<div id="app"></div>
11-
<script type="module" src="/src/main.js"></script>
12-
</body>
13-
</html>
3+
4+
<head>
5+
<meta charset="UTF-8">
6+
<link rel="icon" href="/favicon.ico">
7+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
8+
<title>图书借阅管理系统</title>
9+
</head>
10+
11+
<body>
12+
<div id="app"></div>
13+
<script type="module" src="/src/main.js"></script>
14+
</body>
15+
16+
</html>

src/components/HeaderView.vue

Lines changed: 33 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
<script setup>
2-
3-
import {useDark} from "@vueuse/core";
4-
import {useReaderStore} from "@/stores/reader.js";
5-
import {useTokenStore} from "@/stores/token.js";
6-
import {useAdminStore} from "@/stores/admin.js";
7-
import {ref} from 'vue'
8-
import {Link, Moon, Sunny, SwitchButton} from "@element-plus/icons-vue";
2+
import { useDark } from "@vueuse/core";
3+
import { useReaderStore } from "@/stores/reader.js";
4+
import { useTokenStore } from "@/stores/token.js";
5+
import { useAdminStore } from "@/stores/admin.js";
6+
import { ref } from "vue";
7+
import { Link, Moon, Sunny, SwitchButton } from "@element-plus/icons-vue";
98
import router from "@/router/index.js";
109
1110
const adminStore = useAdminStore();
@@ -27,21 +26,20 @@ const isDark = useDark();
2726
2827
// 头像下拉菜单命令
2928
const handleCommand = function (command) {
30-
if (command === 'logout') {
29+
if (command === "logout") {
3130
// 退出后清除token和reader信息
3231
tokenStore.setToken(null);
3332
readerStore.setReader(null);
34-
router.push('/login');
35-
} else if (command === 'frontend') {
36-
window.open('https://github.com/TankingCao/vue3-vite');
37-
} else if (command === 'backend') {
38-
window.open('https://github.com/TankingCao/java_design');
33+
router.push("/login");
34+
} else if (command === "frontend") {
35+
window.open("https://github.com/TankingCao/vue3-vite");
36+
} else if (command === "backend") {
37+
window.open("https://github.com/TankingCao/java_design");
3938
}
4039
};
4140
4241
// 头像图片
43-
const url = ref('https://pic.imgdb.cn/item/65a271fe871b83018a8f9a8f.gif');
44-
42+
const url = ref("https://pic.imgdb.cn/item/65a271fe871b83018a8f9a8f.gif");
4543
</script>
4644

4745
<template>
@@ -50,8 +48,13 @@ const url = ref('https://pic.imgdb.cn/item/65a271fe871b83018a8f9a8f.gif');
5048
<!--头像-->
5149
<el-dropdown @command="handleCommand">
5250
<el-menu-item index="1">
53-
<el-avatar @click="router.push('/user')" shape="square"
54-
:size="42" :fit="'cover'" :src="url"/>
51+
<el-avatar
52+
@click="router.push('/user')"
53+
shape="square"
54+
:size="42"
55+
:fit="'cover'"
56+
:src="url"
57+
/>
5558
</el-menu-item>
5659
<template #dropdown>
5760
<el-dropdown-menu>
@@ -64,7 +67,9 @@ const url = ref('https://pic.imgdb.cn/item/65a271fe871b83018a8f9a8f.gif');
6467
</el-dropdown-item>
6568

6669
<el-dropdown-item command="logout">
67-
<el-button link type="danger" :icon="SwitchButton">退出登录</el-button>
70+
<el-button link type="danger" :icon="SwitchButton"
71+
>退出登录</el-button
72+
>
6873
</el-dropdown-item>
6974
</el-dropdown-menu>
7075
</template>
@@ -81,19 +86,22 @@ const url = ref('https://pic.imgdb.cn/item/65a271fe871b83018a8f9a8f.gif');
8186
<el-tag v-if="isAdmin" type="warning" size="large" round>
8287
管理员
8388
</el-tag>
89+
<el-tag v-else type="primary" size="large" round> 读者 </el-tag>
8490
</el-menu-item>
8591

8692
<!--深浅色图标-->
8793
<el-menu-item>
8894
<el-switch
89-
v-model="isDark" size="large"
90-
:active-action-icon="Moon"
91-
:inactive-action-icon="Sunny"
92-
style="--el-switch-on-color: rgba(19,206,102,0.7); --el-switch-off-color: rgba(141,141,141,0.79)"/>
95+
v-model="isDark"
96+
size="large"
97+
:active-action-icon="Moon"
98+
:inactive-action-icon="Sunny"
99+
style="
100+
--el-switch-on-color: rgba(19, 206, 102, 0.7);
101+
--el-switch-off-color: rgba(141, 141, 141, 0.79);
102+
"
103+
/>
93104
</el-menu-item>
94-
95105
</el-menu>
96106
</div>
97107
</template>
98-
99-

src/components/SideView.vue

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,58 +2,60 @@
22
<el-menu v-model="activeIndex" class="el-menu-vertical-demo">
33
<el-menu-item index="1" @click="route">
44
<el-icon>
5-
<search/>
5+
<search />
66
</el-icon>
77
<el-button link :type="'primary'">图书信息</el-button>
88
</el-menu-item>
99

10-
<el-menu-item v-if="!adminStore.isAdmin" index="2" @click="router.push('/borrow')">
10+
<el-menu-item
11+
v-if="!adminStore.isAdmin"
12+
index="2"
13+
@click="router.push('/borrow')"
14+
>
1115
<el-icon>
12-
<search/>
16+
<search />
1317
</el-icon>
1418
<el-button link :type="'primary'">借阅记录</el-button>
1519
</el-menu-item>
1620

1721
<el-menu-item index="3" @click="router.push('/user')">
1822
<el-icon>
19-
<setting/>
23+
<setting />
2024
</el-icon>
2125
<el-button link :type="'primary'">个人信息</el-button>
2226
</el-menu-item>
2327

24-
<el-menu-item index="4" @click="router.push('/reader')">
28+
<el-menu-item
29+
v-if="adminStore.isAdmin"
30+
index="4"
31+
@click="router.push('/reader')"
32+
>
2533
<el-icon>
26-
<setting/>
34+
<setting />
2735
</el-icon>
2836
<el-button link :type="'primary'">用户管理</el-button>
2937
</el-menu-item>
3038

3139
<el-menu-item index="5" @click="logout">
3240
<el-icon>
33-
<switch-button/>
41+
<switch-button />
3442
</el-icon>
3543
<el-button link :type="'danger'">退出登录</el-button>
3644
</el-menu-item>
37-
3845
</el-menu>
3946
</template>
4047

4148
<script lang="ts" setup>
49+
import { Search, Setting, SwitchButton } from "@element-plus/icons-vue";
4250
43-
import {
44-
Search,
45-
Setting,
46-
SwitchButton,
47-
} from '@element-plus/icons-vue'
48-
49-
import {ref} from 'vue';
51+
import { ref } from "vue";
5052
51-
const activeIndex = ref('1');
53+
const activeIndex = ref("1");
5254
53-
import {useRouter} from "vue-router";
54-
import {useTokenStore} from "@/stores/token";
55-
import {useReaderStore} from "@/stores/reader";
56-
import {useAdminStore} from "@/stores/admin";
55+
import { useRouter } from "vue-router";
56+
import { useTokenStore } from "@/stores/token";
57+
import { useReaderStore } from "@/stores/reader";
58+
import { useAdminStore } from "@/stores/admin";
5759
5860
const adminStore = useAdminStore();
5961
const tokenStore = useTokenStore();
@@ -66,15 +68,14 @@ const logout = () => {
6668
tokenStore.setToken(null);
6769
readerStore.setReader(null);
6870
adminStore.setAdmin(null);
69-
router.push('/login');
70-
}
71+
router.push("/login");
72+
};
7173
72-
const route = ()=>{
74+
const route = () => {
7375
if (adminStore.isAdmin) {
74-
router.push('/admin/book');
75-
}else{
76-
router.push('/book');
76+
router.push("/admin/book");
77+
} else {
78+
router.push("/book");
7779
}
78-
}
79-
80+
};
8081
</script>

0 commit comments

Comments
 (0)