From a76a0bbebc7db546c68badab8fc5f4c08d3ed002 Mon Sep 17 00:00:00 2001 From: dannc Date: Fri, 22 Feb 2019 21:04:57 +0700 Subject: [PATCH] Add articles list component and store --- src/App.vue | 2 +- src/components/ArticlesList.vue | 149 ++++++++++++++++++++++++++++++++ src/store.js | 4 +- src/store/articles.js | 47 ++++++++++ src/store/general.js | 2 +- src/views/Articles.vue | 8 +- src/views/SignIn.vue | 2 +- src/views/SignUp.vue | 2 +- 8 files changed, 210 insertions(+), 6 deletions(-) create mode 100644 src/components/ArticlesList.vue create mode 100644 src/store/articles.js diff --git a/src/App.vue b/src/App.vue index 1a08a22..d8aed3c 100644 --- a/src/App.vue +++ b/src/App.vue @@ -3,7 +3,7 @@ - + diff --git a/src/components/ArticlesList.vue b/src/components/ArticlesList.vue new file mode 100644 index 0000000..fb2c54d --- /dev/null +++ b/src/components/ArticlesList.vue @@ -0,0 +1,149 @@ + + + + + diff --git a/src/store.js b/src/store.js index 93019a0..a1cf36a 100644 --- a/src/store.js +++ b/src/store.js @@ -1,6 +1,7 @@ import Vue from 'vue'; import Vuex from 'vuex'; +import articleModule from '@/store/articles'; import generalModule from '@/store/general'; import userModule from '@/store/user'; @@ -8,7 +9,8 @@ Vue.use(Vuex); export default new Vuex.Store({ modules: { - userModule, + articleModule, generalModule, + userModule, }, }); diff --git a/src/store/articles.js b/src/store/articles.js new file mode 100644 index 0000000..e6c9d86 --- /dev/null +++ b/src/store/articles.js @@ -0,0 +1,47 @@ +export default { + state: { + articles: [ + { + id: 'sgjngsnaada312', + title: 'Harry Potter und Stein der Weisen - 1', + description: 'Первая глава первой книги о Гарри Поттере', + imageId: 'asfgdfhmfgn131', + parts: 7, + level: ['B2', 'C1'], + rating: 4, + ratingsCount: 164, + youtubePlaylistId: 'asdadsadad', + }, + { + id: 'sgjngsnaadasd2', + title: 'Harry Potter und Stein der Weisen - 2', + description: 'Вторая глава первой книги о Гарри Поттере', + imageId: 'asfgdf111hmfgn131', + parts: 7, + level: ['B1', 'B2'], + rating: 3.5, + ratingsCount: 55, + youtubePlaylistId: 'asdadsadad234234', + }, + { + id: 'sgjngsdbfd12as', + title: 'Harry Potter und Stein der Weisen - 3', + description: 'Третья глава первой книги о Гарри Поттере', + imageId: 'asfgdfhmfgn13111', + parts: 7, + level: ['A2'], + rating: 2, + ratingsCount: 80, + youtubePlaylistId: 'asdadsada435346', + }, + ], + }, + mutations: { + setArticles(state, payload) { + state.articles = payload; + }, + }, + getters: { + getArticles: state => state.articles, + }, +}; diff --git a/src/store/general.js b/src/store/general.js index 0761448..f26eeb0 100644 --- a/src/store/general.js +++ b/src/store/general.js @@ -17,5 +17,5 @@ export default { getters: { getProcessing: state => state.processing, getError: state => state.error, - } + }, }; diff --git a/src/views/Articles.vue b/src/views/Articles.vue index ce18f0b..ec05a2c 100644 --- a/src/views/Articles.vue +++ b/src/views/Articles.vue @@ -1,11 +1,17 @@ diff --git a/src/views/SignIn.vue b/src/views/SignIn.vue index aae6d67..56f2b20 100644 --- a/src/views/SignIn.vue +++ b/src/views/SignIn.vue @@ -60,7 +60,7 @@ isValid: false, emailRules: [ (value) => !!value || 'Пожалуйста, введите email', - (value) => /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(value) || 'Неправильный email', + (value) => /^\w+([.-]?\w+)*@\w+([.-]?\w+)*(\.\w{2,3})+$/.test(value) || 'Неправильный email', ], passwordRules: [ (value) => !!value || 'Пожалуйста введите пароль', diff --git a/src/views/SignUp.vue b/src/views/SignUp.vue index 576d5c5..9c4f719 100644 --- a/src/views/SignUp.vue +++ b/src/views/SignUp.vue @@ -60,7 +60,7 @@ isValid: false, emailRules: [ (value) => !!value || 'Пожалуйста, введите email', - (value) => /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(value) || 'Неправильный email', + (value) => /^\w+([.-]?\w+)*@\w+([.-]?\w+)*(\.\w{2,3})+$/.test(value) || 'Неправильный email', ], passwordRules: [ (value) => !!value || 'Пожалуйста введите пароль',