From 5382574cfd9f7f64c91660e6499496b2290a3c3d Mon Sep 17 00:00:00 2001 From: Jerry Date: Tue, 11 Jun 2024 21:07:16 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E6=B7=BB=E5=8A=A0=E9=9F=B3=E4=B9=90?= =?UTF-8?q?=EF=BC=8C=E8=A6=81=E5=88=B7=E6=96=B0=E4=B8=80=E4=B8=8B=E6=89=8D?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=20#126?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/FriendsMemo.vue | 77 ++++++++++++++++---------------------- components/MemoInput.vue | 68 ++++++++++++++++----------------- pages/index.vue | 2 +- 3 files changed, 66 insertions(+), 81 deletions(-) diff --git a/components/FriendsMemo.vue b/components/FriendsMemo.vue index 02d5dc52..1c324d99 100644 --- a/components/FriendsMemo.vue +++ b/components/FriendsMemo.vue @@ -23,21 +23,12 @@ {{ props.memo.externalTitle }} - - - -
- - + + + +
+
@@ -65,7 +56,7 @@
全文
- +
收起
{{ props.memo.location?.split(/\s+/g).join(' · ') }}
@@ -160,17 +151,7 @@ import { Heart, HeartCrack, MessageSquareMore, Trash2, FilePenLine, Pin } from ' import { memoUpdateEvent } from '@/lib/event' import { toast } from 'vue-sonner'; import { getImgUrl } from '~/lib/utils'; -import { - AlertDialog, - AlertDialogAction, - AlertDialogCancel, - AlertDialogContent, - AlertDialogDescription, - AlertDialogFooter, - AlertDialogHeader, - AlertDialogTitle, - AlertDialogTrigger, -} from '@/components/ui/alert-dialog' + const token = useCookie('token') dayjs.extend(relativeTime) const props = withDefaults( @@ -202,32 +183,34 @@ const musicType = ref('') const musicId = ref('') const musicPlatform = ref('netease') -if(props.memo.music163Url){ - if(props.memo.music163Url.includes("music.163.com")){ - if(props.memo.music163Url.includes("playlist")){ +if (props.memo.music163Url) { + if (props.memo.music163Url.includes("music.163.com")) { + if (props.memo.music163Url.includes("playlist")) { musicType.value = 'playlist' musicId.value = props.memo.music163Url.split('playlist?id=')[1].split('&')[0] - }else if(props.memo.music163Url.includes("song")){ + } else if (props.memo.music163Url.includes("song")) { musicType.value = 'song' musicId.value = props.memo.music163Url.split('song?id=')[1].split('&')[0] - }else if(props.memo.music163Url.includes("album")) { + } else if (props.memo.music163Url.includes("album")) { musicType.value = 'album' musicId.value = props.memo.music163Url.split('album?id=')[1].split('&')[0] } - }else if(props.memo.music163Url.includes("y.qq.com")){ + } else if (props.memo.music163Url.includes("y.qq.com")) { musicPlatform.value = 'tencent' - if(props.memo.music163Url.includes("songDetail")){ + if (props.memo.music163Url.includes("songDetail")) { musicType.value = 'song' musicId.value = props.memo.music163Url.split('songDetail/')[1].split('?')[0] - }else if(props.memo.music163Url.includes("playlist")){ + } else if (props.memo.music163Url.includes("playlist")) { musicType.value = 'playlist' musicId.value = props.memo.music163Url.split('playlist/')[1].split('?')[0] } - }else{ + } else { props.memo.music163Url = '' } } +console.log(props.memo.music163Url, musicType.value, musicId.value) + const { height } = useElementSize(el) const likeList = useStorage>('likeList', []) @@ -235,7 +218,7 @@ const linkReg = /\[(.*?)\]\((.*?)\)/g const memoExt = computed(() => JSON.parse(props.memo.ext || '{}') as MemoExt) const tags = computed(() => props.memo.content.match(/#(\S+)/g) || []) -const memoContent = computed(() => props.memo.content.replaceAll(/\n/g, '
').replace(/#(\S+)/g, '').replace(linkReg,"$1")) +const memoContent = computed(() => props.memo.content.replaceAll(/\n/g, '
').replace(/#(\S+)/g, '').replace(linkReg, "$1")) const imgs = computed(() => props.memo.imgs ? props.memo.imgs.split(',') : []); const gridStyle = computed(() => { @@ -262,7 +245,7 @@ const gridStyle = computed(() => { const like = async () => { showToolbar.value = false const contain = likeList.value.find((id) => id === props.memo.id) - const res = await $fetch('/api/memo/like', { + const res = await $fetch<{ success: boolean }>('/api/memo/like', { method: 'POST', body: JSON.stringify({ memoId: props.memo.id, @@ -285,7 +268,7 @@ const toDetail = () => { const pinned = async () => { showToolbar.value = false - const res = await $fetch('/api/memo/pinned', { + const res = await $fetch<{ success: boolean }>('/api/memo/pinned', { method: 'POST', body: JSON.stringify({ memoId: props.memo.id, @@ -300,7 +283,7 @@ const pinned = async () => { const removeMemo = async () => { showToolbar.value = false - const res = await $fetch('/api/memo/remove', { + const res = await $fetch<{ success: boolean }>('/api/memo/remove', { method: 'POST', body: JSON.stringify({ memoId: props.memo.id @@ -372,7 +355,7 @@ watchOnce(height, () => { width: 100%; } -.aplayer-pic{ +.aplayer-pic { z-index: 1; } @@ -385,13 +368,19 @@ watchOnce(height, () => { animation: scroll 8s linear infinite; } -.aplayer-title, .aplayer-author { +.aplayer-title, +.aplayer-author { padding-right: 10px; } @keyframes scroll { - from { transform: translateX(100%); } - to { transform: translateX(-100%); } + from { + transform: translateX(100%); + } + + to { + transform: translateX(-100%); + } } .aplayer-lrc { diff --git a/components/MemoInput.vue b/components/MemoInput.vue index 5962405b..041ff0b2 100644 --- a/components/MemoInput.vue +++ b/components/MemoInput.vue @@ -47,10 +47,10 @@
- +