增加头部名称

This commit is contained in:
zrh050423 2024-12-21 16:27:06 +08:00
parent 6f6e2d5200
commit 22409d3bd5
3 changed files with 15 additions and 4 deletions

View File

@ -22,7 +22,7 @@
<el-dropdown-item> <el-dropdown-item>
<el-icon><Setting /></el-icon> <el-icon><Setting /></el-icon>
</el-dropdown-item> </el-dropdown-item>
<el-dropdown-item divided> <el-dropdown-item divided @click="logout">
<el-icon><SwitchButton /></el-icon>退 <el-icon><SwitchButton /></el-icon>退
</el-dropdown-item> </el-dropdown-item>
</el-dropdown-menu> </el-dropdown-menu>
@ -37,10 +37,18 @@
<script setup> <script setup>
import { ref } from 'vue' import { ref } from 'vue'
import { User, CaretBottom, UserFilled, Setting, SwitchButton } from '@element-plus/icons-vue' import { User, CaretBottom, UserFilled, Setting, SwitchButton } from '@element-plus/icons-vue'
import router from "@/router/index.js";
const userInfo = ref({ const userInfo = ref({
username: sessionStorage.getItem('username') || '未登录', username: sessionStorage.getItem('username') || '未登录',
}) })
const logout = () => {
// sessionStorage
sessionStorage.clear()
//
router.push('/login')
}
</script> </script>
<style scoped> <style scoped>

View File

@ -60,7 +60,7 @@
<span>文字识别</span> <span>文字识别</span>
</el-menu-item> </el-menu-item>
<el-menu-item index="/user"> <el-menu-item index="/user" v-if="isPermission">
<el-icon><User /></el-icon> <el-icon><User /></el-icon>
<span>用户管理</span> <span>用户管理</span>
</el-menu-item> </el-menu-item>
@ -74,7 +74,7 @@ import { House, Document, ChatLineRound, Files, DataLine, User } from '@element-
const isCollapse = ref(false) const isCollapse = ref(false)
const activeIndex = ref('/home') const activeIndex = ref('/home')
const isPermission = ref(sessionStorage.getItem('permission')==='0')
</script> </script>
<style scoped> <style scoped>

View File

@ -31,7 +31,8 @@ export default {
const user = ref({ const user = ref({
data: '', data: '',
code: 0, code: 0,
message: '' message: '',
permission: ''
}); });
const router = useRouter(); const router = useRouter();
@ -52,9 +53,11 @@ export default {
console.log(data.data); console.log(data.data);
const token = data.data; const token = data.data;
const username = data.username; const username = data.username;
const permission = data.permission;
console.log(token, username); console.log(token, username);
sessionStorage.setItem('token', token); sessionStorage.setItem('token', token);
sessionStorage.setItem('username', username); sessionStorage.setItem('username', username);
sessionStorage.setItem('permission', permission);
await router.push('/home'); await router.push('/home');
} else { } else {
alert(data.message); alert(data.message);