Lan
2025-09-04 10:29:53 +08:00
parent 0f132645a0
commit a4942e1757
+276 -99
View File
@@ -1,74 +1,120 @@
<template> <template>
<div class="min-h-screen flex items-center justify-center p-4 overflow-hidden transition-colors duration-300"> <div
class="min-h-screen flex items-center justify-center p-4 overflow-hidden transition-colors duration-300"
>
<div class="w-full max-w-md relative z-10"> <div class="w-full max-w-md relative z-10">
<div class="rounded-3xl shadow-2xl overflow-hidden border transform transition-all duration-300" :class="[ <div
isDarkMode class="rounded-3xl shadow-2xl overflow-hidden border transform transition-all duration-300"
? 'bg-gray-800 bg-opacity-50 backdrop-filter backdrop-blur-xl border-gray-700' :class="[
: 'bg-white border-gray-200' isDarkMode
]"> ? 'bg-gray-800 bg-opacity-50 backdrop-filter backdrop-blur-xl border-gray-700'
: 'bg-white border-gray-200'
]"
>
<div class="p-8"> <div class="p-8">
<div class="flex justify-center mb-8"> <div class="flex justify-center mb-8">
<div class="rounded-full bg-gradient-to-r from-indigo-500 via-purple-500 to-pink-500 p-1 animate-spin-slow"> <div
class="rounded-full bg-gradient-to-r from-indigo-500 via-purple-500 to-pink-500 p-1 animate-spin-slow"
>
<div class="rounded-full bg-gray-900 p-2"> <div class="rounded-full bg-gray-900 p-2">
<BoxIcon class="w-8 h-8 text-white" /> <BoxIcon class="w-8 h-8 text-white" />
</div> </div>
</div> </div>
</div> </div>
<h2 @click="toSend" class="text-3xl cursor-pointer font-extrabold text-center mb-6" :class="[ <h2
isDarkMode @click="toSend"
? 'text-transparent bg-clip-text bg-gradient-to-r from-indigo-300 via-purple-300 to-pink-300' class="text-3xl cursor-pointer font-extrabold text-center mb-6"
: 'text-indigo-600' :class="[
]"> isDarkMode
? 'text-transparent bg-clip-text bg-gradient-to-r from-indigo-300 via-purple-300 to-pink-300'
: 'text-indigo-600'
]"
>
{{ config.name }} {{ config.name }}
</h2> </h2>
<form @submit.prevent="handleSubmit"> <form @submit.prevent="handleSubmit">
<div class="mb-6 relative"> <div class="mb-6 relative">
<label for="code" class="block text-sm font-medium mb-2" <label
:class="[isDarkMode ? 'text-gray-300' : 'text-gray-800']">取件码</label> for="code"
class="block text-sm font-medium mb-2"
:class="[isDarkMode ? 'text-gray-300' : 'text-gray-800']"
>取件码</label
>
<div class="relative"> <div class="relative">
<input id="code" v-model="code" type="text" ref="codeInput" <input
id="code"
v-model="code"
type="text"
ref="codeInput"
class="w-full px-4 py-3 rounded-lg placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-indigo-500 transition duration-300 pr-10" class="w-full px-4 py-3 rounded-lg placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-indigo-500 transition duration-300 pr-10"
:class="[ :class="[
isDarkMode ? 'bg-gray-700 bg-opacity-50' : 'bg-gray-100', isDarkMode ? 'bg-gray-700 bg-opacity-50' : 'bg-gray-100',
{ 'ring-2 ring-red-500': error }, { 'ring-2 ring-red-500': error },
isDarkMode ? 'text-gray-300' : 'text-gray-800' isDarkMode ? 'text-gray-300' : 'text-gray-800'
]" placeholder="请输入5位取件码" required :readonly="inputStatus.readonly" maxlength="5" ]"
@focus="isInputFocused = true" @blur="isInputFocused = false" /> placeholder="请输入5位取件码"
<div v-if="inputStatus.loading" class="absolute inset-y-0 right-0 flex items-center pr-3"> required
<span class="animate-spin rounded-full h-5 w-5 border-b-2 border-indigo-500"></span> :readonly="inputStatus.readonly"
maxlength="5"
@focus="isInputFocused = true"
@blur="isInputFocused = false"
/>
<div
v-if="inputStatus.loading"
class="absolute inset-y-0 right-0 flex items-center pr-3"
>
<span
class="animate-spin rounded-full h-5 w-5 border-b-2 border-indigo-500"
></span>
</div> </div>
</div> </div>
<div <div
class="absolute -bottom-0.5 left-2 h-0.5 bg-gradient-to-r from-indigo-500 via-purple-500 to-pink-500 transition-all duration-300 ease-in-out" class="absolute -bottom-0.5 left-2 h-0.5 bg-gradient-to-r from-indigo-500 via-purple-500 to-pink-500 transition-all duration-300 ease-in-out"
:class="{ 'w-97-100': isInputFocused, 'w-0': !isInputFocused }"></div> :class="{ 'w-97-100': isInputFocused, 'w-0': !isInputFocused }"
></div>
</div> </div>
<button type="submit" <button
type="submit"
class="w-full bg-gradient-to-r from-indigo-500 via-purple-500 to-pink-500 text-white font-bold py-3 px-4 rounded-lg hover:from-indigo-600 hover:via-purple-600 hover:to-pink-600 focus:outline-none focus:ring-2 focus:ring-purple-500 focus:ring-opacity-50 transition duration-300 transform hover:scale-105 hover:shadow-lg relative overflow-hidden group" class="w-full bg-gradient-to-r from-indigo-500 via-purple-500 to-pink-500 text-white font-bold py-3 px-4 rounded-lg hover:from-indigo-600 hover:via-purple-600 hover:to-pink-600 focus:outline-none focus:ring-2 focus:ring-purple-500 focus:ring-opacity-50 transition duration-300 transform hover:scale-105 hover:shadow-lg relative overflow-hidden group"
:disabled="inputStatus.loading"> :disabled="inputStatus.loading"
>
<span class="flex items-center justify-center relative z-10"> <span class="flex items-center justify-center relative z-10">
<span>{{ inputStatus.loading ? '处理中...' : '提取文件' }}</span> <span>{{ inputStatus.loading ? '处理中...' : '提取文件' }}</span>
<ArrowRightIcon <ArrowRightIcon
class="w-5 h-5 ml-2 transition-transform duration-300 transform group-hover:translate-x-1" /> class="w-5 h-5 ml-2 transition-transform duration-300 transform group-hover:translate-x-1"
/>
</span> </span>
<span <span
class="absolute top-0 left-0 w-full h-full bg-gradient-to-r from-pink-500 via-purple-500 to-indigo-500 opacity-0 group-hover:opacity-100 transition-opacity duration-300"></span> class="absolute top-0 left-0 w-full h-full bg-gradient-to-r from-pink-500 via-purple-500 to-indigo-500 opacity-0 group-hover:opacity-100 transition-opacity duration-300"
></span>
</button> </button>
</form> </form>
<div class="mt-6 text-center"> <div class="mt-6 text-center">
<router-link to="/send" class="text-indigo-400 hover:text-indigo-300 transition duration-300"> <router-link
to="/send"
class="text-indigo-400 hover:text-indigo-300 transition duration-300"
>
需要发送文件点击这里 需要发送文件点击这里
</router-link> </router-link>
</div> </div>
</div> </div>
<div class="px-8 py-4 bg-opacity-50 flex justify-between items-center" <div
:class="[isDarkMode ? 'bg-gray-800' : 'bg-gray-100']"> class="px-8 py-4 bg-opacity-50 flex justify-between items-center"
<span class="text-sm flex items-center" :class="[isDarkMode ? 'text-gray-300' : 'text-gray-800']"> :class="[isDarkMode ? 'bg-gray-800' : 'bg-gray-100']"
>
<span
class="text-sm flex items-center"
:class="[isDarkMode ? 'text-gray-300' : 'text-gray-800']"
>
<ShieldCheckIcon class="w-4 h-4 mr-1 text-green-400" /> <ShieldCheckIcon class="w-4 h-4 mr-1 text-green-400" />
安全加密 安全加密
</span> </span>
<button @click="toggleDrawer" class="text-sm hover:text-indigo-300 transition duration-300 flex items-center" <button
:class="[isDarkMode ? 'text-indigo-400' : 'text-indigo-600']"> @click="toggleDrawer"
class="text-sm hover:text-indigo-300 transition duration-300 flex items-center"
:class="[isDarkMode ? 'text-indigo-400' : 'text-indigo-600']"
>
取件记录 取件记录
<ClipboardListIcon class="w-4 h-4 ml-1" /> <ClipboardListIcon class="w-4 h-4 ml-1" />
</button> </button>
@@ -77,56 +123,84 @@
</div> </div>
<transition name="drawer"> <transition name="drawer">
<div v-if="showDrawer" <div
v-if="showDrawer"
class="fixed inset-y-0 right-0 w-full sm:w-120 bg-opacity-70 backdrop-filter backdrop-blur-xl shadow-2xl z-50 overflow-hidden flex flex-col" class="fixed inset-y-0 right-0 w-full sm:w-120 bg-opacity-70 backdrop-filter backdrop-blur-xl shadow-2xl z-50 overflow-hidden flex flex-col"
:class="[isDarkMode ? 'bg-gray-900' : 'bg-white']"> :class="[isDarkMode ? 'bg-gray-900' : 'bg-white']"
<div class="flex justify-between items-center p-6 border-b" >
:class="[isDarkMode ? 'border-gray-700' : 'border-gray-200']"> <div
class="flex justify-between items-center p-6 border-b"
:class="[isDarkMode ? 'border-gray-700' : 'border-gray-200']"
>
<h3 class="text-2xl font-bold" :class="[isDarkMode ? 'text-white' : 'text-gray-800']"> <h3 class="text-2xl font-bold" :class="[isDarkMode ? 'text-white' : 'text-gray-800']">
取件记录 取件记录
</h3> </h3>
<button @click="toggleDrawer" class="hover:text-white transition duration-300" <button
:class="[isDarkMode ? 'text-gray-400' : 'text-gray-800']"> @click="toggleDrawer"
class="hover:text-white transition duration-300"
:class="[isDarkMode ? 'text-gray-400' : 'text-gray-800']"
>
<XIcon class="w-6 h-6" /> <XIcon class="w-6 h-6" />
</button> </button>
</div> </div>
<div class="flex-grow overflow-y-auto p-6"> <div class="flex-grow overflow-y-auto p-6">
<transition-group name="list" tag="div" class="space-y-4"> <transition-group name="list" tag="div" class="space-y-4">
<div v-for="record in records" :key="record.id" <div
v-for="record in records"
:key="record.id"
class="bg-opacity-50 rounded-lg p-4 flex items-center shadow-md hover:shadow-lg transition duration-300 transform hover:scale-102" class="bg-opacity-50 rounded-lg p-4 flex items-center shadow-md hover:shadow-lg transition duration-300 transform hover:scale-102"
:class="[isDarkMode ? 'bg-gray-800 hover:bg-gray-700' : 'bg-gray-100 hover:bg-white']"> :class="[isDarkMode ? 'bg-gray-800 hover:bg-gray-700' : 'bg-gray-100 hover:bg-white']"
>
<div class="flex-shrink-0 mr-4"> <div class="flex-shrink-0 mr-4">
<FileIcon class="w-10 h-10" :class="[isDarkMode ? 'text-indigo-400' : 'text-indigo-600']" /> <FileIcon
class="w-10 h-10"
:class="[isDarkMode ? 'text-indigo-400' : 'text-indigo-600']"
/>
</div> </div>
<div class="flex-grow min-w-0 mr-4"> <div class="flex-grow min-w-0 mr-4">
<p class="font-medium text-lg truncate" :class="[isDarkMode ? 'text-white' : 'text-gray-800']"> <p
class="font-medium text-lg truncate"
:class="[isDarkMode ? 'text-white' : 'text-gray-800']"
>
{{ record.filename }} {{ record.filename }}
</p> </p>
<p class="text-sm truncate" :class="[isDarkMode ? 'text-gray-400' : 'text-gray-600']"> <p
class="text-sm truncate"
:class="[isDarkMode ? 'text-gray-400' : 'text-gray-600']"
>
{{ record.date }} · {{ record.size }} {{ record.date }} · {{ record.size }}
</p> </p>
</div> </div>
<div class="flex-shrink-0 flex space-x-2"> <div class="flex-shrink-0 flex space-x-2">
<button @click="viewDetails(record)" <button
class="p-2 rounded-full hover:bg-opacity-20 transition duration-300" :class="[ @click="viewDetails(record)"
class="p-2 rounded-full hover:bg-opacity-20 transition duration-300"
:class="[
isDarkMode isDarkMode
? 'hover:bg-indigo-400 text-indigo-400' ? 'hover:bg-indigo-400 text-indigo-400'
: 'hover:bg-indigo-100 text-indigo-600' : 'hover:bg-indigo-100 text-indigo-600'
]"> ]"
>
<EyeIcon class="w-5 h-5" /> <EyeIcon class="w-5 h-5" />
</button> </button>
<button @click="downloadRecord(record)" <button
class="p-2 rounded-full hover:bg-opacity-20 transition duration-300" :class="[ @click="downloadRecord(record)"
class="p-2 rounded-full hover:bg-opacity-20 transition duration-300"
:class="[
isDarkMode isDarkMode
? 'hover:bg-green-400 text-green-400' ? 'hover:bg-green-400 text-green-400'
: 'hover:bg-green-100 text-green-600' : 'hover:bg-green-100 text-green-600'
]"> ]"
>
<DownloadIcon class="w-5 h-5" /> <DownloadIcon class="w-5 h-5" />
</button> </button>
<button @click="deleteRecord(record.id)" <button
class="p-2 rounded-full hover:bg-opacity-20 transition duration-300" :class="[ @click="deleteRecord(record.id)"
class="p-2 rounded-full hover:bg-opacity-20 transition duration-300"
:class="[
isDarkMode ? 'hover:bg-red-400 text-red-400' : 'hover:bg-red-100 text-red-600' isDarkMode ? 'hover:bg-red-400 text-red-400' : 'hover:bg-red-100 text-red-600'
]"> ]"
>
<TrashIcon class="w-5 h-5" /> <TrashIcon class="w-5 h-5" />
</button> </button>
</div> </div>
@@ -137,53 +211,80 @@
</transition> </transition>
<transition name="fade"> <transition name="fade">
<div v-if="selectedRecord" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50"> <div
v-if="selectedRecord"
class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50"
>
<div <div
class="p-8 rounded-2xl max-w-md w-full mx-4 shadow-2xl transform transition-all duration-300 ease-out backdrop-filter backdrop-blur-lg overflow-hidden" class="p-8 rounded-2xl max-w-md w-full mx-4 shadow-2xl transform transition-all duration-300 ease-out backdrop-filter backdrop-blur-lg overflow-hidden"
:class="[ :class="[isDarkMode ? 'bg-gray-800 bg-opacity-70' : 'bg-white bg-opacity-95']"
isDarkMode >
? 'bg-gray-800 bg-opacity-70' <h3
: 'bg-white bg-opacity-95' class="text-2xl font-bold mb-6 truncate"
]"> :class="[isDarkMode ? 'text-white' : 'text-gray-800']"
<h3 class="text-2xl font-bold mb-6 truncate" :class="[isDarkMode ? 'text-white' : 'text-gray-800']"> >
文件详情 文件详情
</h3> </h3>
<div class="space-y-4"> <div class="space-y-4">
<div class="flex items-center"> <div class="flex items-center">
<FileIcon class="w-6 h-6 mr-3 flex-shrink-0" <FileIcon
:class="[isDarkMode ? 'text-indigo-400' : 'text-indigo-600']" /> class="w-6 h-6 mr-3 flex-shrink-0"
<p :class="[isDarkMode ? 'text-gray-300' : 'text-gray-800']" class="truncate flex-grow"> :class="[isDarkMode ? 'text-indigo-400' : 'text-indigo-600']"
/>
<p
:class="[isDarkMode ? 'text-gray-300' : 'text-gray-800']"
class="truncate flex-grow"
>
<span class="font-medium">文件名</span>{{ selectedRecord.filename }} <span class="font-medium">文件名</span>{{ selectedRecord.filename }}
</p> </p>
</div> </div>
<div class="flex items-center"> <div class="flex items-center">
<CalendarIcon class="w-6 h-6 mr-3 flex-shrink-0" <CalendarIcon
:class="[isDarkMode ? 'text-indigo-400' : 'text-indigo-600']" /> class="w-6 h-6 mr-3 flex-shrink-0"
<p :class="[isDarkMode ? 'text-gray-300' : 'text-gray-800']" class="truncate flex-grow"> :class="[isDarkMode ? 'text-indigo-400' : 'text-indigo-600']"
/>
<p
:class="[isDarkMode ? 'text-gray-300' : 'text-gray-800']"
class="truncate flex-grow"
>
<span class="font-medium">取件日期</span>{{ selectedRecord.date }} <span class="font-medium">取件日期</span>{{ selectedRecord.date }}
</p> </p>
</div> </div>
<div class="flex items-center"> <div class="flex items-center">
<HardDriveIcon class="w-6 h-6 mr-3 flex-shrink-0" <HardDriveIcon
:class="[isDarkMode ? 'text-indigo-400' : 'text-indigo-600']" /> class="w-6 h-6 mr-3 flex-shrink-0"
<p :class="[isDarkMode ? 'text-gray-300' : 'text-gray-800']" class="truncate flex-grow"> :class="[isDarkMode ? 'text-indigo-400' : 'text-indigo-600']"
/>
<p
:class="[isDarkMode ? 'text-gray-300' : 'text-gray-800']"
class="truncate flex-grow"
>
<span class="font-medium">文件大小</span>{{ selectedRecord.size }} <span class="font-medium">文件大小</span>{{ selectedRecord.size }}
</p> </p>
</div> </div>
<div class="flex items-center"> <div class="flex items-center">
<DownloadIcon class="w-6 h-6 mr-3" :class="[isDarkMode ? 'text-indigo-400' : 'text-indigo-600']" /> <DownloadIcon
class="w-6 h-6 mr-3"
:class="[isDarkMode ? 'text-indigo-400' : 'text-indigo-600']"
/>
<p :class="[isDarkMode ? 'text-gray-300' : 'text-gray-800']"> <p :class="[isDarkMode ? 'text-gray-300' : 'text-gray-800']">
<span class="font-medium">文件内容</span> <span class="font-medium">文件内容</span>
</p> </p>
<div v-if="selectedRecord.filename === 'Text'" class="ml-2"> <div v-if="selectedRecord.filename === 'Text'" class="ml-2">
<button @click="showContentPreview" <button
class="px-4 py-2 bg-indigo-600 text-white rounded-lg hover:bg-indigo-700 transition duration-300"> @click="showContentPreview"
class="px-4 py-2 bg-indigo-600 text-white rounded-lg hover:bg-indigo-700 transition duration-300"
>
预览内容 预览内容
</button> </button>
</div> </div>
<div v-else> <div v-else>
<a :href="getDownloadUrl(selectedRecord)" target="_blank" rel="noopener noreferrer" <a
class="px-4 py-2 bg-indigo-600 text-white rounded-lg hover:bg-indigo-700 transition duration-300"> :href="getDownloadUrl(selectedRecord)"
target="_blank"
rel="noopener noreferrer"
class="px-4 py-2 bg-indigo-600 text-white rounded-lg hover:bg-indigo-700 transition duration-300"
>
点击下载 点击下载
</a> </a>
</div> </div>
@@ -191,7 +292,10 @@
</div> </div>
<div class="mt-6 flex flex-col items-center"> <div class="mt-6 flex flex-col items-center">
<h4 class="text-lg font-semibold mb-3" :class="[isDarkMode ? 'text-white' : 'text-gray-800']"> <h4
class="text-lg font-semibold mb-3"
:class="[isDarkMode ? 'text-white' : 'text-gray-800']"
>
取件二维码 取件二维码
</h4> </h4>
<div class="bg-white p-2 rounded-lg shadow-md"> <div class="bg-white p-2 rounded-lg shadow-md">
@@ -202,60 +306,69 @@
</p> </p>
</div> </div>
<button @click="selectedRecord = null" <button
class="mt-8 w-full bg-gradient-to-r from-indigo-500 to-purple-600 text-white px-6 py-3 rounded-lg font-medium hover:from-indigo-600 hover:to-purple-700 focus:outline-none focus:ring-2 focus:ring-purple-500 focus:ring-opacity-50 transition duration-300 transform hover:scale-105"> @click="selectedRecord = null"
class="mt-8 w-full bg-gradient-to-r from-indigo-500 to-purple-600 text-white px-6 py-3 rounded-lg font-medium hover:from-indigo-600 hover:to-purple-700 focus:outline-none focus:ring-2 focus:ring-purple-500 focus:ring-opacity-50 transition duration-300 transform hover:scale-105"
>
关闭 关闭
</button> </button>
</div> </div>
</div> </div>
</transition> </transition>
<transition name="fade"> <transition name="fade">
<div v-if="showPreview" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50"> <div
v-if="showPreview"
class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50"
>
<div <div
class="p-6 rounded-2xl max-w-3xl w-full mx-4 shadow-2xl transform transition-all duration-300 ease-out backdrop-filter backdrop-blur-lg bg-opacity-70 max-h-[85vh] overflow-hidden flex flex-col" class="p-6 rounded-2xl max-w-3xl w-full mx-4 shadow-2xl transform transition-all duration-300 ease-out backdrop-filter backdrop-blur-lg bg-opacity-70 max-h-[85vh] overflow-hidden flex flex-col"
:class="[isDarkMode ? 'bg-gray-800' : 'bg-white']"> :class="[isDarkMode ? 'bg-gray-800' : 'bg-white']"
>
<div class="flex justify-between items-center mb-4 flex-shrink-0"> <div class="flex justify-between items-center mb-4 flex-shrink-0">
<h3 class="text-2xl font-bold" :class="[isDarkMode ? 'text-white' : 'text-gray-800']"> <h3 class="text-2xl font-bold" :class="[isDarkMode ? 'text-white' : 'text-gray-800']">
内容预览 内容预览
</h3> </h3>
<div class="flex items-center gap-3"> <div class="flex items-center gap-3">
<button @click="copyContent" <button
@click="copyContent"
class="px-4 py-1.5 rounded-lg transition duration-300 flex items-center gap-2 text-sm font-medium" class="px-4 py-1.5 rounded-lg transition duration-300 flex items-center gap-2 text-sm font-medium"
:class="[ :class="[
isDarkMode isDarkMode
? 'bg-gray-700 hover:bg-gray-600 text-gray-300 hover:text-white' ? 'bg-gray-700 hover:bg-gray-600 text-gray-300 hover:text-white'
: 'bg-gray-100 hover:bg-gray-200 text-gray-700 hover:text-gray-900' : 'bg-gray-100 hover:bg-gray-200 text-gray-700 hover:text-gray-900'
]"> ]"
>
<CopyIcon class="w-4 h-4" /> <CopyIcon class="w-4 h-4" />
复制 复制
</button> </button>
<button @click="showPreview = false" class="p-1.5 rounded-lg transition duration-300 hover:bg-opacity-10" <button
@click="showPreview = false"
class="p-1.5 rounded-lg transition duration-300 hover:bg-opacity-10"
:class="[ :class="[
isDarkMode isDarkMode
? 'text-gray-400 hover:text-white hover:bg-white' ? 'text-gray-400 hover:text-white hover:bg-white'
: 'text-gray-500 hover:text-gray-900 hover:bg-black' : 'text-gray-500 hover:text-gray-900 hover:bg-black'
]"> ]"
>
<XIcon class="w-5 h-5" /> <XIcon class="w-5 h-5" />
</button> </button>
</div> </div>
</div> </div>
<div class="flex-1 overflow-y-auto custom-scrollbar"> <div class="flex-1 overflow-y-auto custom-scrollbar">
<div class="prose max-w-none p-6 rounded-xl" :class="[ <div
isDarkMode class="prose max-w-none p-6 rounded-xl break-words overflow-wrap-anywhere"
? 'prose-invert bg-gray-900 bg-opacity-50' :class="[isDarkMode ? 'prose-invert bg-gray-900 bg-opacity-50' : 'bg-gray-50']"
: 'bg-gray-50' v-html="renderedContent"
]" v-html="renderedContent"> ></div>
</div>
</div> </div>
</div> </div>
</div> </div>
</transition> </transition>
</div> </div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref, inject, onMounted, watch, computed } from 'vue' import { ref, inject, onMounted, watch } from 'vue'
// 定义数据接口 // 定义数据接口
interface FileRecord { interface FileRecord {
@@ -489,10 +602,31 @@ watch(
const rawHtml = await marked(content) const rawHtml = await marked(content)
renderedContent.value = DOMPurify.sanitize(rawHtml, { renderedContent.value = DOMPurify.sanitize(rawHtml, {
// 允许的标签和属性 // 允许的标签和属性
ALLOWED_TAGS: ['p', 'br', 'strong', 'em', 'u', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'ul', 'ol', 'li', 'blockquote', 'code', 'pre', 'a', 'img'], ALLOWED_TAGS: [
'p',
'br',
'strong',
'em',
'u',
'h1',
'h2',
'h3',
'h4',
'h5',
'h6',
'ul',
'ol',
'li',
'blockquote',
'code',
'pre',
'a',
'img'
],
ALLOWED_ATTR: ['href', 'src', 'alt', 'title', 'class'], ALLOWED_ATTR: ['href', 'src', 'alt', 'title', 'class'],
// 禁用危险的协议 // 禁用危险的协议
ALLOWED_URI_REGEXP: /^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp|xxx):|[^a-z]|[a-z+.-]+(?:[^a-z+.-:]|$))/i ALLOWED_URI_REGEXP:
/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp|xxx):|[^a-z]|[a-z+.-]+(?:[^a-z+.-:]|$))/i
}) })
} catch (error) { } catch (error) {
console.error('Markdown 渲染失败:', error) console.error('Markdown 渲染失败:', error)
@@ -512,7 +646,6 @@ const showContentPreview = () => {
<style scoped> <style scoped>
@keyframes blob { @keyframes blob {
0%, 0%,
100% { 100% {
transform: translate(0, 0) scale(1); transform: translate(0, 0) scale(1);
@@ -559,6 +692,9 @@ const showContentPreview = () => {
/* 添加 Markdown 样式 */ /* 添加 Markdown 样式 */
:deep(.prose) { :deep(.prose) {
text-align: left; text-align: left;
word-wrap: break-word;
overflow-wrap: break-word;
word-break: break-word;
} }
:deep(.prose h1), :deep(.prose h1),
@@ -569,10 +705,30 @@ const showContentPreview = () => {
:deep(.prose h6) { :deep(.prose h6) {
color: rgb(79, 70, 229); color: rgb(79, 70, 229);
/* text-indigo-600 */ /* text-indigo-600 */
word-wrap: break-word;
overflow-wrap: break-word;
}
:deep(.prose p),
:deep(.prose div),
:deep(.prose span),
:deep(.prose code),
:deep(.prose pre) {
word-wrap: break-word;
overflow-wrap: break-word;
word-break: break-word;
}
:deep(.prose pre) {
white-space: pre-wrap;
overflow-x: auto;
}
:deep(.prose code) {
white-space: pre-wrap;
} }
@media (prefers-color-scheme: dark) { @media (prefers-color-scheme: dark) {
:deep(.prose h1), :deep(.prose h1),
:deep(.prose h2), :deep(.prose h2),
:deep(.prose h3), :deep(.prose h3),
@@ -595,7 +751,7 @@ const showContentPreview = () => {
/* 自定义滚动条样式 */ /* 自定义滚动条样式 */
.custom-scrollbar { .custom-scrollbar {
scrollbar-width: thin; scrollbar-width: thin;
scrollbar-color: rgba(156, 163, 175, 0.3) transparent; scrollbar-color: rgba(156, 163, 175, 0.3) rgba(243, 244, 246, 0.5);
} }
.custom-scrollbar::-webkit-scrollbar { .custom-scrollbar::-webkit-scrollbar {
@@ -604,29 +760,50 @@ const showContentPreview = () => {
} }
.custom-scrollbar::-webkit-scrollbar-track { .custom-scrollbar::-webkit-scrollbar-track {
background: transparent; background: rgba(243, 244, 246, 0.5);
border-radius: 3px;
} }
.custom-scrollbar::-webkit-scrollbar-thumb { .custom-scrollbar::-webkit-scrollbar-thumb {
background-color: rgba(156, 163, 175, 0.3); background-color: rgba(156, 163, 175, 0.5);
border-radius: 3px; border-radius: 3px;
transition: background-color 0.3s; transition: background-color 0.3s;
} }
.custom-scrollbar::-webkit-scrollbar-thumb:hover { .custom-scrollbar::-webkit-scrollbar-thumb:hover {
background-color: rgba(156, 163, 175, 0.5); background-color: rgba(156, 163, 175, 0.7);
} }
/* 深色模式下的滚动条样式 */ /* 深色模式下的滚动条样式 */
:deep([class*='dark']) .custom-scrollbar { :deep([class*='dark']) .custom-scrollbar {
scrollbar-color: rgba(75, 85, 99, 0.3) transparent; scrollbar-color: rgba(75, 85, 99, 0.5) rgba(31, 41, 55, 0.5);
}
:deep([class*='dark']) .custom-scrollbar::-webkit-scrollbar-track {
background: rgba(31, 41, 55, 0.5);
} }
:deep([class*='dark']) .custom-scrollbar::-webkit-scrollbar-thumb { :deep([class*='dark']) .custom-scrollbar::-webkit-scrollbar-thumb {
background-color: rgba(75, 85, 99, 0.3); background-color: rgba(75, 85, 99, 0.5);
} }
:deep([class*='dark']) .custom-scrollbar::-webkit-scrollbar-thumb:hover { :deep([class*='dark']) .custom-scrollbar::-webkit-scrollbar-thumb:hover {
background-color: rgba(75, 85, 99, 0.5); background-color: rgba(75, 85, 99, 0.7);
}
/* 确保滚动容器有背景色 */
.custom-scrollbar {
background: inherit;
}
/* 文本换行相关样式 */
.break-words {
word-wrap: break-word;
overflow-wrap: break-word;
word-break: break-word;
}
.overflow-wrap-anywhere {
overflow-wrap: anywhere;
} }
</style> </style>