SCopperUpload2.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738
  1. const n = `<template>
  2. <div class="s-file-upload-common" :class="[\`is-\${listType}\`, { 'is-readonly': isReadonly }]">
  3. <div class="head" v-if="label">
  4. <div class="label">{{ label }}</div>
  5. </div>
  6. <!-- 同步 portal demo PictureUpload.vue:draggable 拖拽排序 + hover 工具条(预览/下载/删除/拖拽) -->
  7. <draggable
  8. v-model="fileList"
  9. @start="dragStart"
  10. @end="dragEnd"
  11. handle=".move"
  12. :class="isCard ? 'img-list-wrap' : 'file-list-wrap'"
  13. :style="picStyle"
  14. :disabled="!canDrag"
  15. item-key="uid"
  16. >
  17. <template #item="{ element: item, index }">
  18. <div
  19. :key="item.uid || index"
  20. :class="isCard ? 'img-item-wrap' : 'file-row'"
  21. @mouseover="handleMouseEnter(item, index)"
  22. @mouseleave="handleMouseLeave(item, index)"
  23. >
  24. <!-- card:图片展示原图,其他类型展示文件类型 -->
  25. <template v-if="isCard">
  26. <img
  27. v-if="isImageItem(item)"
  28. class="upload-img-wrap"
  29. :src="fileUrl(item)"
  30. :alt="fileName(item)"
  31. />
  32. <div v-else class="file-thumb">
  33. <component :is="fileIcon(item)" class="file-thumb-icon" />
  34. <span class="file-thumb-ext">{{ fileExt(item) || 'FILE' }}</span>
  35. </div>
  36. <div v-show="item.showTool" class="tool-wrap">
  37. <div class="left">
  38. <EyeOutlined
  39. v-if="showPreview"
  40. class="tool-icon-wrap"
  41. :title="$l('预览')"
  42. @click.stop="preview(item, index)"
  43. />
  44. <DownloadOutlined
  45. v-if="showDownload"
  46. class="tool-icon-wrap"
  47. :title="$l('下载')"
  48. @click.stop="download(item)"
  49. />
  50. <DeleteOutlined
  51. v-if="canRemove"
  52. class="tool-icon-wrap"
  53. :title="$l('删除')"
  54. @click.stop="handleRemove(index, item)"
  55. />
  56. </div>
  57. <div class="right move">
  58. <DragOutlined v-if="canDrag" />
  59. </div>
  60. </div>
  61. </template>
  62. <!-- list:文件类型 + 文件名称 + 预览/下载/删除 -->
  63. <template v-else>
  64. <component :is="fileIcon(item)" class="file-row-icon" />
  65. <span class="file-row-ext">{{ fileExt(item) || 'FILE' }}</span>
  66. <span class="file-row-name" :title="fileName(item)">{{ fileName(item) }}</span>
  67. <span class="file-row-actions">
  68. <EyeOutlined
  69. v-if="showPreview"
  70. class="file-action"
  71. :title="$l('预览')"
  72. @click.stop="preview(item)"
  73. />
  74. <DownloadOutlined
  75. v-if="showDownload"
  76. class="file-action"
  77. :title="$l('下载')"
  78. @click.stop="download(item)"
  79. />
  80. <DeleteOutlined
  81. v-if="canRemove"
  82. class="file-action"
  83. :title="$l('删除')"
  84. @click.stop="handleRemove(index, item)"
  85. />
  86. <DragOutlined v-if="canDrag" class="file-action move" :title="$l('拖动排序')" />
  87. </span>
  88. </template>
  89. </div>
  90. </template>
  91. <template #footer>
  92. <div
  93. v-if="fileList.length < maxFileCount && isAdd && !isReadonly"
  94. :class="isCard ? 'img-add-wrap' : 'file-add-wrap'"
  95. @click="addPic"
  96. >
  97. <PlusOutlined :class="isCard ? 'plus-icon' : 'plus-icon plus-icon-small'" />
  98. <span v-if="!isCard" class="file-add-text">{{ $l('上传文件') }}</span>
  99. <input
  100. :accept="accept || 'image/*'"
  101. :multiple="true"
  102. type="file"
  103. :disabled="disabled"
  104. ref="fileInput"
  105. style="display: none"
  106. @change="fileChange"
  107. />
  108. </div>
  109. </template>
  110. </draggable>
  111. <s-file-preview v-model:value="previewVisible" :list="fileList" :active="active" />
  112. <!-- 选图后逐张裁剪:只取裁剪结果,上传仍走 batchFileSaveApi,保持原通道与数据结构 -->
  113. <CropperModal ref="cropperRef" @cropper-ok="onCropperOk" @cropper-no="onCropperNo" />
  114. </div>
  115. </template>
  116. <script setup>
  117. import { ref, computed, watch } from 'vue'
  118. import {
  119. EyeOutlined,
  120. DeleteOutlined,
  121. DragOutlined,
  122. PlusOutlined,
  123. DownloadOutlined,
  124. FileOutlined,
  125. FilePdfOutlined,
  126. FileWordOutlined,
  127. FileExcelOutlined,
  128. FilePptOutlined,
  129. FileZipOutlined,
  130. FileTextOutlined,
  131. FileMarkdownOutlined,
  132. FileImageOutlined,
  133. VideoCameraOutlined,
  134. AudioOutlined
  135. } from '@ant-design/icons-vue'
  136. import draggable from 'vuedraggable'
  137. import SFilePreview from './SFilePreview.vue'
  138. import CropperModal from './CropperModal.vue'
  139. import { batchFileSaveApi, deleteFileApi } from '../../api/upload'
  140. const emit = defineEmits(['change', 'handChange', 'dragChange', 'download'])
  141. const props = defineProps({
  142. /**
  143. * 文件列表(同 PictureUpload 的 data)
  144. * @list
  145. */
  146. list: {
  147. type: Array,
  148. default: () => {
  149. return []
  150. }
  151. },
  152. /**
  153. * 标题
  154. * @label
  155. */
  156. label: {
  157. type: String,
  158. default: ''
  159. },
  160. /**
  161. * 只读(同 PictureUpload 的 disabled)
  162. * @readonly
  163. */
  164. readonly: {
  165. type: Boolean,
  166. default: false
  167. },
  168. /**
  169. * 详情模式:只读展示,不显示新增入口、不可删除拖拽,仅保留预览与下载
  170. * @detailMode
  171. */
  172. detailMode: {
  173. type: Boolean,
  174. default: false
  175. },
  176. /**
  177. * 是否显示新增(isAdd=false 等价 PictureUpload 的 ishiddenAdd=true:隐藏添加框且不可删除/拖拽)
  178. * @isAdd
  179. */
  180. isAdd: {
  181. type: Boolean,
  182. default: true
  183. },
  184. /**
  185. * 文件类型
  186. * @accept
  187. */
  188. accept: {
  189. type: String,
  190. default: 'image/*'
  191. },
  192. /**
  193. * 裁剪比例:1 = 1:1(头像);'16:9' 或 16/9 = 封面;0 = 自由裁剪
  194. * @aspectRatio
  195. */
  196. aspectRatio: {
  197. type: [Number, String],
  198. default: 1
  199. },
  200. /**
  201. * 选图后是否先裁剪(false 时原图直传,等同改造前的行为)
  202. * @crop
  203. */
  204. crop: {
  205. type: Boolean,
  206. default: true
  207. },
  208. /**
  209. * 展示形态:card 卡片(图片显示原图,其他类型显示文件类型);list 列表(文件类型 + 文件名 + 操作按钮)
  210. * @listType
  211. */
  212. listType: {
  213. type: String,
  214. default: 'card'
  215. },
  216. /**
  217. * 是否显示预览按钮
  218. * @showPreview
  219. */
  220. showPreview: {
  221. type: Boolean,
  222. default: true
  223. },
  224. /**
  225. * 是否显示下载按钮
  226. * @showDownload
  227. */
  228. showDownload: {
  229. type: Boolean,
  230. default: true
  231. },
  232. /**
  233. * 是否显示删除按钮(仍需 isAdd 且非只读)
  234. * @showRemove
  235. */
  236. showRemove: {
  237. type: Boolean,
  238. default: true
  239. },
  240. // 最多可上传数量(同 PictureUpload 的 maxSize)
  241. maxFileCount: {
  242. type: Number,
  243. default: 5
  244. },
  245. // 单文件大小上限,单位 KB(同 PictureUpload 的 fileSize)
  246. fileSize: {
  247. type: Number,
  248. default: 200
  249. },
  250. // FTP 上传目录(同 PictureUpload 的 path),不传时回退 businessTableName
  251. path: {
  252. type: String,
  253. default: undefined
  254. },
  255. // 是否隐藏拖拽排序图标(同 PictureUpload 的 noDrag)
  256. noDrag: {
  257. type: Boolean,
  258. default: false
  259. },
  260. // 图片列表容器样式(同 PictureUpload 的 picStyle)
  261. picStyle: {
  262. type: Object,
  263. default: () => {}
  264. },
  265. // 兼容保留:不传 path 时作为 FTP 目录名
  266. businessTableName: {
  267. type: String,
  268. default: 'sapit-ui-plus-components-upload'
  269. },
  270. // 业务主键,随上传一起提交用于关联业务数据
  271. businessKey: {
  272. type: String,
  273. default: undefined
  274. },
  275. // 兼容保留(PictureUpload 无上传列表概念,仅声明避免外部传参告警)
  276. showUploadList: {
  277. type: Boolean,
  278. default: true
  279. },
  280. // 已废弃:由 showRemove 取代,仅保留声明避免外部传参告警
  281. showRemoveIcon: {
  282. type: Boolean,
  283. default: false
  284. }
  285. })
  286. const disabled = computed(() => props.readonly || props.detailMode)
  287. const isReadonly = computed(() => props.readonly || props.detailMode)
  288. const isCard = computed(() => props.listType !== 'list')
  289. const canDrag = computed(() => props.isAdd && !isReadonly.value && !props.noDrag)
  290. const canRemove = computed(() => props.isAdd && !isReadonly.value && props.showRemove)
  291. const ftpPath = () => props.path || props.businessTableName
  292. // --- 文件类型识别(用于 card 的原图/图标切换、list 的图标与扩展名) ---
  293. const IMAGE_EXTS = ['png', 'jpg', 'jpeg', 'gif', 'webp', 'bmp', 'svg', 'ico', 'avif', 'tif', 'tiff']
  294. const FILE_ICON_MAP = {
  295. pdf: FilePdfOutlined,
  296. doc: FileWordOutlined,
  297. docx: FileWordOutlined,
  298. wps: FileWordOutlined,
  299. rtf: FileWordOutlined,
  300. xls: FileExcelOutlined,
  301. xlsx: FileExcelOutlined,
  302. csv: FileExcelOutlined,
  303. ppt: FilePptOutlined,
  304. pptx: FilePptOutlined,
  305. zip: FileZipOutlined,
  306. rar: FileZipOutlined,
  307. '7z': FileZipOutlined,
  308. gz: FileZipOutlined,
  309. tar: FileZipOutlined,
  310. txt: FileTextOutlined,
  311. log: FileTextOutlined,
  312. json: FileTextOutlined,
  313. xml: FileTextOutlined,
  314. md: FileMarkdownOutlined,
  315. png: FileImageOutlined,
  316. jpg: FileImageOutlined,
  317. jpeg: FileImageOutlined,
  318. gif: FileImageOutlined,
  319. webp: FileImageOutlined,
  320. bmp: FileImageOutlined,
  321. svg: FileImageOutlined,
  322. ico: FileImageOutlined,
  323. mp4: VideoCameraOutlined,
  324. mov: VideoCameraOutlined,
  325. avi: VideoCameraOutlined,
  326. mkv: VideoCameraOutlined,
  327. webm: VideoCameraOutlined,
  328. mp3: AudioOutlined,
  329. wav: AudioOutlined,
  330. flac: AudioOutlined,
  331. aac: AudioOutlined,
  332. m4a: AudioOutlined
  333. }
  334. const fileUrl = (item = {}) => item.imageUrl || item.url || item.uid || ''
  335. // 文件名优先取上传时记录的原始名,回显数据缺失时按 URL 末段兜底
  336. const nameFromUrl = (url = '') => {
  337. const clean = String(url).split('?')[0].split('#')[0]
  338. const base = clean.substring(clean.lastIndexOf('/') + 1)
  339. try {
  340. return decodeURIComponent(base)
  341. } catch (e) {
  342. return base
  343. }
  344. }
  345. const fileName = (item = {}) => item.name || nameFromUrl(fileUrl(item)) || window.$l('未命名文件')
  346. const fileExt = (item = {}) => {
  347. const name = fileName(item)
  348. const i = name.lastIndexOf('.')
  349. return i > -1 ? name.slice(i + 1).toLowerCase() : ''
  350. }
  351. const isImageItem = (item = {}) => {
  352. const type = item.type || item.mimeType || ''
  353. if (type) return String(type).indexOf('image/') === 0
  354. return IMAGE_EXTS.includes(fileExt(item))
  355. }
  356. const fileIcon = (item = {}) => FILE_ICON_MAP[fileExt(item)] || FileOutlined
  357. // 文件列表:项结构同步 PictureUpload(sort/imageUrl),并兼容基座业务契约(uid/url 供提交与回显预览)
  358. const fileList = ref([])
  359. const previewVisible = ref(false)
  360. const active = ref(0)
  361. // 监听(同 PictureUpload:immediate + deep,直接替换引用)
  362. watch(
  363. () => props.list,
  364. (newVal) => {
  365. fileList.value = newVal || []
  366. },
  367. { immediate: true, deep: true }
  368. )
  369. const emitChange = () => {
  370. emit('change', fileList.value)
  371. emit('handChange', fileList.value)
  372. }
  373. // 拖拽(同 PictureUpload:结束后按新顺序写回 sort)
  374. const dragStart = (evt) => {}
  375. const dragEnd = (evt) => {
  376. if (fileList.value && fileList.value.length > 1) {
  377. fileList.value.forEach((f, i) => {
  378. f.sort = i
  379. })
  380. }
  381. emit('dragChange', fileList.value)
  382. emitChange()
  383. }
  384. const addPic = () => {
  385. if (fileInput.value) fileInput.value.click()
  386. }
  387. const fileInput = ref(null)
  388. const cropperRef = ref(null)
  389. // 逐张裁剪时,同一时刻只有一个待决的 Promise,保存/取消都通过它回传
  390. let cropSettle = null
  391. const openCropper = (file, index, total) => {
  392. const url = URL.createObjectURL(file)
  393. return new Promise((resolve) => {
  394. cropSettle = (blob) => {
  395. cropSettle = null
  396. URL.revokeObjectURL(url)
  397. resolve(blob)
  398. }
  399. cropperRef.value.edit({
  400. img: url,
  401. aspectRatio: props.aspectRatio,
  402. title: total > 1 ? \`\${window.$l('图片裁剪')}(\${index}/\${total})\` : window.$l('图片裁剪'),
  403. // png 保留 png(可能有透明背景),其余走 jpeg 控制体积
  404. outputType: file.type === 'image/png' ? 'png' : 'jpeg',
  405. file
  406. })
  407. })
  408. }
  409. const onCropperOk = (payload) => {
  410. if (cropSettle) cropSettle((payload && payload.blob) || null)
  411. }
  412. const onCropperNo = () => {
  413. if (cropSettle) cropSettle(null)
  414. }
  415. // 裁剪结果 Blob → File:扩展名跟随实际输出类型,避免 .jpg 里装 png 内容
  416. const blobToFile = (blob, origin) => {
  417. const type = blob.type || origin.type || 'image/png'
  418. const ext = type === 'image/png' ? 'png' : 'jpg'
  419. const base = (origin.name || 'image').replace(/\\.[^.]+$/, '')
  420. return new File([blob], \`\${base}.\${ext}\`, { type, lastModified: Date.now() })
  421. }
  422. const fileChange = async (e) => {
  423. const files = Array.from((e && e.target && e.target.files) || [])
  424. // 清空 input value,保证连续选择同一文件也能触发 change
  425. if (fileInput.value) fileInput.value.value = ''
  426. if (!files.length) return
  427. if (fileList.value.length + files.length > props.maxFileCount) {
  428. window.$message.warning(
  429. window.$l('上传图片,最多可上传') + props.maxFileCount + window.$l('张')
  430. )
  431. return
  432. }
  433. // 需要裁剪时逐张弹窗;用户取消的那张直接跳过,不影响同批其余图片
  434. let todo = files
  435. if (props.crop) {
  436. todo = []
  437. for (let i = 0; i < files.length; i++) {
  438. const blob = await openCropper(files[i], i + 1, files.length)
  439. if (!blob) continue
  440. const file = blobToFile(blob, files[i])
  441. // 裁剪后体积会变化,大小校验必须放在裁剪之后
  442. if (file.size > props.fileSize * 1024) {
  443. window.$message.warning(\`\${window.$l('上传图片大小不能大于')}\${props.fileSize}KB\`)
  444. continue
  445. }
  446. todo.push(file)
  447. }
  448. if (!todo.length) return
  449. } else {
  450. for (let i = 0; i < files.length; i++) {
  451. if (files[i].size > props.fileSize * 1024) {
  452. window.$message.warning(\`\${window.$l('上传图片大小不能大于')}\${props.fileSize}KB\`)
  453. return
  454. }
  455. }
  456. }
  457. batchFileSaveApi(ftpPath(), todo).then((res) => {
  458. if (res && res.length) {
  459. for (let i = 0; i < res.length; i++) {
  460. // uid/url 兼容基座业务契约(uid 供提交、url 供旧回显数据预览)
  461. // name 记录原始文件名,供 list 形态展示
  462. fileList.value.push({
  463. sort: i,
  464. name: (todo[i] && todo[i].name) || nameFromUrl(res[i].imageUrl),
  465. imageUrl: res[i].imageUrl,
  466. uid: res[i].imageUrl,
  467. url: res[i].imageUrl
  468. })
  469. }
  470. }
  471. emitChange()
  472. })
  473. }
  474. const handleMouseEnter = (record) => {
  475. // hover 工具条只用于 card 形态,list 形态按钮常显
  476. if (!isCard.value) return
  477. record.showTool = true
  478. }
  479. const handleMouseLeave = (record) => {
  480. if (!isCard.value) return
  481. record.showTool = false
  482. }
  483. const handleRemove = (indexToRemove, record) => {
  484. fileList.value.splice(indexToRemove, 1)
  485. // 同步 PictureUpload:删除时同步删除 FTP 文件(imageUrl 为完整 URL)
  486. deleteFileApi(ftpPath(), record.imageUrl || record.uid)
  487. emitChange()
  488. }
  489. // 预览:图片走弹层大图,其他类型交给浏览器新窗口打开(pdf/txt 等可直接预览)
  490. const preview = (record = {}) => {
  491. const url = fileUrl(record)
  492. if (!url) return
  493. if (!isImageItem(record)) {
  494. window.open(url, '_blank', 'noopener')
  495. return
  496. }
  497. // 弹窗按列表下标定位,引用比对失败时按 URL 兜底,避免打开到错误的图
  498. let idx = fileList.value.findIndex((i) => i === record)
  499. if (idx < 0) idx = fileList.value.findIndex((i) => fileUrl(i) === url)
  500. active.value = idx > -1 ? idx : 0
  501. previewVisible.value = true
  502. }
  503. // 下载:先取 blob 保证文件名生效;跨域不可读时退回新窗口打开
  504. const download = async (record = {}) => {
  505. const url = fileUrl(record)
  506. if (!url) return
  507. emit('download', record)
  508. const name = fileName(record)
  509. const saveByHref = (href, useBlobUrl) => {
  510. const a = document.createElement('a')
  511. a.href = href
  512. a.download = name
  513. if (!useBlobUrl) {
  514. a.target = '_blank'
  515. a.rel = 'noopener'
  516. }
  517. document.body.appendChild(a)
  518. a.click()
  519. document.body.removeChild(a)
  520. }
  521. try {
  522. const res = await fetch(url)
  523. if (!res.ok) throw new Error('fetch failed')
  524. const blob = await res.blob()
  525. const blobUrl = URL.createObjectURL(blob)
  526. saveByHref(blobUrl, true)
  527. setTimeout(() => URL.revokeObjectURL(blobUrl), 1000)
  528. } catch (err) {
  529. saveByHref(url, false)
  530. }
  531. }
  532. <\/script>
  533. <style lang="less" scoped>
  534. .s-file-upload-common {
  535. .head {
  536. display: flex;
  537. justify-content: flex-start;
  538. align-items: center;
  539. margin: 10px;
  540. .label {
  541. font-weight: 500;
  542. font-size: 15px;
  543. margin-right: 30px;
  544. }
  545. }
  546. }
  547. .plus-icon {
  548. font-size: 30px;
  549. color: var(--s-border-color-base);
  550. }
  551. .plus-icon-small {
  552. font-size: 16px;
  553. }
  554. .img-list-wrap {
  555. padding: 10px;
  556. display: flex;
  557. justify-content: flex-start;
  558. align-items: center;
  559. row-gap: 10px;
  560. column-gap: 10px;
  561. flex-wrap: wrap;
  562. .img-item-wrap {
  563. position: relative;
  564. width: 100px;
  565. height: 100px;
  566. border-radius: 8px;
  567. border: 1px solid var(--s-border-color-base);
  568. padding: 5px;
  569. box-sizing: border-box;
  570. .upload-img-wrap {
  571. width: 90px;
  572. height: 90px;
  573. border-radius: 8px;
  574. object-fit: cover;
  575. }
  576. .file-thumb {
  577. width: 100px;
  578. height: 100px;
  579. border-radius: 8px;
  580. box-sizing: border-box;
  581. display: flex;
  582. flex-direction: column;
  583. justify-content: center;
  584. align-items: center;
  585. gap: 6px;
  586. background: var(--s-color-bg);
  587. color: var(--s-color);
  588. .file-thumb-icon {
  589. font-size: 32px;
  590. }
  591. .file-thumb-ext {
  592. font-size: 12px;
  593. text-transform: uppercase;
  594. color: var(--s-text-color-secondary);
  595. }
  596. }
  597. }
  598. .img-add-wrap {
  599. cursor: pointer;
  600. width: 100px;
  601. height: 100px;
  602. display: flex;
  603. justify-content: center;
  604. align-items: center;
  605. border: 1px dashed var(--s-border-color-base);
  606. border-radius: 8px;
  607. &:hover {
  608. border-color: var(--s-color);
  609. }
  610. }
  611. .tool-wrap {
  612. width: 100%;
  613. height: 30px;
  614. line-height: 30px;
  615. cursor: pointer;
  616. padding: 0 10px;
  617. box-sizing: border-box;
  618. background-color: var(--s-mask-color);
  619. color: var(--s-text-color-inverse);
  620. transition: 0.45s;
  621. position: relative;
  622. bottom: 2rem;
  623. left: 0;
  624. z-index: 2;
  625. display: flex;
  626. justify-content: space-between;
  627. align-items: center;
  628. border-bottom-left-radius: 10px;
  629. border-bottom-right-radius: 10px;
  630. .left {
  631. display: flex;
  632. align-items: center;
  633. gap: 8px;
  634. }
  635. }
  636. }
  637. /* list 形态:文件类型 + 文件名称 + 预览/下载/删除 */
  638. .file-list-wrap {
  639. padding: 10px;
  640. display: flex;
  641. flex-direction: column;
  642. row-gap: 8px;
  643. .file-row {
  644. display: flex;
  645. justify-content: space-between;
  646. align-items: center;
  647. column-gap: 10px;
  648. height: 40px;
  649. padding: 0 12px;
  650. box-sizing: border-box;
  651. border: 1px solid var(--s-border-color-base);
  652. border-radius: 6px;
  653. transition: background-color 0.2s;
  654. &:hover {
  655. background: var(--s-bg-color-hover);
  656. }
  657. .file-row-icon {
  658. font-size: 18px;
  659. color: var(--s-color);
  660. }
  661. .file-row-ext {
  662. width: 56px;
  663. height: 20px;
  664. font-size: 12px;
  665. display: flex;
  666. justify-content: flex-start;
  667. align-items: center;
  668. text-transform: uppercase;
  669. color: var(--s-text-color-secondary);
  670. overflow: hidden;
  671. text-overflow: ellipsis;
  672. white-space: nowrap;
  673. }
  674. .file-row-name {
  675. height: 20px;
  676. display: flex;
  677. justify-content: flex-start;
  678. align-items: center;
  679. flex: 1;
  680. color: var(--s-text-color);
  681. overflow: hidden;
  682. text-overflow: ellipsis;
  683. white-space: nowrap;
  684. word-break: break-all;
  685. }
  686. .file-row-actions {
  687. height: 20px;
  688. display: flex;
  689. align-items: center;
  690. column-gap: 12px;
  691. .file-action {
  692. font-size: 16px;
  693. color: var(--s-text-color-secondary);
  694. cursor: pointer;
  695. transition: color 0.2s;
  696. &:hover {
  697. color: var(--s-color);
  698. }
  699. &.move {
  700. cursor: move;
  701. }
  702. }
  703. }
  704. }
  705. .file-add-wrap {
  706. display: flex;
  707. align-items: center;
  708. justify-content: center;
  709. column-gap: 6px;
  710. height: 40px;
  711. cursor: pointer;
  712. border: 1px dashed var(--s-border-color-base);
  713. border-radius: 6px;
  714. color: var(--s-text-color-secondary);
  715. transition: 0.2s;
  716. &:hover {
  717. color: var(--s-color);
  718. border-color: var(--s-color);
  719. }
  720. .file-add-text {
  721. font-size: 13px;
  722. }
  723. }
  724. }
  725. .tool-icon-wrap {
  726. cursor: pointer;
  727. }
  728. </style>
  729. `;
  730. export {
  731. n as default
  732. };