-
+
...
-
+
-
-
+
+
{{ audio?.title }}
+
{{ audio?.style }}
+
@@ -28,7 +31,12 @@ import { VideoPlay, VideoPause } from '@element-plus/icons-vue';
export default defineComponent({
name: 'TaskPreview',
- components: {},
+ components: {
+ ElImage,
+ ElIcon,
+ VideoPlay,
+ VideoPause
+ },
props: {
modelValue: {
type: Object as () => ISunoTask,
@@ -39,6 +47,9 @@ export default defineComponent({
return {};
},
computed: {
+ task() {
+ return this.$store.state.suno?.tasks;
+ },
audios(): ISunoAudio[] {
let result: ISunoAudio[] = [];
if (Array.isArray(this.modelValue?.response?.data)) {
@@ -47,6 +58,7 @@ export default defineComponent({
result.push(audio);
});
}
+ console.log('audios', result);
return result;
},
application() {
@@ -60,7 +72,80 @@ export default defineComponent({
useFormatDuring,
onTogglePlay() {
console.log('on toggle play');
+ },
+ onClick(audio: ISunoAudio) {
+ console.log('on click', audio);
}
}
});
+
+
diff --git a/src/pages/suno/Index.vue b/src/pages/suno/Index.vue
index 3a03b096..bb67e98e 100644
--- a/src/pages/suno/Index.vue
+++ b/src/pages/suno/Index.vue
@@ -80,15 +80,6 @@ export default defineComponent({
application() {
return this.$store.state.suno.application;
}
- // ended() {
- // return this.$store.state.suno.player.ended;
- // }
- },
- watch: {
- ended(val: boolean) {
- if (!val) return;
- this.$store.dispatch('suno/playEnd');
- }
},
async mounted() {
await this.onGetService();
@@ -100,8 +91,6 @@ export default defineComponent({
this.job = setInterval(() => {
this.onGetTasks();
}, 5000);
- this.$store.dispatch('suno/initPlayer');
- this.timer = setInterval(() => this.$store.dispatch('suno/interval'), 1000);
},
async unmounted() {
clearInterval(this.job);
diff --git a/src/store/suno/actions.ts b/src/store/suno/actions.ts
index 292a61c8..ded55f9b 100644
--- a/src/store/suno/actions.ts
+++ b/src/store/suno/actions.ts
@@ -1,5 +1,5 @@
import { applicationOperator, sunoOperator, serviceOperator } from '@/operators';
-import { RootState } from './models';
+import { ISunoState } from './models';
import { ActionContext } from 'vuex';
import { log } from '@/utils/log';
import { IRootState } from '../common/models';
@@ -7,7 +7,7 @@ import { IApplication, ICredential, ISunoConfig, ISunoTask, IService, Song } fro
import { Status } from '@/models/common';
import { SUNO_SERVICE_ID } from '@/constants';
-export const resetAll = ({ commit }: ActionContext
): void => {
+export const resetAll = ({ commit }: ActionContext): void => {
commit('resetAll');
};
@@ -33,7 +33,7 @@ export const getApplication = async ({
commit,
state,
rootState
-}: ActionContext): Promise => {
+}: ActionContext): Promise => {
log(getApplication, 'start to get application for suno');
return new Promise(async (resolve, reject) => {
state.status.getApplication = Status.Request;
@@ -74,6 +74,10 @@ export const setTasksActive = ({ commit }: any, payload: ISunoTask) => {
commit('setTasksActive', payload);
};
+export const setAudio = ({ commit }: any, payload: any) => {
+ commit('setAudio', payload);
+};
+
export const getService = async ({ commit, state }: ActionContext): Promise => {
return new Promise(async (resolve, reject) => {
log(getService, 'start to get service for suno');
@@ -93,7 +97,7 @@ export const getService = async ({ commit, state }: ActionContext,
+ { commit, state }: ActionContext,
{ offset, limit }: { offset?: number; limit?: number }
): Promise => {
return new Promise(async (resolve, reject) => {
@@ -124,157 +128,157 @@ export const getTasks = async (
});
};
-// 歌曲播放action部分
-// 播放器相关的 actions
-export const initPlayer = ({ commit, state }: ActionContext): void => {
- commit('setVolume', state.player.volume);
-};
-// 将歌曲放入播放列表
-export const pushPlayList = (
- { commit }: ActionContext,
- { replace, list }: { replace: boolean; list: Song[] }
-): void => {
- commit('pushPlayList', { replace, list });
-};
-// 清空播放列表
-export const clearPlayList = ({ commit }: ActionContext): void => {
- commit('clearPlayList');
-};
-// 播放歌曲
-export const play = ({ commit, state, dispatch }: ActionContext, song: Song): void => {
- if (song.id == state.player?.id) return;
- commit('setIsPlaying', false);
- // const data = await useSongUrl(id);
- // @ts-ignore
- state.player.audio.src = song.audio_url;
- // @ts-ignore
- state.player.audio
- .play()
- .then(() => {
- commit('setIsPlaying', true);
- commit('setUrl', song.audio_url);
- commit('setId', song.id);
- dispatch('songDetail', song);
- })
- .catch((res) => {
- console.log(res);
- });
-};
+// // 歌曲播放action部分
+// // 播放器相关的 actions
+// export const initPlayer = ({ commit, state }: ActionContext): void => {
+// commit('setVolume', state.player.volume);
+// };
+// // 将歌曲放入播放列表
+// export const pushPlayList = (
+// { commit }: ActionContext,
+// { replace, list }: { replace: boolean; list: Song[] }
+// ): void => {
+// commit('pushPlayList', { replace, list });
+// };
+// // 清空播放列表
+// export const clearPlayList = ({ commit }: ActionContext): void => {
+// commit('clearPlayList');
+// };
+// // 播放歌曲
+// export const play = ({ commit, state, dispatch }: ActionContext, song: Song): void => {
+// if (song.id == state.player?.id) return;
+// commit('setIsPlaying', false);
+// // const data = await useSongUrl(id);
+// // @ts-ignore
+// state.player.audio.src = song.audio_url;
+// // @ts-ignore
+// state.player.audio
+// .play()
+// .then(() => {
+// commit('setIsPlaying', true);
+// commit('setUrl', song.audio_url);
+// commit('setId', song.id);
+// dispatch('songDetail', song);
+// })
+// .catch((res) => {
+// console.log(res);
+// });
+// };
-// 播放结束
-export const playEnd = ({ state, dispatch }: ActionContext): void => {
- console.log('播放结束');
- switch (state.player?.loopType) {
- case 0:
- dispatch('rePlay');
- break;
- case 1:
- dispatch('next');
- break;
- case 2:
- dispatch('randomPlay');
- break;
- }
-};
+// // 播放结束
+// export const playEnd = ({ state, dispatch }: ActionContext): void => {
+// console.log('播放结束');
+// switch (state.player?.loopType) {
+// case 0:
+// dispatch('rePlay');
+// break;
+// case 1:
+// dispatch('next');
+// break;
+// case 2:
+// dispatch('randomPlay');
+// break;
+// }
+// };
-export const songDetail = ({ commit, state }: ActionContext, song: Song): void => {
- commit('setSong', song);
- commit('pushPlayList', { replace: false, list: [song] });
-};
-// 重复播放歌曲
-export const rePlay = ({ commit, state }: ActionContext): void => {
- setTimeout(() => {
- commit('setCurrentTime', 0);
- // @ts-ignore
- state.player?.audio.play();
- }, 1500);
-};
-// 下一首
-export const next = ({ state, dispatch, getters }: ActionContext): void => {
- if (state.player?.loopType === 2) {
- dispatch('randomPlay');
- } else {
- dispatch('play', getters.nextSong);
- }
-};
-// 上一首
-export const prev = ({ dispatch, getters }: ActionContext): void => {
- dispatch('play', getters.prevSong);
-};
-// 随机播放
-export const randomPlay = ({ state, dispatch }: ActionContext): void => {
- // @ts-ignore
- const randomSong = state.player?.playList[Math.floor(Math.random() * state.player?.playList.length)];
- dispatch('play', randomSong);
-};
+// export const songDetail = ({ commit, state }: ActionContext, song: Song): void => {
+// commit('setSong', song);
+// commit('pushPlayList', { replace: false, list: [song] });
+// };
+// // 重复播放歌曲
+// export const rePlay = ({ commit, state }: ActionContext): void => {
+// setTimeout(() => {
+// commit('setCurrentTime', 0);
+// // @ts-ignore
+// state.player?.audio.play();
+// }, 1500);
+// };
+// // 下一首
+// export const next = ({ state, dispatch, getters }: ActionContext): void => {
+// if (state.player?.loopType === 2) {
+// dispatch('randomPlay');
+// } else {
+// dispatch('play', getters.nextSong);
+// }
+// };
+// // 上一首
+// export const prev = ({ dispatch, getters }: ActionContext): void => {
+// dispatch('play', getters.prevSong);
+// };
+// // 随机播放
+// export const randomPlay = ({ state, dispatch }: ActionContext): void => {
+// // @ts-ignore
+// const randomSong = state.player?.playList[Math.floor(Math.random() * state.player?.playList.length)];
+// dispatch('play', randomSong);
+// };
-export const togglePlay = ({ commit, state }: ActionContext): void => {
- if (!state.player?.song?.id) return;
- const isPlaying = !state.player.isPlaying;
- commit('setIsPlaying', isPlaying);
- if (!isPlaying) {
- // @ts-ignore
- state.player?.audio.pause();
- commit('setIsPause', true);
- } else {
- // @ts-ignore
- state.player?.audio.play();
- commit('setIsPause', false);
- }
-};
+// export const togglePlay = ({ commit, state }: ActionContext): void => {
+// if (!state.player?.song?.id) return;
+// const isPlaying = !state.player.isPlaying;
+// commit('setIsPlaying', isPlaying);
+// if (!isPlaying) {
+// // @ts-ignore
+// state.player?.audio.pause();
+// commit('setIsPause', true);
+// } else {
+// // @ts-ignore
+// state.player?.audio.play();
+// commit('setIsPause', false);
+// }
+// };
-export const setPlay = ({ commit, state }: ActionContext): void => {
- if (!state.player?.song?.id) return;
- commit('setIsPlaying', true);
- // @ts-ignore
- state.player?.audio.play();
- commit('setIsPause', false);
-};
+// export const setPlay = ({ commit, state }: ActionContext): void => {
+// if (!state.player?.song?.id) return;
+// commit('setIsPlaying', true);
+// // @ts-ignore
+// state.player?.audio.play();
+// commit('setIsPause', false);
+// };
-export const setPause = ({ commit, state }: ActionContext): void => {
- if (!state.player?.song?.id) return;
- commit('setIsPlaying', false);
- // @ts-ignore
- state.player?.audio.pause();
- commit('setIsPause', true);
-};
+// export const setPause = ({ commit, state }: ActionContext): void => {
+// if (!state.player?.song?.id) return;
+// commit('setIsPlaying', false);
+// // @ts-ignore
+// state.player?.audio.pause();
+// commit('setIsPause', true);
+// };
-export const toggleLoop = ({ commit, state }: ActionContext): void => {
- // @ts-ignore
- const newLoopType = state.player?.loopType === 2 ? 0 : state.player?.loopType + 1;
- commit('setLoopType', newLoopType);
-};
+// export const toggleLoop = ({ commit, state }: ActionContext): void => {
+// // @ts-ignore
+// const newLoopType = state.player?.loopType === 2 ? 0 : state.player?.loopType + 1;
+// commit('setLoopType', newLoopType);
+// };
-export const toggleMuted = ({ commit, state }: ActionContext): void => {
- commit('setMuted', !state.player?.muted);
-};
+// export const toggleMuted = ({ commit, state }: ActionContext): void => {
+// commit('setMuted', !state.player?.muted);
+// };
-export const setVolume = ({ commit }: ActionContext, volume: number): void => {
- volume = Math.min(100, Math.max(0, volume));
- commit('setVolume', volume);
-};
+// export const setVolume = ({ commit }: ActionContext, volume: number): void => {
+// volume = Math.min(100, Math.max(0, volume));
+// commit('setVolume', volume);
+// };
-export const onSliderChange = ({ commit, state }: ActionContext, val: number): void => {
- commit('setCurrentTime', val);
- commit('setSliderInput', false);
- // @ts-ignore
- state.player.audio.currentTime = val;
-};
+// export const onSliderChange = ({ commit, state }: ActionContext, val: number): void => {
+// commit('setCurrentTime', val);
+// commit('setSliderInput', false);
+// // @ts-ignore
+// state.player.audio.currentTime = val;
+// };
-export const onSliderInput = ({ commit }: ActionContext, val: number): void => {
- commit('setSliderInput', true);
-};
+// export const onSliderInput = ({ commit }: ActionContext, val: number): void => {
+// commit('setSliderInput', true);
+// };
-export const interval = ({ commit, state }: ActionContext): void => {
- if (state.player?.isPlaying && !state.player.sliderInput) {
- // @ts-ignore
- commit('setCurrentTime', Math.floor(state.player?.audio?.currentTime));
- // @ts-ignore
- commit('setDuration', Math.floor(state.player?.audio.duration));
- // @ts-ignore
- commit('setEnded', state.player?.audio.ended);
- }
-};
+// export const interval = ({ commit, state }: ActionContext): void => {
+// if (state.player?.isPlaying && !state.player.sliderInput) {
+// // @ts-ignore
+// commit('setCurrentTime', Math.floor(state.player?.audio?.currentTime));
+// // @ts-ignore
+// commit('setDuration', Math.floor(state.player?.audio.duration));
+// // @ts-ignore
+// commit('setEnded', state.player?.audio.ended);
+// }
+// };
export default {
setService,
@@ -289,24 +293,25 @@ export default {
setTasksTotal,
setTasksActive,
getTasks,
- // 播放器相关的 actions
- initPlayer,
- pushPlayList,
- clearPlayList,
- play,
- playEnd,
- songDetail,
- rePlay,
- next,
- prev,
- randomPlay,
- togglePlay,
- setPlay,
- setPause,
- toggleLoop,
- toggleMuted,
- setVolume,
- onSliderChange,
- onSliderInput,
- interval
+ setAudio
+ // // 播放器相关的 actions
+ // initPlayer,
+ // pushPlayList,
+ // clearPlayList,
+ // play,
+ // playEnd,
+ // songDetail,
+ // rePlay,
+ // next,
+ // prev,
+ // randomPlay,
+ // togglePlay,
+ // setPlay,
+ // setPause,
+ // toggleLoop,
+ // toggleMuted,
+ // setVolume,
+ // onSliderChange,
+ // onSliderInput,
+ // interval
};
diff --git a/src/store/suno/index.ts b/src/store/suno/index.ts
index 7f17fc69..a3ac7f42 100644
--- a/src/store/suno/index.ts
+++ b/src/store/suno/index.ts
@@ -1,35 +1,14 @@
import { Module } from 'vuex';
-import { RootState } from './models';
+import { ISunoState } from './models';
import actions from './actions';
import mutations from './mutations';
import state from './state';
-export const suno: Module = {
+export const suno: Module = {
namespaced: true,
state,
mutations,
- actions,
- getters: {
- playListCount: (state) => state.player.playList.length,
- // @ts-ignore
- thisIndex: (state) => state.player.playList.findIndex((song) => song.id === state.player.id),
- nextSong: (state, getters) => {
- const { thisIndex, playListCount } = getters;
- if (thisIndex === playListCount - 1) {
- return state.player.playList[0];
- } else {
- return state.player.playList[thisIndex + 1];
- }
- },
- prevSong: (state, getters) => {
- const { thisIndex } = getters;
- if (thisIndex === 0) {
- return state.player.playList[state.player.playList.length - 1];
- } else {
- return state.player.playList[thisIndex - 1];
- }
- }
- }
+ actions
};
export default suno;
diff --git a/src/store/suno/models.ts b/src/store/suno/models.ts
index 258e984d..17990540 100644
--- a/src/store/suno/models.ts
+++ b/src/store/suno/models.ts
@@ -1,4 +1,4 @@
-import { IApplication, ICredential, IService, Status } from '@/models';
+import { IApplication, ICredential, IService, ISunoAudio, Status } from '@/models';
import { ISunoConfig, ISunoTask, Song } from '@/models';
export interface ISunoState {
@@ -13,6 +13,7 @@ export interface ISunoState {
active: ISunoTask | undefined;
}
| undefined;
+ audio: ISunoAudio | undefined;
status: {
getService: Status;
getApplication: Status;
diff --git a/src/store/suno/mutations.ts b/src/store/suno/mutations.ts
index ab6ccf2e..410f1768 100644
--- a/src/store/suno/mutations.ts
+++ b/src/store/suno/mutations.ts
@@ -1,11 +1,11 @@
import { IApplication, ICredential, ISunoConfig, ISunoTask, IService } from '@/models';
-import { RootState } from './models';
-import { Song, SongUrl } from '@/models';
+import { ISunoState } from './models';
+// import { Song, SongUrl } from '@/models';
-const KEYS = {
- volume: 'PLAYER-VOLUME'
-};
-export const resetAll = (state: RootState): void => {
+// const KEYS = {
+// volume: 'PLAYER-VOLUME'
+// };
+export const resetAll = (state: ISunoState): void => {
state.service = undefined;
state.application = undefined;
state.config = undefined;
@@ -13,23 +13,23 @@ export const resetAll = (state: RootState): void => {
state.tasks = undefined;
};
-export const setService = (state: RootState, payload: IService): void => {
+export const setService = (state: ISunoState, payload: IService): void => {
state.service = payload;
};
-export const setCredential = (state: RootState, payload: ICredential): void => {
+export const setCredential = (state: ISunoState, payload: ICredential): void => {
state.credential = payload;
};
-export const setApplication = (state: RootState, payload: IApplication): void => {
+export const setApplication = (state: ISunoState, payload: IApplication): void => {
state.application = payload;
};
-export const setConfig = (state: RootState, payload: ISunoConfig): void => {
+export const setConfig = (state: ISunoState, payload: ISunoConfig): void => {
state.config = payload;
};
-export const setTasksItems = (state: RootState, payload: ISunoTask[]): void => {
+export const setTasksItems = (state: ISunoState, payload: ISunoTask[]): void => {
const newPayload = {
...state.tasks,
items: payload
@@ -37,7 +37,7 @@ export const setTasksItems = (state: RootState, payload: ISunoTask[]): void => {
state.tasks = newPayload;
};
-export const setTasksTotal = (state: RootState, payload: number): void => {
+export const setTasksTotal = (state: ISunoState, payload: number): void => {
const newPayload = {
...state.tasks,
total: payload
@@ -45,7 +45,7 @@ export const setTasksTotal = (state: RootState, payload: number): void => {
state.tasks = newPayload;
};
-export const setTasksActive = (state: RootState, payload: ISunoTask): void => {
+export const setTasksActive = (state: ISunoState, payload: ISunoTask): void => {
const newPayload = {
...state.tasks,
active: payload
@@ -53,103 +53,107 @@ export const setTasksActive = (state: RootState, payload: ISunoTask): void => {
state.tasks = newPayload;
};
-export const setTasks = (state: RootState, payload: any): void => {
- state.tasks = payload;
-};
-// 歌曲播放的mutations方法
-// 播放器相关的 mutations
-export const setAudio = (state: RootState, audio: HTMLAudioElement): void => {
- state.player.audio = audio;
-};
-// 设置循环模式
-export const setLoopType = (state: RootState, loopType: number): void => {
- state.player.loopType = loopType;
-};
-// 设置音量
-export const setVolume = (state: RootState, volume: number): void => {
- state.player.volume = volume;
- state.player.audio.volume = volume / 100;
- localStorage.setItem(KEYS.volume, volume.toString());
-};
-// 设置播放列表
-export const setPlayList = (state: RootState, playList: Song[]): void => {
- state.player.playList = playList;
-};
-// 设置是否展示播放列表
-export const setShowPlayList = (state: RootState, showPlayList: boolean): void => {
- state.player.showPlayList = showPlayList;
-};
-// 设置歌曲ID
-export const setId = (state: RootState, id: string): void => {
- state.player.id = id;
-};
-// 设置歌曲URL
-export const setUrl = (state: RootState, url: string): void => {
- state.player.url = url;
-};
-// 设置歌曲
-export const setSong = (state: RootState, song: Song): void => {
- state.player.song = song;
+export const setAudio = (state: ISunoState, payload: any): void => {
+ state.audio = payload;
};
-// 设置歌曲正在播放
-export const setIsPlaying = (state: RootState, isPlaying: boolean): void => {
- state.player.isPlaying = isPlaying;
-};
-// 设置歌曲正在暂停
-export const setIsPause = (state: RootState, isPause: boolean): void => {
- state.player.isPause = isPause;
-};
-// 设置歌曲播放进度
-export const setSliderInput = (state: RootState, sliderInput: boolean): void => {
- state.player.sliderInput = sliderInput;
-};
-// 设置歌曲播放结束
-export const setEnded = (state: RootState, ended: boolean): void => {
- state.player.ended = ended;
-};
-// 设置歌曲静音
-export const setMuted = (state: RootState, muted: boolean): void => {
- state.player.muted = muted;
- state.player.audio.muted = muted;
-};
-// 设置歌曲播放当前时间
-export const setCurrentTime = (state: RootState, currentTime: number): void => {
- state.player.currentTime = currentTime;
-};
-// 设置歌曲总时长
-export const setDuration = (state: RootState, duration: number): void => {
- state.player.duration = duration;
-};
-// 将歌曲添加到播放列表
-export const pushPlayList = (state: RootState, { replace, list }: { replace: boolean; list: Song[] }): void => {
- if (replace) {
- state.player.playList = list;
- } else {
- list.forEach((song) => {
- if (state.player.playList.filter((s) => s.id == song.id).length <= 0) {
- state.player.playList.push(song);
- }
- });
- }
-};
-// 清空播放列表
-export const clearPlayList = (state: RootState): void => {
- state.player.url = '';
- state.player.id = '0';
- state.player.song = {} as Song;
- state.player.isPlaying = false;
- state.player.isPause = false;
- state.player.sliderInput = false;
- state.player.ended = false;
- state.player.muted = false;
- state.player.currentTime = 0;
- state.player.playList = [];
- state.player.showPlayList = false;
- state.player.audio.load();
- setTimeout(() => {
- state.player.duration = 0;
- }, 500);
+
+export const setTasks = (state: ISunoState, payload: any): void => {
+ state.tasks = payload;
};
+// // 歌曲播放的mutations方法
+// // 播放器相关的 mutations
+// export const setAudio = (state: RootState, audio: HTMLAudioElement): void => {
+// state.player.audio = audio;
+// };
+// // 设置循环模式
+// export const setLoopType = (state: RootState, loopType: number): void => {
+// state.player.loopType = loopType;
+// };
+// // 设置音量
+// export const setVolume = (state: RootState, volume: number): void => {
+// state.player.volume = volume;
+// state.player.audio.volume = volume / 100;
+// localStorage.setItem(KEYS.volume, volume.toString());
+// };
+// // 设置播放列表
+// export const setPlayList = (state: RootState, playList: Song[]): void => {
+// state.player.playList = playList;
+// };
+// // 设置是否展示播放列表
+// export const setShowPlayList = (state: RootState, showPlayList: boolean): void => {
+// state.player.showPlayList = showPlayList;
+// };
+// // 设置歌曲ID
+// export const setId = (state: RootState, id: string): void => {
+// state.player.id = id;
+// };
+// // 设置歌曲URL
+// export const setUrl = (state: RootState, url: string): void => {
+// state.player.url = url;
+// };
+// // 设置歌曲
+// export const setSong = (state: RootState, song: Song): void => {
+// state.player.song = song;
+// };
+// // 设置歌曲正在播放
+// export const setIsPlaying = (state: RootState, isPlaying: boolean): void => {
+// state.player.isPlaying = isPlaying;
+// };
+// // 设置歌曲正在暂停
+// export const setIsPause = (state: RootState, isPause: boolean): void => {
+// state.player.isPause = isPause;
+// };
+// // 设置歌曲播放进度
+// export const setSliderInput = (state: RootState, sliderInput: boolean): void => {
+// state.player.sliderInput = sliderInput;
+// };
+// // 设置歌曲播放结束
+// export const setEnded = (state: RootState, ended: boolean): void => {
+// state.player.ended = ended;
+// };
+// // 设置歌曲静音
+// export const setMuted = (state: RootState, muted: boolean): void => {
+// state.player.muted = muted;
+// state.player.audio.muted = muted;
+// };
+// // 设置歌曲播放当前时间
+// export const setCurrentTime = (state: RootState, currentTime: number): void => {
+// state.player.currentTime = currentTime;
+// };
+// // 设置歌曲总时长
+// export const setDuration = (state: RootState, duration: number): void => {
+// state.player.duration = duration;
+// };
+// // 将歌曲添加到播放列表
+// export const pushPlayList = (state: RootState, { replace, list }: { replace: boolean; list: Song[] }): void => {
+// if (replace) {
+// state.player.playList = list;
+// } else {
+// list.forEach((song) => {
+// if (state.player.playList.filter((s) => s.id == song.id).length <= 0) {
+// state.player.playList.push(song);
+// }
+// });
+// }
+// };
+// // 清空播放列表
+// export const clearPlayList = (state: RootState): void => {
+// state.player.url = '';
+// state.player.id = '0';
+// state.player.song = {} as Song;
+// state.player.isPlaying = false;
+// state.player.isPause = false;
+// state.player.sliderInput = false;
+// state.player.ended = false;
+// state.player.muted = false;
+// state.player.currentTime = 0;
+// state.player.playList = [];
+// state.player.showPlayList = false;
+// state.player.audio.load();
+// setTimeout(() => {
+// state.player.duration = 0;
+// }, 500);
+// };
export default {
setTasks,
@@ -160,24 +164,6 @@ export default {
setTasksActive,
setTasksItems,
setTasksTotal,
- resetAll,
- // 歌曲播放器配置
- // 播放器相关的 mutations
setAudio,
- setLoopType,
- setVolume,
- setPlayList,
- setShowPlayList,
- setId,
- setUrl,
- setSong,
- setIsPlaying,
- setIsPause,
- setSliderInput,
- setEnded,
- setMuted,
- setCurrentTime,
- setDuration,
- pushPlayList,
- clearPlayList
+ resetAll
};
diff --git a/src/store/suno/persist.ts b/src/store/suno/persist.ts
index 0c3fc2d5..0ed13f33 100644
--- a/src/store/suno/persist.ts
+++ b/src/store/suno/persist.ts
@@ -1 +1 @@
-export default ['suno.config', 'suno.credential', 'suno.application', 'suno.tasks'];
+export default ['suno.config', 'suno.credential', 'suno.application', 'suno.tasks', 'suno.audio'];
diff --git a/src/store/suno/state.ts b/src/store/suno/state.ts
index 241d1561..70898a90 100644
--- a/src/store/suno/state.ts
+++ b/src/store/suno/state.ts
@@ -1,38 +1,39 @@
-import { RootState } from './models';
+import { ISunoState } from './models';
import { Status, Song } from '@/models';
-const KEYS = {
- volume: 'PLAYER-VOLUME'
-};
+// const KEYS = {
+// volume: 'PLAYER-VOLUME'
+// };
-export default (): RootState => {
+export default (): ISunoState => {
return {
service: undefined,
application: undefined,
tasks: undefined,
+ audio: undefined,
credential: undefined,
config: undefined,
status: {
getService: Status.None,
getApplication: Status.None,
getTasks: Status.None
- },
- player: {
- audio: new Audio(),
- loopType: 0,
- volume: parseInt(localStorage.getItem(KEYS.volume) || '60'),
- playList: [],
- showPlayList: false,
- id: '',
- url: '',
- song: undefined,
- isPlaying: false,
- isPause: false,
- sliderInput: false,
- ended: false,
- muted: false,
- currentTime: 0,
- duration: 0
}
+ // player: {
+ // audio: new Audio(),
+ // loopType: 0,
+ // volume: parseInt(localStorage.getItem(KEYS.volume) || '60'),
+ // playList: [],
+ // showPlayList: false,
+ // id: '',
+ // url: '',
+ // song: undefined,
+ // isPlaying: false,
+ // isPause: false,
+ // sliderInput: false,
+ // ended: false,
+ // muted: false,
+ // currentTime: 0,
+ // duration: 0
+ // }
};
};