Commit c7b6030418156a16b841298553848078427b7285
1 parent
2d5571bc
feat: 添加消息图标面板
Showing
8 changed files
with
157 additions
and
2 deletions
yudao-ui-admin-vue3/src/layout/components/Message/index.ts
0 → 100644
yudao-ui-admin-vue3/src/layout/components/Message/src/Message.vue
0 → 100644
| 1 | +<template> | |
| 2 | + <div class="message"> | |
| 3 | + <el-popover placement="bottom" :width="310" trigger="click"> | |
| 4 | + <template #reference> | |
| 5 | + <el-badge :value="noticeList.length" class="item"> | |
| 6 | + <Icon icon="ep:bell" :size="18" class="cursor-pointer" /> | |
| 7 | + </el-badge> | |
| 8 | + </template> | |
| 9 | + <el-tabs v-model="activeName"> | |
| 10 | + <el-tab-pane label="通知(5)" name="first"> | |
| 11 | + <div class="message-list"> | |
| 12 | + <template v-for="item in noticeList" :key="item.id"> | |
| 13 | + <div class="message-item"> | |
| 14 | + <img src="@/assets/imgs/avatar.gif" alt="" class="message-icon" /> | |
| 15 | + <div class="message-content"> | |
| 16 | + <span class="message-title">{{ item.title }}</span> | |
| 17 | + <span class="message-date">{{ item.date }}</span> | |
| 18 | + </div> | |
| 19 | + </div> | |
| 20 | + </template> | |
| 21 | + </div> | |
| 22 | + </el-tab-pane> | |
| 23 | + <el-tab-pane label="消息(0)" name="second"> | |
| 24 | + <div class="message-list"> | |
| 25 | + <template v-for="item in messageList" :key="item.id"> | |
| 26 | + <div class="message-item"> | |
| 27 | + <img src="@/assets/imgs/avatar.gif" alt="" class="message-icon" /> | |
| 28 | + <div class="message-content"> | |
| 29 | + <span class="message-title">{{ item.title }}</span> | |
| 30 | + <span class="message-date">{{ item.date }}</span> | |
| 31 | + </div> | |
| 32 | + </div> | |
| 33 | + </template> | |
| 34 | + </div> | |
| 35 | + </el-tab-pane> | |
| 36 | + <el-tab-pane label="代办(0)" name="third"> | |
| 37 | + <div class="message-list"> | |
| 38 | + <template v-for="item in needList" :key="item.id"> | |
| 39 | + <div class="message-item"> | |
| 40 | + <img src="@/assets/imgs/avatar.gif" alt="" class="message-icon" /> | |
| 41 | + <div class="message-content"> | |
| 42 | + <span class="message-title">{{ item.title }}</span> | |
| 43 | + <span class="message-date">{{ item.date }}</span> | |
| 44 | + </div> | |
| 45 | + </div> | |
| 46 | + </template> | |
| 47 | + </div> | |
| 48 | + </el-tab-pane> | |
| 49 | + </el-tabs> | |
| 50 | + </el-popover> | |
| 51 | + </div> | |
| 52 | +</template> | |
| 53 | + | |
| 54 | +<script setup lang="ts"> | |
| 55 | +import { ref } from 'vue' | |
| 56 | +import { ElTabs, ElTabPane, ElPopover, ElBadge } from 'element-plus' | |
| 57 | + | |
| 58 | +const activeName = ref('first') | |
| 59 | + | |
| 60 | +const noticeList = ref([ | |
| 61 | + { id: 1, title: '版本升级1', date: '2022-12-12 10:00:00' }, | |
| 62 | + { id: 2, title: '版本升级2', date: '2022-12-12 10:00:00' }, | |
| 63 | + { id: 3, title: '版本升级3', date: '2022-12-12 10:00:00' }, | |
| 64 | + { id: 4, title: '版本升级4', date: '2022-12-12 10:00:00' }, | |
| 65 | + { id: 5, title: '版本升级5', date: '2022-12-12 10:00:00' } | |
| 66 | +]) | |
| 67 | +const messageList = ref([ | |
| 68 | + { id: 1, title: '加班1', date: '2022-12-12 10:00:00' }, | |
| 69 | + { id: 2, title: '加班2', date: '2022-12-12 10:00:00' }, | |
| 70 | + { id: 3, title: '加班3', date: '2022-12-12 10:00:00' }, | |
| 71 | + { id: 4, title: '加班4', date: '2022-12-12 10:00:00' }, | |
| 72 | + { id: 5, title: '加班5', date: '2022-12-12 10:00:00' } | |
| 73 | +]) | |
| 74 | +const needList = ref([ | |
| 75 | + { id: 1, title: '审批1', date: '2022-12-12 10:00:00' }, | |
| 76 | + { id: 2, title: '审批2', date: '2022-12-12 10:00:00' }, | |
| 77 | + { id: 3, title: '审批3', date: '2022-12-12 10:00:00' }, | |
| 78 | + { id: 4, title: '审批4', date: '2022-12-12 10:00:00' }, | |
| 79 | + { id: 5, title: '审批5', date: '2022-12-12 10:00:00' } | |
| 80 | +]) | |
| 81 | +</script> | |
| 82 | + | |
| 83 | +<style scoped lang="scss"> | |
| 84 | +.message-empty { | |
| 85 | + display: flex; | |
| 86 | + flex-direction: column; | |
| 87 | + align-items: center; | |
| 88 | + justify-content: center; | |
| 89 | + height: 260px; | |
| 90 | + line-height: 45px; | |
| 91 | +} | |
| 92 | +.message-list { | |
| 93 | + display: flex; | |
| 94 | + flex-direction: column; | |
| 95 | + .message-item { | |
| 96 | + display: flex; | |
| 97 | + align-items: center; | |
| 98 | + padding: 20px 0; | |
| 99 | + border-bottom: 1px solid var(--el-border-color-light); | |
| 100 | + &:last-child { | |
| 101 | + border: none; | |
| 102 | + } | |
| 103 | + .message-icon { | |
| 104 | + width: 40px; | |
| 105 | + height: 40px; | |
| 106 | + margin: 0 20px 0 5px; | |
| 107 | + } | |
| 108 | + .message-content { | |
| 109 | + display: flex; | |
| 110 | + flex-direction: column; | |
| 111 | + .message-title { | |
| 112 | + margin-bottom: 5px; | |
| 113 | + } | |
| 114 | + .message-date { | |
| 115 | + font-size: 12px; | |
| 116 | + color: var(--el-text-color-secondary); | |
| 117 | + } | |
| 118 | + } | |
| 119 | + } | |
| 120 | +} | |
| 121 | +</style> | ... | ... |
yudao-ui-admin-vue3/src/layout/components/Setting/src/Setting.vue
yudao-ui-admin-vue3/src/layout/components/Setting/src/components/InterfaceDisplay.vue
| ... | ... | @@ -57,6 +57,13 @@ const localeChange = (show: boolean) => { |
| 57 | 57 | appStore.setLocale(show) |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | +// 消息图标 | |
| 61 | +const message = ref(appStore.getMessage) | |
| 62 | + | |
| 63 | +const messageChange = (show: boolean) => { | |
| 64 | + appStore.setMessage(show) | |
| 65 | +} | |
| 66 | + | |
| 60 | 67 | // 标签页 |
| 61 | 68 | const tagsView = ref(appStore.getTagsView) |
| 62 | 69 | |
| ... | ... | @@ -165,6 +172,11 @@ watch( |
| 165 | 172 | </div> |
| 166 | 173 | |
| 167 | 174 | <div class="flex justify-between items-center"> |
| 175 | + <span class="text-14px">{{ t('setting.messageIcon') }}</span> | |
| 176 | + <ElSwitch v-model="message" @change="messageChange" /> | |
| 177 | + </div> | |
| 178 | + | |
| 179 | + <div class="flex justify-between items-center"> | |
| 168 | 180 | <span class="text-14px">{{ t('setting.tagsView') }}</span> |
| 169 | 181 | <ElSwitch v-model="tagsView" @change="tagsViewChange" /> |
| 170 | 182 | </div> | ... | ... |
yudao-ui-admin-vue3/src/layout/components/ToolHeader.vue
| 1 | 1 | <script lang="tsx"> |
| 2 | 2 | import { defineComponent, computed } from 'vue' |
| 3 | +import { Message } from '@/layout/components//Message' | |
| 3 | 4 | import { Collapse } from '@/layout/components/Collapse' |
| 4 | -import { LocaleDropdown } from '@/layout/components/LocaleDropdown' | |
| 5 | -import { SizeDropdown } from '@/layout/components/SizeDropdown' | |
| 6 | 5 | import { UserInfo } from '@/layout/components/UserInfo' |
| 7 | 6 | import { Screenfull } from '@/layout/components/Screenfull' |
| 8 | 7 | import { Breadcrumb } from '@/layout/components/Breadcrumb' |
| 8 | +import { SizeDropdown } from '@/layout/components/SizeDropdown' | |
| 9 | +import { LocaleDropdown } from '@/layout/components/LocaleDropdown' | |
| 9 | 10 | import { useAppStore } from '@/store/modules/app' |
| 10 | 11 | import { useDesign } from '@/hooks/web/useDesign' |
| 11 | 12 | |
| ... | ... | @@ -33,6 +34,9 @@ const layout = computed(() => appStore.getLayout) |
| 33 | 34 | // 多语言图标 |
| 34 | 35 | const locale = computed(() => appStore.getLocale) |
| 35 | 36 | |
| 37 | +// 消息图标 | |
| 38 | +const message = computed(() => appStore.getMessage) | |
| 39 | + | |
| 36 | 40 | export default defineComponent({ |
| 37 | 41 | name: 'ToolHeader', |
| 38 | 42 | setup() { |
| ... | ... | @@ -66,6 +70,9 @@ export default defineComponent({ |
| 66 | 70 | color="var(--top-header-text-color)" |
| 67 | 71 | ></LocaleDropdown> |
| 68 | 72 | ) : undefined} |
| 73 | + {message.value ? ( | |
| 74 | + <Message class="hover-trigger" color="var(--top-header-text-color)"></Message> | |
| 75 | + ) : undefined} | |
| 69 | 76 | <UserInfo class="hover-trigger"></UserInfo> |
| 70 | 77 | </div> |
| 71 | 78 | </div> | ... | ... |
yudao-ui-admin-vue3/src/locales/en.ts
yudao-ui-admin-vue3/src/locales/zh-CN.ts
yudao-ui-admin-vue3/src/store/modules/app.ts
| ... | ... | @@ -18,6 +18,7 @@ interface AppState { |
| 18 | 18 | screenfull: boolean |
| 19 | 19 | size: boolean |
| 20 | 20 | locale: boolean |
| 21 | + message: boolean | |
| 21 | 22 | tagsView: boolean |
| 22 | 23 | tagsViewIcon: boolean |
| 23 | 24 | logo: boolean |
| ... | ... | @@ -53,6 +54,7 @@ export const useAppStore = defineStore('app', { |
| 53 | 54 | screenfull: true, // 全屏图标 |
| 54 | 55 | size: true, // 尺寸图标 |
| 55 | 56 | locale: true, // 多语言图标 |
| 57 | + message: true, // 消息图标 | |
| 56 | 58 | tagsView: true, // 标签页 |
| 57 | 59 | tagsViewIcon: true, // 是否显示标签图标 |
| 58 | 60 | logo: true, // logo |
| ... | ... | @@ -121,6 +123,9 @@ export const useAppStore = defineStore('app', { |
| 121 | 123 | getLocale(): boolean { |
| 122 | 124 | return this.locale |
| 123 | 125 | }, |
| 126 | + getMessage(): boolean { | |
| 127 | + return this.message | |
| 128 | + }, | |
| 124 | 129 | getTagsView(): boolean { |
| 125 | 130 | return this.tagsView |
| 126 | 131 | }, |
| ... | ... | @@ -195,6 +200,9 @@ export const useAppStore = defineStore('app', { |
| 195 | 200 | setLocale(locale: boolean) { |
| 196 | 201 | this.locale = locale |
| 197 | 202 | }, |
| 203 | + setMessage(message: boolean) { | |
| 204 | + this.message = message | |
| 205 | + }, | |
| 198 | 206 | setTagsView(tagsView: boolean) { |
| 199 | 207 | this.tagsView = tagsView |
| 200 | 208 | }, | ... | ... |