refactor: make code more readable
This commit is contained in:
parent
f32fcde23a
commit
173f577b10
|
|
@ -59,9 +59,9 @@ export default defineComponent({
|
|||
const navigationUseProps = computed(() => ({
|
||||
useGlobalFeed: props.useGlobalFeed && articlesTypeInfo.value.globalFeed,
|
||||
useMyFeed: props.useMyFeed && articlesTypeInfo.value.myFeed,
|
||||
useTag: props.useTag ? articlesTypeInfo.value.tag ?? '' : '',
|
||||
useAuthor: props.useAuthor ? articlesTypeInfo.value.author ?? '' : '',
|
||||
useFavorited: props.useFavorited ? articlesTypeInfo.value.favorited ?? '' : '',
|
||||
useTag: props.useTag ? articlesTypeInfo.value.tag : '',
|
||||
useAuthor: props.useAuthor ? articlesTypeInfo.value.author : '',
|
||||
useFavorited: props.useFavorited ? articlesTypeInfo.value.favorited : '',
|
||||
}))
|
||||
|
||||
await fetchArticles()
|
||||
|
|
|
|||
|
|
@ -35,9 +35,9 @@ export function useArticles () {
|
|||
const articlesTypeInfo = computed(() => ({
|
||||
globalFeed: true,
|
||||
myFeed: isAuthorized(user),
|
||||
tag: tag.value,
|
||||
author: username.value,
|
||||
favorited: username.value,
|
||||
tag: tag.value ?? '',
|
||||
author: username.value ?? '',
|
||||
favorited: username.value ?? '',
|
||||
}))
|
||||
|
||||
async function fetchArticles () {
|
||||
|
|
@ -47,13 +47,13 @@ export function useArticles () {
|
|||
if (articlesType.value === 'my-feed') {
|
||||
responsePromise = getFeeds(page.value)
|
||||
}
|
||||
if (articlesType.value === 'tag' && tag?.value !== undefined) {
|
||||
if (articlesType.value === 'tag' && tag.value !== undefined) {
|
||||
responsePromise = getArticlesByTag(tag.value, page.value)
|
||||
}
|
||||
if (articlesType.value === 'profile' && username?.value !== undefined) {
|
||||
if (articlesType.value === 'profile' && username.value !== undefined) {
|
||||
responsePromise = getProfileArticles(username.value, page.value)
|
||||
}
|
||||
if (articlesType.value === 'profile-favorites' && username?.value !== undefined) {
|
||||
if (articlesType.value === 'profile-favorites' && username.value !== undefined) {
|
||||
responsePromise = getFavoritedArticles(username.value, page.value)
|
||||
}
|
||||
if (articlesType.value === 'global-feed') {
|
||||
|
|
|
|||
Loading…
Reference in New Issue