@@ -34,7 +43,13 @@
import { ref, onMounted } from 'vue'
import { getRecycleFilesList } from './utils'
import type { responseRecycleFilesList } from './utils'
+import { post } from '@/utils/request'
+const ctxIndex = ref(-1)
+const optionsTop = ref(0)
+const optionsLeft = ref(0)
+const ctxTarget = ref()
+const isShowOptions = ref(false)
const recycleFilesList = ref
({
files: [
{
@@ -66,6 +81,66 @@ onMounted(async() => {
})
})
+const cancelShowPop = (e: MouseEvent) => {
+ isShowOptions.value = false
+ const target = e.target as HTMLElement
+ if (target.className !== ctxTarget.value.className && ctxTarget.value) {
+ ctxIndex.value = -1
+ ctxTarget.value = null
+ }
+}
+
+const deleteFiles = () => {
+ const fileIds = getFilesId()
+ post('/content/deleteFile', {
+ fileIds,
+ deleteType: 3
+ })
+ .then(async() => {
+ recycleFilesList.value = await getRecycleFilesList({
+ limit: 100,
+ backward: true,
+ offset: 0
+ })
+ })
+}
+const recoverFiles = () => {
+ const fileIds = getFilesId()
+ post('/content/recoverRecycleBinFile', {
+ fileIds
+ })
+ .then(async() => {
+ recycleFilesList.value = await getRecycleFilesList({
+ limit: 100,
+ backward: true,
+ offset: 0
+ })
+ })
+}
+
+const getFilesId = () => {
+ let fileId: string[] = []
+ recycleFilesList.value.files.forEach(file => {
+ if (file.isChoose) {
+ fileId.push(file.fileId)
+ }
+ })
+ if (ctxIndex.value !== -1) {
+ fileId.push(recycleFilesList.value.files[ctxIndex.value].fileId)
+ }
+ return fileId
+}
+
+const openRecycleOptions = (e: MouseEvent, index: number) => {
+ e.preventDefault()
+ isShowOptions.value = true
+ optionsLeft.value = e.clientX
+ optionsTop.value = e.clientY
+ if (!recycleFilesList.value.files[index].isChoose) {
+ ctxIndex.value = index
+ ctxTarget.value = e.target
+ }
+}
const chooseFile = (file: any) => {
file.isChoose = !file.isChoose
}
@@ -77,12 +152,40 @@ const chooseFile = (file: any) => {
height: 100%;
padding: 10px 10px;
+ .options {
+ position: absolute;
+ width: 120px;
+ height: 60px;
+ background-color: #fff;
+ box-shadow: 0 0 10px 1px rgb(214, 214, 214);
+ border-radius: 10px;
+ display: flex;
+ flex-direction: column;
+ justify-content: space-around;
+
+ button {
+ width: 100%;
+ height: 30px;
+ background-color: #fff;
+ border: none;
+ cursor: pointer;
+ text-align: center;
+ }
+ button:hover {
+ background-color: #f5f5f5;
+ }
+ button:last-child {
+ color: red;
+ }
+ }
+
.recycle-file-content {
display: flex;
justify-content: space-between;
align-items: center;
padding: 10px;
border-bottom: 1px solid #e5e5e5;
+ cursor: pointer;
.name-box {
width: 77%;