From f667f3bf0b06f48745786efc90efbe30ffec9916 Mon Sep 17 00:00:00 2001 From: Chilfish Date: Wed, 7 Aug 2024 01:56:15 +0800 Subject: [PATCH] feat(web): show post detail on clicked --- apps/web/nuxt.config.ts | 1 + apps/web/src/App.vue | 4 ++- apps/web/src/pages/album.vue | 48 ++++++++++++++++++++++++++---- packages/core/src/stores/post.ts | 19 +++++++----- packages/core/src/utils/storage.ts | 10 ++++++- packages/ui/package.json | 2 +- packages/ui/src/AppMain.vue | 9 ++++-- packages/ui/src/MainHeader.vue | 44 +++++++++++++++++++-------- packages/ui/src/MainImage.vue | 7 ++++- packages/ui/src/index.ts | 5 ++++ packages/ui/src/post/Profile.vue | 2 +- 11 files changed, 117 insertions(+), 34 deletions(-) create mode 100644 packages/ui/src/index.ts diff --git a/apps/web/nuxt.config.ts b/apps/web/nuxt.config.ts index 852dc23..fc55836 100644 --- a/apps/web/nuxt.config.ts +++ b/apps/web/nuxt.config.ts @@ -45,6 +45,7 @@ export default defineNuxtConfig({ alias: { '@core': core, '@shared': shared, + '@ui': ui, }, imports: { diff --git a/apps/web/src/App.vue b/apps/web/src/App.vue index 9045049..114ee8c 100644 --- a/apps/web/src/App.vue +++ b/apps/web/src/App.vue @@ -62,7 +62,9 @@ onNuxtReady(async () => { diff --git a/packages/ui/src/MainImage.vue b/packages/ui/src/MainImage.vue index e0db2a0..da6655c 100644 --- a/packages/ui/src/MainImage.vue +++ b/packages/ui/src/MainImage.vue @@ -2,6 +2,8 @@ import { useStorage } from '@vueuse/core' import { ImgPlaceholder } from '@core/constants' +import type { ImageProps } from 'naive-ui' + const props = withDefaults(defineProps<{ src: string alt?: string @@ -10,10 +12,12 @@ const props = withDefaults(defineProps<{ minHeight?: string | number fit?: 'fill' | 'contain' | 'cover' | 'none' | 'scale-down' lazy?: boolean -}>(), { + preview?: boolean +} >(), { fit: 'contain', alt: 'image', lazy: true, + preview: true, }) const realSrc = ref(props.src) @@ -64,6 +68,7 @@ onUnmounted(() => { minHeight, }, }" + :preview-disabled="!preview" /> diff --git a/packages/ui/src/index.ts b/packages/ui/src/index.ts new file mode 100644 index 0000000..a96e5b3 --- /dev/null +++ b/packages/ui/src/index.ts @@ -0,0 +1,5 @@ +import PostItem from './post/Item.vue' + +export { + PostItem, +} diff --git a/packages/ui/src/post/Profile.vue b/packages/ui/src/post/Profile.vue index 68b0c43..87759d1 100644 --- a/packages/ui/src/post/Profile.vue +++ b/packages/ui/src/post/Profile.vue @@ -9,7 +9,7 @@ const props = defineProps<{ const publicStore = usePublicStore() -const user = toRef(props.user || inject(KeyUser)!) +const user = toRef(props.user || inject(KeyUser) || publicStore.curUser!) const avatar = computed(() => { const url = user.value.avatar