diff --git a/src/components/nav/index.vue b/src/components/nav/index.vue index ac75891e9fbc14c65c2655700564801447329f04..aa70b9670fd77e92b380c6a23e68052c388c439a 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 3cb88079f63c265c6e821c236c9174ccdefdf200..9504a92720d2f6557e8c6e1e72ce76e5891d7ddd 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 37a2615cb156cbfe6c42c48025a6a50b29085f93..2c8a283f1fdf6b6fecc9fd0c192c400d7878f46d 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 419f4036df25e9d31182d7c7519f581a8b5c4f03..e339d70393c865bec84c2ae3256d142e38b460b6 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 0000000000000000000000000000000000000000..c0891c0cb7224804a8e712b43c5fa19ebc2999a6 --- /dev/null +++ b/src/views/DetailsArticle.vue @@ -0,0 +1,199 @@ + + + + + diff --git a/src/views/HomeView.vue b/src/views/HomeView.vue index c43f6a3926a2aa527e3f909124579d2f99fe4ecc..56a1cf33ebdd1a89a23ff352f36d4751ce8193ea 100644 --- a/src/views/HomeView.vue +++ b/src/views/HomeView.vue @@ -1,17 +1,24 @@