Skip to content

Commit

Permalink
fix(notifications): 修复通知记录菜单栏在有新通知时菜单焦点会出错的问题
Browse files Browse the repository at this point in the history
fixed: #12
  • Loading branch information
Light authored and Light committed Nov 22, 2023
1 parent 44336da commit 0ba3b86
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions src/components/GloriaNotificationMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@
{{ i18n('popupNotificationVisited') }}
</el-menu-item>
<el-menu-item
v-for="(item, index) in notificationsTitleList"
:key="index"
:index="index.toString()"
v-for="item in notificationsTitleList"
:key="'t-' + item"
:index="'t-' + item"
class="history-menu-item"
:title="item"
@contextmenu.prevent="onContextmenu($event, index.toString())"
@contextmenu.prevent="onContextmenu($event, 't-' + item)"
>
<template v-if="configs.notificationShowMenuCount">
<el-row type="flex">
Expand Down Expand Up @@ -104,7 +104,7 @@ export default defineComponent({
} else if (key == '-3') {
isVisited = true;
} else if (key != '-1') {
menuName = this.notificationsTitleList[key];
menuName = key.substring(2);
}
this.$emit('select-menu', {
Expand All @@ -113,19 +113,19 @@ export default defineComponent({
isVisited,
});
},
onContextmenu(event: MouseEvent, index: string) {
const { notificationsTitleList, laterCount, laterList } = this;
onContextmenu(event: MouseEvent, key: string) {
const { laterCount, laterList } = this;
const items = [];
if (index !== '-1' && index !== '-2' && index !== '-3') {
if (key !== '-1' && key !== '-2' && key !== '-3') {
items.push(
{
label: this.i18n('popupContextNotificationMenuCopy'),
icon: 'el-icon-document-copy',
divided: true,
onClick: () => {
this.copyToClip(
notificationsTitleList[index],
key.substring(2),
() => {
ElMessage.success(this.i18n('popupContextNotificationMenuCopyCompleted'));
},
Expand All @@ -139,21 +139,21 @@ export default defineComponent({
label: this.i18n('popupContextNotificationMenuMarkLater'),
icon: 'el-icon-collection-tag',
onClick: () => {
this.markLaterByName(notificationsTitleList[index]);
this.markLaterByName(key.substring(2));
},
},
{
label: this.i18n('popupContextNotificationMenuRemoveLater'),
icon: 'el-icon-finished',
divided: true,
onClick: () => {
this.removeLaterByName(notificationsTitleList[index]);
this.removeLaterByName(key.substring(2));
},
}
);
}
if (index === '-2') {
if (key === '-2') {
if (laterCount <= 10) {
items.push({
label: this.i18n('popupContextNotificationMenuOpenLater'),
Expand All @@ -173,16 +173,16 @@ export default defineComponent({
});
}
if (index !== '-2') {
if (index === '-1') {
if (key !== '-2') {
if (key === '-1') {
items.push({
label: this.i18n('popupContextNotificationMenuClearAll'),
icon: 'el-icon-delete-solid',
onClick: () => {
this.clearNotifications();
},
});
} else if (index === '-3') {
} else if (key === '-3') {
items.push({
label: this.i18n('popupContextNofificationMenuClearVisited'),
icon: 'el-icon-delete-solid',
Expand All @@ -195,7 +195,7 @@ export default defineComponent({
label: this.i18n('popupContextNotificationMenuClear'),
icon: 'el-icon-delete-solid',
onClick: () => {
this.removeNotificationsByName(notificationsTitleList[index]);
this.removeNotificationsByName(key.substring(2));
},
});
}
Expand Down

0 comments on commit 0ba3b86

Please sign in to comment.