From c2aa7d9428e59233507ab0baf7c98e21b3fe979d Mon Sep 17 00:00:00 2001 From: xiaoxian521 <1923740402@qq.com> Date: Thu, 18 Nov 2021 08:34:35 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E5=90=8C=E6=AD=A5=E4=B8=BB=E5=88=86?= =?UTF-8?q?=E6=94=AF=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/layout/components/navbar.vue | 9 ++ src/layout/components/notice/data.ts | 146 +++++++++++++++++++++++ src/layout/components/notice/index.vue | 80 +++++++++++++ src/layout/components/notice/noticeItem.vue | 168 +++++++++++++++++++++++++++ src/layout/components/notice/noticeList.vue | 23 ++++ src/layout/components/sidebar/horizontal.vue | 3 + src/plugins/element-plus/index.ts | 27 +++-- src/style/sidebar.scss | 9 ++ 8 files changed, 458 insertions(+), 7 deletions(-) create mode 100644 src/layout/components/notice/data.ts create mode 100644 src/layout/components/notice/index.vue create mode 100644 src/layout/components/notice/noticeItem.vue create mode 100644 src/layout/components/notice/noticeList.vue diff --git a/src/layout/components/navbar.vue b/src/layout/components/navbar.vue index 17da9d3..4064e3e 100644 --- a/src/layout/components/navbar.vue +++ b/src/layout/components/navbar.vue @@ -5,6 +5,7 @@ import Hamburger from "./sidebar/hamBurger.vue"; import { useRouter, useRoute } from "vue-router"; import { storageSession } from "/@/utils/storage"; import Breadcrumb from "./sidebar/breadCrumb.vue"; +import Notice from "./notice/index.vue"; import { useAppStoreHook } from "/@/store/modules/app"; import { unref, watch, getCurrentInstance } from "vue"; import { deviceDetection } from "/@/utils/deviceDetection"; @@ -70,6 +71,8 @@ function translationEn() {
+ + @@ -156,6 +159,12 @@ function translationEn() { color: #000000d9; justify-content: flex-end; + :deep(.dropdown-badge) { + &:hover { + background: #f6f6f6; + } + } + .screen-full { cursor: pointer; diff --git a/src/layout/components/notice/data.ts b/src/layout/components/notice/data.ts new file mode 100644 index 0000000..b918e62 --- /dev/null +++ b/src/layout/components/notice/data.ts @@ -0,0 +1,146 @@ +export interface ListItem { + avatar: string; + title: string; + datetime: string; + type: string; + description: string; + status?: "" | "success" | "warning" | "info" | "danger"; + extra?: string; +} + +export interface TabItem { + key: string; + name: string; + list: ListItem[]; +} + +export const noticesData: TabItem[] = [ + { + key: "1", + name: "通知", + list: [ + { + avatar: + "https://gw.alipayobjects.com/zos/rmsportal/ThXAXghbEsBCCSDihZxY.png", + title: "你收到了 12 份新周报", + datetime: "一年前", + description: "", + type: "1" + }, + { + avatar: + "https://gw.alipayobjects.com/zos/rmsportal/OKJXDXrmkNshAMvwtvhu.png", + title: "你推荐的 前端高手 已通过第三轮面试", + datetime: "一年前", + description: "", + type: "1" + }, + { + avatar: + "https://gw.alipayobjects.com/zos/rmsportal/kISTdvpyTAhtGxpovNWd.png", + title: "这种模板可以区分多种通知类型", + datetime: "一年前", + description: "", + type: "1" + }, + { + avatar: + "https://gw.alipayobjects.com/zos/rmsportal/GvqBnKhFgObvnSGkDsje.png", + title: + "展示标题内容超过一行后的处理方式,如果内容超过1行将自动截断并支持tooltip显示完整标题。", + datetime: "一年前", + description: "", + type: "1" + }, + { + avatar: + "https://gw.alipayobjects.com/zos/rmsportal/GvqBnKhFgObvnSGkDsje.png", + title: "左侧图标用于区分不同的类型", + datetime: "一年前", + description: "", + type: "1" + }, + { + avatar: + "https://gw.alipayobjects.com/zos/rmsportal/GvqBnKhFgObvnSGkDsje.png", + title: "左侧图标用于区分不同的类型", + datetime: "一年前", + description: "", + type: "1" + } + ] + }, + { + key: "2", + name: "消息", + list: [ + { + avatar: + "https://gw.alipayobjects.com/zos/rmsportal/fcHMVNCjPOsbUGdEduuv.jpeg", + title: "李白 评论了你", + description: "长风破浪会有时,直挂云帆济沧海", + datetime: "一年前", + type: "2" + }, + { + avatar: + "https://gw.alipayobjects.com/zos/rmsportal/fcHMVNCjPOsbUGdEduuv.jpeg", + title: "李白 回复了你", + description: "行路难,行路难,多歧路,今安在。", + datetime: "一年前", + type: "2" + }, + { + avatar: + "https://gw.alipayobjects.com/zos/rmsportal/fcHMVNCjPOsbUGdEduuv.jpeg", + title: "标题", + description: + "请将鼠标移动到此处,以便测试超长的消息在此处将如何处理。本例中设置的描述最大行数为2,超过2行的描述内容将被省略并且可以通过tooltip查看完整内容", + datetime: "一年前", + type: "2" + } + ] + }, + { + key: "3", + name: "代办", + list: [ + { + avatar: "", + title: "任务名称", + description: "任务需要在 2021-11-16 20:00 前启动", + datetime: "", + extra: "未开始", + status: "info", + type: "3" + }, + { + avatar: "", + title: "第三方紧急代码变更", + description: + "一拳提交于 2021-11-16,需在 2021-11-18 前完成代码变更任务", + datetime: "", + extra: "马上到期", + status: "danger", + type: "3" + }, + { + avatar: "", + title: "信息安全考试", + description: "指派小仙于 2021-12-12 前完成更新并发布", + datetime: "", + extra: "已耗时 8 天", + status: "warning", + type: "3" + }, + { + avatar: "", + title: "vue-pure-admin 版本发布", + description: "vue-pure-admin 版本发布", + datetime: "", + extra: "进行中", + type: "3" + } + ] + } +]; diff --git a/src/layout/components/notice/index.vue b/src/layout/components/notice/index.vue new file mode 100644 index 0000000..108bebd --- /dev/null +++ b/src/layout/components/notice/index.vue @@ -0,0 +1,80 @@ + + + + + diff --git a/src/layout/components/notice/noticeItem.vue b/src/layout/components/notice/noticeItem.vue new file mode 100644 index 0000000..9004690 --- /dev/null +++ b/src/layout/components/notice/noticeItem.vue @@ -0,0 +1,168 @@ + + + + + + diff --git a/src/layout/components/notice/noticeList.vue b/src/layout/components/notice/noticeList.vue new file mode 100644 index 0000000..90f6e98 --- /dev/null +++ b/src/layout/components/notice/noticeList.vue @@ -0,0 +1,23 @@ + + + diff --git a/src/layout/components/sidebar/horizontal.vue b/src/layout/components/sidebar/horizontal.vue index 7fc7715..4d2e2d7 100644 --- a/src/layout/components/sidebar/horizontal.vue +++ b/src/layout/components/sidebar/horizontal.vue @@ -9,6 +9,7 @@ import { } from "vue"; import { useI18n } from "vue-i18n"; import { emitter } from "/@/utils/mitt"; +import Notice from "../notice/index.vue"; import { templateRef } from "@vueuse/core"; import SidebarItem from "./sidebarItem.vue"; import { algorithm } from "/@/utils/algorithm"; @@ -138,6 +139,8 @@ onMounted(() => { />
+ + diff --git a/src/plugins/element-plus/index.ts b/src/plugins/element-plus/index.ts index 1260028..380943f 100644 --- a/src/plugins/element-plus/index.ts +++ b/src/plugins/element-plus/index.ts @@ -23,7 +23,6 @@ import { ElInput, ElForm, ElFormItem, - ElLoading, ElPopover, ElPopper, ElTooltip, @@ -36,7 +35,15 @@ import { ElDescriptions, ElDescriptionsItem, ElBacktop, - ElSwitch + ElSwitch, + ElBadge, + ElTabs, + ElTabPane, + ElAvatar, + ElEmpty, + // 指令 + ElLoading, + ElInfiniteScroll } from "element-plus"; // https://element-plus.org/zh-CN/component/icon.html @@ -54,7 +61,8 @@ import { RefreshRight, ArrowDown, Close, - CloseBold + CloseBold, + Bell } from "@element-plus/icons"; const components = [ @@ -93,9 +101,13 @@ const components = [ ElDescriptions, ElDescriptionsItem, ElBacktop, - ElSwitch + ElSwitch, + ElBadge, + ElTabs, + ElTabPane, + ElAvatar, + ElEmpty ]; - // icon export const iconComponents = [ Check, @@ -111,10 +123,11 @@ export const iconComponents = [ RefreshRight, ArrowDown, Close, - CloseBold + CloseBold, + Bell ]; -const plugins = [ElLoading]; +const plugins = [ElLoading, ElInfiniteScroll]; export function useElementPlus(app: App) { components.push(...iconComponents); diff --git a/src/style/sidebar.scss b/src/style/sidebar.scss index 35d6e95..b82d9d7 100644 --- a/src/style/sidebar.scss +++ b/src/style/sidebar.scss @@ -212,6 +212,15 @@ color: $subMenuActiveText; justify-content: flex-end; + .dropdown-badge { + height: 62px; + color: $subMenuActiveText; + + &:hover { + background: $menuHover; + } + } + .screen-full { cursor: pointer;