|
|
@@ -0,0 +1,667 @@
|
|
|
+<template>
|
|
|
+ <!-- 右键列表 -->
|
|
|
+ <transition name="el-fade-in-linear">
|
|
|
+ <!-- 在某个文件上右键 -->
|
|
|
+ <ul
|
|
|
+ class="right-menu-list"
|
|
|
+ id="rightMenuList"
|
|
|
+ v-show="visible"
|
|
|
+ v-if="selectedFile !== undefined"
|
|
|
+ :style="`top: ${rightMenu.top};right: ${rightMenu.right};bottom: ${rightMenu.bottom};left: ${rightMenu.left};`"
|
|
|
+ >
|
|
|
+ <li
|
|
|
+ class="right-menu-item"
|
|
|
+ @click="fileHelper.handleFileNameClick(selectedFile, 0, [selectedFile])"
|
|
|
+ v-if="seeBtnShow"
|
|
|
+ >
|
|
|
+ <i class="el-icon-view"></i> 查看
|
|
|
+ </li>
|
|
|
+ <li class="right-menu-item" @click="handleDeleteFileBtnClick(selectedFile)" v-if="deleteBtnShow">
|
|
|
+ <i class="el-icon-delete"></i> 删除
|
|
|
+ </li>
|
|
|
+ <li class="right-menu-item" @click="handleRestoreFileBtnClick(selectedFile)" v-if="restoreBtnShow">
|
|
|
+ <i class="el-icon-refresh-left"></i> 还原
|
|
|
+ </li>
|
|
|
+ <li class="right-menu-item" @click="handleCopyFileBtnClick(selectedFile)" v-if="copyBtnShow">
|
|
|
+ <i class="el-icon-copy-document"></i> 复制到
|
|
|
+ </li>
|
|
|
+ <li class="right-menu-item" @click="handleMoveFileBtnClick(selectedFile)" v-if="moveBtnShow">
|
|
|
+ <i class="el-icon-s-promotion"></i> 移动
|
|
|
+ </li>
|
|
|
+ <li class="right-menu-item" @click="handleAddMyFileList(selectedFile)" v-if="addMyFileListBtnShow">
|
|
|
+ <i class="el-icon-edit-outline"></i> 添加至我的云盘
|
|
|
+ </li>
|
|
|
+
|
|
|
+ <li class="right-menu-item" @click="handleEnterpriseDisk(selectedFile)" v-if="addEnterpriseDiskBtnShow">
|
|
|
+ <i class="el-icon-edit-outline"></i> 添加至企业云盘
|
|
|
+ </li>
|
|
|
+
|
|
|
+ <li class="right-menu-item" @click="handleRenameFileBtnClick(selectedFile)" v-if="renameBtnShow">
|
|
|
+ <i class="el-icon-edit-outline"></i> 重命名
|
|
|
+ </li>
|
|
|
+ <li class="right-menu-item" @click="handleShareFileBtnClick(selectedFile)" v-if="shareBtnShow">
|
|
|
+ <i class="el-icon-share"></i> 分享
|
|
|
+ </li>
|
|
|
+ <li class="right-menu-item" @click="visible = false" v-if="downloadBtnShow">
|
|
|
+ <a
|
|
|
+ @click="geta1(fileHelper.getDownloadFilePath(selectedFile))"
|
|
|
+ id="aaaa"
|
|
|
+ target="_blank"
|
|
|
+ style="display: block; color: inherit"
|
|
|
+ :href="fileHelper.getDownloadFilePath(selectedFile)"
|
|
|
+ :download="selectedFile.fileName + '.' + selectedFile.extendName"
|
|
|
+ >
|
|
|
+ <i class="el-icon-download"></i> 下载
|
|
|
+ </a>
|
|
|
+ </li>
|
|
|
+ <!-- 0-解压到当前文件夹, 1-自动创建该文件名目录,并解压到目录里, 3-手动选择解压目录 -->
|
|
|
+ <li class="right-menu-item unzip-menu-item" v-if="unzipBtnShow">
|
|
|
+ <i class="el-icon-files"></i> 解压缩
|
|
|
+ <i class="el-icon-arrow-right"></i>
|
|
|
+ <ul
|
|
|
+ class="unzip-list"
|
|
|
+ :style="`top: ${unzipMenu.top};bottom: ${unzipMenu.bottom};left: ${unzipMenu.left};right: ${unzipMenu.right};`"
|
|
|
+ >
|
|
|
+ <li class="unzip-item" @click="handleUnzipFileBtnClick(selectedFile, 0)">
|
|
|
+ <i class="el-icon-files"></i> 解压到当前文件夹
|
|
|
+ </li>
|
|
|
+ <li
|
|
|
+ class="unzip-item"
|
|
|
+ @click="handleUnzipFileBtnClick(selectedFile, 1)"
|
|
|
+ :title="`解压到"${selectedFile.fileName}"`"
|
|
|
+ >
|
|
|
+ <i class="el-icon-files"></i> 解压到"{{ selectedFile.fileName }}"
|
|
|
+ </li>
|
|
|
+ <li class="unzip-item" @click="handleUnzipFileBtnClick(selectedFile, 2)">
|
|
|
+ <i class="el-icon-files"></i> 解压到目标文件夹
|
|
|
+ </li>
|
|
|
+ </ul>
|
|
|
+ </li>
|
|
|
+ <li
|
|
|
+ class="right-menu-item"
|
|
|
+ @click="fileHelper.copyShareLink(selectedFile.shareBatchNum, selectedFile.extractionCode)"
|
|
|
+ v-if="copyLinkBtnShow"
|
|
|
+ >
|
|
|
+ <i class="el-icon-edit"></i> 复制链接
|
|
|
+ </li>
|
|
|
+ <li class="right-menu-item" @click="handleShowDetailInfo(selectedFile)" v-if="detailInfoBtnShow">
|
|
|
+ <i class="el-icon-document"></i> 文件详情
|
|
|
+ </li>
|
|
|
+ </ul>
|
|
|
+ <!-- 在空白处右键,右键列表展示新建文件夹、新建文件等操作按钮 -->
|
|
|
+ <ul
|
|
|
+ class="right-menu-list add"
|
|
|
+ id="rightMenuList"
|
|
|
+ v-show="visible"
|
|
|
+ v-else
|
|
|
+ :style="`top: ${rightMenu.top};right: ${rightMenu.right};bottom: ${rightMenu.bottom};left: ${rightMenu.left};`"
|
|
|
+ >
|
|
|
+ <li class="right-menu-item" @click="callback('confirm')"><i class="el-icon-refresh"></i> 刷新</li>
|
|
|
+ <template v-if="fileType === 0">
|
|
|
+ <a-divider />
|
|
|
+ <li class="right-menu-item" @click="handleClickAddFolderBtn"><i class="el-icon-folder-add"></i> 新建文件夹</li>
|
|
|
+ <!-- 图片路径需要修改 -->
|
|
|
+ <li class="right-menu-item" @click="handleCreateFile('docx')"><img :src="wordImg" />新建 Word 文档</li>
|
|
|
+ <li class="right-menu-item" @click="handleCreateFile('xlsx')"><img :src="excelImg" />新建 Excel 工作表</li>
|
|
|
+ <li class="right-menu-item" @click="handleCreateFile('pptx')"><img :src="pptImg" />新建 PPT 演示文稿</li>
|
|
|
+ <a-divider />
|
|
|
+ <li class="right-menu-item" @click="handleUploadFileBtnClick(1)"><i class="el-icon-upload2"></i> 上传文件</li>
|
|
|
+ <li class="right-menu-item" @click="handleUploadFileBtnClick(2)">
|
|
|
+ <i class="el-icon-folder-opened"></i> 上传文件夹
|
|
|
+ </li>
|
|
|
+ <li class="right-menu-item" @click="handleUploadFileBtnClick(3)"><i class="el-icon-thumb"></i> 拖拽上传</li>
|
|
|
+ </template>
|
|
|
+ </ul>
|
|
|
+ </transition>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script setup>
|
|
|
+ import { ref, computed, watch, onMounted, getCurrentInstance } from 'vue'
|
|
|
+ import { useRouter, useRoute } from 'vue-router'
|
|
|
+ import { message as antMessage } from 'ant-design-vue' // 重命名以避免与 window.message 冲突
|
|
|
+ import { officeFileType, fileSuffixCodeModeMap, markdownFileType } from '@/libs/map.js'
|
|
|
+ import { addMyFileListApi, addEnterpriseDiskApi } from '@/api/myResource/file'
|
|
|
+ import axios from 'axios' // 如果需要
|
|
|
+ import fileOperationPlugins from '@/libs/fileOperationPlugins.js'
|
|
|
+ import globalFunction from '@/libs/globalFunction/index.js'
|
|
|
+ import appConfig from '@/config/index.js'
|
|
|
+
|
|
|
+ // 从插件或模块中获取方法
|
|
|
+ const { openDialog } = fileOperationPlugins
|
|
|
+ const { openBox } = fileOperationPlugins
|
|
|
+ const fileHelper = globalFunction.file // $file
|
|
|
+
|
|
|
+ // $common 的处理: common.js 未找到,暂时保留 proxy.$common
|
|
|
+ // 如果 $common 是必须的,你需要找到它的定义并导入
|
|
|
+ const { proxy } = getCurrentInstance() // 保留 proxy 以便访问 $common (如果确实需要且未找到其来源)
|
|
|
+
|
|
|
+ const props = defineProps({
|
|
|
+ selectedFile: Object,
|
|
|
+ domEvent: Object,
|
|
|
+ serviceEl: Object,
|
|
|
+ callType: String,
|
|
|
+ callback: Function
|
|
|
+ })
|
|
|
+
|
|
|
+ const router = useRouter()
|
|
|
+ const route = useRoute()
|
|
|
+
|
|
|
+ const visible = ref(false)
|
|
|
+
|
|
|
+ const rightMenu = ref({
|
|
|
+ top: 0,
|
|
|
+ left: 0,
|
|
|
+ bottom: 'auto',
|
|
|
+ right: 'auto'
|
|
|
+ })
|
|
|
+
|
|
|
+ const unzipMenu = ref({
|
|
|
+ top: 0,
|
|
|
+ bottom: 'auto',
|
|
|
+ left: '126px',
|
|
|
+ right: 'auto'
|
|
|
+ })
|
|
|
+
|
|
|
+ // 图片资源: 请将路径修改为实际项目中的正确路径
|
|
|
+ // 例如: import wordIcon from '@/assets/images/file_word.svg'; const wordImg = ref(wordIcon);
|
|
|
+ // 或者如果图片在 public 目录: const wordImg = ref('/images/file_word.svg');
|
|
|
+ const dirImg = ref('/img/file/dir.png') // 示例: 假设在 public/img/file/dir.png
|
|
|
+ const wordImg = ref('/img/file/file_word.svg') // 示例: 假设在 public/img/file/file_word.svg
|
|
|
+ const excelImg = ref('/img/file/file_excel.svg') // 示例: 假设在 public/img/file/file_excel.svg
|
|
|
+ const pptImg = ref('/img/file/file_ppt.svg') // 示例: 假设在 public/img/file/file_ppt.svg
|
|
|
+
|
|
|
+ const newname = ref('')
|
|
|
+
|
|
|
+ // 计算属性
|
|
|
+ const routeName = computed(() => route.name)
|
|
|
+ const fileType = computed(() => (route.query.fileType ? Number(route.query.fileType) : 0))
|
|
|
+ const filePath = computed(() => route.query.filePath)
|
|
|
+
|
|
|
+ const seeBtnShow = computed(() => {
|
|
|
+ const PIC = ['png', 'jpg', 'jpeg', 'gif', 'svg', 'webp']
|
|
|
+ return props.selectedFile && fileType.value !== 6 && PIC.includes(props.selectedFile.extendName?.toLowerCase())
|
|
|
+ })
|
|
|
+
|
|
|
+ const deleteBtnShow = computed(() => {
|
|
|
+ return fileType.value !== 8 && !['Share'].includes(routeName.value)
|
|
|
+ })
|
|
|
+
|
|
|
+ const restoreBtnShow = computed(() => {
|
|
|
+ return fileType.value === 6 && !['Share'].includes(routeName.value)
|
|
|
+ })
|
|
|
+
|
|
|
+ const copyBtnShow = computed(() => {
|
|
|
+ return ![6, 8, 15].includes(fileType.value) && !['Share'].includes(routeName.value)
|
|
|
+ })
|
|
|
+
|
|
|
+ const moveBtnShow = computed(() => {
|
|
|
+ return ![6, 8, 15].includes(fileType.value) && !['Share'].includes(routeName.value)
|
|
|
+ })
|
|
|
+
|
|
|
+ const addMyFileListBtnShow = computed(() => {
|
|
|
+ return fileType.value == 15 && !['Share'].includes(routeName.value)
|
|
|
+ })
|
|
|
+
|
|
|
+ const addEnterpriseDiskBtnShow = computed(() => {
|
|
|
+ return ![6, 8, 15].includes(fileType.value) && !['Share'].includes(routeName.value)
|
|
|
+ })
|
|
|
+
|
|
|
+ const renameBtnShow = computed(() => {
|
|
|
+ return ![6, 8].includes(fileType.value) && !['Share'].includes(routeName.value)
|
|
|
+ })
|
|
|
+
|
|
|
+ const shareBtnShow = computed(() => {
|
|
|
+ return ![6, 8, 15].includes(fileType.value) && !['Share'].includes(routeName.value)
|
|
|
+ })
|
|
|
+
|
|
|
+ const downloadBtnShow = computed(() => {
|
|
|
+ return ![6, 8].includes(fileType.value)
|
|
|
+ })
|
|
|
+
|
|
|
+ const unzipBtnShow = computed(() => {
|
|
|
+ return (
|
|
|
+ props.selectedFile &&
|
|
|
+ ![6, 8].includes(fileType.value) &&
|
|
|
+ !['Share'].includes(routeName.value) &&
|
|
|
+ ['zip', 'rar', '7z', 'tar', 'gz'].includes(props.selectedFile.extendName)
|
|
|
+ )
|
|
|
+ })
|
|
|
+
|
|
|
+ const folderEditBtnShow = computed(() => {
|
|
|
+ return (
|
|
|
+ props.selectedFile &&
|
|
|
+ ![6, 8].includes(fileType.value) &&
|
|
|
+ props.selectedFile.isDir === 1 &&
|
|
|
+ !['Share'].includes(routeName.value)
|
|
|
+ )
|
|
|
+ })
|
|
|
+
|
|
|
+ const onlineEditBtnShow = computed(() => {
|
|
|
+ if (!props.selectedFile) return false
|
|
|
+ return (
|
|
|
+ ![6, 8].includes(fileType.value) &&
|
|
|
+ (officeFileType.includes(props.selectedFile.extendName) ||
|
|
|
+ markdownFileType.includes(props.selectedFile.extendName) ||
|
|
|
+ fileSuffixCodeModeMap.has(props.selectedFile.extendName)) &&
|
|
|
+ !['Share'].includes(routeName.value)
|
|
|
+ )
|
|
|
+ })
|
|
|
+
|
|
|
+ const copyLinkBtnShow = computed(() => {
|
|
|
+ return fileType.value === 8
|
|
|
+ })
|
|
|
+
|
|
|
+ const detailInfoBtnShow = computed(() => {
|
|
|
+ return true
|
|
|
+ })
|
|
|
+
|
|
|
+ const uploadFileParams = computed(() => {
|
|
|
+ return {
|
|
|
+ filePath: filePath.value,
|
|
|
+ isDir: 0
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ // Watcher
|
|
|
+ watch(visible, (newValue) => {
|
|
|
+ if (newValue === true) {
|
|
|
+ document.body.addEventListener('click', closeRightMenu)
|
|
|
+ handleOpenContextMenu()
|
|
|
+ } else {
|
|
|
+ document.body.removeEventListener('click', closeRightMenu)
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ onMounted(() => {
|
|
|
+ // onMounted logic if any
|
|
|
+ })
|
|
|
+
|
|
|
+ // Methods
|
|
|
+ const geta1 = (src) => {
|
|
|
+ console.log('src', src)
|
|
|
+ // $common.getCookies 依赖 proxy.$common,如果 $common 无法解析,这里会报错
|
|
|
+ const cookies = proxy.$common?.getCookies(appConfig.TOKEN_NAME)
|
|
|
+ const aElement = document.getElementById('aaaa')
|
|
|
+ if (!aElement) return
|
|
|
+
|
|
|
+ const downloadNameParts = aElement.download.split('.')
|
|
|
+ const name1 = downloadNameParts[0]
|
|
|
+ const name2 = downloadNameParts[1]
|
|
|
+
|
|
|
+ if (name2) {
|
|
|
+ newname.value = name1 + '.' + name2
|
|
|
+ } else {
|
|
|
+ newname.value = name1 + '.' + 'zip'
|
|
|
+ }
|
|
|
+
|
|
|
+ console.log('appConfig.API_URL', appConfig.API_URL) // 使用导入的 appConfig
|
|
|
+ const newname1 = newname.value
|
|
|
+ // 确保 aElement.href 是完整的 URL 或者正确拼接
|
|
|
+ const apiUrlPart = aElement.href.includes('/api') ? aElement.href.split('/api')[1] : aElement.href
|
|
|
+ const url = `${
|
|
|
+ (appConfig.API_URL.startsWith('http') ? '' : 'http://' + window.location.host) +
|
|
|
+ appConfig.API_URL + // 使用导入的 appConfig
|
|
|
+ apiUrlPart +
|
|
|
+ '&' +
|
|
|
+ cookies
|
|
|
+ }`
|
|
|
+
|
|
|
+ let isios = navigator.userAgent.indexOf('iPhone') > -1
|
|
|
+ let isAndroid = navigator.userAgent.indexOf('Android') > -1
|
|
|
+ console.log('url', url)
|
|
|
+ console.log('cookies', cookies)
|
|
|
+ console.log('newname1', newname1)
|
|
|
+ if (isios) {
|
|
|
+ window.webkit.messageHandlers.Download.postMessage({
|
|
|
+ params: {
|
|
|
+ url,
|
|
|
+ cookies,
|
|
|
+ newname1
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else if (isAndroid) {
|
|
|
+ window.Download.downList(url, cookies, newname1)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ const downloadPost = (src) => {
|
|
|
+ console.log(window.location.origin)
|
|
|
+ console.log(33333, src)
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ axios({
|
|
|
+ url: window.location.origin + src, // 确保 src 是正确的相对路径
|
|
|
+ method: 'get',
|
|
|
+ responseType: 'blob'
|
|
|
+ })
|
|
|
+ .then((res) => {
|
|
|
+ fileDownload(res, props.selectedFile?.fileName || 'download')
|
|
|
+ console.log(res)
|
|
|
+ resolve(res)
|
|
|
+ })
|
|
|
+ .catch((err) => {
|
|
|
+ reject(err)
|
|
|
+ })
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ const fileDownload = (res, filename) => {
|
|
|
+ let blob = new Blob([res.data])
|
|
|
+ if ('msSaveOrOpenBlob' in navigator) {
|
|
|
+ window.navigator.msSaveOrOpenBlob(blob, filename)
|
|
|
+ } else {
|
|
|
+ let objectUrl = (window.URL || window.webkitURL).createObjectURL(blob)
|
|
|
+ let downFile = document.createElement('a')
|
|
|
+ downFile.style.display = 'none'
|
|
|
+ downFile.href = objectUrl
|
|
|
+ downFile.download = filename
|
|
|
+ document.body.appendChild(downFile)
|
|
|
+ downFile.click()
|
|
|
+ document.body.removeChild(downFile)
|
|
|
+ window.URL.revokeObjectURL(objectUrl)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ const handleOpenContextMenu = () => {
|
|
|
+ console.log('handleOpenContextMenu', props)
|
|
|
+ if (!props.domEvent) return
|
|
|
+ if (
|
|
|
+ document.body.clientHeight - props.domEvent.clientY <
|
|
|
+ document.querySelectorAll('#rightMenuList > .right-menu-item').length * 36 + 10
|
|
|
+ ) {
|
|
|
+ rightMenu.value.top = 'auto'
|
|
|
+ rightMenu.value.bottom = `${document.body.clientHeight - props.domEvent.clientY}px`
|
|
|
+ unzipMenu.value.top = 'auto'
|
|
|
+ unzipMenu.value.bottom = '0px'
|
|
|
+ } else {
|
|
|
+ rightMenu.value.top = `${props.domEvent.clientY}px`
|
|
|
+ rightMenu.value.bottom = 'auto'
|
|
|
+ unzipMenu.value.top = '0px'
|
|
|
+ unzipMenu.value.bottom = 'auto'
|
|
|
+ }
|
|
|
+ if (document.body.clientWidth - props.domEvent.clientX < 138) {
|
|
|
+ rightMenu.value.left = 'auto'
|
|
|
+ rightMenu.value.right = `${document.body.clientWidth - props.domEvent.clientX}px`
|
|
|
+ unzipMenu.value.left = '-200px'
|
|
|
+ unzipMenu.value.right = 'auto'
|
|
|
+ } else {
|
|
|
+ rightMenu.value.left = `${props.domEvent.clientX + 8}px`
|
|
|
+ rightMenu.value.right = 'auto'
|
|
|
+ unzipMenu.value.left = '126px'
|
|
|
+ unzipMenu.value.right = 'auto'
|
|
|
+ }
|
|
|
+ visible.value = true
|
|
|
+ }
|
|
|
+
|
|
|
+ const closeRightMenu = (event) => {
|
|
|
+ if (!event.target.className.includes('operate-more-') && !event.target.className.includes('unzip-menu-item')) {
|
|
|
+ visible.value = false
|
|
|
+ if (props.selectedFile !== undefined) {
|
|
|
+ props.callback?.('cancel')
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ const handleCopyFileBtnClick = (fileInfo) => {
|
|
|
+ visible.value = false
|
|
|
+ openDialog
|
|
|
+ .copyFile({
|
|
|
+ fileInfo
|
|
|
+ })
|
|
|
+ .then((res) => {
|
|
|
+ props.callback?.(res)
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ const handleMoveFileBtnClick = (fileInfo) => {
|
|
|
+ visible.value = false
|
|
|
+ openDialog
|
|
|
+ .moveFile({
|
|
|
+ isBatchMove: false,
|
|
|
+ fileInfo
|
|
|
+ })
|
|
|
+ .then((res) => {
|
|
|
+ props.callback?.(res)
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ const handleUnzipFileBtnClick = (fileInfo, unzipMode) => {
|
|
|
+ visible.value = false
|
|
|
+ openDialog
|
|
|
+ .unzipFile({
|
|
|
+ unzipMode: unzipMode,
|
|
|
+ userFileId: fileInfo.userFileId
|
|
|
+ })
|
|
|
+ .then((res) => {
|
|
|
+ props.callback?.(res)
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ const handleDeleteFileBtnClick = (fileInfo) => {
|
|
|
+ visible.value = false
|
|
|
+ openDialog
|
|
|
+ .deleteFile({
|
|
|
+ isBatchOperation: false,
|
|
|
+ fileInfo,
|
|
|
+ deleteMode: fileType.value === 6 ? 2 : 1
|
|
|
+ })
|
|
|
+ .then((res) => {
|
|
|
+ props.callback?.(res)
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ const handleRestoreFileBtnClick = (fileInfo) => {
|
|
|
+ visible.value = false
|
|
|
+ openDialog
|
|
|
+ .restoreFile({
|
|
|
+ deleteBatchNum: fileInfo.deleteBatchNum,
|
|
|
+ filePath: fileInfo.filePath
|
|
|
+ })
|
|
|
+ .then((res) => {
|
|
|
+ props.callback?.(res)
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ const handleRenameFileBtnClick = (fileInfo) => {
|
|
|
+ visible.value = false
|
|
|
+ openDialog
|
|
|
+ .renameFile({
|
|
|
+ oldFileName: fileInfo.fileName,
|
|
|
+ userFileId: fileInfo.userFileId
|
|
|
+ })
|
|
|
+ .then((res) => {
|
|
|
+ props.callback?.(res)
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ const handleShareFileBtnClick = (fileInfo) => {
|
|
|
+ visible.value = false
|
|
|
+ openDialog.shareFile({
|
|
|
+ fileInfo: [
|
|
|
+ {
|
|
|
+ userFileId: fileInfo.userFileId
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ const handleClickFolderEdit = () => {
|
|
|
+ router.push({
|
|
|
+ name: 'WebIDE',
|
|
|
+ query: { filePath: props.selectedFile.filePath }
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ const handleClickFileEdit = (fileInfo) => {
|
|
|
+ if (officeFileType.includes(fileInfo.extendName)) {
|
|
|
+ fileHelper.getFileOnlineEditPathByOffice(fileInfo)
|
|
|
+ } else if (markdownFileType.includes(fileInfo.extendName)) {
|
|
|
+ openBox.markdownPreview({
|
|
|
+ fileInfo: fileInfo,
|
|
|
+ editable: true
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ openBox.codePreview({ fileInfo: fileInfo, isEdit: true })
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ const handleShowDetailInfo = (fileInfo) => {
|
|
|
+ visible.value = false
|
|
|
+ openDialog.showFileDetail({ fileInfo })
|
|
|
+ }
|
|
|
+
|
|
|
+ const handleClickAddFolderBtn = () => {
|
|
|
+ openDialog
|
|
|
+ .addFolder({
|
|
|
+ filePath: route.query.filePath || '/'
|
|
|
+ })
|
|
|
+ .then((res) => {
|
|
|
+ props.callback?.(res)
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ const handleCreateFile = (fileExt) => {
|
|
|
+ // Renamed parameter to avoid conflict
|
|
|
+ openDialog
|
|
|
+ .createFile({
|
|
|
+ fileType: fileExt, // Use the renamed parameter
|
|
|
+ filePath: route.query.filePath || '/'
|
|
|
+ })
|
|
|
+ .then((res) => {
|
|
|
+ props.callback?.(res)
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ const handleUploadFileBtnClick = (uploadType) => {
|
|
|
+ if (uploadType === 1 || uploadType === 2) {
|
|
|
+ openDialog?.upload({ type: uploadType, filePath: filePath.value }).then((res) => {
|
|
|
+ props.callback?.(res)
|
|
|
+ })
|
|
|
+ } else if (uploadType === 3) {
|
|
|
+ antMessage.info('请拖拽文件或文件夹到此区域以上传')
|
|
|
+ }
|
|
|
+ visible.value = false
|
|
|
+ }
|
|
|
+
|
|
|
+ const handleAddMyFileList = (fileInfo) => {
|
|
|
+ addMyFileListApi({ userFileId: fileInfo.userFileId, filePath: '/' }).then((res) => {
|
|
|
+ if (res.success) {
|
|
|
+ antMessage.success('添加成功')
|
|
|
+ } else {
|
|
|
+ antMessage.error(res.message)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ const handleEnterpriseDisk = (fileInfo) => {
|
|
|
+ addEnterpriseDiskApi({ userFileId: fileInfo.userFileId, filePath: '/' }).then((res) => {
|
|
|
+ if (res.success) {
|
|
|
+ antMessage.success('添加成功')
|
|
|
+ } else {
|
|
|
+ antMessage.error(res.message)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ // Expose any properties/methods that need to be accessed by the parent component
|
|
|
+ defineExpose({
|
|
|
+ visible, // if parent needs to control visibility directly
|
|
|
+ handleOpenContextMenu // if parent needs to trigger opening context menu
|
|
|
+ })
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="less" scoped>
|
|
|
+ /* 保持原有样式 */
|
|
|
+ .right-menu-list {
|
|
|
+ position: fixed;
|
|
|
+ z-index: 9999; // 确保在最上层
|
|
|
+ width: auto;
|
|
|
+ min-width: 128px;
|
|
|
+ max-width: 200px;
|
|
|
+ padding: 4px 0;
|
|
|
+ border: 1px solid #e4e7ed;
|
|
|
+ border-radius: 4px;
|
|
|
+ background-color: #fff;
|
|
|
+ box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
|
|
|
+
|
|
|
+ &.add {
|
|
|
+ .right-menu-item {
|
|
|
+ padding: 0 8px;
|
|
|
+ img {
|
|
|
+ width: 14px;
|
|
|
+ margin-right: 8px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .right-menu-item {
|
|
|
+ box-sizing: border-box;
|
|
|
+ position: relative;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ width: 100%;
|
|
|
+ height: 36px;
|
|
|
+ padding: 0 16px;
|
|
|
+ font-size: 14px;
|
|
|
+ line-height: 36px;
|
|
|
+ color: #606266;
|
|
|
+ cursor: pointer;
|
|
|
+ user-select: none;
|
|
|
+
|
|
|
+ &:hover {
|
|
|
+ background: #ecf5ff;
|
|
|
+ color: #409eff;
|
|
|
+ }
|
|
|
+
|
|
|
+ &.unzip-menu-item {
|
|
|
+ justify-content: space-between;
|
|
|
+ }
|
|
|
+
|
|
|
+ .el-icon-arrow-right {
|
|
|
+ position: absolute;
|
|
|
+ right: 8px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .unzip-list {
|
|
|
+ position: absolute;
|
|
|
+ z-index: 1;
|
|
|
+ padding: 4px 0;
|
|
|
+ border: 1px solid #e4e7ed;
|
|
|
+ border-radius: 4px;
|
|
|
+ background-color: #fff;
|
|
|
+ box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
|
|
|
+ display: none;
|
|
|
+ }
|
|
|
+
|
|
|
+ &.unzip-menu-item:hover > .unzip-list {
|
|
|
+ display: block;
|
|
|
+ }
|
|
|
+
|
|
|
+ .unzip-item {
|
|
|
+ box-sizing: border-box;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ width: 100%;
|
|
|
+ min-width: max-content;
|
|
|
+ height: 36px;
|
|
|
+ padding: 0 16px;
|
|
|
+ font-size: 14px;
|
|
|
+ line-height: 36px;
|
|
|
+ color: #606266;
|
|
|
+ cursor: pointer;
|
|
|
+
|
|
|
+ &:hover {
|
|
|
+ background: #ecf5ff;
|
|
|
+ color: #409eff;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ i {
|
|
|
+ margin-right: 8px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .el-divider--horizontal {
|
|
|
+ margin: 4px 0;
|
|
|
+ }
|
|
|
+</style>
|