|
@@ -1,4 +1,4 @@
|
|
|
-import { defineComponent, ref } from 'vue';
|
|
|
+import { defineComponent, ref, onMounted, onBeforeMount } from 'vue';
|
|
|
import styles from './index.module.less';
|
|
|
import { NImage, NBadge, NPopover, NIcon, NModal, NTooltip } from 'naive-ui';
|
|
|
import schoolIcon from './images/schoolIcon.png';
|
|
@@ -14,6 +14,7 @@ import { storeToRefs } from 'pinia';
|
|
|
|
|
|
import 'animate.css';
|
|
|
import ForgotPassword from '/src/views/setting/modal/forgotPassword';
|
|
|
+import ImGroup from './imGroup';
|
|
|
|
|
|
export default defineComponent({
|
|
|
name: 'layoutTop',
|
|
@@ -21,6 +22,8 @@ export default defineComponent({
|
|
|
const router = useRouter();
|
|
|
const noReadCount = ref(0); // 未读数
|
|
|
const showHeadFlag = ref(false);
|
|
|
+ const showImGroup = ref(false);
|
|
|
+ const showImGroupLoading = ref(true);
|
|
|
|
|
|
const users = useUserStore();
|
|
|
const showWord = ref(false);
|
|
@@ -38,6 +41,29 @@ export default defineComponent({
|
|
|
console.log('resetPwd');
|
|
|
};
|
|
|
|
|
|
+ onMounted(() => {
|
|
|
+ window.addEventListener('message', onImMessage);
|
|
|
+ showImGroup.value = true;
|
|
|
+ // showImGroupLoading.value = true;
|
|
|
+ setTimeout(() => {
|
|
|
+ showImGroup.value = false;
|
|
|
+ }, 50);
|
|
|
+ setTimeout(() => {
|
|
|
+ showImGroupLoading.value = false;
|
|
|
+ }, 1000);
|
|
|
+ });
|
|
|
+
|
|
|
+ const onImMessage = (evt: MessageEvent) => {
|
|
|
+ if (evt.data.api === 'onImClose') {
|
|
|
+ showImGroup.value = false;
|
|
|
+ } else if (evt.data.api === 'getNoReadMessageCount') {
|
|
|
+ noReadCount.value = evt.data.count || 0;
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ onBeforeMount(() => {
|
|
|
+ window.removeEventListener('message', onImMessage);
|
|
|
+ });
|
|
|
return () => (
|
|
|
<>
|
|
|
<div class={styles.layoutTop}>
|
|
@@ -52,20 +78,22 @@ export default defineComponent({
|
|
|
</p>
|
|
|
</div>
|
|
|
<div class={styles.layoutRight}>
|
|
|
- <NBadge
|
|
|
- value={noReadCount.value}
|
|
|
- max={99}
|
|
|
- class={styles.messageBadge}
|
|
|
- {...{ id: 'home-2' }}
|
|
|
- color={'#FF1036'}>
|
|
|
- <NImage
|
|
|
- class={[
|
|
|
- styles.messageIcon,
|
|
|
- noReadCount.value > 0 ? styles.animation : ''
|
|
|
- ]}
|
|
|
- preview-disabled
|
|
|
- src={messageIcon}></NImage>
|
|
|
- </NBadge>
|
|
|
+ <div onClick={() => (showImGroup.value = true)}>
|
|
|
+ <NBadge
|
|
|
+ value={noReadCount.value}
|
|
|
+ max={99}
|
|
|
+ class={styles.messageBadge}
|
|
|
+ {...{ id: 'home-2' }}
|
|
|
+ color={'#FF1036'}>
|
|
|
+ <NImage
|
|
|
+ class={[
|
|
|
+ styles.messageIcon,
|
|
|
+ noReadCount.value > 0 ? styles.animation : ''
|
|
|
+ ]}
|
|
|
+ preview-disabled
|
|
|
+ src={messageIcon}></NImage>
|
|
|
+ </NBadge>
|
|
|
+ </div>
|
|
|
|
|
|
<div class={styles.line}></div>
|
|
|
<NPopover
|
|
@@ -181,6 +209,14 @@ export default defineComponent({
|
|
|
}}
|
|
|
/>
|
|
|
</NModal>
|
|
|
+
|
|
|
+ <NModal
|
|
|
+ v-model:show={showImGroup.value}
|
|
|
+ showIcon={false}
|
|
|
+ class={showImGroupLoading.value ? styles.hideModal : ''}
|
|
|
+ displayDirective="show">
|
|
|
+ <ImGroup />
|
|
|
+ </NModal>
|
|
|
</div>
|
|
|
</>
|
|
|
);
|