рефакторинг getPlaying. Добавил кастомное правило в .eslintrc.cjs

This commit is contained in:
Norbaev 2024-06-28 09:41:56 +05:00
parent 15acc8c861
commit 6e1fbf6b16
3 changed files with 11 additions and 8 deletions

View File

@ -83,5 +83,8 @@ module.exports = {
'vue/multi-word-component-names': 'off',
// allow debugger during development only
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
// Custom
'no-console': 'warn',
},
};

View File

@ -239,20 +239,21 @@ export default {
getPlaying(e) {
// console.log('getPlaying', e);
const jsonData = JSON.parse(e.data);
console.log('jsonData', jsonData);
// console.log('jsonData', jsonData);
const data =
// Второй ответ
jsonData?.pub?.data ||
// Первый ответ
jsonData?.connect?.subs?.['station:it-radio']?.publications?.[0]?.data;
console.log('getPlaying', data);
// console.log('getPlaying', data);
if (!data) return;
if (this.currentPlay.live) {
const dataUrl = data.np.station.listen_url;
if (data.np.station.listen_url !== this.player.target.src) {
console.log('data.np.station.listen_url', data.np.station.listen_url);
this.$store.dispatch('changePlayer', data.np.station.listen_url);
const playerUrl = this.player.target.src;
if (dataUrl !== playerUrl) {
// console.log('data.np.station.listen_url', dataUrl);
this.$store.dispatch('changePlayer', dataUrl);
console.log(this.player);
const params = {
...this.currentPlay,
@ -262,9 +263,9 @@ export default {
live: true,
currentIndex: null,
};
console.log('params in getPlaying ', params);
delete params.unique_id;
this.$store.dispatch('setCurrentPlay', params);
console.log(this.$store.state);
}
}
},

View File

@ -25,7 +25,7 @@ export default class extends REST {
sseBaseUri + '?' + sseUriParams.toString(),
);
// window.connection = this.connection;
this.connection.onopen = (e) => console.log('connected', e);
// this.connection.onopen = (e) => console.log('connected', e);
}
removePlay() {
@ -66,7 +66,6 @@ export default class extends REST {
// return this._get(`station/${station}/playlists`, params, {}).then((data) => {
return this._get(`radio.mp3`, params, {})
.then((data) => {
console.log(data);
return data;
})
.catch((error) => {