2
This commit is contained in:
@@ -0,0 +1,960 @@
|
||||
<template>
|
||||
<div
|
||||
class="min-h-screen flex flex-col lg:flex-row transition-colors duration-300"
|
||||
:class="[isDarkMode ? 'bg-gray-900' : 'bg-gray-50']"
|
||||
>
|
||||
<!-- Sidebar -->
|
||||
<aside
|
||||
class="fixed inset-y-0 left-0 z-50 w-64 transform transition-all duration-300 ease-in-out lg:relative lg:translate-x-0 border-r"
|
||||
:class="[
|
||||
isDarkMode
|
||||
? 'bg-gray-800 bg-opacity-90 backdrop-filter backdrop-blur-xl border-gray-700'
|
||||
: 'bg-white border-gray-200',
|
||||
{ '-translate-x-full': !isSidebarOpen }
|
||||
]"
|
||||
>
|
||||
<!-- Logo区域 -->
|
||||
<div
|
||||
class="flex items-center justify-between h-16 px-4 border-b"
|
||||
:class="[isDarkMode ? 'border-gray-700' : 'border-gray-200']"
|
||||
>
|
||||
<div class="flex items-center">
|
||||
<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 p-1" :class="[isDarkMode ? 'bg-gray-800' : 'bg-white']">
|
||||
<BoxIcon
|
||||
class="w-6 h-6"
|
||||
:class="[isDarkMode ? 'text-indigo-400' : 'text-indigo-600']"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<h1
|
||||
class="ml-2 text-xl font-semibold"
|
||||
:class="[isDarkMode ? 'text-white' : 'text-gray-800']"
|
||||
>
|
||||
FileCodeBox
|
||||
</h1>
|
||||
</div>
|
||||
<button @click="toggleSidebar" class="lg:hidden">
|
||||
<XIcon class="w-6 h-6" :class="[isDarkMode ? 'text-gray-400' : 'text-gray-600']" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- 导航菜单 -->
|
||||
<nav class="flex-1 overflow-y-auto">
|
||||
<ul class="p-4 space-y-2">
|
||||
<li v-for="item in menuItems" :key="item.id">
|
||||
<a
|
||||
href="#"
|
||||
@click="currentSection = item.id"
|
||||
class="flex items-center p-2 rounded-lg transition-colors duration-200"
|
||||
:class="[
|
||||
currentSection === item.id
|
||||
? isDarkMode
|
||||
? 'bg-indigo-900 text-indigo-400'
|
||||
: 'bg-indigo-100 text-indigo-600'
|
||||
: isDarkMode
|
||||
? 'text-gray-400 hover:bg-gray-700'
|
||||
: 'text-gray-600 hover:bg-gray-100'
|
||||
]"
|
||||
>
|
||||
<component :is="item.icon" class="w-5 h-5 mr-3" />
|
||||
{{ item.name }}
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
</aside>
|
||||
|
||||
<!-- Main Content -->
|
||||
<div class="flex-1 flex flex-col min-h-screen">
|
||||
<!-- Header -->
|
||||
<header
|
||||
class="shadow-md border-b transition-colors duration-300"
|
||||
:class="[isDarkMode ? 'bg-gray-800 border-gray-700' : 'bg-white border-gray-200']"
|
||||
>
|
||||
<div class="flex items-center justify-between h-16 px-4">
|
||||
<button @click="toggleSidebar" class="lg:hidden">
|
||||
<MenuIcon class="w-6 h-6" :class="[isDarkMode ? 'text-gray-400' : 'text-gray-600']" />
|
||||
</button>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<!-- Content -->
|
||||
<main
|
||||
class="flex-1 p-6 overflow-y-auto transition-colors duration-300"
|
||||
:class="[isDarkMode ? 'bg-gray-900' : 'bg-gray-50']"
|
||||
>
|
||||
<div v-if="currentSection === 'dashboard'">
|
||||
<h2
|
||||
class="text-2xl font-bold mb-6"
|
||||
:class="[isDarkMode ? 'text-white' : 'text-gray-800']"
|
||||
>
|
||||
仪表盘
|
||||
</h2>
|
||||
|
||||
<!-- 统计卡片区域 -->
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 mb-8">
|
||||
<div
|
||||
class="p-6 rounded-lg shadow-md transition-colors duration-300"
|
||||
:class="[isDarkMode ? 'bg-gray-800 bg-opacity-70' : 'bg-white']"
|
||||
>
|
||||
<div class="flex items-center justify-between">
|
||||
<div>
|
||||
<p class="text-sm" :class="[isDarkMode ? 'text-gray-400' : 'text-gray-600']">
|
||||
总文件数
|
||||
</p>
|
||||
<h3
|
||||
class="text-2xl font-bold mt-1"
|
||||
:class="[isDarkMode ? 'text-white' : 'text-gray-800']"
|
||||
>
|
||||
128
|
||||
</h3>
|
||||
</div>
|
||||
<div
|
||||
class="p-3 rounded-full"
|
||||
:class="[isDarkMode ? 'bg-indigo-900' : 'bg-indigo-100']"
|
||||
>
|
||||
<FileIcon
|
||||
class="w-6 h-6"
|
||||
:class="[isDarkMode ? 'text-indigo-400' : 'text-indigo-600']"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<p class="text-sm mt-2" :class="[isDarkMode ? 'text-green-400' : 'text-green-600']">
|
||||
<span>↑ 12% </span>
|
||||
<span :class="[isDarkMode ? 'text-gray-400' : 'text-gray-600']">较上月</span>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="p-6 rounded-lg shadow-md transition-colors duration-300"
|
||||
:class="[isDarkMode ? 'bg-gray-800 bg-opacity-70' : 'bg-white']"
|
||||
>
|
||||
<div class="flex items-center justify-between">
|
||||
<div>
|
||||
<p class="text-sm" :class="[isDarkMode ? 'text-gray-400' : 'text-gray-600']">
|
||||
存储空间
|
||||
</p>
|
||||
<h3
|
||||
class="text-2xl font-bold mt-1"
|
||||
:class="[isDarkMode ? 'text-white' : 'text-gray-800']"
|
||||
>
|
||||
1.2 TB
|
||||
</h3>
|
||||
</div>
|
||||
<div
|
||||
class="p-3 rounded-full"
|
||||
:class="[isDarkMode ? 'bg-purple-900' : 'bg-purple-100']"
|
||||
>
|
||||
<HardDriveIcon
|
||||
class="w-6 h-6"
|
||||
:class="[isDarkMode ? 'text-purple-400' : 'text-purple-600']"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-4 h-2 bg-gray-200 rounded-full overflow-hidden">
|
||||
<div class="h-full bg-purple-500" style="width: 75%"></div>
|
||||
</div>
|
||||
<p class="text-sm mt-2" :class="[isDarkMode ? 'text-gray-400' : 'text-gray-600']">
|
||||
已使用 75%
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="p-6 rounded-lg shadow-md transition-colors duration-300"
|
||||
:class="[isDarkMode ? 'bg-gray-800 bg-opacity-70' : 'bg-white']"
|
||||
>
|
||||
<div class="flex items-center justify-between">
|
||||
<div>
|
||||
<p class="text-sm" :class="[isDarkMode ? 'text-gray-400' : 'text-gray-600']">
|
||||
活跃用户
|
||||
</p>
|
||||
<h3
|
||||
class="text-2xl font-bold mt-1"
|
||||
:class="[isDarkMode ? 'text-white' : 'text-gray-800']"
|
||||
>
|
||||
25
|
||||
</h3>
|
||||
</div>
|
||||
<div
|
||||
class="p-3 rounded-full"
|
||||
:class="[isDarkMode ? 'bg-green-900' : 'bg-green-100']"
|
||||
>
|
||||
<UsersIcon
|
||||
class="w-6 h-6"
|
||||
:class="[isDarkMode ? 'text-green-400' : 'text-green-600']"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<p class="text-sm mt-2" :class="[isDarkMode ? 'text-red-400' : 'text-red-600']">
|
||||
<span>↓ 5% </span>
|
||||
<span :class="[isDarkMode ? 'text-gray-400' : 'text-gray-600']">较上周</span>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="p-6 rounded-lg shadow-md transition-colors duration-300"
|
||||
:class="[isDarkMode ? 'bg-gray-800 bg-opacity-70' : 'bg-white']"
|
||||
>
|
||||
<div class="flex items-center justify-between">
|
||||
<div>
|
||||
<p class="text-sm" :class="[isDarkMode ? 'text-gray-400' : 'text-gray-600']">
|
||||
系统状态
|
||||
</p>
|
||||
<h3
|
||||
class="text-2xl font-bold mt-1"
|
||||
:class="[isDarkMode ? 'text-white' : 'text-gray-800']"
|
||||
>
|
||||
正常
|
||||
</h3>
|
||||
</div>
|
||||
<div class="p-3 rounded-full" :class="[isDarkMode ? 'bg-blue-900' : 'bg-blue-100']">
|
||||
<ActivityIcon
|
||||
class="w-6 h-6"
|
||||
:class="[isDarkMode ? 'text-blue-400' : 'text-blue-600']"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<p class="text-sm mt-2" :class="[isDarkMode ? 'text-gray-400' : 'text-gray-600']">
|
||||
服务器运行时间: 30天
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 最近活动 -->
|
||||
<div
|
||||
class="rounded-lg shadow-md overflow-hidden transition-colors duration-300"
|
||||
:class="[isDarkMode ? 'bg-gray-800 bg-opacity-70' : 'bg-white']"
|
||||
>
|
||||
<div
|
||||
class="px-6 py-4 border-b"
|
||||
:class="[isDarkMode ? 'border-gray-700' : 'border-gray-200']"
|
||||
>
|
||||
<h3
|
||||
class="text-lg font-medium"
|
||||
:class="[isDarkMode ? 'text-white' : 'text-gray-800']"
|
||||
>
|
||||
最近活动
|
||||
</h3>
|
||||
</div>
|
||||
<div class="p-6">
|
||||
<div class="space-y-4">
|
||||
<div
|
||||
v-for="(activity, index) in recentActivities"
|
||||
:key="index"
|
||||
class="flex items-center space-x-4"
|
||||
>
|
||||
<div class="flex-shrink-0">
|
||||
<component
|
||||
:is="activity.icon"
|
||||
class="w-5 h-5"
|
||||
:class="[isDarkMode ? 'text-gray-400' : 'text-gray-600']"
|
||||
/>
|
||||
</div>
|
||||
<div class="flex-1">
|
||||
<p :class="[isDarkMode ? 'text-gray-300' : 'text-gray-700']">
|
||||
{{ activity.description }}
|
||||
</p>
|
||||
<p class="text-sm" :class="[isDarkMode ? 'text-gray-400' : 'text-gray-500']">
|
||||
{{ activity.time }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="currentSection === 'files'">
|
||||
<h2
|
||||
class="text-2xl font-bold mb-6"
|
||||
:class="[isDarkMode ? 'text-white' : 'text-gray-800']"
|
||||
>
|
||||
文件管理
|
||||
</h2>
|
||||
|
||||
<!-- 添加文件操作栏 -->
|
||||
<div
|
||||
class="mb-6 flex flex-col sm:flex-row gap-4 items-start sm:items-center justify-between"
|
||||
>
|
||||
<!-- 搜索和过滤 -->
|
||||
<div class="flex flex-1 gap-4">
|
||||
<div class="relative flex-1">
|
||||
<input
|
||||
type="text"
|
||||
v-model="fileSearchQuery"
|
||||
:class="[
|
||||
isDarkMode
|
||||
? 'bg-gray-700 border-gray-600 text-white placeholder-gray-400'
|
||||
: 'bg-white border-gray-300 text-gray-900 placeholder-gray-400'
|
||||
]"
|
||||
class="w-full pl-10 pr-4 py-2 rounded-lg border focus:ring-2 focus:ring-indigo-500 focus:border-transparent"
|
||||
placeholder="搜索文件..."
|
||||
/>
|
||||
<SearchIcon
|
||||
class="absolute left-3 top-2.5 w-5 h-5"
|
||||
:class="[isDarkMode ? 'text-gray-400' : 'text-gray-500']"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<select
|
||||
v-model="fileTypeFilter"
|
||||
:class="[
|
||||
isDarkMode
|
||||
? 'bg-gray-700 border-gray-600 text-white'
|
||||
: 'bg-white border-gray-300 text-gray-900'
|
||||
]"
|
||||
class="border rounded-lg px-4 py-2 focus:ring-2 focus:ring-indigo-500 focus:border-transparent"
|
||||
>
|
||||
<option value="">所有类型</option>
|
||||
<option value="PDF">PDF</option>
|
||||
<option value="Image">图片</option>
|
||||
<option value="Video">视频</option>
|
||||
<option value="Document">文档</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<!-- 上传按钮 -->
|
||||
<div class="flex gap-4">
|
||||
<button
|
||||
@click="$refs.fileInput.click()"
|
||||
class="flex items-center px-4 py-2 rounded-lg bg-indigo-600 text-white hover:bg-indigo-700 transition-colors duration-200"
|
||||
>
|
||||
<UploadIcon class="w-5 h-5 mr-2" />
|
||||
上传文件
|
||||
</button>
|
||||
<input
|
||||
ref="fileInput"
|
||||
type="file"
|
||||
multiple
|
||||
class="hidden"
|
||||
@change="handleFileUpload"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 拖拽上传区域 -->
|
||||
<div
|
||||
v-if="showDropZone"
|
||||
class="mb-6 border-2 border-dashed rounded-lg p-8 text-center"
|
||||
:class="[isDarkMode ? 'border-gray-600 bg-gray-800/50' : 'border-gray-300 bg-gray-50']"
|
||||
@drop.prevent="handleFileDrop"
|
||||
@dragover.prevent="showDropZone = true"
|
||||
@dragleave.prevent="showDropZone = false"
|
||||
>
|
||||
<UploadCloudIcon
|
||||
class="mx-auto w-12 h-12 mb-4"
|
||||
:class="[isDarkMode ? 'text-gray-400' : 'text-gray-500']"
|
||||
/>
|
||||
<p :class="[isDarkMode ? 'text-gray-300' : 'text-gray-700']">拖拽文件到此处上传</p>
|
||||
</div>
|
||||
|
||||
<!-- File List -->
|
||||
<div
|
||||
class="rounded-lg shadow-md overflow-hidden transition-colors duration-300"
|
||||
:class="[isDarkMode ? 'bg-gray-800 bg-opacity-70' : 'bg-white']"
|
||||
>
|
||||
<div
|
||||
class="px-6 py-4 border-b"
|
||||
:class="[isDarkMode ? 'border-gray-700' : 'border-gray-200']"
|
||||
>
|
||||
<h3
|
||||
class="text-lg font-medium"
|
||||
:class="[isDarkMode ? 'text-white' : 'text-gray-800']"
|
||||
>
|
||||
所有文件
|
||||
</h3>
|
||||
</div>
|
||||
<div class="overflow-x-auto">
|
||||
<table
|
||||
class="min-w-full divide-y"
|
||||
:class="[isDarkMode ? 'divide-gray-700' : 'divide-gray-200']"
|
||||
>
|
||||
<thead :class="[isDarkMode ? 'bg-gray-900' : 'bg-gray-100']">
|
||||
<tr>
|
||||
<th
|
||||
v-for="header in fileTableHeaders"
|
||||
:key="header"
|
||||
class="px-6 py-3 text-left text-xs font-medium uppercase tracking-wider"
|
||||
:class="[isDarkMode ? 'text-gray-400' : 'text-gray-500']"
|
||||
>
|
||||
{{ header }}
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody
|
||||
:class="[
|
||||
isDarkMode
|
||||
? 'bg-gray-800 divide-y divide-gray-700'
|
||||
: 'bg-white divide-y divide-gray-200'
|
||||
]"
|
||||
>
|
||||
<tr v-for="file in files" :key="file.id">
|
||||
<td class="px-6 py-4 whitespace-nowrap">
|
||||
<div class="flex items-center">
|
||||
<FileIcon
|
||||
class="w-5 h-5 mr-2"
|
||||
:class="[isDarkMode ? 'text-indigo-400' : 'text-indigo-500']"
|
||||
/>
|
||||
<span
|
||||
class="font-medium"
|
||||
:class="[isDarkMode ? 'text-white' : 'text-gray-900']"
|
||||
>
|
||||
{{ file.name }}
|
||||
</span>
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap">
|
||||
<span :class="[isDarkMode ? 'text-gray-400' : 'text-gray-500']">
|
||||
{{ file.size }}
|
||||
</span>
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap">
|
||||
<span :class="[isDarkMode ? 'text-gray-400' : 'text-gray-500']">
|
||||
{{ file.type }}
|
||||
</span>
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap">
|
||||
<span :class="[isDarkMode ? 'text-gray-400' : 'text-gray-500']">
|
||||
{{ file.lastModified }}
|
||||
</span>
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-right text-sm font-medium">
|
||||
<button
|
||||
@click="downloadFile(file)"
|
||||
class="mr-3 transition-colors duration-200"
|
||||
:class="[
|
||||
isDarkMode
|
||||
? 'text-indigo-400 hover:text-indigo-300'
|
||||
: 'text-indigo-600 hover:text-indigo-900'
|
||||
]"
|
||||
>
|
||||
下载
|
||||
</button>
|
||||
<button
|
||||
@click="deleteFile(file)"
|
||||
class="transition-colors duration-200"
|
||||
:class="[
|
||||
isDarkMode
|
||||
? 'text-red-400 hover:text-red-300'
|
||||
: 'text-red-600 hover:text-red-900'
|
||||
]"
|
||||
>
|
||||
删除
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 在文件列表表格下方添加分页组件 -->
|
||||
<div
|
||||
class="mt-4 flex items-center justify-between px-6 py-3 border-t"
|
||||
:class="[isDarkMode ? 'border-gray-700' : 'border-gray-200']"
|
||||
>
|
||||
<!-- 分页信息 -->
|
||||
<div
|
||||
class="flex items-center text-sm"
|
||||
:class="[isDarkMode ? 'text-gray-400' : 'text-gray-500']"
|
||||
>
|
||||
显示第 {{ (params.page - 1) * params.size + 1 }} 到
|
||||
{{ Math.min(params.page * params.size, params.total) }} 条,共 {{ params.total }} 条
|
||||
</div>
|
||||
|
||||
<!-- 分页控制器 -->
|
||||
<div class="flex items-center space-x-2">
|
||||
<!-- 上一页 -->
|
||||
<button
|
||||
@click="handlePageChange(params.page - 1)"
|
||||
:disabled="params.page === 1"
|
||||
class="px-3 py-1 rounded-md transition-colors duration-200"
|
||||
:class="[
|
||||
isDarkMode
|
||||
? params.page === 1
|
||||
? 'bg-gray-700 text-gray-500 cursor-not-allowed'
|
||||
: 'bg-gray-700 text-gray-300 hover:bg-gray-600'
|
||||
: params.page === 1
|
||||
? 'bg-gray-100 text-gray-400 cursor-not-allowed'
|
||||
: 'bg-gray-100 text-gray-700 hover:bg-gray-200'
|
||||
]"
|
||||
>
|
||||
上一页
|
||||
</button>
|
||||
|
||||
<!-- 页码 -->
|
||||
<div class="flex items-center space-x-1">
|
||||
<template v-for="pageNum in displayedPages" :key="pageNum">
|
||||
<button
|
||||
v-if="pageNum !== '...'"
|
||||
@click="handlePageChange(pageNum)"
|
||||
class="px-3 py-1 rounded-md transition-colors duration-200"
|
||||
:class="[
|
||||
params.page === pageNum
|
||||
? 'bg-indigo-600 text-white'
|
||||
: isDarkMode
|
||||
? 'bg-gray-700 text-gray-300 hover:bg-gray-600'
|
||||
: 'bg-gray-100 text-gray-700 hover:bg-gray-200'
|
||||
]"
|
||||
>
|
||||
{{ pageNum }}
|
||||
</button>
|
||||
<span
|
||||
v-else
|
||||
class="px-2"
|
||||
:class="[isDarkMode ? 'text-gray-400' : 'text-gray-500']"
|
||||
>
|
||||
...
|
||||
</span>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<!-- 下一页 -->
|
||||
<button
|
||||
@click="handlePageChange(params.page + 1)"
|
||||
:disabled="params.page >= totalPages"
|
||||
class="px-3 py-1 rounded-md transition-colors duration-200"
|
||||
:class="[
|
||||
isDarkMode
|
||||
? params.page >= totalPages
|
||||
? 'bg-gray-700 text-gray-500 cursor-not-allowed'
|
||||
: 'bg-gray-700 text-gray-300 hover:bg-gray-600'
|
||||
: params.page >= totalPages
|
||||
? 'bg-gray-100 text-gray-400 cursor-not-allowed'
|
||||
: 'bg-gray-100 text-gray-700 hover:bg-gray-200'
|
||||
]"
|
||||
>
|
||||
下一页
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="currentSection === 'settings'">
|
||||
<h2
|
||||
class="text-2xl font-bold mb-6"
|
||||
:class="[isDarkMode ? 'text-white' : 'text-gray-800']"
|
||||
>
|
||||
系统设置
|
||||
</h2>
|
||||
<div
|
||||
class="rounded-lg shadow-md p-6 transition-colors duration-300"
|
||||
:class="[
|
||||
isDarkMode
|
||||
? 'bg-gray-800 bg-opacity-70 backdrop-filter backdrop-blur-xl border border-gray-700'
|
||||
: 'bg-white border border-gray-200'
|
||||
]"
|
||||
>
|
||||
<div class="space-y-6">
|
||||
<div>
|
||||
<h3
|
||||
class="text-lg font-medium mb-2"
|
||||
:class="[isDarkMode ? 'text-white' : 'text-gray-800']"
|
||||
>
|
||||
常规设置
|
||||
</h3>
|
||||
<div class="space-y-4">
|
||||
<div class="flex items-center justify-between">
|
||||
<span :class="[isDarkMode ? 'text-gray-300' : 'text-gray-700']">启用通知</span>
|
||||
<label class="switch">
|
||||
<input type="checkbox" v-model="settings.notifications" />
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="flex items-center justify-between">
|
||||
<span :class="[isDarkMode ? 'text-gray-300' : 'text-gray-700']">自动更新</span>
|
||||
<label class="switch">
|
||||
<input type="checkbox" v-model="settings.autoUpdate" />
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h3
|
||||
class="text-lg font-medium mb-2"
|
||||
:class="[isDarkMode ? 'text-white' : 'text-gray-800']"
|
||||
>
|
||||
安全设置
|
||||
</h3>
|
||||
<div class="space-y-4">
|
||||
<div class="flex items-center justify-between">
|
||||
<span :class="[isDarkMode ? 'text-gray-300' : 'text-gray-700']"
|
||||
>双因素认证</span
|
||||
>
|
||||
<label class="switch">
|
||||
<input type="checkbox" v-model="settings.twoFactor" />
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<label
|
||||
for="password"
|
||||
class="block text-sm font-medium mb-1"
|
||||
:class="[isDarkMode ? 'text-gray-300' : 'text-gray-700']"
|
||||
>
|
||||
更改密码
|
||||
</label>
|
||||
<div class="mt-1 relative rounded-md shadow-sm">
|
||||
<input
|
||||
type="password"
|
||||
id="password"
|
||||
v-model="newPassword"
|
||||
class="block w-full pr-10 sm:text-sm rounded-md focus:ring-indigo-500 focus:border-indigo-500"
|
||||
:class="[
|
||||
isDarkMode
|
||||
? 'bg-gray-700 border-gray-600 text-white placeholder-gray-400'
|
||||
: 'border-gray-300 text-gray-900 placeholder-gray-400'
|
||||
]"
|
||||
placeholder="新密码"
|
||||
/>
|
||||
<button
|
||||
@click="changePassword"
|
||||
class="absolute inset-y-0 right-0 px-3 flex items-center bg-indigo-600 text-white rounded-r-md hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 transition-colors duration-200"
|
||||
>
|
||||
更改
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, inject, onMounted, onUnmounted, computed, watch } from 'vue'
|
||||
import {
|
||||
BoxIcon,
|
||||
MenuIcon,
|
||||
XIcon,
|
||||
FileIcon,
|
||||
FolderIcon,
|
||||
CogIcon,
|
||||
LayoutDashboardIcon,
|
||||
HardDriveIcon,
|
||||
UsersIcon,
|
||||
ActivityIcon,
|
||||
UploadIcon,
|
||||
TrashIcon,
|
||||
UserIcon,
|
||||
SearchIcon,
|
||||
UploadCloudIcon
|
||||
} from 'lucide-vue-next'
|
||||
|
||||
interface MenuItem {
|
||||
id: string
|
||||
name: string
|
||||
icon: any
|
||||
}
|
||||
|
||||
interface File {
|
||||
id: number
|
||||
name: string
|
||||
size: string
|
||||
type: string
|
||||
lastModified: string
|
||||
}
|
||||
|
||||
interface Settings {
|
||||
notifications: boolean
|
||||
autoUpdate: boolean
|
||||
twoFactor: boolean
|
||||
}
|
||||
|
||||
const isDarkMode = inject('isDarkMode')
|
||||
const menuItems: MenuItem[] = [
|
||||
{ id: 'dashboard', name: '仪表盘', icon: LayoutDashboardIcon },
|
||||
{ id: 'files', name: '文件管理', icon: FolderIcon },
|
||||
{ id: 'settings', name: '系统设置', icon: CogIcon }
|
||||
]
|
||||
|
||||
const currentSection = ref('dashboard')
|
||||
const isSidebarOpen = ref(true)
|
||||
const newPassword = ref('')
|
||||
|
||||
const settings = ref<Settings>({
|
||||
notifications: true,
|
||||
autoUpdate: false,
|
||||
twoFactor: false
|
||||
})
|
||||
|
||||
const fileTableHeaders = ['名称', '大小', '类型', '最后修改', '操作']
|
||||
|
||||
const files: File[] = [
|
||||
{ id: 1, name: 'document.pdf', size: '2.5 MB', type: 'PDF', lastModified: '2024-01-15' },
|
||||
{ id: 2, name: 'image.jpg', size: '1.8 MB', type: 'Image', lastModified: '2024-01-14' },
|
||||
{
|
||||
id: 3,
|
||||
name: 'spreadsheet.xlsx',
|
||||
size: '3.2 MB',
|
||||
type: 'Spreadsheet',
|
||||
lastModified: '2024-01-13'
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
name: 'presentation.pptx',
|
||||
size: '5.1 MB',
|
||||
type: 'Presentation',
|
||||
lastModified: '2024-01-12'
|
||||
},
|
||||
{ id: 5, name: 'video.mp4', size: '15.7 MB', type: 'Video', lastModified: '2024-01-11' }
|
||||
]
|
||||
|
||||
const toggleSidebar = () => {
|
||||
isSidebarOpen.value = !isSidebarOpen.value
|
||||
}
|
||||
|
||||
const downloadFile = (file: File) => {
|
||||
console.log('Downloading file:', file.name)
|
||||
}
|
||||
|
||||
const deleteFile = (file: File) => {
|
||||
console.log('Deleting file:', file.name)
|
||||
}
|
||||
|
||||
const changePassword = () => {
|
||||
console.log('Changing password to:', newPassword.value)
|
||||
newPassword.value = ''
|
||||
}
|
||||
|
||||
// 响应式处理
|
||||
const handleResize = () => {
|
||||
if (window.innerWidth >= 1024) {
|
||||
isSidebarOpen.value = true
|
||||
} else {
|
||||
isSidebarOpen.value = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
handleResize()
|
||||
window.addEventListener('resize', handleResize)
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
window.removeEventListener('resize', handleResize)
|
||||
})
|
||||
|
||||
// 添加最近活动数据
|
||||
const recentActivities = [
|
||||
{
|
||||
icon: UploadIcon,
|
||||
description: '张三上传了文件 "项目计划.pdf"',
|
||||
time: '10分钟前'
|
||||
},
|
||||
{
|
||||
icon: UserIcon,
|
||||
description: '新用户李四加入了系统',
|
||||
time: '30分钟前'
|
||||
},
|
||||
{
|
||||
icon: TrashIcon,
|
||||
description: '王五删除了文件 "旧文档.doc"',
|
||||
time: '1小时前'
|
||||
},
|
||||
{
|
||||
icon: FileIcon,
|
||||
description: '系统自动备份完成',
|
||||
time: '2小时前'
|
||||
}
|
||||
]
|
||||
|
||||
// 新增的响应式变量
|
||||
const fileSearchQuery = ref('')
|
||||
const fileTypeFilter = ref('')
|
||||
const showDropZone = ref(false)
|
||||
|
||||
const handleFileUpload = (event: Event) => {
|
||||
const files = (event.target as HTMLInputElement).files
|
||||
if (files && files.length > 0) {
|
||||
console.log('Uploading files:', files)
|
||||
}
|
||||
}
|
||||
|
||||
const handleFileDrop = (event: Event) => {
|
||||
const files = (event.dataTransfer as DataTransfer).files
|
||||
if (files && files.length > 0) {
|
||||
console.log('Dropped files:', files)
|
||||
}
|
||||
}
|
||||
|
||||
// 分页参数
|
||||
const params = ref({
|
||||
page: 1,
|
||||
size: 10,
|
||||
total: 0
|
||||
})
|
||||
|
||||
// 计算总页数
|
||||
const totalPages = computed(() => Math.ceil(params.value.total / params.value.size))
|
||||
|
||||
// 计算要显示的页码
|
||||
const displayedPages = computed(() => {
|
||||
const current = params.value.page
|
||||
const total = totalPages.value
|
||||
const delta = 2 // 当前页码前后显示的页码数
|
||||
|
||||
let pages: (number | string)[] = []
|
||||
|
||||
// 始终显示第一页
|
||||
pages.push(1)
|
||||
|
||||
// 计算显示范围
|
||||
let left = Math.max(2, current - delta)
|
||||
let right = Math.min(total - 1, current + delta)
|
||||
|
||||
// 添加省略号和页码
|
||||
if (left > 2) {
|
||||
pages.push('...')
|
||||
}
|
||||
|
||||
for (let i = left; i <= right; i++) {
|
||||
pages.push(i)
|
||||
}
|
||||
|
||||
if (right < total - 1) {
|
||||
pages.push('...')
|
||||
}
|
||||
|
||||
// 始终显示最后一页
|
||||
if (total > 1) {
|
||||
pages.push(total)
|
||||
}
|
||||
|
||||
return pages
|
||||
})
|
||||
|
||||
// 页码改变处理函数
|
||||
const handlePageChange = async (page: number) => {
|
||||
if (page < 1 || page > totalPages.value) return
|
||||
params.value.page = page
|
||||
await loadFiles() // 重新加载文件列表
|
||||
}
|
||||
|
||||
// 加载文件列表
|
||||
const loadFiles = async () => {
|
||||
try {
|
||||
// 这里实现实际的API调用
|
||||
// const response = await api.getFiles({
|
||||
// page: params.value.page,
|
||||
// size: params.value.size,
|
||||
// search: fileSearchQuery.value,
|
||||
// type: fileTypeFilter.value
|
||||
// });
|
||||
|
||||
// params.value.total = response.total;
|
||||
// files.value = response.data;
|
||||
|
||||
// 模拟API响应
|
||||
params.value.total = 85 // 示例总数
|
||||
// 更新文件列表数据...
|
||||
} catch (error) {
|
||||
console.error('加载文件列表失败:', error)
|
||||
// 处理错误...
|
||||
}
|
||||
}
|
||||
|
||||
// 监听搜索和筛选条件变化
|
||||
watch(
|
||||
[fileSearchQuery, fileTypeFilter],
|
||||
() => {
|
||||
params.value.page = 1 // 重置页码
|
||||
loadFiles()
|
||||
},
|
||||
{ debounce: 300 }
|
||||
)
|
||||
|
||||
// 初始加载
|
||||
onMounted(() => {
|
||||
loadFiles()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.switch {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
width: 60px;
|
||||
height: 34px;
|
||||
}
|
||||
|
||||
.switch input {
|
||||
opacity: 0;
|
||||
width: 0;
|
||||
height: 0;
|
||||
}
|
||||
|
||||
.slider {
|
||||
position: absolute;
|
||||
cursor: pointer;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background-color: #e5e7eb;
|
||||
transition: 0.4s;
|
||||
}
|
||||
|
||||
.dark .slider {
|
||||
background-color: #4b5563;
|
||||
}
|
||||
|
||||
input:checked + .slider {
|
||||
background-color: #4f46e5;
|
||||
}
|
||||
|
||||
.dark input:checked + .slider {
|
||||
background-color: #4f46e5;
|
||||
}
|
||||
|
||||
.slider:before {
|
||||
position: absolute;
|
||||
content: '';
|
||||
height: 26px;
|
||||
width: 26px;
|
||||
left: 4px;
|
||||
bottom: 4px;
|
||||
background-color: white;
|
||||
transition: 0.4s;
|
||||
}
|
||||
|
||||
.dark .slider:before {
|
||||
background-color: #e5e7eb;
|
||||
}
|
||||
|
||||
.slider.round {
|
||||
border-radius: 34px;
|
||||
}
|
||||
|
||||
.slider.round:before {
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
from {
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
|
||||
.animate-spin-slow {
|
||||
animation: spin 8s linear infinite;
|
||||
}
|
||||
|
||||
.transition-colors {
|
||||
transition-property: background-color, border-color, color, fill, stroke;
|
||||
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
|
||||
transition-duration: 300ms;
|
||||
}
|
||||
</style>
|
||||
+88
-407
@@ -11,6 +11,7 @@
|
||||
: 'bg-white border-gray-200'
|
||||
]"
|
||||
>
|
||||
<!-- Logo and Title Section -->
|
||||
<div class="p-8">
|
||||
<div class="flex justify-center mb-8">
|
||||
<div
|
||||
@@ -32,61 +33,9 @@
|
||||
>
|
||||
FileCodeBox
|
||||
</h2>
|
||||
<form @submit.prevent="handleSubmit">
|
||||
<div class="mb-6 relative">
|
||||
<label
|
||||
for="code"
|
||||
class="block text-sm font-medium mb-2"
|
||||
:class="[isDarkMode ? 'text-gray-300' : 'text-gray-800']"
|
||||
>取件码</label
|
||||
>
|
||||
<div class="relative">
|
||||
<input
|
||||
id="code"
|
||||
v-model="code"
|
||||
type="text"
|
||||
class="w-full px-4 py-3 rounded-lg text-white placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-indigo-500 transition duration-300 pr-10"
|
||||
:class="[
|
||||
isDarkMode ? 'bg-gray-700 bg-opacity-50' : 'bg-gray-100',
|
||||
{ 'ring-2 ring-red-500': error }
|
||||
]"
|
||||
placeholder="请输入5位取件码"
|
||||
required
|
||||
: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
|
||||
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>
|
||||
</div>
|
||||
<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"
|
||||
:disabled="inputStatus.loading"
|
||||
>
|
||||
<span class="flex items-center justify-center relative z-10">
|
||||
<span>{{ inputStatus.loading ? '处理中...' : '提取文件' }}</span>
|
||||
<ArrowRightIcon
|
||||
class="w-5 h-5 ml-2 transition-transform duration-300 transform group-hover:translate-x-1"
|
||||
/>
|
||||
</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>
|
||||
</button>
|
||||
</form>
|
||||
|
||||
<!-- File Input Form Component -->
|
||||
<FileInputForm :is-dark-mode="isDarkMode" @submit="handleSubmit" />
|
||||
|
||||
<div class="mt-6 text-center">
|
||||
<router-link
|
||||
@@ -97,6 +46,8 @@
|
||||
</router-link>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Footer Section -->
|
||||
<div
|
||||
class="px-8 py-4 bg-opacity-50 flex justify-between items-center"
|
||||
:class="[isDarkMode ? 'bg-gray-800' : 'bg-gray-100']"
|
||||
@@ -120,302 +71,85 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<transition name="drawer">
|
||||
<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="[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']"
|
||||
>
|
||||
<h3 class="text-2xl font-bold" :class="[isDarkMode ? 'text-white' : 'text-gray-800']">
|
||||
取件记录
|
||||
</h3>
|
||||
<button
|
||||
@click="toggleDrawer"
|
||||
class="hover:text-white transition duration-300"
|
||||
:class="[isDarkMode ? 'text-gray-400' : 'text-gray-800']"
|
||||
>
|
||||
<XIcon class="w-6 h-6" />
|
||||
</button>
|
||||
</div>
|
||||
<div class="flex-grow overflow-y-auto p-6">
|
||||
<transition-group name="list" tag="div" class="space-y-4">
|
||||
<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="[isDarkMode ? 'bg-gray-800 hover:bg-gray-700' : 'bg-gray-100 hover:bg-white']"
|
||||
>
|
||||
<div class="flex-shrink-0 mr-4">
|
||||
<FileIcon
|
||||
class="w-10 h-10"
|
||||
:class="[isDarkMode ? 'text-indigo-400' : 'text-indigo-600']"
|
||||
/>
|
||||
</div>
|
||||
<div class="flex-grow min-w-0 mr-4">
|
||||
<p
|
||||
class="font-medium text-lg truncate"
|
||||
:class="[isDarkMode ? 'text-white' : 'text-gray-800']"
|
||||
>
|
||||
{{ record.filename }}
|
||||
</p>
|
||||
<p
|
||||
class="text-sm truncate"
|
||||
:class="[isDarkMode ? 'text-gray-400' : 'text-gray-600']"
|
||||
>
|
||||
{{ record.date }} · {{ record.size }}
|
||||
</p>
|
||||
</div>
|
||||
<div class="flex-shrink-0 flex space-x-2">
|
||||
<button
|
||||
@click="viewDetails(record)"
|
||||
class="p-2 rounded-full hover:bg-opacity-20 transition duration-300"
|
||||
:class="[
|
||||
isDarkMode
|
||||
? 'hover:bg-indigo-400 text-indigo-400'
|
||||
: 'hover:bg-indigo-100 text-indigo-600'
|
||||
]"
|
||||
>
|
||||
<EyeIcon class="w-5 h-5" />
|
||||
</button>
|
||||
<button
|
||||
@click="downloadRecord(record)"
|
||||
class="p-2 rounded-full hover:bg-opacity-20 transition duration-300"
|
||||
:class="[
|
||||
isDarkMode
|
||||
? 'hover:bg-green-400 text-green-400'
|
||||
: 'hover:bg-green-100 text-green-600'
|
||||
]"
|
||||
>
|
||||
<DownloadIcon class="w-5 h-5" />
|
||||
</button>
|
||||
<button
|
||||
@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'
|
||||
]"
|
||||
>
|
||||
<TrashIcon class="w-5 h-5" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</transition-group>
|
||||
</div>
|
||||
</div>
|
||||
</transition>
|
||||
<!-- History Drawer Component -->
|
||||
<HistoryDrawer
|
||||
:show="showDrawer"
|
||||
:records="records"
|
||||
:is-dark-mode="isDarkMode"
|
||||
@close="toggleDrawer"
|
||||
@view-details="viewDetails"
|
||||
@download="downloadRecord"
|
||||
@delete="deleteRecord"
|
||||
/>
|
||||
|
||||
<transition name="fade">
|
||||
<div
|
||||
v-if="selectedRecord"
|
||||
class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50"
|
||||
>
|
||||
<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 bg-opacity-70 overflow-hidden"
|
||||
:class="[isDarkMode ? 'bg-gray-800' : 'bg-white']"
|
||||
>
|
||||
<h3
|
||||
class="text-2xl font-bold mb-6 truncate"
|
||||
:class="[isDarkMode ? 'text-white' : 'text-gray-800']"
|
||||
>
|
||||
文件详情
|
||||
</h3>
|
||||
<div class="space-y-4">
|
||||
<div class="flex items-center">
|
||||
<FileIcon
|
||||
class="w-6 h-6 mr-3 flex-shrink-0"
|
||||
: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 }}
|
||||
</p>
|
||||
</div>
|
||||
<div class="flex items-center">
|
||||
<CalendarIcon
|
||||
class="w-6 h-6 mr-3 flex-shrink-0"
|
||||
: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 }}
|
||||
</p>
|
||||
</div>
|
||||
<div class="flex items-center">
|
||||
<HardDriveIcon
|
||||
class="w-6 h-6 mr-3 flex-shrink-0"
|
||||
: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 }}
|
||||
</p>
|
||||
</div>
|
||||
<div class="flex items-center">
|
||||
<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']">
|
||||
<span class="font-medium">文件内容:</span>
|
||||
</p>
|
||||
<div v-if="selectedRecord.content" class="ml-2">
|
||||
<button
|
||||
@click="showContentPreview"
|
||||
class="px-4 py-2 bg-indigo-600 text-white rounded-lg hover:bg-indigo-700 transition duration-300"
|
||||
>
|
||||
预览内容
|
||||
</button>
|
||||
</div>
|
||||
<div v-else>
|
||||
<a
|
||||
:href="`${baseUrl}${selectedRecord.downloadUrl}`"
|
||||
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>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- File Details Modal Component -->
|
||||
<FileDetailsModal
|
||||
:record="selectedRecord"
|
||||
:is-dark-mode="isDarkMode"
|
||||
:base-url="baseUrl"
|
||||
@close="selectedRecord = null"
|
||||
@show-preview="showContentPreview"
|
||||
@download="downloadRecord"
|
||||
/>
|
||||
|
||||
<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>
|
||||
<div class="bg-white p-2 rounded-lg shadow-md">
|
||||
<QRCode :value="getQRCodeValue(selectedRecord)" :size="128" level="M" />
|
||||
</div>
|
||||
<p class="mt-2 text-sm" :class="[isDarkMode ? 'text-gray-400' : 'text-gray-600']">
|
||||
扫描二维码快速取件
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<button
|
||||
@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>
|
||||
</div>
|
||||
</div>
|
||||
</transition>
|
||||
|
||||
<!-- 新增内容预览弹框 -->
|
||||
<transition name="fade">
|
||||
<div
|
||||
v-if="showPreview"
|
||||
class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50"
|
||||
>
|
||||
<div
|
||||
class="p-8 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-[80vh] overflow-y-auto"
|
||||
:class="[isDarkMode ? 'bg-gray-800' : 'bg-white']"
|
||||
>
|
||||
<div class="flex justify-between items-center mb-4">
|
||||
<h3 class="text-2xl font-bold" :class="[isDarkMode ? 'text-white' : 'text-gray-800']">
|
||||
内容预览
|
||||
</h3>
|
||||
<button @click="showPreview = false" class="text-gray-500 hover:text-gray-700">
|
||||
<XIcon class="w-6 h-6" />
|
||||
</button>
|
||||
</div>
|
||||
<div
|
||||
class="prose max-w-none"
|
||||
:class="[isDarkMode ? 'prose-invert' : '']"
|
||||
v-html="renderedContent"
|
||||
></div>
|
||||
</div>
|
||||
</div>
|
||||
</transition>
|
||||
<!-- Content Preview Modal Component -->
|
||||
<ContentPreviewModal
|
||||
:show="showPreview"
|
||||
:content="selectedRecord?.content"
|
||||
:is-dark-mode="isDarkMode"
|
||||
@close="showPreview = false"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, inject, onMounted, watch, computed } from 'vue'
|
||||
import {
|
||||
BoxIcon,
|
||||
EyeIcon,
|
||||
ArrowRightIcon,
|
||||
ShieldCheckIcon,
|
||||
ClipboardListIcon,
|
||||
XIcon,
|
||||
TrashIcon,
|
||||
FileIcon,
|
||||
CalendarIcon,
|
||||
HardDriveIcon,
|
||||
DownloadIcon
|
||||
} from 'lucide-vue-next'
|
||||
import { ref, inject, onMounted } from 'vue'
|
||||
import { useRouter, useRoute } from 'vue-router'
|
||||
import QRCode from 'qrcode.vue'
|
||||
import { useFileDataStore } from '@/stores/fileData'
|
||||
import { storeToRefs } from 'pinia'
|
||||
import { useFileDataStore } from '@/stores/fileData'
|
||||
import { useAlertStore } from '@/stores/alertStore'
|
||||
import api from '@/utils/api'
|
||||
import { saveAs } from 'file-saver'
|
||||
import { marked } from 'marked'
|
||||
import { useAlertStore } from '@/stores/alertStore'
|
||||
import { BoxIcon, ShieldCheckIcon, ClipboardListIcon } from 'lucide-vue-next'
|
||||
|
||||
// Components
|
||||
import FileInputForm from '@/components/retrievew/FileInputForm.vue'
|
||||
import HistoryDrawer from '@/components/retrievew/HistoryDrawer.vue'
|
||||
import FileDetailsModal from '@/components/retrievew/FileDetailsModal.vue'
|
||||
import ContentPreviewModal from '@/components/retrievew/ContentPreviewModal.vue'
|
||||
|
||||
// Store and Router setup
|
||||
const router = useRouter()
|
||||
const route = useRoute()
|
||||
const fileStore = useFileDataStore()
|
||||
const alertStore = useAlertStore()
|
||||
const { receiveData: records } = storeToRefs(fileStore)
|
||||
|
||||
// Inject and Environment Variables
|
||||
const isDarkMode = inject('isDarkMode')
|
||||
const baseUrl =
|
||||
import.meta.env.MODE === 'production'
|
||||
? import.meta.env.VITE_API_BASE_URL_PROD
|
||||
: import.meta.env.VITE_API_BASE_URL_DEV
|
||||
|
||||
const router = useRouter()
|
||||
const isDarkMode = inject('isDarkMode')
|
||||
const fileStore = useFileDataStore()
|
||||
const { receiveData } = storeToRefs(fileStore)
|
||||
const code = ref('')
|
||||
const inputStatus = ref({
|
||||
readonly: false,
|
||||
loading: false
|
||||
})
|
||||
const isInputFocused = ref(false)
|
||||
const error = ref('')
|
||||
const selectedRecord = ref(null)
|
||||
// Reactive References
|
||||
const showDrawer = ref(false)
|
||||
const route = useRoute()
|
||||
|
||||
// 使用 receiveData 替代原来的 records
|
||||
const records = receiveData
|
||||
const selectedRecord = ref(null)
|
||||
const showPreview = ref(false)
|
||||
|
||||
// Lifecycle Hooks
|
||||
onMounted(() => {
|
||||
const query_code = route.query.code
|
||||
if (query_code) {
|
||||
code.value = query_code
|
||||
}
|
||||
})
|
||||
watch(code, (newVal) => {
|
||||
if (newVal.length === 5) {
|
||||
handleSubmit()
|
||||
const queryCode = route.query.code
|
||||
if (queryCode) {
|
||||
handleSubmit(queryCode)
|
||||
}
|
||||
})
|
||||
|
||||
const handleSubmit = async () => {
|
||||
if (code.value.length !== 5) {
|
||||
alertStore.showAlert('请输入5位取件码', 'error')
|
||||
return
|
||||
}
|
||||
|
||||
inputStatus.value.readonly = true
|
||||
inputStatus.value.loading = true
|
||||
|
||||
// Methods
|
||||
const handleSubmit = async (code) => {
|
||||
try {
|
||||
const res = await api.post('/share/select/', {
|
||||
code: code.value
|
||||
})
|
||||
const res = await api.post('/share/select/', { code })
|
||||
|
||||
if (res.code === 200) {
|
||||
if (res.detail) {
|
||||
const isFile = res.detail.text.startsWith('/share/download')
|
||||
@@ -429,16 +163,12 @@ const handleSubmit = async () => {
|
||||
date: new Date().toLocaleString()
|
||||
}
|
||||
|
||||
let flag = true
|
||||
fileStore.receiveData.forEach((file) => {
|
||||
if (file.code === newFileData.code) {
|
||||
flag = false
|
||||
return
|
||||
}
|
||||
})
|
||||
if (flag) {
|
||||
// Check if file already exists in history
|
||||
const exists = fileStore.receiveData.some((file) => file.code === newFileData.code)
|
||||
if (!exists) {
|
||||
fileStore.addReceiveData(newFileData)
|
||||
}
|
||||
|
||||
showDrawer.value = true
|
||||
alertStore.showAlert('文件获取成功', 'success')
|
||||
} else {
|
||||
@@ -450,10 +180,6 @@ const handleSubmit = async () => {
|
||||
} catch (err) {
|
||||
console.error('取件失败:', err)
|
||||
alertStore.showAlert('取件失败,请稍后重试', 'error')
|
||||
} finally {
|
||||
inputStatus.value.readonly = false
|
||||
inputStatus.value.loading = false
|
||||
code.value = ''
|
||||
}
|
||||
}
|
||||
|
||||
@@ -484,35 +210,23 @@ const toSend = () => {
|
||||
router.push('/send')
|
||||
}
|
||||
|
||||
const getQRCodeValue = (record) => {
|
||||
return `${baseUrl}${record.downloadUrl}`
|
||||
}
|
||||
|
||||
const downloadRecord = (record) => {
|
||||
if (record.downloadUrl) {
|
||||
// 如果是文件,直接下载
|
||||
// If it's a file, open in new tab for download
|
||||
window.open(`${baseUrl}${record.downloadUrl}`, '_blank')
|
||||
} else if (record.content) {
|
||||
// 如果是文本,转成txt下载
|
||||
// If it's text content, download as txt file
|
||||
const blob = new Blob([record.content], { type: 'text/plain;charset=utf-8' })
|
||||
saveAs(blob, `${record.filename}.txt`)
|
||||
}
|
||||
}
|
||||
|
||||
const showPreview = ref(false)
|
||||
const renderedContent = computed(() => {
|
||||
if (selectedRecord.value && selectedRecord.value.content) {
|
||||
return marked(selectedRecord.value.content)
|
||||
}
|
||||
return ''
|
||||
})
|
||||
|
||||
const showContentPreview = () => {
|
||||
showPreview.value = true
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
<style>
|
||||
@keyframes blob {
|
||||
0%,
|
||||
100% {
|
||||
@@ -528,23 +242,6 @@ const showContentPreview = () => {
|
||||
transform: translate(50px, 50px) scale(1.05);
|
||||
}
|
||||
}
|
||||
@media (min-width: 640px) {
|
||||
.sm\:w-120 {
|
||||
width: 30rem; /* 480px */
|
||||
}
|
||||
}
|
||||
.animate-blob-1 {
|
||||
animation: blob 25s infinite;
|
||||
}
|
||||
.animate-blob-2 {
|
||||
animation: blob 30s infinite;
|
||||
}
|
||||
.animate-blob-3 {
|
||||
animation: blob 35s infinite;
|
||||
}
|
||||
.animate-blob-4 {
|
||||
animation: blob 40s infinite;
|
||||
}
|
||||
|
||||
.animate-spin-slow {
|
||||
animation: spin 8s linear infinite;
|
||||
@@ -559,58 +256,42 @@ const showContentPreview = () => {
|
||||
}
|
||||
}
|
||||
|
||||
/* Media Queries */
|
||||
@media (min-width: 640px) {
|
||||
.sm\:w-120 {
|
||||
width: 30rem;
|
||||
}
|
||||
}
|
||||
|
||||
/* Transitions */
|
||||
.fade-enter-active,
|
||||
.fade-leave-active {
|
||||
transition: opacity 0.3s ease;
|
||||
}
|
||||
|
||||
.fade-enter-from,
|
||||
.fade-leave-to {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.list-enter-active,
|
||||
.list-leave-active {
|
||||
transition: all 0.5s ease;
|
||||
}
|
||||
.list-enter-from,
|
||||
.list-leave-to {
|
||||
opacity: 0;
|
||||
transform: translateX(30px);
|
||||
}
|
||||
|
||||
.drawer-enter-active,
|
||||
.drawer-leave-active {
|
||||
transition: transform 0.3s ease;
|
||||
}
|
||||
.drawer-enter-from,
|
||||
.drawer-leave-to {
|
||||
|
||||
.drawer-leave-to,
|
||||
.drawer-enter-from {
|
||||
transform: translateX(100%);
|
||||
}
|
||||
.w-97-100 {
|
||||
width: 97%;
|
||||
|
||||
.list-enter-active,
|
||||
.list-leave-active {
|
||||
transition: all 0.5s ease;
|
||||
}
|
||||
|
||||
/* 添加 Markdown 样式 */
|
||||
:deep(.prose) {
|
||||
@apply text-left;
|
||||
}
|
||||
:deep(.prose h1, .prose h2, .prose h3, .prose h4, .prose h5, .prose h6) {
|
||||
@apply text-indigo-600 dark:text-indigo-400;
|
||||
}
|
||||
:deep(.prose a) {
|
||||
@apply text-blue-600 dark:text-blue-400;
|
||||
}
|
||||
:deep(.prose code) {
|
||||
@apply bg-gray-100 dark:bg-gray-700 rounded px-1;
|
||||
}
|
||||
:deep(.prose pre) {
|
||||
@apply bg-gray-100 dark:bg-gray-700 rounded p-4 overflow-x-auto;
|
||||
}
|
||||
|
||||
/* 添加新的宽度类 */
|
||||
@media (min-width: 640px) {
|
||||
.sm\:w-120 {
|
||||
width: 30rem; /* 480px */
|
||||
}
|
||||
.list-enter-from,
|
||||
.list-leave-to {
|
||||
opacity: 0;
|
||||
transform: translateX(30px);
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -409,7 +409,7 @@ import {
|
||||
ClipboardCopyIcon
|
||||
} from 'lucide-vue-next'
|
||||
import { useRouter } from 'vue-router'
|
||||
import BorderProgressBar from '../components/BorderProgressBar.vue'
|
||||
import BorderProgressBar from '@/components/common/BorderProgressBar.vue'
|
||||
import QRCode from 'qrcode.vue'
|
||||
import SparkMD5 from 'spark-md5'
|
||||
import { useFileDataStore } from '../stores/fileData'
|
||||
|
||||
Reference in New Issue
Block a user