@peng_kai/kit 0.3.0-beta.38 → 0.3.0-beta.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/admin/layout/large/Notice.vue +25 -14
- package/package.json +1 -1
|
@@ -1,24 +1,38 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { useEventListener, useIntervalFn } from '@vueuse/core';
|
|
2
|
+
import { useEventListener, useIntervalFn, useLocalStorage } from '@vueuse/core';
|
|
3
3
|
import { Empty, Dropdown, Badge, Menu, MenuItem } from 'ant-design-vue';
|
|
4
4
|
import { type UseQueryReturnType } from '@tanstack/vue-query'
|
|
5
|
-
import {
|
|
5
|
+
import { ref, computed, customRef, triggerRef } from 'vue'
|
|
6
6
|
import dayjs from '../../../libs/dayjs';
|
|
7
7
|
import { useRouter } from 'vue-router';
|
|
8
8
|
import audioURL from './y682.mp3?url';
|
|
9
9
|
|
|
10
|
+
function useAudioMuted(audio: HTMLAudioElement, cacheKey: string) {
|
|
11
|
+
const audioMutedCache = useLocalStorage(cacheKey, false);
|
|
12
|
+
const audioMuted = customRef<boolean>((track, tracker) => ({
|
|
13
|
+
get: () => {
|
|
14
|
+
track();
|
|
15
|
+
return audio.muted;
|
|
16
|
+
},
|
|
17
|
+
set: (val) => {
|
|
18
|
+
audio.muted = audioMutedCache.value = val;
|
|
19
|
+
tracker();
|
|
20
|
+
}
|
|
21
|
+
}));
|
|
22
|
+
|
|
23
|
+
useEventListener(document, 'click', () => {
|
|
24
|
+
audio.muted = audioMutedCache.value;
|
|
25
|
+
triggerRef(audioMuted);
|
|
26
|
+
}, {once: true});
|
|
27
|
+
|
|
28
|
+
return audioMuted;
|
|
29
|
+
}
|
|
30
|
+
|
|
10
31
|
const noticeAudio = new Audio(audioURL);
|
|
11
32
|
noticeAudio.muted = true;
|
|
12
33
|
noticeAudio.src = audioURL;
|
|
13
34
|
document.body.append(noticeAudio);
|
|
14
|
-
|
|
15
|
-
export const audioMuted = customRef<boolean>((tracker) => ({
|
|
16
|
-
get: () => noticeAudio.muted,
|
|
17
|
-
set: (val) => {
|
|
18
|
-
noticeAudio.muted = val;
|
|
19
|
-
tracker();
|
|
20
|
-
}
|
|
21
|
-
}));
|
|
35
|
+
export const audioMuted = useAudioMuted(noticeAudio, 'notice_audio_muted');
|
|
22
36
|
|
|
23
37
|
const faviconEle = document.querySelector('link[rel="icon"]');
|
|
24
38
|
const logoFaviconHref = document.querySelector('link[rel="icon"]')?.getAttribute('href')!;
|
|
@@ -59,10 +73,7 @@ function operate(notice: TNotice) {
|
|
|
59
73
|
// watch(noticeNum, (num = 0, oldNum = 0) => {
|
|
60
74
|
// num > oldNum && noticeAudio.play();
|
|
61
75
|
// }, { immediate: true });
|
|
62
|
-
|
|
63
|
-
// noticeAudio.muted = false;
|
|
64
|
-
audioMuted.value = false;
|
|
65
|
-
});
|
|
76
|
+
|
|
66
77
|
|
|
67
78
|
useIntervalFn(() => {
|
|
68
79
|
const num = noticeNum.value;
|