fix: 修复挂载文件无法通过位置跳转的问题

This commit is contained in:
jmal 2024-12-31 21:15:10 +08:00
parent e37ab71b22
commit f42ce5bb0e
3 changed files with 34 additions and 5 deletions

View File

@ -264,6 +264,14 @@ export default {
data: data data: data
}) })
}, },
// 挂用户获取分享文件信息 /mount/file_info
getMountFileInfo: function(params) {
return request({
url: '/mount/file_info',
method: 'get',
params
})
},
// 验证提取码 // 验证提取码
validShareCode: function(data) { validShareCode: function(data) {
return request({ return request({

View File

@ -626,7 +626,7 @@
:specifyPreviewer="specifyPreviewer" :specifyPreviewer="specifyPreviewer"
></iframe-preview> ></iframe-preview>
<file-details :audio-cover-url="audioCoverUrl" :image-url="imageUrl" :file="rowContextData" :visible.sync="drawer" @openFile="fileClick" @openOnlyOffice="openOnlyOffice"></file-details> <file-details :audio-cover-url="audioCoverUrl" :image-url="imageUrl" :file="rowContextData" :file-username="fileUsername" :visible.sync="drawer" @openFile="fileClick" @openOnlyOffice="openOnlyOffice"></file-details>
<el-dialog <el-dialog
class="open-file-dialog" class="open-file-dialog"
@ -1154,7 +1154,8 @@ export default {
deleteLoading: false, // 删除loading deleteLoading: false, // 删除loading
debounceSearch: null,// 搜索防抖 debounceSearch: null,// 搜索防抖
debounceGetFileList: null,// 获取文件列表防抖 debounceGetFileList: null,// 获取文件列表防抖
searchDialogVisible: false searchDialogVisible: false,
fileUsername: '', // 一般用于挂载文件
} }
}, },
computed: { computed: {
@ -2803,6 +2804,7 @@ export default {
// 高亮新增的文件 // 高亮新增的文件
this.highlightNewFile() this.highlightNewFile()
// 设置挂载文件的用户名(文件的所有者) // 设置挂载文件的用户名(文件的所有者)
this.fileUsername = ''
this.setMountFileOwner(res.props) this.setMountFileOwner(res.props)
const path = this.$route.query.path ? this.$route.query.path : '/' const path = this.$route.query.path ? this.$route.query.path : '/'
const basePath = this.$route.query.basePath const basePath = this.$route.query.basePath
@ -2820,6 +2822,7 @@ export default {
localStorage.removeItem('mountFileOwner') localStorage.removeItem('mountFileOwner')
if (this.$route.query.folder) { if (this.$route.query.folder) {
if (props && props.fileUsername && props.fileUsername !== this.$store.getters.name) { if (props && props.fileUsername && props.fileUsername !== this.$store.getters.name) {
this.fileUsername = props.fileUsername
localStorage.setItem('mountFileOwner', props.fileUsername) localStorage.setItem('mountFileOwner', props.fileUsername)
} }
} }

View File

@ -80,7 +80,7 @@
<span> {{ formatSize(file.size) }}</span> <span> {{ formatSize(file.size) }}</span>
</el-form-item> </el-form-item>
<el-form-item label="位置:" class="details-position"> <el-form-item label="位置:" class="details-position">
<a :href="'/?path=' + file.path + '&highlight=' + file.name">{{ file.path }}</a> <a :href="pathUrl">{{ filepath }}</a>
</el-form-item> </el-form-item>
<el-form-item label="上传时间:"> <el-form-item label="上传时间:">
<span>{{ file.uploadDate }}</span> <span>{{ file.uploadDate }}</span>
@ -103,6 +103,7 @@
</template> </template>
<script> <script>
import fileApi from '@/api/file-api'
import { onlyOfficeSupportedFormats } from '@/utils/file-type' import { onlyOfficeSupportedFormats } from '@/utils/file-type'
// 引入VueOfficeDocx 组件 // 引入VueOfficeDocx 组件
@ -146,6 +147,10 @@ export default {
type: String, type: String,
required: true, required: true,
}, },
fileUsername: {
type: String,
required: true,
},
}, },
data() { data() {
return { return {
@ -159,7 +164,9 @@ export default {
widthOffset: 10, widthOffset: 10,
heightOffset: 10, heightOffset: 10,
excel: window.location.origin + fileConfig.previewUrl(this.$store.state.user.name, this.file, this.$store.getters.token) excel: window.location.origin + fileConfig.previewUrl(this.$store.state.user.name, this.file, this.$store.getters.token)
} },
filepath: '',
pathUrl: ''
} }
}, },
mounted() { mounted() {
@ -188,7 +195,18 @@ export default {
visible(val) { visible(val) {
this.$emit('update:visible', val) this.$emit('update:visible', val)
if (val) { if (val) {
this.filepath = this.file.path
this.pathUrl = `/?path=${this.file.path}&highlight=${this.file.name}`
this.getIsSync() this.getIsSync()
if (this.fileUsername) {
fileApi.getMountFileInfo({
fileId: this.file.id,
fileUsername: this.fileUsername
}).then((res) => {
this.filepath = res.data.path
this.pathUrl = `/?path=${res.data.path}&highlight=${this.file.name}&folder=${res.data.folder}`
})
}
} }
} }
}, },
@ -207,7 +225,7 @@ export default {
this.$emit('openOnlyOffice', this.file) this.$emit('openOnlyOffice', this.file)
}, },
rendered() { rendered() {
console.log('rendered') //console.log('rendered')
}, },
formatSize(size) { formatSize(size) {
return formatSize(size) return formatSize(size)