From bcf533af62edcc93fb0c26a7c526a8235e3b9dba Mon Sep 17 00:00:00 2001 From: lrl <742798240@qq.com> Date: Mon, 15 Nov 2021 23:19:00 +0800 Subject: [PATCH 1/5] feat: add headerNotice --- src/layout/components/navbar.vue | 9 ++ src/layout/components/notice/index.vue | 110 +++++++++++++++++++ src/layout/components/notice/noticeItem.vue | 62 +++++++++++ src/layout/components/notice/noticeList.vue | 23 ++++ src/layout/components/sidebar/horizontal.vue | 3 + src/layout/types.ts | 6 + src/plugins/element-plus/index.ts | 20 +++- src/style/sidebar.scss | 9 ++ 8 files changed, 238 insertions(+), 4 deletions(-) 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 badaaf0b5..a5b1eff3f 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/index.vue b/src/layout/components/notice/index.vue new file mode 100644 index 000000000..d90a5f8b1 --- /dev/null +++ b/src/layout/components/notice/index.vue @@ -0,0 +1,110 @@ + + + + + diff --git a/src/layout/components/notice/noticeItem.vue b/src/layout/components/notice/noticeItem.vue new file mode 100644 index 000000000..82692a5f7 --- /dev/null +++ b/src/layout/components/notice/noticeItem.vue @@ -0,0 +1,62 @@ + + + + + diff --git a/src/layout/components/notice/noticeList.vue b/src/layout/components/notice/noticeList.vue new file mode 100644 index 000000000..3f2367252 --- /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 7fc7715df..4d2e2d759 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/layout/types.ts b/src/layout/types.ts index 1aaabd5b9..5e518eac3 100644 --- a/src/layout/types.ts +++ b/src/layout/types.ts @@ -71,3 +71,9 @@ export type themeColorsType = { rgb: string; themeColor: string; }; + +export type noticeItemType = { + imgUrl: string; + title: string; + description: string; +}; diff --git a/src/plugins/element-plus/index.ts b/src/plugins/element-plus/index.ts index fbaad0b5c..d83470347 100644 --- a/src/plugins/element-plus/index.ts +++ b/src/plugins/element-plus/index.ts @@ -36,7 +36,12 @@ import { ElDescriptions, ElDescriptionsItem, ElBacktop, - ElSwitch + ElSwitch, + ElBadge, + ElTabs, + ElTabPane, + ElAvatar, + ElEmpty } from "element-plus"; // https://element-plus.org/zh-CN/component/icon.html @@ -54,7 +59,8 @@ import { RefreshRight, ArrowDown, Close, - CloseBold + CloseBold, + Bell } from "@element-plus/icons"; const components = [ @@ -93,7 +99,12 @@ const components = [ ElDescriptions, ElDescriptionsItem, ElBacktop, - ElSwitch + ElSwitch, + ElBadge, + ElTabs, + ElTabPane, + ElAvatar, + ElEmpty ]; // icon export const iconComponents = [ @@ -110,7 +121,8 @@ export const iconComponents = [ RefreshRight, ArrowDown, Close, - CloseBold + CloseBold, + Bell ]; const plugins = [ElLoading]; diff --git a/src/style/sidebar.scss b/src/style/sidebar.scss index 35d6e9515..b82d9d796 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; From 6b064bdef9500d61299022a79512ac45a9c7d01a Mon Sep 17 00:00:00 2001 From: xiaoxian521 <1923740402@qq.com> Date: Tue, 16 Nov 2021 22:21:05 +0800 Subject: [PATCH 2/5] fix: icon --- src/utils/storage/responsive.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/storage/responsive.ts b/src/utils/storage/responsive.ts index 6288b47b5..4df889f00 100644 --- a/src/utils/storage/responsive.ts +++ b/src/utils/storage/responsive.ts @@ -14,7 +14,7 @@ export const injectResponsiveStorage = (app: App, config: ServerConfigs) => { meta: { title: "message.hshome", i18n: true, - icon: "el-icon-s-home", + icon: "HomeFilled", showLink: true } } From 5d9638758be0075bc3fcf7aa5ce569c1b35d77db Mon Sep 17 00:00:00 2001 From: lrl <742798240@qq.com> Date: Tue, 16 Nov 2021 23:46:34 +0800 Subject: [PATCH 3/5] perf: headerNotice --- src/layout/components/notice/data.ts | 130 +++++++++++++++++++ src/layout/components/notice/index.vue | 73 +++-------- src/layout/components/notice/noticeItem.vue | 135 ++++++++++++++++++-- src/layout/components/notice/noticeList.vue | 4 +- src/layout/types.ts | 6 - 5 files changed, 268 insertions(+), 80 deletions(-) create mode 100644 src/layout/components/notice/data.ts diff --git a/src/layout/components/notice/data.ts b/src/layout/components/notice/data.ts new file mode 100644 index 000000000..4b0402b54 --- /dev/null +++ b/src/layout/components/notice/data.ts @@ -0,0 +1,130 @@ +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" + } + ] + }, + { + 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 index d90a5f8b1..90579c7da 100644 --- a/src/layout/components/notice/index.vue +++ b/src/layout/components/notice/index.vue @@ -1,74 +1,30 @@