Merge pull request #350 from jamebal/dev

fix: 修复挂载文件无法通过位置跳转的问题
This commit is contained in:
jmal 2024-12-31 21:16:06 +08:00 committed by GitHub
commit d4584c8da1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 34 additions and 5 deletions

View File

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

View File

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

View File

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