From e124e67086d337f64be6ac17b241a4a8f5bfdf96 Mon Sep 17 00:00:00 2001 From: 628992d768790c7144c1f639 <628992d768790c7144c1f639@devide> Date: Tue, 9 May 2023 14:52:00 +0000 Subject: [PATCH] Tue May 9 14:52:00 UTC 2023 inscode --- src/components/nav/index.vue | 3 +- src/router/index.js | 5 + src/stores/article.js | 34 +++--- src/utils/mockData.js | 57 ++++++---- src/views/DetailsArticle.vue | 199 +++++++++++++++++++++++++++++++++++ src/views/HomeView.vue | 29 +++-- src/views/NewArticle.vue | 40 ++++++- 7 files changed, 320 insertions(+), 47 deletions(-) create mode 100644 src/views/DetailsArticle.vue diff --git a/src/components/nav/index.vue b/src/components/nav/index.vue index ac75891..aa70b96 100644 --- a/src/components/nav/index.vue +++ b/src/components/nav/index.vue @@ -33,6 +33,7 @@ console.log(value); store.sigin(userModalConfig); vibisible.value = false; + userStatus.value = store.isRejecter(); } catch (error) { console.log(error); } @@ -62,7 +63,7 @@ - + diff --git a/src/router/index.js b/src/router/index.js index 3cb8807..9504a92 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -21,6 +21,11 @@ const router = createRouter({ path: '/newArticle', name:'newArticle', component: () => import('../views/NewArticle.vue') + }, + { + path: '/detailsArticle', + name:'detailsArticle', + component: () => import('../views/DetailsArticle.vue') } ] }) diff --git a/src/stores/article.js b/src/stores/article.js index 37a2615..2c8a283 100644 --- a/src/stores/article.js +++ b/src/stores/article.js @@ -4,29 +4,39 @@ import { getStorage, setStorage } from '@/utils/storage' export const useArticleStore = defineStore('article', () => { const articles = reactive([]) - const setArticle = (id, data) => { - let atc = getArticle(id) - if (atc) { - atc = data - } else { - articles.push(data) + const addAtricle = (data) => { + const atc = getAllArticle() + if (!atc) { + articles.unshift(data) console.log(articles); - setStorage('article', articles) + setStorage('article', articles) + } else{ + console.log(atc) + atc.unshift(data) + setStorage('article', atc) } } - const getArticle = (id) => { - const atc = getAllArticle() ?? false - if (atc) { - return atc.filter(item => item.id === id) + const setArticle = (id, data) => { + let atcs = getAllArticle() ?? false + if (atcs) { + atcs.forEach(item => { + if(item.id == id) { + console.log(item) + item.comment.unshift(data) + } + }) + console.log(atcs) + setStorage('article', atcs) } } + const getAllArticle = () => { return getStorage('article') } return { articles, + addAtricle, setArticle, - getArticle, getAllArticle, } }) \ No newline at end of file diff --git a/src/utils/mockData.js b/src/utils/mockData.js index 419f403..e339d70 100644 --- a/src/utils/mockData.js +++ b/src/utils/mockData.js @@ -1,52 +1,63 @@ export const mockData = [ { id: '01', - username: 'admin', + username: 'justin', date: new Date().toLocaleString(), content: { title: '震惊!原来日记可以唱出来', abstract: '11月20日零点,北京,小雨,心情好平静,今天做了很多事情,回到家里有点烦心', - article: '', - } + article: ',今天做了很多事情,回到家里有点烦心', + }, + comment: [ + { + author: 'test', + content: '哈哈', + datetime: '2023/5/8 18:41:39', + } + ], }, { id: '02', - username: 'admin', + username: 'lolita', date: new Date().toLocaleString(), content: { - title: '震惊!原来日记可以唱出来', - abstract: '11月20日零点,北京,小雨,心情好平静,今天做了很多事情,回到家里有点烦心', - article: '', - } + title: '忘不掉的是回忆嘛?', + abstract: '我多想忘掉回忆的坐标,但现实却是多么可笑,我们是从初次遇见不如不见到好久再见', + article: '我多想忘掉回忆的坐标,但现实却是多么可笑,我们是从初次遇见不如不见到好久再见', + }, + comment: [] }, { id: '03', - username: 'admin', + username: 'angle', date: new Date().toLocaleString(), content: { - title: '震惊!原来日记可以唱出来', - abstract: '11月20日零点,北京,小雨,心情好平静,今天做了很多事情,回到家里有点烦心', - article: '', - } + title: '我爱你iloveyou', + abstract: '我以为我不会比今天更爱你了,但是我昨天也是这么想的,随时间流走在回忆里遨游', + article: '我以为我不会比今天更爱你了,但是我昨天也是这么想的,随时间流走在回忆里遨游', + }, + comment: [] }, { id: '04', - username: 'admin', + username: 'toms', date: new Date().toLocaleString(), content: { - title: '震惊!原来日记可以唱出来', - abstract: '11月20日零点,北京,小雨,心情好平静,今天做了很多事情,回到家里有点烦心', - article: '', - } + title: '原来这才是爱情', + abstract: '如果你并不期待,那么我翻山越岭将毫无意义,细节是双向的,爱情是相互的', + article: '如果你并不期待,那么我翻山越岭将毫无意义,细节是双向的,爱情是相互的', + }, + comment: [] }, { id: '05', - username: 'admin', + username: 'john', date: new Date().toLocaleString(), content: { - title: '震惊!原来日记可以唱出来', - abstract: '11月20日零点,北京,小雨,心情好平静,今天做了很多事情,回到家里有点烦心', - article: '', - } + title: '青春的真谛', + abstract: '生活不得万分如意,现实不过千般磨砺,趁青春时可肆意,人海中,似有意,更似无意', + article: '生活不得万分如意,现实不过千般磨砺,趁青春时可肆意,人海中,似有意,更似无意', + }, + comment: [] }, ] \ No newline at end of file diff --git a/src/views/DetailsArticle.vue b/src/views/DetailsArticle.vue new file mode 100644 index 0000000..c0891c0 --- /dev/null +++ b/src/views/DetailsArticle.vue @@ -0,0 +1,199 @@ + + + + + diff --git a/src/views/HomeView.vue b/src/views/HomeView.vue index c43f6a3..56a1cf3 100644 --- a/src/views/HomeView.vue +++ b/src/views/HomeView.vue @@ -1,17 +1,24 @@