6565 </button >
6666 </div >
6767 <div v-else class =" ml-2 flex flex-wrap gap-2" >
68+ <a
69+ v-if =" isHtmlPreviewable(record)"
70+ :href =" getHtmlPreviewUrl(record)"
71+ target =" _blank"
72+ rel =" noopener noreferrer"
73+ class =" rounded-xl px-4 py-2 text-sm font-semibold transition duration-300"
74+ :class =" isDarkMode ? 'bg-zinc-200 text-zinc-950 hover:bg-zinc-100' : 'bg-zinc-800 text-white hover:bg-zinc-900'"
75+ >
76+ {{ t('fileRecord.preview') }}
77+ </a >
6878 <button
69- v-if =" isPreviewable(record)"
79+ v-else- if =" isPreviewable(record)"
7080 type =" button"
7181 class =" rounded-xl px-4 py-2 text-sm font-semibold transition duration-300"
72- :class ="
73- isDarkMode
74- ? 'bg-zinc-200 text-zinc-950 hover:bg-zinc-100'
75- : 'bg-zinc-800 text-white hover:bg-zinc-900'
76- "
82+ :class =" isDarkMode ? 'bg-zinc-200 text-zinc-950 hover:bg-zinc-100' : 'bg-zinc-800 text-white hover:bg-zinc-900'"
7783 @click =" $emit('preview-file')"
7884 >
7985 {{ t('fileRecord.preview') }}
@@ -132,7 +138,7 @@ import { useI18n } from 'vue-i18n'
132138import { FileIcon , CalendarIcon , HardDriveIcon , DownloadIcon } from ' lucide-vue-next'
133139import QRCode from ' qrcode.vue'
134140import type { ReceivedFileRecord } from ' @/types'
135- import { buildDownloadUrl , buildReceivedRecordQrValue } from ' @/utils/share-url'
141+ import { buildAbsoluteUrl , buildDownloadUrl , buildReceivedRecordQrValue } from ' @/utils/share-url'
136142
137143interface Props {
138144 visible: boolean
@@ -154,6 +160,14 @@ const getDownloadUrl = (record: ReceivedFileRecord) => {
154160 return buildDownloadUrl (record .downloadUrl )
155161}
156162
163+ const isHtmlPreviewable = (record : ReceivedFileRecord ) => {
164+ const extension = record .filename .split (' .' ).pop ()?.toLowerCase () || ' '
165+ return Boolean (record .downloadUrl ) && [' html' , ' htm' ].includes (extension )
166+ }
167+
168+ const getHtmlPreviewUrl = (record : ReceivedFileRecord ) =>
169+ buildAbsoluteUrl (` /share/preview/html/${encodeURIComponent (record .code )} ` )
170+
157171const getQRCodeValue = (record : ReceivedFileRecord ) => {
158172 return buildReceivedRecordQrValue (record )
159173}
@@ -178,7 +192,9 @@ const isPreviewable = (record: ReceivedFileRecord) => {
178192 ' wav' ,
179193 ' m4a' ,
180194 ' flac' ,
181- ' pdf'
195+ ' pdf' ,
196+ ' html' ,
197+ ' htm'
182198 ].includes (extension )
183199}
184200 </script >
0 commit comments