From 6741099695922121cd27015545cc89da587f1e82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=80=E4=B8=83=E5=B9=B4=E5=A4=8F?= <2098833867@qq.com> Date: Wed, 30 Aug 2023 10:36:17 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0Navbar?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mock/excel.ts | 2 +- src/layout/default/app-main/NavBarAppTools.ts | 29 ++++ src/layout/default/app-main/Navbar.vue | 160 ++---------------- .../default/app-main/component/Avatar.vue | 28 +++ .../app-main/component/AvatarFrame.vue | 81 +++++++++ src/store/basic.ts | 4 +- src/views/login/index.vue | 107 ++++++------ 7 files changed, 208 insertions(+), 203 deletions(-) create mode 100644 src/layout/default/app-main/NavBarAppTools.ts create mode 100644 src/layout/default/app-main/component/Avatar.vue create mode 100644 src/layout/default/app-main/component/AvatarFrame.vue diff --git a/mock/excel.ts b/mock/excel.ts index b4631a7..c5ca37b 100644 --- a/mock/excel.ts +++ b/mock/excel.ts @@ -44,7 +44,7 @@ export default [ { order_no: '@guid()', timestamp: +Mock.Random.date('T'), - username: '@name()', + userName: '@name()', price: '@float(1000, 15000, 0, 2)', 'status|1': ['success', 'pending'] } diff --git a/src/layout/default/app-main/NavBarAppTools.ts b/src/layout/default/app-main/NavBarAppTools.ts new file mode 100644 index 0000000..87f8f0e --- /dev/null +++ b/src/layout/default/app-main/NavBarAppTools.ts @@ -0,0 +1,29 @@ +import { Fragment } from '@vue/runtime-core' +import type { Prop, VNode } from 'vue' +import { Comment, defineComponent } from 'vue' + +export default defineComponent({ + name: 'NavBarAppTools', + props: { + position: { + type: String, + require: true + } as Prop<'left' | 'right' | 'center'> + }, + render() { + const navbar = useBasicStore().navbar + const sorts = navbar[this.position!] as Map VNode[]> + if (!sorts) return h(Comment, 'nav bar app tools') + + let out = [] as VNode[] + for (const value of sorts.values()) { + try { + out.push(...value()) + } catch (e) { + console.error(e) + } + } + if (this.$props.position === 'right') out = out.reverse() + return h(Fragment, out) + } +}) diff --git a/src/layout/default/app-main/Navbar.vue b/src/layout/default/app-main/Navbar.vue index 066673c..2db1dca 100644 --- a/src/layout/default/app-main/Navbar.vue +++ b/src/layout/default/app-main/Navbar.vue @@ -12,131 +12,39 @@ - + diff --git a/src/layout/default/app-main/component/AvatarFrame.vue b/src/layout/default/app-main/component/AvatarFrame.vue new file mode 100644 index 0000000..f9c1e97 --- /dev/null +++ b/src/layout/default/app-main/component/AvatarFrame.vue @@ -0,0 +1,81 @@ + + + + + diff --git a/src/store/basic.ts b/src/store/basic.ts index 556e0d6..fc0df6c 100644 --- a/src/store/basic.ts +++ b/src/store/basic.ts @@ -13,7 +13,7 @@ export const useBasicStore = defineStore('basic', { getUserInfo: false, online: true, userInfo: { - username: '', + userName: '', realName: '', avatar: '', phone: '', @@ -75,7 +75,7 @@ export const useBasicStore = defineStore('basic', { state.filterAsyncRoutes = [] //reset userInfo state.userInfo = { - username: '', + userName: '', realName: '', avatar: '', phone: '', diff --git a/src/views/login/index.vue b/src/views/login/index.vue index 468a8e2..40e63d0 100644 --- a/src/views/login/index.vue +++ b/src/views/login/index.vue @@ -7,11 +7,11 @@

{{ settings.title }}

- + - + @@ -40,117 +40,116 @@