Merge pull request #320 from jamebal/dev
feat: 以下文件格式可以使用OnlyOffice打开: 'doc', 'docx', 'odt', 'rtf', 'xls', 'xlsx', 'ods', 'csv', 'ppt', 'ppsx', 'pps', 'odp', 'pptx', 'pdf', 'epub', 'html'
This commit is contained in:
commit
2fb5895c47
@ -606,9 +606,10 @@
|
|||||||
:file="iframePreviewRow"
|
:file="iframePreviewRow"
|
||||||
:fileHandler="fileHandler"
|
:fileHandler="fileHandler"
|
||||||
:status.sync="iframePreviewVisible"
|
:status.sync="iframePreviewVisible"
|
||||||
|
:specifyPreviewer="specifyPreviewer"
|
||||||
></iframe-preview>
|
></iframe-preview>
|
||||||
|
|
||||||
<file-details :audio-cover-url="audioCoverUrl" :image-url="imageUrl" :file="rowContextData" :visible.sync="drawer" @openFile="fileClick"></file-details>
|
<file-details :audio-cover-url="audioCoverUrl" :image-url="imageUrl" :file="rowContextData" :visible.sync="drawer" @openFile="fileClick" @openOnlyOffice="openOnlyOffice"></file-details>
|
||||||
|
|
||||||
<el-dialog
|
<el-dialog
|
||||||
class="open-file-dialog"
|
class="open-file-dialog"
|
||||||
@ -1095,6 +1096,7 @@ export default {
|
|||||||
iframePreviewRow: {},
|
iframePreviewRow: {},
|
||||||
fileHandler: {},
|
fileHandler: {},
|
||||||
iframePreviewVisible: false,
|
iframePreviewVisible: false,
|
||||||
|
specifyPreviewer: '', // 指定预览器
|
||||||
audioPreviewRow: {},
|
audioPreviewRow: {},
|
||||||
audioPreviewVisible: false,
|
audioPreviewVisible: false,
|
||||||
drawer: false,
|
drawer: false,
|
||||||
@ -4395,6 +4397,13 @@ export default {
|
|||||||
this.notPreviewDialogVisible = true
|
this.notPreviewDialogVisible = true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
openOnlyOffice(row) {
|
||||||
|
this.drawer = false
|
||||||
|
this.iframePreviewVisible = true
|
||||||
|
this.iframePreviewRow = row
|
||||||
|
this.fileHandler = {}
|
||||||
|
this.specifyPreviewer = 'office'
|
||||||
|
},
|
||||||
checkPreviewVisible() {
|
checkPreviewVisible() {
|
||||||
if (this.iframePreviewVisible) {
|
if (this.iframePreviewVisible) {
|
||||||
return true
|
return true
|
||||||
|
|||||||
@ -96,12 +96,15 @@
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-scrollbar>
|
</el-scrollbar>
|
||||||
<el-button v-if="allowOpenFile" type="primary" size="small" @click="openFile" class="open-file">打开文件</el-button>
|
<el-button v-if="allowOpenFile" type="primary" size="small" @click="openFile" class="open-file">打开文件</el-button>
|
||||||
|
<el-button v-if="onlyOfficeSupportedFormats(file)" type="primary" size="small" @click="openOnlyOffice" class="open-file">使用OnlyOffice打开</el-button>
|
||||||
</el-form>
|
</el-form>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import { onlyOfficeSupportedFormats } from '@/utils/file-type'
|
||||||
|
|
||||||
// 引入VueOfficeDocx 组件
|
// 引入VueOfficeDocx 组件
|
||||||
import VueOfficeDocx from '@vue-office/docx'
|
import VueOfficeDocx from '@vue-office/docx'
|
||||||
// 引入VueOfficeDocx 相关样式
|
// 引入VueOfficeDocx 相关样式
|
||||||
@ -193,6 +196,9 @@ export default {
|
|||||||
openFile() {
|
openFile() {
|
||||||
this.$emit('openFile', this.file)
|
this.$emit('openFile', this.file)
|
||||||
},
|
},
|
||||||
|
openOnlyOffice() {
|
||||||
|
this.$emit('openOnlyOffice', this.file)
|
||||||
|
},
|
||||||
rendered() {
|
rendered() {
|
||||||
console.log('rendered')
|
console.log('rendered')
|
||||||
},
|
},
|
||||||
@ -210,6 +216,12 @@ export default {
|
|||||||
this.updateSyncStatus(res.data)
|
this.updateSyncStatus(res.data)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
onlyOfficeSupportedFormats(file) {
|
||||||
|
if (!file || !file.suffix) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return onlyOfficeSupportedFormats.includes(file.suffix.toLowerCase())
|
||||||
|
},
|
||||||
updateSyncStatus(dataPercent) {
|
updateSyncStatus(dataPercent) {
|
||||||
if (this.clickSync) {
|
if (this.clickSync) {
|
||||||
return
|
return
|
||||||
|
|||||||
@ -73,6 +73,10 @@ export default {
|
|||||||
status: {
|
status: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false
|
default: false
|
||||||
|
},
|
||||||
|
specifyPreviewer: {
|
||||||
|
type: String,
|
||||||
|
default: ''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
@ -91,6 +95,9 @@ export default {
|
|||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
fileType() {
|
fileType() {
|
||||||
|
if (this.specifyPreviewer === 'office') {
|
||||||
|
return 'office'
|
||||||
|
}
|
||||||
return this.getType(this.file.suffix)
|
return this.getType(this.file.suffix)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@ -19,6 +19,11 @@ monaco.languages.getLanguages().forEach(language => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// onlyOffice支持的文件格式
|
||||||
|
export const onlyOfficeSupportedFormats = [
|
||||||
|
'doc', 'docx', 'odt', 'rtf', 'xls', 'xlsx', 'ods', 'csv', 'ppt', 'ppsx', 'pps', 'odp', 'pptx', 'pdf', 'epub', 'html'
|
||||||
|
]
|
||||||
|
|
||||||
// 换行
|
// 换行
|
||||||
export const lineWrapping = [
|
export const lineWrapping = [
|
||||||
''
|
''
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user