<template>
    <div>
        <OnlyOfficeViewer
            :document-url="documentUrl"
            :document-title="documentTitle"
            :document-key="documentKey"
            :mode="mode"
            :type="type"
            @document-ready="handleDocumentReady"
            @app-ready="handleAppReady"
            @error="handleError"
            @initialized="handleInitialized"
            :force-save="true"
            :save-timeout="15000"
        />
    </div>
</template>

<script>
import OnlyOfficeViewer from '@/views/common/OnlyOfficeViewer.vue'
export default {
    name: 'TestOnlyOffice',
    components: {
        OnlyOfficeViewer,
    },
    data() {
        return {
            documentUrl:
                'http://192.168.0.14:9090/smart-bid/technicalSolutionDatabase/2025/11/03/716d9f3d89434c56bc49296dbbccc226.docx',
            documentTitle: '.docx',
            documentKey: '98',
            mode: 'edit',
            type: 'desktop', // desktop, mobile embedded
        }
    },
    methods: {
        handleDocumentReady() {
            console.log('文档已准备就绪')
        },
        handleAppReady() {
            console.log('应用已准备就绪')
        },
        handleError(error) {
            console.log('错误：', error)
        },
        handleInitialized() {
            console.log('初始化完成')
        },
    },
}
</script>
