Onlyoffice集成與AI交互操作指引(Iframe版)

Onlyoffice集成與AI交互操作指引(Iframe版)

本文檔系統介紹了軟件系統集成OnlyOffice實現在線編輯與AI輔助功能的方案。主要內容包括:后端需提供文檔配置信息并實現Callback接口以處理文檔保存;前端通過Vue集成編輯器,利用連接器(connector)調用API實現文本操作、菜單定制及事件監聽;AI交互采用基于postMessage的消息機制,實現從編輯器發送文本到AI處理并返回結果替換的完整異步流程。該方案實現了文檔編輯與AI能力的深度結合。

OnlyOffice集成

后端對接

Onlyoffice只提供的是文檔的在線編輯能力,文檔的保存、權限、文檔信息、配置信息等都需要通過后端服務進行返回。

獲取config配置
  1. 描述

    • 配置文件主要包含用戶信息,文檔信息,編輯器配置,監聽事件,及token等配置,用于文件內容的讀取和編輯器的渲染。
  2. 文檔參考鏈接

    • https://api.onlyoffice.com/zh-CN/docs/docs-api/usage-api/config/
  3. 獲取配置及文檔信息(根據文檔鏈接和操作模式返回配置信息)

{"document": {"fileType": "docx","info": {"favorite": true,"folder": "Example Files","owner": "John Smith","sharingSettings": [{"permissions": "Full Access","user": "John Smith"},{"isLink": true,"permissions": "Read Only","user": "External link"}],"uploaded": "2010-07-07 3:46 PM"},"isForm": true,"key": "Khirz6zTPdfd7","permissions": {"chat": true,"comment": true,"commentGroups": [{"edit": ["Group2",""],"remove": [""],"view": ""}],"copy": true,"deleteCommentAuthorOnly": false,"download": true,"edit": true,"editCommentAuthorOnly": false,"fillForms": true,"modifyContentControl": true,"modifyFilter": true,"print": true,"protect": true,"review": true,"reviewGroups": ["Group1","Group2",""],"userInfoGroups": ["Group1",""]},"referenceData": {"fileKey": "BCFA2CED","instanceId": "https://example.com"},"title": "Example Document Title.docx","url": "https://example.com/url-to-example-document.docx"},"documentType": "word","editorConfig": {"actionLink": "ACTION_DATA","callbackUrl": "https://example.com/url-to-callback.ashx","coEditing": {"change": true,"mode": "fast"},"createUrl": "https://example.com/url-to-create-document/","customization": {"about": true,"anonymous": {"label": "Guest","request": true},"autosave": true,"close": {"text": "Close file","visible": true},"comments": true,"compactHeader": false,"compactToolbar": false,"compatibleFeatures": false,"customer": {"address": "My City, 123a-45","info": "Some additional information","logo": "https://example.com/logo-big.png","logoDark": "https://example.com/dark-logo-big.png","mail": "john@example.com","name": "John Smith and Co.","phone": "123456789","www": "example.com"},"features": {"featuresTips": true,"roles": true,"spellcheck": {"change": true,"mode": true},"tabBackground": {"change": true,"mode": "header"},"tabStyle": {"change": true,"mode": "fill"}},"feedback": {"url": "https://example.com","visible": true},"font": {"name": "Arial","size": "11px"},"forceWesternFontSize": false,"forcesave": false,"goback": {"blank": true,"text": "Open file location","url": "https://example.com"},"help": true,"hideNotes": false,"hideRightMenu": true,"hideRulers": false,"integrationMode": "embed","layout": {"header": {"editMode": true,"save": true,"user": true,"users": true},"leftMenu": {"mode": true,"navigation": true,"spellcheck": true},"rightMenu": {"mode": true},"statusBar": {"actionStatus": true,"docLang": true,"textLang": true},"toolbar": {"collaboration": {"mailmerge": true},"draw": true,"file": {"close": true,"info": true,"save": true,"settings": true},"home": {},"layout": true,"plugins": true,"protect": true,"references": true,"save": true,"view": {"navigation": true}}},"loaderLogo": "https://example.com/loader-logo.png","loaderName": "The document is loading, please wait...","logo": {"image": "https://example.com/logo.png","imageDark": "https://example.com/dark-logo.png","imageLight": "https://example.com/light-logo.png","url": "https://example.com","visible": true},"macros": true,"macrosMode": "warn","mentionShare": true,"mobile": {"forceView": true,"info": false,"standardView": false},"plugins": true,"pointerMode": "select","review": {"hideReviewDisplay": false,"hoverMode": false,"reviewDisplay": "original","showReviewChanges": false,"trackChanges": true},"showHorizontalScroll": true,"showVerticalScroll": true,"slidePlayerBackground": "#000000","submitForm": {"resultMessage": "text","visible": true},"toolbarHideFileName": false,"uiTheme": "theme-dark","unit": "cm","wordHeadingsColor": "#00ff00","zoom": 100},"embedded": {"embedUrl": "https://example.com/embedded?doc=exampledocument1.docx","fullscreenUrl": "https://example.com/embedded?doc=exampledocument1.docx#fullscreen","saveUrl": "https://example.com/download?doc=exampledocument1.docx","shareUrl": "https://example.com/view?doc=exampledocument1.docx","toolbarDocked": "top"},"lang": "en","mode": "edit","plugins": {"autostart": ["asc.{0616AE85-5DBE-4B6B-A0A9-455C4F1503AD}","asc.{FFE1F462-1EA2-4391-990D-4CC84940B754}"],"options": {"all": {"keyAll": "valueAll"},"asc.{38E022EA-AD92-45FC-B22B-49DF39746DB4}": {"keyYoutube": "valueYoutube"}},"pluginsData": ["https://example.com/plugin1/config.json","https://example.com/plugin2/config.json"]},"recent": [{"folder": "Example Files","title": "exampledocument1.docx","url": "https://example.com/exampledocument1.docx"},{"folder": "Example Files","title": "exampledocument2.docx","url": "https://example.com/exampledocument2.docx"}],"region": "en-US","templates": [{"image": "https://example.com/exampletemplate1.png","title": "exampletemplate1.docx","url": "https://example.com/url-to-create-template1"},{"image": "https://example.com/exampletemplate2.png","title": "exampletemplate2.docx","url": "https://example.com/url-to-create-template2"}],"user": {"group": "Group1,Group2","id": "78e1e841","image": "https://example.com/url-to-user-avatar.png","name": "John Smith"}},"events": {},"height": "100%","token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.e30.LwimMJA3puF3ioGeS-tfczR3370GXBZMIL-bdpu4hOU","type": "desktop","width": "100%"
}
實現Callback接口
  1. 描述

    • callback的鏈接在獲取配置時已經返回,onlyoffice會根據配置的callback地址,進行回調,通知服務有關文檔編輯的狀態,用戶需要根據相關狀態實現文檔的保存。
  2. 文檔參考鏈接

  • https://api.onlyoffice.com/zh-CN/docs/docs-api/usage-api/callback-handler/
  1. 注意事項
  • 要對回調內容中token進行校驗,校驗合法后才允許文件的更新保存

頁面集成

VUE集成
  1. 文檔參考鏈接

    • https://api.onlyoffice.com/zh-CN/docs/docs-api/get-started/frontend-frameworks/vue/
  2. 參考實現(測試驗證時的實現)

該集成頁面實現了編輯器集成,自定義菜單注冊,API執行,AI交互,消息發送與監聽

<template><div style="height: 100%;"><div>OnlyOffice + AI交互示例</div><!-- 控制按鈕 --><button @click="getFullText">獲取全文</button><button @click="replaceWithAIResult">替換文本</button><button @click="getFullHtml">獲取全文(HTML)</button><button @click="showMessage">消息展示</button><button @click="addComment">添加注釋</button><button @click="getSelection">獲取選中文本</button><button @click="getSelectionType">獲取選擇類型</button><button @click="inputText">輸入文本</button><button @click="pasteHtml">粘貼HTML</button><button @click="searchAndReplace">搜索替換</button><div id="container"><div id="onlyoffice"></div><!-- <iframe id="aiIframe"src="AIURL"></iframe> --></div></div>
</template><script>
export default {data() {return {docEditor: null,connector: null,aiBox: {width: 226,height: 284,bottom: 5,isDragging: false},aiResult: ""};},mounted() {this.initOnlyOffice();// ---------------- AI iframe 返回結果 ----------------window.addEventListener('message', (event) => {if (!event.data || event.data.type !== 'replaceText') return;const { content } = event.data.data;// 這里執行文檔替換操作,比如調用 OnlyOffice connector 方法if (this.connector) {this.connector.executeMethod("PasteText", [content]);console.log("已替換選中文本", content);}});},methods: {// 初始化 OnlyOffice 編輯器async initOnlyOffice() {try {const res = await fetch("http://{yourbacekservice}/onlyoffice/config?id=123");const config = await res.json();config.editorConfig.events = {onAppReady: () => {console.log("OnlyOffice加載完成");},onDocumentReady: this.onDocumentReady};const script = document.createElement("script");script.src = "http://{youronlrofficehost}/web-apps/apps/api/documents/api.js";script.onload = () => {this.docEditor = new DocsAPI.DocEditor("onlyoffice", config.editorConfig);};document.head.appendChild(script);} catch (e) {console.error("OnlyOffice初始化失敗", e);}},onDocumentReady() {this.connector = this.docEditor.createConnector();console.log("文檔準備就緒", this.connector);this.connector.attachEvent("onContextMenuShow", () => {this.connector.executeMethod("GetSelectedText", [], selectedText => {const hasSelection = selectedText && selectedText.trim().length > 0;const childItems = [{ id: "analyzeText", text: "分析文本內容", onClick: () => this.sendToAI(selectedText, "analyzeText") }];if (hasSelection) {childItems.push({id: "optimizeText",text: "文案優化",onClick: () => this.sendToAI(selectedText, "optimizeText")},{ id: "correctText", text: "文本糾錯", onClick: () => this.sendToAI(selectedText, "correctText") },{id: "translateText",text: "文本翻譯",onClick: () => this.sendToAI(selectedText, "translateText")});}this.connector.addContextMenuItem([{ id: "hopeSeekAI", text: "HopeSeek(AI)", items: childItems }]);});});const iframe = document.getElementById('aiIframe');if (!iframe) return;iframe.contentWindow.postMessage({type: 'openChange',data: { isShow: true }}, '*');},sendToAI(content, action) {const iframe = document.getElementById("aiIframe");if (!iframe) return;iframe.contentWindow.postMessage({type: "aiRequest",data: { content, action, source: "onlyoffice" }}, "*");},getSelectionType() {this.connector.executeMethod("GetSelectionType", [], selectedType => {console.log("獲取選擇類型", selectedType);});},inputText() {this.connector.executeMethod("InputText", ["ONLYOFFICE Plugins", ""])},getSelection() {// this.connector.executeMethod("GetSelectedText", [], selectedText => {//     console.log("已獲取選中文本", selectedText);// });this.connector.executeMethod("GetSelectedText", [{ "Numbering": false, "Math": false, "TableCellSeparator": '\n', "ParaSeparator": '\n', "TabSymbol": String.fromCharCode(9) }], function (data) {const sText = data;// ExecTypograf (sText);console.log(sText);});},replaceWithAIResult() {this.connector.executeMethod("PasteText", ["要粘貼的內容"]);},pasteHtml() {this.connector.executeMethod("PasteHtml", ["&lt;p&gt;&lt;b&gt;Plugin methods for OLE objects&lt;/b&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;AddOleObject&lt;/li&gt;&lt;li&gt;EditOleObject&lt;/li&gt;&lt;/ul&gt;"]);},searchAndReplace() {this.connector.executeMethod("SearchAndReplace", [{"searchString": "目標","replaceString": "R目標R","matchCase": true}]);},getFullText() {this.connector.callCommand(() => Api.GetDocument().GetText(), data => console.log(data));},getFullHtml() {this.connector.executeMethod("GetFileHTML", null, res => console.log(res));},showMessage() {this.docEditor.showMessage("12324")},// AI 浮窗拖拽操作startDrag(e) {e.preventDefault();this.aiBox.isDragging = true;this.aiBox.startY = e.clientY - this.aiBox.bottom;document.addEventListener('mousemove', this.onDrag);document.addEventListener('mouseup', this.stopDrag);},onDrag(e) {if (!this.aiBox.isDragging) return;let newY = window.innerHeight - e.clientY;if (newY > 5 && (window.innerHeight - newY) > 150) this.aiBox.bottom = newY;document.getElementById('aiBox').style.bottom = this.aiBox.bottom + 'px';},stopDrag() {this.aiBox.isDragging = false;document.removeEventListener('mousemove', this.onDrag);document.removeEventListener('mouseup', this.stopDrag);},addComment() {this.connector.executeMethod("AddComment", [{"UserName": "John Smith","QuoteText": "text","Text": "要填寫的注釋內容","Time": "1662737941471","Solved": false,}], function (comment) {console.log(comment)});}}};
</script><style scoped>
body,
html {margin: 0;height: 100%;overflow: hidden;
}#container {display: flex;height: 100%;
}#onlyoffice {flex: 2;
}#sidebar {width: 350px;border-left: 1px solid #ddd;
}#aiBox {position: fixed;right: 0;bottom: 5px;width: 600px;height: 100%;z-index: 2000;border: 1px solid #ccc;background: #fff;box-shadow: 0 0 8px rgba(0, 0, 0, 0.3);
}#aiIframe {width: 70%;height: 100%;border: none;
}
</style>

連接器(connector)介紹

簡介

對于我們而言,很多情況下都是簡單的操作一下文檔,做一些和業務系統相關操作的功能,使用到:callCommand 、executeMethod、attachEvent、detachEvent這四個核心塊api模塊。

初始化
this.connector = this.docEditor.createConnector();
核心塊說明
  1. callCommand()
-   基礎api調用模塊,用于組合并執行復雜api或者自定義代碼。-  文檔鏈接:[https://api.onlyoffice.com/docs/plugin-and-macros/interacting-with-editors/overview/how-to-call-commands/](https://api.onlyoffice.com/docs/plugin-and-macros/interacting-with-editors/overview/how-to-call-commands/)
  • 示例
this.connector.callCommand(() => Api.GetDocument().GetText(), data => console.log(data));
  1. executeMethod()。

    • 直接執行某個api,它與callCommand的區別是:callCommand是自己寫代碼執行也就是執行function(){xxxxx}方法體,executeMethod執行的只是某一個方法。

    • 文檔鏈接:https://api.onlyoffice.com/docs/plugin-and-macros/interacting-with-editors/overview/how-to-call-methods/

  • 示例
this.connector.executeMethod("PasteText", ["要粘貼的內容"]);
  1. attachEvent、detachEvent
  • 綁定、解綁事件。
-  文檔在這:[https://api.onlyoffice.com/docs/plugin-and-macros/interacting-with-editors/overview/how-to-attach-events/](https://api.onlyoffice.com/docs/plugin-and-macros/interacting-with-editors/overview/how-to-attach-events/)-   示例
/**
* 綁定事件
*/
connector.attachEvent("onAddComment", function(){console.log("event: onAddComment");
});/**
* 解綁事件
*/
connector.detachEvent("onAddComment");

常用API

添加上下文菜單-addContextMenuItem
  1. 文檔鏈接

    • https://api.onlyoffice.com/zh-CN/docs/docs-api/usage-api/automation-api/
  • 代碼示例
connector.attachEvent("onContextMenuShow", (options) => {connector.addContextMenuItem([{text: "mainItem",onClick: () => {console.log("[CONTEXTMENUCLICK] menuSubItem1");},}]);
});
添加工具欄菜單-addToolbarMenuItem
  1. 文檔鏈接

    • https://api.onlyoffice.com/zh-CN/docs/docs-api/usage-api/automation-api/#addtoolbarmenuitem
  2. 代碼示例

connector.addToolbarMenuItem({tabs: [{text: "Connector",items: [{id: "toolConnector1",type: "button",text: "Meaning",hint: "Meaning",lockInViewMode: true,icons: "./icon.svg",items: [{id: "toolC1",text: "Text",data: "Hello",onClick: (data) => {console.log(`[TOOLBARMENUCLICK]: ${data}`);},},],},],},],
});
事件監聽-attachEvent
  1. 文檔鏈接

    • https://api.onlyoffice.com/zh-CN/docs/docs-api/usage-api/automation-api/#attachevent
  2. 代碼示例

connector.attachEvent("onChangeContentControl", (obj) => {console.log(`[EVENT] onChangeContentControl: ${JSON.stringify(obj)}`)
})
添加注釋-AddComment
  1. 文檔鏈接

    • https://api.onlyoffice.com/zh-CN/docs/plugin-and-macros/interacting-with-editors/text-document-api/Methods/AddComment/
  2. 代碼示例

addComment() {this.connector.executeMethod("AddComment", [{"UserName": "John Smith","QuoteText": "text","Text": "要填寫的注釋內容","Time": "1662737941471","Solved": false,}], function (comment) {console.log(comment)});}
獲取選中內容-GetSelectedContent
  1. 文檔鏈接

    • https://api.onlyoffice.com/zh-CN/docs/plugin-and-macros/interacting-with-editors/text-document-api/Methods/GetSelectedContent/
  2. 代碼示例


getSelection() {方法一:this.connector.executeMethod("GetSelectedText", [], selectedText => {console.log("已獲取選中文本", selectedText);});方法二:this.connector.executeMethod("GetSelectedText", [{"Numbering": false, "Math": false, "TableCellSeparator": '\n', "ParaSeparator": '\n', "TabSymbol": String.fromCharCode(9)}], function (data) {const sText = data;// ExecTypograf (sText);console.log(sText);});
},
獲取選擇類型-GetSelectionType
  1. 文檔鏈接

    • https://api.onlyoffice.com/zh-CN/docs/plugin-and-macros/interacting-with-editors/text-document-api/Methods/GetSelectionType/
  2. 代碼示例

getSelectionType() {this.connector.executeMethod("GetSelectionType", [], selectedType => {console.log("獲取選擇類型", selectedType);});
},
輸入文本-InputText
  1. 文檔鏈接

    • https://api.onlyoffice.com/zh-CN/docs/plugin-and-macros/interacting-with-editors/text-document-api/Methods/InputText/
  2. 代碼示例

  inputText() {this.connector.executeMethod("InputText", ["ONLYOFFICE Plugins", ""])},
粘貼文本-PasteText(如果當期有選中內容的話,實際是刪除并粘貼)
  1. 文檔鏈接

    • https://api.onlyoffice.com/zh-CN/docs/plugin-and-macros/interacting-with-editors/text-document-api/Methods/PasteText/
  2. 代碼示例

this.connector.executeMethod("PasteText", ["要粘貼的內容"]);
查找并替換文本-SearchAndReplace
  1. 文檔鏈接
  • https://api.onlyoffice.com/zh-CN/docs/plugin-and-macros/interacting-with-editors/text-document-api/Methods/SearchAndReplace/
  1. 代碼示例
searchAndReplace() {this.connector.executeMethod("SearchAndReplace", [{"searchString": "目標","replaceString": "R目標R","matchCase": true}]);},

AI交互

整體說明

ONLYOFFICE與AI助手的交互本質上是一個基于 “消息驅動” 的異步通信模型,其核心是 postMessage API。整個過程可以清晰地劃分為兩個主要階段:請求階段響應階段

整個交互流程可以概括為以下兩個核心階段:

第一階段:從編輯器到AI助手(發送請求)

此階段完成從用戶操作到AI接收處理任務的閉環。

  1. 用戶操作觸發

    • 用戶在ONLYOFFICE在線編輯器中選擇一段文本內容。

    • 用戶點擊編輯器菜單中集成的AI功能按鈕(例如:“內容優化”、“續寫”、“翻譯”、“添加注釋”等)。

  2. 集成頁面捕獲事件并組裝消息

    • 集成頁面(即嵌入編輯器的父頁面)監聽到來自編輯器的這個特定菜單點擊事件。

    • 集成頁面通過編輯器提供的API(如getSelectedText)獲取用戶當前選中的內容。

    • 集成頁面將操作事件類型(如:"analyzeText")和選中的內容組裝成一個結構化的消息對象。例如:

{"type": "ai-request", // 固定消息類型,表明這是一條AI請求"source":"onlyoffice", "data": {"action": "analyzeText",     // 具體的事件類型"selectedText": "這里是用戶選中的文本內容...","otherParams": {}     // 其他可能需要的參數}
}
  1. 發送消息至AI助手

    • 集成頁面通過 postMessage 方法,將該消息對象發送到AI助手(通常是一個獨立的、隱藏的或浮層的<iframe>窗口)。

    • 發送時指定AI助手窗口的源(origin),以確保安全。

 const iframe = document.getElementById("aiIframe");if (!iframe) return;iframe.contentWindow.postMessage({"type": "ai-request", // 固定消息類型,表明這是一條AI請求"source":"onlyoffice", "data": {"action": "analyzeText",     // 具體的事件類型"selectedText": "這里是用戶選中的文本內容...","otherParams": {}     // 其他可能需要的參數}}, "");

第二階段:從AI助手回編輯器(執行操作)

此階段完成從AI生成結果到編輯器內容更新的閉環。

  1. AI助手監聽并處理消息

    • AI助手窗口通過window.addEventListener('message', ...)持續監聽消息。

    • 接收到消息后,首先驗證消息來源的合法性,確保其來自集成的父頁面。

    • 解析消息內容,根據action字段判斷需要執行的具體AI任務(例如:調用“內容優化”的API)。

    • AI助手調用相應的后端AI服務接口,獲取生成的結果。

  2. 用戶確認與指令發送

    • AI助手將生成的結果展示給用戶(在它的UI界面中)。

    • 用戶查看結果后,點擊“替換”、“插入”或“取消”等按鈕。

    • 當用戶點擊“替換”時,AI助手會組裝一條響應消息。例如:


{"type": "ai-response", // 固定消息類型,表明這是一條AI請求"source":"ai-plugin", "data": {"action": "analyzeText",     // 具體的事件類型"content": "content","otherParams": {"sourceMessage":{源消息內容}}     // 其他可能需要的參數}
}
  1. 集成頁面接收并執行操作

    • 集成頁面監聽來自AI助手窗口的message事件。

    • 接收到響應消息后,同樣進行來源驗證和解析。

    • 根據解析出的

      • 替換(Replace):用 響應的content 替換當前選中的文本。

      • 插入(Insert):在光標處或選定位置插入響應的 content

      • 添加注釋(Comment):為選定文本或指定位置添加以響應的content為內容的注釋。

 window.addEventListener('message', (event) => {//進行事件,消息源,源數據的校驗
});

整體交互流程

整個交互過程可以概括為下圖所示的閉環流程:

UserEditor(ONLYOFFICE)Parent Page(集成頁面)AI Helper(AI助手 iframe)AI ServiceAI Helper1. 選擇文本并點擊AI菜單2. 觸發事件3. 獲取選中文本,組裝消息4. postMessage(請求)5. 調用API生成內容6. 返回結果7. 展示生成結果8. 點擊“替換”9. 組裝響應消息10. postMessage(響應)11. 調用編輯器API執行操作12. 更新文檔內容UserEditor(ONLYOFFICE)Parent Page(集成頁面)AI Helper(AI助手 iframe)AI ServiceAI Helper

核心特點:

  • 解耦設計:編輯器與AI功能模塊分離,通過標準API通信,易于開發和維護。

  • 安全通信:使用postMessage并嚴格驗證 origin,保障跨域通信安全。

  • 異步交互:所有操作均為非阻塞,保證用戶體驗流暢。

  • 可擴展性:只需定義新的type和對應的處理邏輯,即可輕松添加更多AI功能。

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/pingmian/95642.shtml
繁體地址,請注明出處:http://hk.pswp.cn/pingmian/95642.shtml
英文地址,請注明出處:http://en.pswp.cn/pingmian/95642.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

TypeScript 中 keyof、typeof 和 instanceof

在 TypeScript 開發中&#xff0c;keyof、typeof 和 instanceof 是核心的類型操作符和操作符&#xff0c;專門用于提升類型安全、代碼可讀性和維護性。1. keyof 操作符定義和用途&#xff1a;keyof 是一個類型操作符&#xff0c;用于獲取對象類型的所有鍵&#xff08;屬性名&am…

分布式專題——1.1 Redis單機、主從、哨兵、集群部署

1 Redis 部署 下面演示在 Linux 環境下部署 Redis7。 1.1 單機部署 1.1.1 檢查安裝 gcc 環境Redis 是由 C 語言編寫的&#xff0c;它的運行需要 C 環境&#xff0c;因此我們需要先安裝 gcc&#xff1b; # 關閉防?墻 systemctl stop firewalld.service # 查看防火墻狀態 firewa…

2025年滲透測試面試題總結-54(題目+回答)

安全領域各種資源&#xff0c;學習文檔&#xff0c;以及工具分享、前沿信息分享、POC、EXP分享。不定期分享各種好玩的項目及好用的工具&#xff0c;歡迎關注。1、SQL注入的防護方法有哪些&#xff1f; 2、永恒之藍的漏洞原理是什么&#xff1f;怎么做到的&#xff1f; 3、命令…

安卓學習 之 按鈕點擊事件

今天學習安卓應用中的按鈕點擊事件&#xff1a;總結下來在安卓應用中的Button注冊點擊事件的方法主要是以下4種方法&#xff0c;稍后會逐個介紹&#xff1a; 第一種方法&#xff1a;自定義內部類的方法 第二種方法&#xff1a;匿名內部類的方法 第三種方法&#xff1a;當前Acti…

鴻蒙NEXT主題設置指南:應用級與頁面級主題定制詳解

在鴻蒙應用開發中&#xff0c;靈活的主題設置能力是實現個性化用戶體驗的關鍵技術&#xff0c;HarmonyOS NEXT提供了強大而靈活的主題設置功能&#xff0c;讓開發者能夠輕松實現應用級和頁面級的主題定制。在當今追求個性化的時代&#xff0c;用戶希望應用能夠根據自己的喜好呈…

全球汽車氮化鎵技術市場規模將于2031年增長至180.5億美元,2025-2031年復合增長率達94.3%,由Infineon和Navitas驅動

全球汽車氮化鎵技術市場規模將于2031年增長至180.5億美元&#xff0c;2025-2031年復合增長率達94.3%&#xff0c;由Infineon和Navitas驅動汽車氮化鎵技術正從一個有前景的細分市場加速進入主流電力電子領域。根據QYResearch&#xff08;恒州博智&#xff09;的《全球汽車GaN技術…

xftp斷網后提示錯誤如何繼續下載?

問題&#xff1a;xftp斷網后提示錯誤如何繼續下載&#xff1f;解決方法&#xff1a;斷網后&#xff0c;先連接上網&#xff0c;然后繼續雙擊右側的那兩個要傳輸的文件&#xff0c;然后會彈出一個覆蓋還是繼續下載&#xff08;如下圖&#xff09;的選擇框&#xff0c;選擇繼續下…

Day22_【機器學習—集成學習(4)—Boosting—GBDT算法】

提升樹 &#xff08;Boosting Decision Tree &#xff09;每一個弱學習器通過擬合殘差來構建強學習器梯度提升樹 &#xff08;Gradient Boosting Decision Tree&#xff09;每一個弱學習器通過擬合負梯度來構建強學習器一、提升樹殘差數學公式為&#xff1a;殘差真實值?預測值…

前綴和、子矩陣的和;差分、差分矩陣

一、前綴和數組要稍微注意前綴和數組從1開始#include <iostream>using namespace std;const int N 100010;int n, m; int a[N], s[N];int main() {scanf("%d%d", &n, &m);for (int i 1; i < n; i ) scanf("%d", &a[i]);for (int i…

啟用BBR擁塞控制算法

目錄 &#x1f4cb; 先決條件 &#x1f527; 啟用步驟 &#x1f4dd; 額外檢查與說明 ?? 注意事項 BBR&#xff08;Bottleneck Bandwidth and Round-trip time&#xff09;是谷歌開發的一種TCP擁塞控制算法&#xff0c;它能有效提升網絡傳輸速度和性能&#xff0c;尤其在…

Python:AI開發第一語言的全面剖析

文章目錄引言1. Python的歷史與AI開發的契合1.1 Python的誕生與設計哲學1.2 Python與AI發展的歷史交匯2. 語言特性如何支持AI開發2.1 動態類型與交互式編程2.2 簡潔優雅的語法2.3 高級數據結構的原生支持2.4 函數式編程特性2.5 強大的元編程能力3. 豐富的AI生態系統和庫支持3.1…

Nikto 漏洞掃描工具使用指南

目錄 ? 核心功能一覽 &#x1f680; 基本使用方法 1. 掃描單個目標 2. 指定端口掃描 3. 掃描 HTTPS 目標 使用 -ssl 參數主要有兩個核心原因 ?? 高級使用技巧 1. 使用代理掃描 2. 保存掃描結果 3. 使用特定插件 4.交互命令 ? 核心功能一覽 Nikto 是一款開源的 W…

FunASR的Java實現Paraformer實時語音識別 | 一款無需聯網的本地實時字幕軟件

0. 開發背景 我們在看直播時&#xff0c;沒有視頻字幕&#xff0c;可能看慣了視頻字幕&#xff0c;來到直播中缺少字幕會感覺不習慣&#xff0c;特別是對于聽力障礙的人群&#xff0c;只能依賴于字幕&#xff0c;那么這個軟件可以解決直播&#xff0c;在線會議等場景中無字幕的…

從機器學習的角度實現 excel 中趨勢線:揭秘梯度下降過程

1. 引言&#xff1a;Excel 的“一鍵魔法”背后藏著什么智慧&#xff1f;在 Excel 中&#xff0c;我們只需右鍵 → 添加趨勢線&#xff0c;一條完美的直線就出現了。它快得像魔法&#xff0c;但魔法背后&#xff0c;是數學的嚴謹。今天&#xff0c;我們不關心 Excel 內部用了什么…

關于上拉電阻

上拉電阻的作用&#xff1a;輔助浮空狀態輸出高電平 其實就是確定這根線的電平&#xff0c;不能讓他處于一種未知的狀態。 其次也可以起到限制電流的作用&#xff0c;防止損壞原件 那么上拉電阻如何取值&#xff1f; 首先來看一下驅動能力。 因為線上是一定有寄生電容的&am…

PiscCode構建Mediapipe 手勢識別“剪刀石頭布”小游戲

在計算機視覺與人機交互領域&#xff0c;手勢識別是一個非常有趣的應用場景。本文將帶你用 Mediapipe 和 Python 實現一個基于攝像頭的手勢識別“剪刀石頭布”小游戲&#xff0c;并展示實時手勢與游戲結果。 1. 項目概述 該小游戲能夠實現&#xff1a; 實時檢測手勢&#xff0…

【VoNR】VoNR 不等于 VoLTE on 5G

博主未授權任何人或組織機構轉載博主任何原創文章&#xff0c;感謝各位對原創的支持&#xff01; 博主鏈接 本人就職于國際知名終端廠商&#xff0c;負責modem芯片研發。 在5G早期負責終端數據業務層、核心網相關的開發工作&#xff0c;目前牽頭6G技術研究。 博客內容主要圍繞…

計算機網絡:網絡設備在OSI七層模型中的工作層次和傳輸協議

OSI七層模型&#xff08;物理層、數據鏈路層、網絡層、傳輸層、會話層、表示層、應用層&#xff09;中&#xff0c;不同網絡設備因功能不同&#xff0c;工作在不同層次。以下是典型網絡設備的工作層次及核心功能&#xff1a;1. 物理層&#xff08;第1層&#xff09; 核心功能&a…

RSA-e和phi不互素

1.題目import gmpy2 import libnum p 1656713884642828937525841253265560295123546793973683682208576533764344166170780019002774068042673556637515136828403375582169041170690082676778939857272304925933251736030429644277439899845034340194709105071151095131704526…

基于單片機蒸汽壓力檢測/蒸汽余熱回收

傳送門 &#x1f449;&#x1f449;&#x1f449;&#x1f449;單片機作品題目速選一覽表&#x1f680; &#x1f449;&#x1f449;&#x1f449;&#x1f449;單片機作品題目功能速覽&#x1f680; &#x1f525;更多文章戳&#x1f449;小新單片機-CSDN博客&#x1f68…