feat: 🔥 优化菜单栏

This commit is contained in:
zouzhibing 2022-11-25 22:14:06 +08:00
parent afe261072d
commit accd569fba
5 changed files with 43 additions and 16 deletions

View File

@ -64,11 +64,13 @@
<script lang="ts" setup>
import {computed, ref} from 'vue'
import SwitchDark from '@/components/SwitchDark/index.vue'
import {ElMessage} from "element-plus";
import SwitchDark from '@/components/SwitchDark/index.vue'
import {PRIMARY_COLOR} from "@/config/index";
import {useSettingStore} from "@/store/modules/setting"
import {getDarkColor,getLightColor} from '@/utils/index'
const SettingStore = useSettingStore()
const layout = ref(SettingStore.themeConfig.mode)
const showTag = ref(SettingStore.themeConfig.showTag)
@ -103,9 +105,12 @@
return
}
}
//
const changeSwitch = (key,val) => {
SettingStore.setThemeConfig({key, val})
}
//
const changePrimary = (val)=>{
if (!val) {

View File

@ -61,6 +61,9 @@
.el-menu{
overflow: hidden;
}
:deep(.el-menu-item){
height: 100% !important;
}
.tool-bar-right{
display: flex;
justify-content: flex-end;

View File

@ -23,13 +23,13 @@ const functionPageRouter = [{
path: '404',
component: () => import('@/views/errorPages/404.vue'),
name: 'function-404',
meta: { title: '404', keepAlive: true , icon: 'MenuIcon'}
meta: { title: '404 页面', keepAlive: true , icon: 'MenuIcon'}
},
{
path: '403',
component: () => import('@/views/errorPages/403.vue'),
name: 'function-403',
meta: { title: '403', keepAlive: true , icon: 'MenuIcon'}
meta: { title: '403 页面', keepAlive: true , icon: 'MenuIcon'}
},
]
}]

18
src/utils/element.ts Normal file
View File

@ -0,0 +1,18 @@
import { ElLoading } from 'element-plus'
import {
Loading
} from '@element-plus/icons-vue'
let loading = null
export const openLoading = (options)=>{
const text = options.text||'加载中'
loading = ElLoading.service({
lock: true,
text: text,
spinner:Loading,
background: 'rgba(0, 0, 0, 0.7)',
})
}
export const closeLoading = () = {
loading&&loading()
}

View File

@ -3,7 +3,6 @@
ref="ruleFormRef"
:model="ruleForm"
:rules="rules"
label-width="0"
>
<el-form-item label="" prop="username">
<el-input
@ -18,6 +17,7 @@
</template>
</el-input>
</el-form-item>
<el-form-item label="" prop="password">
<el-input
placeholder="请输入密码"
@ -30,12 +30,13 @@
<el-icon class="el-input__icon"><GoodsFilled /></el-icon>
</template>
<template #suffix>
<div class="show-pwd" @click="showPwd"
><svg-icon :icon-class="passwordType === 'password' ? 'eye' : 'eye-open'"
/></div>
<div class="show-pwd" @click="showPwd">
<svg-icon :icon-class="passwordType === 'password' ? 'eye' : 'eye-open'"/>
</div>
</template>
</el-input>
</el-form-item>
<el-form-item style="width: 100%">
<el-button
:loading="loading"
@ -54,29 +55,29 @@ import { ElNotification } from "element-plus";
import { useRouter } from 'vue-router'
import {useUserStore} from "@/store/modules/user"
import {getTimeState} from '@/utils/index'
const ruleFormRef = ref<FormInstance>()
const router = useRouter()
const UserStore = useUserStore()
const ruleFormRef = ref<FormInstance>()
const passwordType = ref('password')
const loading = ref(false)
const rules = reactive({
password: [{ required: true, message: "请输入用户名", trigger: "blur" }],
username: [{ required: true, message: "请输入密码", trigger: "blur" }],
})
//
const ruleForm = reactive({
username: 'vue-admin-perfect',
username: 'vue-admin',
password: '123456',
})
//
const showPwd = () => {
if (passwordType.value === 'password') {
passwordType.value = ''
} else {
passwordType.value = 'password'
}
passwordType.value = passwordType.value === 'password'?'':'password'
}
const submitForm = (formEl: FormInstance | undefined) => {
if (!formEl) return
formEl.validate((valid) => {
@ -84,7 +85,7 @@ const submitForm = (formEl: FormInstance | undefined) => {
loading.value = true
//
setTimeout(async ()=>{
await UserStore.login( ruleForm)
await UserStore.login(ruleForm)
await router.push({
path: '/',
})