All checks were successful
Build and Deploy Front / deploy (push) Successful in 5m52s
仓租费率改为单页三段矩阵编辑(合并相同值/批量填价/计算公式);同步收敛侧栏、顶栏与官网头像/语言为圆形芯片。 Co-authored-by: Cursor <cursoragent@cursor.com>
184 lines
4.5 KiB
Vue
184 lines
4.5 KiB
Vue
<template>
|
||
<!-- Top-nav inbox / announcement entry (unread: ping, not count). -->
|
||
<a-dropdown
|
||
:trigger="trigger"
|
||
:position="dropdownPosition"
|
||
:content-class="contentClass"
|
||
:popup-translate="popupTranslate"
|
||
@visible-change="onMessageDropdownVisibleChange"
|
||
>
|
||
<div
|
||
class="message-dropdown-trigger"
|
||
:class="{ 'is-hot': totalCount > 0, 'is-emphasized': emphasize && totalCount > 0 }"
|
||
:title="t('navbar.message')"
|
||
:aria-label="t('navbar.message')"
|
||
>
|
||
<IconNotification class="message-icon" />
|
||
<span v-if="showLabel" class="message-label">{{ t('navbar.message') }}</span>
|
||
<span
|
||
v-if="totalCount > 0"
|
||
class="message-ping"
|
||
aria-hidden="true"
|
||
/>
|
||
</div>
|
||
<template #content>
|
||
<a-doption @click="() => onMessageMenuClick({ key: 'notification' })">
|
||
{{ t('navbar.messageInbox') }}({{ notificationCount }})
|
||
</a-doption>
|
||
<a-doption @click="() => onMessageMenuClick({ key: 'notice' })">
|
||
{{ t('navbar.messageNotice') }}({{ noticeCount }})
|
||
</a-doption>
|
||
</template>
|
||
</a-dropdown>
|
||
</template>
|
||
|
||
<script lang="ts" setup>
|
||
import { computed, toRefs } from 'vue';
|
||
import { useRouter } from 'vue-router';
|
||
import { useI18n } from 'vue-i18n';
|
||
import { IconNotification } from '@arco-design/web-vue/es/icon';
|
||
import { useInboxUnread } from '@/composables/useInboxUnread';
|
||
|
||
const props = withDefaults(
|
||
defineProps<{
|
||
dropdownPosition?: 'br' | 'bl' | 'tr' | 'tl' | 'rt' | 'rb'
|
||
trigger?: 'hover' | 'click'
|
||
/** 侧栏:展示「消息」文案,强化未读入口 */
|
||
showLabel?: boolean
|
||
/** 有未读时加强视觉 */
|
||
emphasize?: boolean
|
||
contentClass?: string
|
||
}>(),
|
||
{
|
||
dropdownPosition: 'br',
|
||
trigger: 'hover',
|
||
showLabel: false,
|
||
emphasize: false,
|
||
contentClass: '',
|
||
},
|
||
);
|
||
|
||
const { showLabel, emphasize } = toRefs(props);
|
||
const dropdownPosition = computed(() => props.dropdownPosition);
|
||
const trigger = computed(() => props.trigger);
|
||
const contentClass = computed(() => props.contentClass || undefined);
|
||
const popupTranslate = computed<[number, number] | undefined>(() =>
|
||
props.dropdownPosition === 'tl' || props.dropdownPosition === 'tr'
|
||
? [0, -6]
|
||
: undefined,
|
||
);
|
||
|
||
const router = useRouter();
|
||
const { t } = useI18n();
|
||
const { notificationCount, noticeCount, totalCount, refreshUnread } = useInboxUnread();
|
||
|
||
const onMessageDropdownVisibleChange = (visible: boolean) => {
|
||
if (visible) refreshUnread();
|
||
};
|
||
|
||
const onMessageMenuClick = (event: { key?: string }) => {
|
||
if (event.key === 'notification') {
|
||
router.push({ name: 'SystemAnnouncement', query: { noticeType: 'message' } });
|
||
return;
|
||
}
|
||
if (event.key === 'notice') {
|
||
router.push({ name: 'SystemAnnouncement', query: { noticeType: 'notice' } });
|
||
}
|
||
};
|
||
</script>
|
||
|
||
<style scoped>
|
||
.message-dropdown-trigger {
|
||
position: relative;
|
||
display: inline-flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
gap: 6px;
|
||
width: 30px;
|
||
min-width: 30px;
|
||
height: 30px;
|
||
padding: 0;
|
||
border-radius: 999px;
|
||
background: rgba(26, 46, 56, 0.05);
|
||
color: rgba(26, 46, 56, 0.52);
|
||
line-height: 0;
|
||
cursor: pointer;
|
||
transition: background-color 0.14s ease, color 0.14s ease;
|
||
}
|
||
|
||
.message-dropdown-trigger:hover {
|
||
color: #1a2e38;
|
||
background: rgba(26, 46, 56, 0.09);
|
||
}
|
||
|
||
.message-dropdown-trigger.is-hot {
|
||
color: #1a2e38;
|
||
}
|
||
|
||
.message-dropdown-trigger.is-emphasized {
|
||
color: var(--app-primary-color, rgb(var(--primary-6)));
|
||
background: color-mix(in srgb, var(--app-primary-color, #1d7281) 10%, #fff);
|
||
}
|
||
|
||
.message-icon {
|
||
display: block;
|
||
width: 15px;
|
||
height: 15px;
|
||
font-size: 15px;
|
||
flex-shrink: 0;
|
||
line-height: 1;
|
||
}
|
||
|
||
.message-label {
|
||
flex-shrink: 0;
|
||
font-size: 12px;
|
||
font-weight: 500;
|
||
line-height: 1;
|
||
color: inherit;
|
||
}
|
||
|
||
.message-dropdown-trigger:has(.message-label) {
|
||
width: auto;
|
||
padding: 0 10px 0 8px;
|
||
}
|
||
|
||
.message-ping {
|
||
--msg-ping: #f53f3f;
|
||
position: absolute;
|
||
top: 4px;
|
||
right: 4px;
|
||
width: 7px;
|
||
height: 7px;
|
||
border-radius: 50%;
|
||
background: var(--msg-ping);
|
||
box-shadow: 0 0 0 1.5px #fff;
|
||
pointer-events: none;
|
||
}
|
||
|
||
.message-ping::before {
|
||
content: '';
|
||
position: absolute;
|
||
inset: 0;
|
||
border-radius: 50%;
|
||
background: var(--msg-ping);
|
||
animation: msg-chip-ping 1.6s cubic-bezier(0.22, 1, 0.36, 1) infinite;
|
||
}
|
||
|
||
@keyframes msg-chip-ping {
|
||
0% {
|
||
transform: scale(1);
|
||
opacity: 0.7;
|
||
}
|
||
100% {
|
||
transform: scale(2.6);
|
||
opacity: 0;
|
||
}
|
||
}
|
||
|
||
@media (prefers-reduced-motion: reduce) {
|
||
.message-ping::before {
|
||
animation: none;
|
||
}
|
||
}
|
||
</style>
|