mirror of
https://codeberg.org/yeentown/barkey
synced 2024-11-25 14:05:14 +00:00
feat(client): ジョブキューウィジェットに警報音を鳴らす設定を追加
This commit is contained in:
parent
a8c56afd0f
commit
f95d5701a2
3 changed files with 29 additions and 8 deletions
|
@ -11,6 +11,7 @@
|
||||||
|
|
||||||
### Improvements
|
### Improvements
|
||||||
- Misskey更新時にダイアログを表示するように
|
- Misskey更新時にダイアログを表示するように
|
||||||
|
- ジョブキューウィジェットに警報音を鳴らす設定を追加
|
||||||
|
|
||||||
### Bugfixes
|
### Bugfixes
|
||||||
- ActivityPub: 長いユーザーの名前や自己紹介の対応
|
- ActivityPub: 長いユーザーの名前や自己紹介の対応
|
||||||
|
|
|
@ -2,6 +2,23 @@ import { ColdDeviceStorage } from '@client/store';
|
||||||
|
|
||||||
const cache = new Map<string, HTMLAudioElement>();
|
const cache = new Map<string, HTMLAudioElement>();
|
||||||
|
|
||||||
|
export function getAudio(file: string, useCache = true): HTMLAudioElement {
|
||||||
|
let audio: HTMLAudioElement;
|
||||||
|
if (useCache && cache.has(file)) {
|
||||||
|
audio = cache.get(file);
|
||||||
|
} else {
|
||||||
|
audio = new Audio(`/static-assets/client/sounds/${file}.mp3`);
|
||||||
|
if (useCache) cache.set(file, audio);
|
||||||
|
}
|
||||||
|
return audio;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function setVolume(audio: HTMLAudioElement, volume: number): HTMLAudioElement {
|
||||||
|
const masterVolume = ColdDeviceStorage.get('sound_masterVolume');
|
||||||
|
audio.volume = masterVolume - ((1 - volume) * masterVolume);
|
||||||
|
return audio;
|
||||||
|
}
|
||||||
|
|
||||||
export function play(type: string) {
|
export function play(type: string) {
|
||||||
const sound = ColdDeviceStorage.get('sound_' + type as any);
|
const sound = ColdDeviceStorage.get('sound_' + type as any);
|
||||||
if (sound.type == null) return;
|
if (sound.type == null) return;
|
||||||
|
@ -12,13 +29,6 @@ export function playFile(file: string, volume: number) {
|
||||||
const masterVolume = ColdDeviceStorage.get('sound_masterVolume');
|
const masterVolume = ColdDeviceStorage.get('sound_masterVolume');
|
||||||
if (masterVolume === 0) return;
|
if (masterVolume === 0) return;
|
||||||
|
|
||||||
let audio: HTMLAudioElement;
|
const audio = setVolume(getAudio(file), volume);
|
||||||
if (cache.has(file)) {
|
|
||||||
audio = cache.get(file);
|
|
||||||
} else {
|
|
||||||
audio = new Audio(`/static-assets/client/sounds/${file}.mp3`);
|
|
||||||
cache.set(file, audio);
|
|
||||||
}
|
|
||||||
audio.volume = masterVolume - ((1 - volume) * masterVolume);
|
|
||||||
audio.play();
|
audio.play();
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,6 +50,7 @@ import { defineComponent, markRaw } from 'vue';
|
||||||
import define from './define';
|
import define from './define';
|
||||||
import * as os from '@client/os';
|
import * as os from '@client/os';
|
||||||
import number from '@client/filters/number';
|
import number from '@client/filters/number';
|
||||||
|
import * as sound from '@client/scripts/sound';
|
||||||
|
|
||||||
const widget = define({
|
const widget = define({
|
||||||
name: 'jobQueue',
|
name: 'jobQueue',
|
||||||
|
@ -58,6 +59,10 @@ const widget = define({
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
|
sound: {
|
||||||
|
type: 'boolean',
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -79,6 +84,7 @@ export default defineComponent({
|
||||||
delayed: 0,
|
delayed: 0,
|
||||||
},
|
},
|
||||||
prev: {},
|
prev: {},
|
||||||
|
sound: sound.setVolume(sound.getAudio('syuilo/queue-jammed'), 1)
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
|
@ -107,6 +113,10 @@ export default defineComponent({
|
||||||
this[domain].active = stats[domain].active;
|
this[domain].active = stats[domain].active;
|
||||||
this[domain].waiting = stats[domain].waiting;
|
this[domain].waiting = stats[domain].waiting;
|
||||||
this[domain].delayed = stats[domain].delayed;
|
this[domain].delayed = stats[domain].delayed;
|
||||||
|
|
||||||
|
if (this[domain].waiting > 0 && this.props.sound && this.sound.paused) {
|
||||||
|
this.sound.play();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue