溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

ONLYOFFICE歷史版本功能的開發(fā)

發(fā)布時(shí)間:2020-07-26 00:38:29 來源:網(wǎng)絡(luò) 閱讀:1144 作者:3xxxx 欄目:編程語言

https://api.onlyoffice.com/editors/history

上面的頁面介紹如何進(jìn)行歷史版本功能的開發(fā)。

https://api.onlyoffice.com/editors/howitworks

上面介紹了onlyoffice document server所包含的功能,


The client side includes:

  • Document manager - the list of the documents displayed in the user browser where the user can select the necessary document and perform some actions with it (depending on the provided rights, the user can open the document to view it or edit, share the document with other users).

  • Document editor - the document viewing and editing interface with all the most known document editing features available, used as a medium between the user and the document editing service.

The server side includes:

  • Document storage service - the server service which stores all the documents available to the users with the appropriate access rights. It provides the document IDs and links to these documents to the document manager which the user sees in the browser.

  • Document editing service - the server service which allows to perform the document viewing and editing (in case the user has the appropriate rights to do that). The document editor interface is used to access all the document editing service features.

  • Document command service - the server service which allows to perfom additional commands with document editing service.

  • Document conversion service - the server service which allows to convert the document file into the appropriate Office Open XML format (docx for text documents, xlsx for spreadsheets and pptx for presentations) for their editing or downloading.

Please note, that ONLYOFFICE Document Server includes the document editordocument editing servicedocument command service and document conversion service. The document manager and document storage service are either included to Community Server or must be implemented by the software integrators who use ONLYOFFICE Document Server on their own server.

請注意,onlyoffice document server包括document editordocument editing servicedocument command service(文檔編輯器、文檔編輯服務(wù)、文檔命令服務(wù)和文檔轉(zhuǎn)換服務(wù))。文檔管理器文檔存儲服務(wù)要么包含在社區(qū)服務(wù)器上,要么必須由在自己的服務(wù)器上僅使用office文檔服務(wù)器的軟件集成商實(shí)現(xiàn)。

我用golang就是開發(fā)了文檔管理器和文檔存儲。

ONLYOFFICE歷史版本功能的開發(fā)

類似可道云的那種云盤的資料管理。

ONLYOFFICE歷史版本功能的開發(fā)

但相比可道云,對于我們工程設(shè)計(jì)人員來說,更容易管理文檔,比如編號和名稱分開,文件作為附件放到成果下面,而不像可道云這樣直接看到的就是附件,一個成果下可以放多個附件。還可以發(fā)布文章,可以設(shè)置成果間的關(guān)聯(lián),可以設(shè)置目錄的權(quán)限,可以根據(jù)附件擴(kuò)展名來設(shè)置權(quán)限,比如只運(yùn)行看pdf文件,不運(yùn)行看dwg,dgn等圖紙文件。

回到正題,歷史版本的開發(fā)必須從onlyoffice document server的返回值里找到數(shù)據(jù)結(jié)構(gòu)。

[html] view plain copy

  1. {  

  2.     "key":"1520696086733383100",  

  3.     "status":2,  

  4.       

  5.     "url":"http://192.168.99.100:9000/cache/files/1520696086733383100_1849/outpu  

  6.     t.docx/output.docx?md5=CSBXuCfKbp1zaA2C-IoB2g==&expires=1523288157&  

  7.     disposition=attachment&ooname=output.docx",  

  8.     "changesurl":"http://192.168.99.100:9000/cache/files/  

  9.     1520696086733383100_1849/changes.zip/changes.zip?  

  10.     md5=eQOOXry8Spob255EtEi7QA==&expires=1523288157&  

  11.     disposition=attachment&ooname=output.zip",  

  12. "history":{  

  13.     "serverVersion":"5.0.7",  

  14.     "changes":[  

  15.         {  

  16.             "created":"2018-03-10 15:34:57",  

  17.             "user":  

  18.             {  

  19.                 "id":"9",  

  20.                 "name":"qin.xc"  

  21.             }  

  22.         },  

  23.         {  

  24.             "created":"2018-03-10 15:35:29",  

  25.             "user":  

  26.             {  

  27.                 "id":"8",  

  28.                 "name":"qin8.xc"  

  29.             }  

  30.         }  

  31.     ]  

  32. },  

  33. "users":["8"],  

  34. "actions":[{"type":0,"userid":"9"}],  

  35. "lastsave":"2018-03-10T15:35:37.823Z",  

  36. "notmodified":false  

  37. }  

官網(wǎng)上的例子:

Sample of JSON object sent to the "callbackUrl" address by document editing service when the user changed the document and closed it for editing

[html] view plain copy

  1. {  

  2.     "actions": [{"type": 0, "userid": "78e1e841"}],  

  3.     "changesurl": "https://documentserver/url-to-changes.zip",  

  4.     "history": {  

  5.         "changes": changes,  

  6.         "serverVersion": serverVersion  

  7.     },  

  8.     "key": "Khirz6zTPdfd7",  

  9.     "status": 2,  

  10.     "url": "https://documentserver/url-to-edited-document.docx",  

  11.     "users": ["6d5a81d0"]  

  12. }  

所以用beego開發(fā)先設(shè)置數(shù)據(jù)結(jié)構(gòu),然后解析到結(jié)構(gòu)體就行了。

[plain] view plain copy

  1. type Callback struct {  

  2.     Key         string   `json:"key"`  

  3.     Status      int      `json:"status"`  

  4.     Url         string   `json:"url"`  

  5.     Changesurl  string   `json:"changesurl"`  

  6.     History     history1 `json:"history"`  

  7.     Users       []string `json:"users"`  

  8.     Actions     []action `json:"actions"`  

  9.     Lastsave    string   `json:"lastsave"`  

  10.     Notmodified bool     `json:"notmodified"`  

  11. }  

  12.   

  13. type action struct {  

  14.     Type   int    `json:"type"`  

  15.     Userid string `json:"userid"`  

  16. }  

  17.   

  18. type history1 struct {  

  19.     ServerVersion string   `json:"serverVersion"`  

  20.     Changes       []change `json:"changes"`  

  21. }  

  22.   

  23. type change struct {  

  24.     Created string `json:"created"` //time.Time  

  25.     User    User1  `json:"user"`  

  26. }  

  27.   

  28. type User1 struct {  

  29.     Id   string `json:"id"` //必須大寫才能在tpl中顯示{{.json}}  

  30.     Name string `json:"name"`  

  31. }  

ONLYOFFICE歷史版本功能的開發(fā)


向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI