feat(system): write to system media for tack photo

This commit is contained in:
Timi
2026-11-18 14:08:47 +08:00
parent 635192eae1
commit 60cadff951
8 changed files with 289 additions and 1 deletions
+11
View File
@@ -10,6 +10,7 @@ export interface SoundSetting {
type SoundType = "scanSuccess" | "registerSuccess";
const SOUND_STORAGE_KEY = "gao-customer-h5:sound";
const ALBUM_SAVE_STORAGE_KEY = "gao-customer-h5:album-save";
const soundUrlMap: Record<SoundType, string> = {
scanSuccess: scanSuccessSoundUrl,
registerSuccess: registrationSuccessSoundUrl
@@ -48,6 +49,8 @@ function readStoredSoundSetting(): SoundSetting {
export const useSettingStore = defineStore("setting", () => {
const sound = ref<SoundSetting>(readStoredSoundSetting());
/** 拍照后是否额外存一份到系统相册,默认开启 */
const albumSave = ref(localStorage.getItem(ALBUM_SAVE_STORAGE_KEY) !== "0");
const soundPlayerMap = shallowRef<Record<SoundType, HTMLAudioElement> | null>(null);
const audioContext = shallowRef<AudioContext | null>(null);
const scanSuccessBuffer = shallowRef<AudioBuffer | null>(null);
@@ -64,6 +67,12 @@ export const useSettingStore = defineStore("setting", () => {
applySoundVolume();
}
/** 开关相册副本,只影响后续拍摄,已保存的文件不动 */
function setAlbumSave(value: boolean): void {
albumSave.value = value;
localStorage.setItem(ALBUM_SAVE_STORAGE_KEY, value ? "1" : "0");
}
function loadSoundPlayers(): void {
if (soundPlayerMap.value) {
return;
@@ -223,7 +232,9 @@ export const useSettingStore = defineStore("setting", () => {
return {
sound,
albumSave,
setSound,
setAlbumSave,
loadSoundPlayers,
unlockSoundPlayers,
playScanSuccessSound,