Share.vue 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224
  1. <template>
  2. <div class="share-page">
  3. <div class="container">
  4. <!-- 加载状态 -->
  5. <div v-if="loading" class="loading-container">
  6. <div class="spinner large"></div>
  7. <p>加载中...</p>
  8. </div>
  9. <!-- 密码验证 -->
  10. <div v-else-if="requiresPassword && !passwordVerified" class="password-container card">
  11. <h2>🔒 此内容需要密码</h2>
  12. <input
  13. v-model="password"
  14. type="password"
  15. class="password-input"
  16. placeholder="请输入访问密码"
  17. @keyup.enter="verifyPassword"
  18. >
  19. <button class="btn btn-primary btn-lg" @click="verifyPassword">
  20. 验证密码
  21. </button>
  22. <p v-if="passwordError" class="error-message">{{ passwordError }}</p>
  23. </div>
  24. <!-- 分享内容 -->
  25. <div v-else-if="shareData" class="share-content">
  26. <!-- 左右分栏布局容器 -->
  27. <div v-if="shareData.files && shareData.files.length > 0" class="content-split">
  28. <!-- 左侧:文件下载区 -->
  29. <div class="left-column">
  30. <div class="files-content card">
  31. <div class="content-header">
  32. <h2>📁 分享的文件</h2>
  33. <span class="file-count">{{ shareData.files.length }} 个文件</span>
  34. </div>
  35. <div class="files-list">
  36. <div
  37. v-for="file in shareData.files"
  38. :key="file.fileId"
  39. class="file-item"
  40. >
  41. <div class="file-info">
  42. <svg class="file-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor">
  43. <path d="M13 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"></path>
  44. <polyline points="13 2 13 9 20 9"></polyline>
  45. </svg>
  46. <div class="file-details">
  47. <p class="file-name">{{ file.fileName }}</p>
  48. <p class="file-size">{{ formatFileSize(file.fileSize) }}</p>
  49. </div>
  50. </div>
  51. <div class="file-actions">
  52. <!-- 预览按钮(仅图片和PDF) -->
  53. <button
  54. v-if="isPreviewable(file.mimeType)"
  55. class="btn-action btn-preview"
  56. @click="previewFile(file.fileId)"
  57. title="在新窗口预览"
  58. >
  59. <svg viewBox="0 0 24 24" fill="none" stroke="currentColor">
  60. <path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"></path>
  61. <circle cx="12" cy="12" r="3"></circle>
  62. </svg>
  63. <span>预览</span>
  64. </button>
  65. <!-- 下载按钮 -->
  66. <button
  67. class="btn-action btn-download"
  68. @click="downloadFile(file.fileId, file.fileName)"
  69. title="下载文件"
  70. >
  71. <svg viewBox="0 0 24 24" fill="none" stroke="currentColor">
  72. <path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"></path>
  73. <polyline points="7 10 12 15 17 10"></polyline>
  74. <line x1="12" y1="15" x2="12" y2="3"></line>
  75. </svg>
  76. <span>下载</span>
  77. </button>
  78. </div>
  79. </div>
  80. </div>
  81. <!-- 打包下载按钮 -->
  82. <button
  83. class="btn-download-all btn btn-primary btn-lg"
  84. @click="downloadAll"
  85. :disabled="downloadingAll"
  86. >
  87. {{ downloadingAll ? '⏳ 正在打包...' : '📦 打包下载所有文件' }}
  88. </button>
  89. <div class="content-info">
  90. <p>创建时间:{{ formatTime(shareData.createdTime) }}</p>
  91. <p>过期时间:{{ formatTime(shareData.expirationTime) }}</p>
  92. <p>下载次数:{{ shareData.currentDownloadCount }}/{{ shareData.maxDownloadCount === -1 ? '无限制' : shareData.maxDownloadCount }}</p>
  93. </div>
  94. <!-- 删除资源按钮 -->
  95. <div class="content-actions">
  96. <button
  97. class="btn-delete"
  98. @click="confirmDelete"
  99. title="删除此分享资源"
  100. >
  101. <svg viewBox="0 0 24 24" fill="none" stroke="currentColor">
  102. <polyline points="3 6 5 6 21 6"></polyline>
  103. <path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"></path>
  104. </svg>
  105. <span>删除资源</span>
  106. </button>
  107. </div>
  108. </div>
  109. </div>
  110. <!-- 右侧:文本内容区 -->
  111. <div v-if="shareData.textContent" class="right-column">
  112. <div class="text-content card">
  113. <div class="content-header">
  114. <h2>📝 分享的文本</h2>
  115. <div class="header-actions">
  116. <span class="content-type">{{ shareData.textType }}</span>
  117. <!-- Markdown切换按钮 -->
  118. <button
  119. v-if="shareData.textType === 'markdown'"
  120. class="btn btn-secondary btn-sm"
  121. @click="showMarkdownSource = !showMarkdownSource"
  122. >
  123. {{ showMarkdownSource ? '👁️ 查看预览' : '📝 查看源码' }}
  124. </button>
  125. <!-- 复制按钮 -->
  126. <button
  127. class="btn-copy-text"
  128. :class="{ copied: copyStatus === 'copied' }"
  129. @click="copyTextContent"
  130. :title="copyStatus === 'copied' ? '已复制' : '复制内容'"
  131. >
  132. <svg v-if="copyStatus !== 'copied'" viewBox="0 0 24 24" fill="none" stroke="currentColor">
  133. <rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect>
  134. <path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path>
  135. </svg>
  136. <svg v-else viewBox="0 0 24 24" fill="none" stroke="currentColor">
  137. <polyline points="20 6 9 17 4 12"></polyline>
  138. </svg>
  139. <span>{{ copyStatus === 'copied' ? '已复制' : '复制' }}</span>
  140. </button>
  141. </div>
  142. </div>
  143. <div class="text-display">
  144. <Transition name="fade" mode="out-in">
  145. <!-- Markdown渲染 -->
  146. <MarkdownRenderer
  147. v-if="shareData.textType === 'markdown' && !showMarkdownSource"
  148. :content="shareData.textContent"
  149. key="preview"
  150. />
  151. <!-- Markdown源码 -->
  152. <pre v-else-if="shareData.textType === 'markdown' && showMarkdownSource" key="source">{{ shareData.textContent }}</pre>
  153. <!-- 代码高亮 -->
  154. <CodeHighlight
  155. v-else-if="shareData.textType === 'code'"
  156. :code="shareData.textContent"
  157. key="code"
  158. />
  159. <!-- JSON格式化 -->
  160. <CodeHighlight
  161. v-else-if="shareData.textType === 'json'"
  162. :code="formatJson(shareData.textContent)"
  163. language="json"
  164. key="json"
  165. />
  166. <!-- 纯文本 -->
  167. <pre v-else key="plain">{{ shareData.textContent }}</pre>
  168. </Transition>
  169. </div>
  170. <div class="content-info">
  171. <p>创建时间:{{ formatTime(shareData.createdTime) }}</p>
  172. <p>过期时间:{{ formatTime(shareData.expirationTime) }}</p>
  173. </div>
  174. </div>
  175. </div>
  176. </div>
  177. <!-- 单独显示文本内容(无文件时) -->
  178. <div v-else-if="shareData.textContent" class="text-content card full-width">
  179. <div class="content-header">
  180. <h2>📝 分享的文本</h2>
  181. <div class="header-actions">
  182. <span class="content-type">{{ shareData.textType }}</span>
  183. <!-- Markdown切换按钮 -->
  184. <button
  185. v-if="shareData.textType === 'markdown'"
  186. class="btn btn-secondary btn-sm"
  187. @click="showMarkdownSource = !showMarkdownSource"
  188. >
  189. {{ showMarkdownSource ? '👁️ 查看预览' : '📝 查看源码' }}
  190. </button>
  191. <!-- 复制按钮 -->
  192. <button
  193. class="btn-copy-text"
  194. :class="{ copied: copyStatus === 'copied' }"
  195. @click="copyTextContent"
  196. :title="copyStatus === 'copied' ? '已复制' : '复制内容'"
  197. >
  198. <svg v-if="copyStatus !== 'copied'" viewBox="0 0 24 24" fill="none" stroke="currentColor">
  199. <rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect>
  200. <path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path>
  201. </svg>
  202. <svg v-else viewBox="0 0 24 24" fill="none" stroke="currentColor">
  203. <polyline points="20 6 9 17 4 12"></polyline>
  204. </svg>
  205. <span>{{ copyStatus === 'copied' ? '已复制' : '复制' }}</span>
  206. </button>
  207. </div>
  208. </div>
  209. <div class="text-display">
  210. <Transition name="fade" mode="out-in">
  211. <!-- Markdown渲染 -->
  212. <MarkdownRenderer
  213. v-if="shareData.textType === 'markdown' && !showMarkdownSource"
  214. :content="shareData.textContent"
  215. key="preview"
  216. />
  217. <!-- Markdown源码 -->
  218. <pre v-else-if="shareData.textType === 'markdown' && showMarkdownSource" key="source">{{ shareData.textContent }}</pre>
  219. <!-- 代码高亮 -->
  220. <CodeHighlight
  221. v-else-if="shareData.textType === 'code'"
  222. :code="shareData.textContent"
  223. key="code"
  224. />
  225. <!-- JSON格式化 -->
  226. <CodeHighlight
  227. v-else-if="shareData.textType === 'json'"
  228. :code="formatJson(shareData.textContent)"
  229. language="json"
  230. key="json"
  231. />
  232. <!-- 纯文本 -->
  233. <pre v-else key="plain">{{ shareData.textContent }}</pre>
  234. </Transition>
  235. </div>
  236. <div class="content-info">
  237. <p>创建时间:{{ formatTime(shareData.createdTime) }}</p>
  238. <p>过期时间:{{ formatTime(shareData.expirationTime) }}</p>
  239. <p>下载次数:{{ shareData.currentDownloadCount }}/{{ shareData.maxDownloadCount === -1 ? '无限制' : shareData.maxDownloadCount }}</p>
  240. </div>
  241. <!-- 删除资源按钮 -->
  242. <div class="content-actions">
  243. <button
  244. class="btn-delete"
  245. @click="confirmDelete"
  246. title="删除此分享资源"
  247. >
  248. <svg viewBox="0 0 24 24" fill="none" stroke="currentColor">
  249. <polyline points="3 6 5 6 21 6"></polyline>
  250. <path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"></path>
  251. </svg>
  252. <span>删除资源</span>
  253. </button>
  254. </div>
  255. </div>
  256. <!-- 内容不存在或已过期 -->
  257. <div v-else class="error-container card">
  258. <h2>😔 内容不存在</h2>
  259. <p>该分享内容可能已被删除或已过期</p>
  260. <router-link to="/" class="btn btn-primary">返回首页</router-link>
  261. </div>
  262. </div>
  263. <!-- 错误状态 -->
  264. <div v-else-if="error" class="error-container card">
  265. <h2>❌ 加载失败</h2>
  266. <p>{{ error }}</p>
  267. <router-link to="/" class="btn btn-primary">返回首页</router-link>
  268. </div>
  269. </div>
  270. <!-- 浮动返回首页按钮 -->
  271. <router-link to="/" class="floating-back-btn" title="返回首页">
  272. 返回首页
  273. </router-link>
  274. <!-- 删除确认对话框 -->
  275. <div v-if="showDeleteConfirm" class="modal-overlay" @click="showDeleteConfirm = false">
  276. <div class="modal delete-confirm-modal" @click.stop>
  277. <div class="modal-header">
  278. <h3>⚠️ 确认删除</h3>
  279. </div>
  280. <div class="modal-body">
  281. <p>确定要删除此分享资源吗?</p>
  282. <p class="warning-text">
  283. 删除后将无法恢复,所有文件和文本内容将被永久删除。
  284. </p>
  285. <!-- 如果有密码保护,提示输入密码 -->
  286. <div v-if="shareData && shareData.requiresPassword" class="password-verify">
  287. <label>请输入密码以确认删除:</label>
  288. <input
  289. v-model="deletePassword"
  290. type="password"
  291. class="password-input"
  292. placeholder="输入访问密码"
  293. @keyup.enter="executeDelete"
  294. >
  295. <p v-if="deleteError" class="error-message">{{ deleteError }}</p>
  296. </div>
  297. </div>
  298. <div class="modal-footer">
  299. <button class="btn btn-secondary" @click="showDeleteConfirm = false">
  300. 取消
  301. </button>
  302. <button
  303. class="btn btn-danger"
  304. @click="executeDelete"
  305. :disabled="deleting"
  306. >
  307. <span v-if="deleting">删除中...</span>
  308. <span v-else>确认删除</span>
  309. </button>
  310. </div>
  311. </div>
  312. </div>
  313. </div>
  314. </template>
  315. <script setup>
  316. import { ref, onMounted } from 'vue'
  317. import { useRoute, useRouter } from 'vue-router'
  318. import { getShareContent, verifyAndGetShareContent, downloadFile as downloadFileApi, deleteShare } from '@/api'
  319. import config from '@/config'
  320. import CodeHighlight from '@/components/CodeHighlight.vue'
  321. import MarkdownRenderer from '@/components/MarkdownRenderer.vue'
  322. import toast from '@/utils/toast'
  323. const route = useRoute()
  324. const router = useRouter()
  325. const id = route.params.id
  326. // 状态
  327. const loading = ref(true)
  328. const shareData = ref(null)
  329. const requiresPassword = ref(false)
  330. const passwordVerified = ref(false)
  331. const password = ref('')
  332. const passwordError = ref('')
  333. const error = ref('')
  334. const downloadingAll = ref(false)
  335. const showMarkdownSource = ref(false) // Markdown源码/预览切换状态
  336. const copyStatus = ref('idle') // 'idle' | 'copied'
  337. // 删除相关状态
  338. const showDeleteConfirm = ref(false)
  339. const deletePassword = ref('')
  340. const deleteError = ref('')
  341. const deleting = ref(false)
  342. // 生命周期
  343. onMounted(() => {
  344. loadShareContent()
  345. })
  346. // 方法
  347. async function loadShareContent() {
  348. loading.value = true
  349. error.value = ''
  350. try {
  351. const response = await getShareContent(id)
  352. if (response.requiresPassword) {
  353. requiresPassword.value = true
  354. } else {
  355. shareData.value = response
  356. }
  357. } catch (err) {
  358. error.value = err.message || '加载失败'
  359. } finally {
  360. loading.value = false
  361. }
  362. }
  363. async function verifyPassword() {
  364. passwordError.value = ''
  365. if (!password.value) {
  366. passwordError.value = '请输入密码'
  367. return
  368. }
  369. loading.value = true
  370. try {
  371. const response = await verifyAndGetShareContent(id, password.value)
  372. shareData.value = response
  373. passwordVerified.value = true
  374. } catch (err) {
  375. passwordError.value = '密码错误'
  376. } finally {
  377. loading.value = false
  378. }
  379. }
  380. function downloadFile(fileId, fileName) {
  381. const url = downloadFileApi(id, fileId)
  382. const link = document.createElement('a')
  383. link.href = url
  384. link.download = fileName
  385. link.click()
  386. }
  387. // 判断文件是否可预览(图片或PDF)
  388. function isPreviewable(mimeType) {
  389. if (!mimeType) return false
  390. const previewableTypes = [
  391. // 图片类型
  392. 'image/jpeg',
  393. 'image/jpg',
  394. 'image/png',
  395. 'image/gif',
  396. 'image/webp',
  397. 'image/svg+xml',
  398. 'image/bmp',
  399. 'image/x-icon',
  400. // PDF类型
  401. 'application/pdf'
  402. ]
  403. return previewableTypes.includes(mimeType)
  404. }
  405. // 在新窗口预览文件
  406. function previewFile(fileId) {
  407. const url = downloadFileApi(id, fileId)
  408. window.open(url, '_blank', 'noopener,noreferrer')
  409. }
  410. async function downloadAll() {
  411. if (downloadingAll.value) return
  412. downloadingAll.value = true
  413. try {
  414. const url = `${config.baseURL}/api/share/${id}/download-all`
  415. const link = document.createElement('a')
  416. link.href = url
  417. link.download = `${id}_files.zip`
  418. document.body.appendChild(link)
  419. link.click()
  420. document.body.removeChild(link)
  421. } catch (err) {
  422. error.value = '打包下载失败:' + (err.message || '未知错误')
  423. } finally {
  424. downloadingAll.value = false
  425. }
  426. }
  427. function formatFileSize(bytes) {
  428. if (bytes === 0) return '0 B'
  429. const k = 1024
  430. const sizes = ['B', 'KB', 'MB', 'GB']
  431. const i = Math.floor(Math.log(bytes) / Math.log(k))
  432. return Math.round(bytes / Math.pow(k, i) * 100) / 100 + ' ' + sizes[i]
  433. }
  434. function formatTime(timeStr) {
  435. return new Date(timeStr).toLocaleString('zh-CN')
  436. }
  437. function formatJson(jsonStr) {
  438. try {
  439. const obj = JSON.parse(jsonStr)
  440. return JSON.stringify(obj, null, 2)
  441. } catch (e) {
  442. return jsonStr
  443. }
  444. }
  445. // 复制文本内容到剪贴板
  446. async function copyTextContent() {
  447. if (!shareData.value?.textContent) return
  448. try {
  449. await navigator.clipboard.writeText(shareData.value.textContent)
  450. copyStatus.value = 'copied'
  451. toast.success('内容已复制到剪贴板')
  452. setTimeout(() => { copyStatus.value = 'idle' }, 2000)
  453. } catch (err) {
  454. // clipboard API 不可用时回退方案
  455. const textarea = document.createElement('textarea')
  456. textarea.value = shareData.value.textContent
  457. textarea.style.position = 'fixed'
  458. textarea.style.opacity = '0'
  459. document.body.appendChild(textarea)
  460. textarea.select()
  461. document.execCommand('copy')
  462. document.body.removeChild(textarea)
  463. copyStatus.value = 'copied'
  464. toast.success('内容已复制到剪贴板')
  465. setTimeout(() => { copyStatus.value = 'idle' }, 2000)
  466. }
  467. }
  468. // 显示删除确认对话框
  469. function confirmDelete() {
  470. showDeleteConfirm.value = true
  471. deletePassword.value = ''
  472. deleteError.value = ''
  473. }
  474. // 执行删除
  475. async function executeDelete() {
  476. deleting.value = true
  477. deleteError.value = ''
  478. try {
  479. // 如果有密码保护,先验证密码
  480. if (shareData.value.requiresPassword) {
  481. if (!deletePassword.value) {
  482. deleteError.value = '请输入密码'
  483. return
  484. }
  485. // 验证密码
  486. try {
  487. await verifyAndGetShareContent(id, deletePassword.value)
  488. } catch (err) {
  489. deleteError.value = '密码错误'
  490. return
  491. }
  492. }
  493. // 调用删除API
  494. await deleteShare(id)
  495. // 显示成功提示
  496. toast.success('资源已成功删除')
  497. // 跳转回首页
  498. router.push('/')
  499. } catch (err) {
  500. deleteError.value = err.message || '删除失败,请稍后重试'
  501. } finally {
  502. deleting.value = false
  503. }
  504. }
  505. </script>
  506. <style lang="scss" scoped>
  507. @import '@/styles/variables.scss';
  508. .share-page {
  509. min-height: 100vh;
  510. padding: $spacing-2xl $spacing-lg;
  511. }
  512. .loading-container {
  513. @extend .card !optional;
  514. text-align: center;
  515. padding: $spacing-2xl;
  516. .spinner {
  517. width: 60px;
  518. height: 60px;
  519. margin: 0 auto $spacing-lg;
  520. border-width: 4px;
  521. &.large {
  522. width: 80px;
  523. height: 80px;
  524. border-width: 6px;
  525. }
  526. }
  527. p {
  528. color: $text-secondary;
  529. }
  530. }
  531. .password-container {
  532. max-width: 500px;
  533. margin: $spacing-2xl auto;
  534. text-align: center;
  535. h2 {
  536. margin-bottom: $spacing-xl;
  537. color: $text-secondary;
  538. }
  539. .password-input {
  540. margin-bottom: $spacing-lg;
  541. }
  542. }
  543. .error-message {
  544. color: $error-color;
  545. margin-top: $spacing-md;
  546. }
  547. .share-content {
  548. max-width: 1400px; // 增加宽度以适应左右分栏
  549. margin: 0 auto;
  550. // 左右分栏时增加宽度
  551. &.content-split {
  552. display: flex;
  553. }
  554. }
  555. .text-content,
  556. .files-content {
  557. .content-header {
  558. display: flex;
  559. justify-content: space-between;
  560. align-items: center;
  561. margin-bottom: $spacing-lg;
  562. h2 {
  563. color: $text-secondary;
  564. }
  565. .content-type,
  566. .file-count {
  567. font-size: $font-size-sm;
  568. background: $bg-tertiary;
  569. padding: $spacing-xs $spacing-sm;
  570. border-radius: $radius-full;
  571. color: $text-muted;
  572. }
  573. }
  574. }
  575. .text-display {
  576. background: $bg-tertiary;
  577. border-radius: $radius-md;
  578. padding: $spacing-lg;
  579. margin-bottom: $spacing-lg;
  580. max-height: 500px;
  581. overflow-y: auto;
  582. pre {
  583. white-space: pre-wrap;
  584. word-wrap: break-word;
  585. color: $text-primary;
  586. font-family: 'Courier New', monospace;
  587. line-height: 1.6;
  588. }
  589. }
  590. .files-list {
  591. margin-bottom: $spacing-lg;
  592. }
  593. .file-item {
  594. display: flex;
  595. justify-content: space-between;
  596. align-items: center;
  597. padding: $spacing-md;
  598. background: $bg-tertiary;
  599. border-radius: $radius-md;
  600. margin-bottom: $spacing-sm;
  601. }
  602. .file-info {
  603. display: flex;
  604. align-items: center;
  605. gap: $spacing-md;
  606. flex: 1;
  607. }
  608. .file-icon {
  609. width: 48px;
  610. height: 48px;
  611. color: $accent-color;
  612. }
  613. .file-details {
  614. flex: 1;
  615. min-width: 0; // 确保flex子项不会溢出
  616. .file-name {
  617. color: $text-primary;
  618. margin-bottom: $spacing-xs;
  619. word-break: break-word; // 长文件名自然换行
  620. overflow-wrap: break-word;
  621. white-space: normal; // 允许换行
  622. }
  623. .file-size {
  624. font-size: $font-size-sm;
  625. color: $text-muted;
  626. }
  627. }
  628. // 文件操作按钮容器
  629. .file-actions {
  630. display: flex;
  631. gap: $spacing-sm;
  632. align-items: center;
  633. flex-shrink: 0;
  634. }
  635. // 现代化按钮样式
  636. .btn-action {
  637. display: inline-flex;
  638. align-items: center;
  639. gap: $spacing-xs;
  640. padding: $spacing-sm $spacing-md;
  641. border-radius: $radius-md;
  642. border: none;
  643. font-size: $font-size-sm;
  644. font-weight: 500;
  645. cursor: pointer;
  646. transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  647. white-space: nowrap;
  648. svg {
  649. width: 18px;
  650. height: 18px;
  651. stroke-width: 2;
  652. }
  653. &:hover {
  654. transform: translateY(-1px);
  655. }
  656. &:active {
  657. transform: translateY(0);
  658. }
  659. }
  660. .btn-preview {
  661. background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  662. color: white;
  663. box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
  664. &:hover {
  665. box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
  666. background: linear-gradient(135deg, #7c8efc 0%, #8a5db8 100%);
  667. }
  668. }
  669. .btn-download {
  670. background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
  671. color: white;
  672. box-shadow: 0 2px 8px rgba(17, 153, 142, 0.3);
  673. &:hover {
  674. box-shadow: 0 4px 12px rgba(17, 153, 142, 0.4);
  675. background: linear-gradient(135deg, #14b89f 0%, #4fff8d 100%);
  676. }
  677. }
  678. .btn-download-all {
  679. width: 100%;
  680. margin-bottom: $spacing-lg;
  681. }
  682. .content-info {
  683. padding-top: $spacing-lg;
  684. border-top: 1px solid $border-color;
  685. p {
  686. font-size: $font-size-sm;
  687. color: $text-muted;
  688. margin-bottom: $spacing-xs;
  689. }
  690. }
  691. // 内容操作区
  692. .content-actions {
  693. margin-top: $spacing-md;
  694. display: flex;
  695. justify-content: flex-end;
  696. }
  697. // 删除按钮
  698. .btn-delete {
  699. display: inline-flex;
  700. align-items: center;
  701. gap: $spacing-xs;
  702. padding: $spacing-sm $spacing-md;
  703. background: linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%); // 红色渐变
  704. color: white;
  705. border: none;
  706. border-radius: $radius-md;
  707. font-size: $font-size-sm;
  708. font-weight: 500;
  709. cursor: pointer;
  710. box-shadow: 0 2px 8px rgba(238, 90, 111, 0.3);
  711. transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  712. svg {
  713. width: 18px;
  714. height: 18px;
  715. stroke-width: 2;
  716. }
  717. &:hover {
  718. transform: translateY(-1px);
  719. box-shadow: 0 4px 12px rgba(238, 90, 111, 0.4);
  720. background: linear-gradient(135deg, #ff8787 0%, #ff6b6b 100%);
  721. }
  722. &:active {
  723. transform: translateY(0);
  724. }
  725. &:disabled {
  726. opacity: 0.6;
  727. cursor: not-allowed;
  728. transform: none !important;
  729. }
  730. }
  731. .error-container {
  732. max-width: 500px;
  733. margin: $spacing-2xl auto;
  734. text-align: center;
  735. h2 {
  736. margin-bottom: $spacing-lg;
  737. color: $error-color;
  738. }
  739. p {
  740. color: $text-muted;
  741. margin-bottom: $spacing-xl;
  742. }
  743. }
  744. // ==================== 新增样式 ====================
  745. // 删除确认对话框
  746. .delete-confirm-modal {
  747. max-width: 450px;
  748. .warning-text {
  749. color: $warning-color;
  750. font-weight: 500;
  751. margin: $spacing-md 0;
  752. }
  753. .password-verify {
  754. margin-top: $spacing-lg;
  755. padding: $spacing-md;
  756. background: $bg-tertiary;
  757. border-radius: $radius-md;
  758. label {
  759. display: block;
  760. margin-bottom: $spacing-sm;
  761. color: $text-secondary;
  762. }
  763. .password-input {
  764. width: 100%;
  765. padding: $spacing-sm $spacing-md;
  766. background: $bg-secondary;
  767. border: 1px solid $border-color;
  768. border-radius: $radius-md;
  769. color: $text-primary;
  770. &:focus {
  771. outline: none;
  772. border-color: $primary-color;
  773. }
  774. }
  775. .error-message {
  776. color: $error-color;
  777. margin-top: $spacing-sm;
  778. font-size: $font-size-sm;
  779. }
  780. }
  781. }
  782. .btn-danger {
  783. background: linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%);
  784. box-shadow: 0 2px 8px rgba(238, 90, 111, 0.3);
  785. &:hover:not(:disabled) {
  786. background: linear-gradient(135deg, #ff8787 0%, #ff6b6b 100%);
  787. box-shadow: 0 4px 12px rgba(238, 90, 111, 0.4);
  788. }
  789. &:disabled {
  790. opacity: 0.6;
  791. cursor: not-allowed;
  792. }
  793. }
  794. // 左右分栏布局
  795. .content-split {
  796. display: flex;
  797. gap: $spacing-xl;
  798. align-items: stretch;
  799. @media (max-width: 968px) {
  800. flex-direction: column;
  801. }
  802. }
  803. .left-column,
  804. .right-column {
  805. flex: 1;
  806. min-width: 0; // 防止flex子项溢出
  807. }
  808. .full-width {
  809. max-width: 100%;
  810. }
  811. // 头部操作区
  812. .header-actions {
  813. display: flex;
  814. gap: $spacing-md;
  815. align-items: center;
  816. }
  817. // 复制文本按钮
  818. .btn-copy-text {
  819. display: inline-flex;
  820. align-items: center;
  821. gap: $spacing-xs;
  822. padding: $spacing-xs $spacing-md;
  823. border-radius: $radius-md;
  824. border: 1px solid $border-color;
  825. background: $bg-tertiary;
  826. color: $text-secondary;
  827. font-size: $font-size-sm;
  828. font-weight: 500;
  829. cursor: pointer;
  830. transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  831. white-space: nowrap;
  832. svg {
  833. width: 16px;
  834. height: 16px;
  835. stroke-width: 2;
  836. }
  837. &:hover {
  838. border-color: $primary-color;
  839. color: $primary-color;
  840. background: rgba($primary-color, 0.08);
  841. }
  842. &:active {
  843. transform: scale(0.97);
  844. }
  845. &.copied {
  846. border-color: #11998e;
  847. color: #38ef7d;
  848. background: rgba(#11998e, 0.1);
  849. }
  850. }
  851. // Markdown过渡动画
  852. .fade-enter-active,
  853. .fade-leave-active {
  854. transition: opacity 0.3s ease;
  855. }
  856. .fade-enter-from,
  857. .fade-leave-to {
  858. opacity: 0;
  859. }
  860. // 浮动返回按钮(文字样式 - 蓝色)
  861. .floating-back-btn {
  862. position: fixed;
  863. right: $spacing-xl;
  864. bottom: $spacing-xl;
  865. padding: $spacing-md $spacing-xl;
  866. border-radius: $radius-lg;
  867. background: #3b82f6; // 蓝色纯色
  868. color: white;
  869. display: flex;
  870. align-items: center;
  871. justify-content: center;
  872. font-size: $font-size-base;
  873. font-weight: 700; // 黑体
  874. text-decoration: none;
  875. box-shadow: 0 4px 16px rgba(59, 130, 246, 0.4); // 蓝色阴影
  876. z-index: 1030;
  877. transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  878. cursor: pointer;
  879. border: 1px solid rgba(255, 255, 255, 0.2);
  880. &:hover {
  881. transform: translateY(-2px);
  882. box-shadow: 0 6px 24px rgba(59, 130, 246, 0.5); // 更亮的蓝色阴影
  883. background: #2563eb; // hover时变深一点的蓝色
  884. border-color: rgba(255, 255, 255, 0.3);
  885. }
  886. &:active {
  887. transform: translateY(0);
  888. box-shadow: 0 2px 12px rgba(59, 130, 246, 0.3);
  889. }
  890. // 移动端适配
  891. @media (max-width: 768px) {
  892. padding: $spacing-sm $spacing-lg;
  893. font-size: $font-size-sm;
  894. right: $spacing-lg;
  895. bottom: $spacing-lg;
  896. }
  897. }
  898. // ==================== 移动端优化 ====================
  899. @media (max-width: 768px) {
  900. .share-page {
  901. padding: $spacing-lg $spacing-md;
  902. }
  903. // 卡片通用优化
  904. .card {
  905. padding: $spacing-md;
  906. }
  907. // 内容头部优化
  908. .text-content,
  909. .files-content {
  910. .content-header {
  911. flex-direction: column;
  912. align-items: flex-start;
  913. gap: $spacing-sm;
  914. margin-bottom: $spacing-md;
  915. h2 {
  916. font-size: $font-size-lg;
  917. }
  918. .header-actions {
  919. width: 100%;
  920. justify-content: space-between;
  921. }
  922. }
  923. }
  924. // 文件列表优化
  925. .file-item {
  926. flex-direction: column;
  927. align-items: stretch;
  928. gap: $spacing-sm;
  929. padding: $spacing-sm;
  930. .file-info {
  931. gap: $spacing-sm;
  932. }
  933. .file-icon {
  934. width: 36px;
  935. height: 36px;
  936. }
  937. .file-details {
  938. .file-name {
  939. font-size: $font-size-sm;
  940. }
  941. .file-size {
  942. font-size: $font-size-xs;
  943. }
  944. }
  945. .file-actions {
  946. justify-content: flex-end;
  947. gap: $spacing-xs;
  948. }
  949. }
  950. // 按钮优化
  951. .btn-action {
  952. padding: $spacing-xs $spacing-sm;
  953. font-size: $font-size-xs;
  954. svg {
  955. width: 16px;
  956. height: 16px;
  957. }
  958. span {
  959. // 在极小屏幕上隐藏文字,只显示图标
  960. @media (max-width: 480px) {
  961. display: none;
  962. }
  963. }
  964. }
  965. // 删除按钮移动端优化
  966. .btn-delete {
  967. padding: $spacing-xs $spacing-sm;
  968. font-size: $font-size-xs;
  969. svg {
  970. width: 16px;
  971. height: 16px;
  972. }
  973. span {
  974. // 在极小屏幕上隐藏文字,只显示图标
  975. @media (max-width: 480px) {
  976. display: none;
  977. }
  978. }
  979. }
  980. // 打包下载按钮优化
  981. .btn-download-all {
  982. padding: $spacing-sm $spacing-md;
  983. font-size: $font-size-base;
  984. }
  985. // 文本显示区优化
  986. .text-display {
  987. max-height: 400px;
  988. padding: $spacing-md;
  989. font-size: $font-size-sm;
  990. }
  991. // 内容信息优化
  992. .content-info {
  993. p {
  994. font-size: $font-size-xs;
  995. }
  996. }
  997. // 错误容器优化
  998. .error-container {
  999. h2 {
  1000. font-size: $font-size-xl;
  1001. }
  1002. p {
  1003. font-size: $font-size-sm;
  1004. }
  1005. }
  1006. // 加载容器优化
  1007. .loading-container {
  1008. padding: $spacing-xl;
  1009. .spinner {
  1010. width: 50px;
  1011. height: 50px;
  1012. border-width: 4px;
  1013. }
  1014. p {
  1015. font-size: $font-size-sm;
  1016. }
  1017. }
  1018. // 密码容器优化
  1019. .password-container {
  1020. padding: $spacing-lg;
  1021. max-width: 100%;
  1022. h2 {
  1023. font-size: $font-size-xl;
  1024. }
  1025. .password-input {
  1026. font-size: $font-size-base;
  1027. }
  1028. }
  1029. // 左右分栏在移动端的额外优化
  1030. .content-split {
  1031. gap: $spacing-md;
  1032. }
  1033. .left-column,
  1034. .right-column {
  1035. min-width: 0;
  1036. }
  1037. }
  1038. // 超小屏幕优化(<480px)
  1039. @media (max-width: 480px) {
  1040. .share-page {
  1041. padding: $spacing-md $spacing-sm;
  1042. }
  1043. .file-actions {
  1044. .btn-action {
  1045. padding: $spacing-xs;
  1046. min-width: 36px; // 确保按钮可点击区域足够
  1047. justify-content: center;
  1048. span {
  1049. display: none; // 只显示图标
  1050. }
  1051. }
  1052. }
  1053. .text-display {
  1054. font-size: $font-size-xs;
  1055. }
  1056. .content-header h2 {
  1057. font-size: $font-size-base;
  1058. }
  1059. }
  1060. </style>