123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- /* eslint no-param-reassign: 0 */
- import Vue from "vue";
- import admin from "../../api/admin/index";
- const state = {};
- const getters = {};
- const actions = {};
- const mutations = {};
- const modules = {
- songs: {
- namespaced: true,
- state: {
- songs: []
- },
- getters: {},
- actions: {
- addSong: ({ commit }, song) => commit("addSong", song),
- removeSong: ({ commit }, songId) => commit("removeSong", songId),
- updateSong: ({ commit }, updatedSong) =>
- commit("updateSong", updatedSong)
- },
- mutations: {
- addSong(state, song) {
- state.songs.push(song);
- },
- removeSong(state, songId) {
- state.songs = state.songs.filter(song => {
- return song._id !== songId;
- });
- },
- updateSong(state, updatedSong) {
- state.songs.forEach((song, index) => {
- if (song._id === updatedSong._id)
- Vue.set(state.songs, index, updatedSong);
- });
- }
- }
- },
- stations: {
- namespaced: true,
- state: {
- stations: []
- },
- getters: {},
- actions: {
- loadStations: ({ commit }, stations) =>
- commit("loadStations", stations),
- stationRemoved: ({ commit }, stationId) =>
- commit("stationRemoved", stationId),
- stationAdded: ({ commit }, station) =>
- commit("stationAdded", station)
- },
- mutations: {
- loadStations(state, stations) {
- state.stations = stations;
- },
- stationAdded(state, station) {
- state.stations.push(station);
- },
- stationRemoved(state, stationId) {
- state.stations = state.stations.filter(station => {
- return station._id !== stationId;
- });
- }
- }
- },
- reports: {
- namespaced: true,
- state: {
- report: {}
- },
- getters: {},
- actions: {
- viewReport: ({ commit }, report) => commit("viewReport", report),
- /* eslint-disable-next-line no-unused-vars */
- resolveReport: ({ commit }, reportId) => {
- return new Promise((resolve, reject) => {
- return admin.reports
- .resolve(reportId)
- .then(res => {
- return resolve(res);
- })
- .catch(err => {
- return reject(new Error(err.message));
- });
- });
- }
- },
- mutations: {
- viewReport(state, report) {
- state.report = report;
- }
- }
- },
- users: {
- namespaced: true,
- state: {},
- getters: {},
- actions: {},
- mutations: {}
- },
- news: {
- namespaced: true,
- state: {
- news: []
- },
- getters: {},
- actions: {
- addNews: ({ commit }, news) => commit("addNews", news),
- removeNews: ({ commit }, newsId) => commit("removeNews", newsId),
- updateNews: ({ commit }, updatedNews) =>
- commit("updateNews", updatedNews)
- },
- mutations: {
- addNews(state, news) {
- state.news.push(news);
- },
- removeNews(state, newsId) {
- state.news = state.news.filter(news => {
- return news._id !== newsId;
- });
- },
- updateNews(state, updatedNews) {
- state.news.forEach((news, index) => {
- if (news._id === updatedNews._id)
- Vue.set(state.news, index, updatedNews);
- });
- }
- }
- }
- };
- export default {
- namespaced: true,
- state,
- getters,
- actions,
- mutations,
- modules
- };
|