From 848c32b65b3097f4408f7140313de4f1386e5e04 Mon Sep 17 00:00:00 2001 From: Jerry Date: Sun, 2 Jun 2024 20:14:21 +0800 Subject: [PATCH] =?UTF-8?q?fix=20#105=20=E6=94=AF=E6=8C=81=E6=8F=92?= =?UTF-8?q?=E5=85=A5=E9=9F=B3=E9=A2=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/FriendsMemo.vue | 2 ++ components/MemoInput.vue | 74 +++++++++++++++++++++++--------------- lib/types.ts | 1 + 3 files changed, 49 insertions(+), 28 deletions(-) diff --git a/components/FriendsMemo.vue b/components/FriendsMemo.vue index b3032691..ab17263b 100644 --- a/components/FriendsMemo.vue +++ b/components/FriendsMemo.vue @@ -32,6 +32,8 @@ + + diff --git a/components/MemoInput.vue b/components/MemoInput.vue index 56ecd90e..2c26026e 100644 --- a/components/MemoInput.vue +++ b/components/MemoInput.vue @@ -63,15 +63,20 @@
-
嵌入网易云音乐 - - 如何获取? +
+
嵌入网易云音乐 + + 如何获取? +
+ + + +
- + @click="music163IfrUrl = ''; music163Url = ''; audioUrl = ''; music163Open = false;">清空
@@ -128,7 +133,12 @@ - + + + +

引入豆瓣读书和豆瓣电影

@@ -199,6 +209,8 @@ + + @@ -237,9 +249,7 @@
+ @dragstart="event => dragStart(event, index)" @dragover="dragOver" @drop="event => drop(event, index)"> @@ -249,7 +259,9 @@
-
{{ fmtLocation }}
+
+ {{ fmtLocation }} +
@@ -260,7 +272,7 @@
- +
@@ -273,7 +285,7 @@ import { Textarea } from '@/components/ui/textarea' import { Button, buttonVariants } from '@/components/ui/button' import { toast } from 'vue-sonner' import { memoUpdateEvent } from '@/lib/event' -import type {DoubanBook, DoubanMovie, Memo, MemoExt, PrivateConfig, PublicConfig} from '~/lib/types'; +import type { DoubanBook, DoubanMovie, Memo, MemoExt, PrivateConfig, PublicConfig } from '~/lib/types'; import { useAnimate } from '@vueuse/core'; import { Image, Music4, Settings, Trash2, LogOut, Link, Youtube, CircleX, Check, Loader2, MapPin } from 'lucide-vue-next' import jsonp from "jsonp"; @@ -300,6 +312,7 @@ const fmtLocation = computed(() => { const content = ref('') const id = ref(-1) const music163Url = ref('') +const audioUrl = ref('') const music163IfrUrl = ref('') const music163Open = ref(false) @@ -399,7 +412,7 @@ const submitMemo = async () => { && music163IfrUrl.value === '' && bilibiliIfrUrl.value === '' && videoIfrUrl.value === '' && youtubeIfrUrl.value === '' && externalUrl.value === '' && !doubanBook.value - && !doubanMovie.value && localVideoUrl.value === '') { + && !doubanMovie.value && localVideoUrl.value === ''&& audioUrl.value === '') { toast.warning('请输入内容') return } @@ -420,7 +433,8 @@ const submitMemo = async () => { doubanMovie: doubanMovie.value, youtubeUrl: youtubeIfrUrl.value, videoUrl: videoIfrUrl.value, - localVideoUrl: localVideoUrl.value + localVideoUrl: localVideoUrl.value, + audioUrl: audioUrl.value }, showType: showType.value }) @@ -449,6 +463,7 @@ const submitMemo = async () => { douban.id = '' douban.type = 'book' localVideoUrl.value = '' + audioUrl.value = '' emit(id.value > 0 ? 'memoUpdated' : 'memoAdded') id.value = -1 } else { @@ -552,16 +567,19 @@ const uploadImgs = async (event: Event) => { } const importMusic = () => { - if (music163Url.value === '') { - toast.warning('请输入网易云音乐代码') + if (music163Url.value === '' && audioUrl.value === '') { + toast.warning('请输入网易云音乐代码或者在线音频的地址') return } - const match = music163Url.value.match(/src="(.*)&auto.*"/) - if (match && match.length > 1) { - const url = match[1] - music163IfrUrl.value = url + '&auto=0&height=66' - music163Open.value = false + if (music163Url.value) { + const match = music163Url.value.match(/src="(.*)&auto.*"/) + if (match && match.length > 1) { + const url = match[1] + music163IfrUrl.value = url + '&auto=0&height=66' + } } + music163Open.value = false + } @@ -647,7 +665,7 @@ memoUpdateEvent.on((event: Memo & { index?: number }) => { music163IfrUrl.value = event.music163Url || '' music163Url.value = `` textareaRef.value?.getRef().focus() - showType.value = event.showType==1 + showType.value = event.showType == 1 }) const getTmpLocation = async () => { @@ -666,7 +684,7 @@ const getTmpLocation = async () => { }; const queryString = new URLSearchParams(params).toString(); const jsonpUrl = `${url}?${queryString}`; - + jsonp(jsonpUrl, null, (err: any, data: any) => { if (err) { return '获取位置失败'; @@ -738,12 +756,12 @@ async function updateLocation() { \ No newline at end of file diff --git a/lib/types.ts b/lib/types.ts index 9706e4ed..494aa16a 100644 --- a/lib/types.ts +++ b/lib/types.ts @@ -83,6 +83,7 @@ export type MemoExt = { youtubeUrl: string; videoUrl: string; localVideoUrl: string; + audioUrl: string; }; export type SysConfig = {