<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                # 協議 `protocol` 模塊可以注冊一個自定義協議,或者使用一個已經存在的協議. 例子,使用一個與 `file://` 功能相似的協議 : ```javascript const electron = require('electron'); const app = electron.app; const path = require('path'); app.on('ready', function() { var protocol = electron.protocol; protocol.registerFileProtocol('atom', function(request, callback) { var url = request.url.substr(7); callback({path: path.normalize(__dirname + '/' + url)}); }, function (error) { if (error) console.error('Failed to register protocol') }); }); ``` **注意:** 這個模塊只有在 `app` 模塊的 `ready` 事件觸發之后才可使用. ## 方法 `protocol` 模塊有如下方法: ### `protocol.registerStandardSchemes(schemes)` * `schemes` Array - 將一個自定義的方案注冊為標準的方案. 一個標準的 `scheme` 遵循 RFC 3986 的 [generic URI syntax](https://tools.ietf.org/html/rfc3986#section-3) 標準. 這包含了 `file:` 和 `filesystem:`. ### `protocol.registerServiceWorkerSchemes(schemes)` * `schemes` Array - 將一個自定義的方案注冊為處理 service workers. ### `protocol.registerFileProtocol(scheme, handler[, completion])` * `scheme` String * `handler` Function * `completion` Function (可選) 注冊一個協議,用來發送響應文件.當通過這個協議來發起一個請求的時候,將使用 `handler(request, callback)` 來調用 `handler` .當 `scheme` 被成功注冊或者完成(錯誤)時失敗,將使用 `completion(null)` 調用 `completion`. * `request` Object * `url` String * `referrer` String * `method` String * `uploadData` Array (可選) * `callback` Function `uploadData` 是一個 `data` 對象數組: * `data` Object * `bytes` Buffer - 被發送的內容. * `file` String - 上傳的文件路徑. 為了處理請求,調用 `callback` 時需要使用文件路徑或者一個帶 `path` 參數的對象, 例如 `callback(filePath)` 或 `callback({path: filePath})`. 當不使用任何參數調用 `callback` 時,你可以指定一個數字或一個帶有 `error` 參數的對象,來標識 `request` 失敗.你可以使用的 error number 可以參考 [net error list][net-error]. 默認 `scheme` 會被注冊為一個 `http:` 協議,它與遵循 "generic URI syntax" 規則的協議解析不同,例如 `file:` ,所以你或許應該調用 `protocol.registerStandardSchemes` 來創建一個標準的 scheme. ### `protocol.registerBufferProtocol(scheme, handler[, completion])` * `scheme` String * `handler` Function * `completion` Function (可選) 注冊一個 `scheme` 協議,用來發送響應 `Buffer` . 這個方法的用法類似 `registerFileProtocol`,除非使用一個 `Buffer` 對象,或一個有 `data`, `mimeType`, 和 `charset` 屬性的對象來調用 `callback` . 例子: ```javascript protocol.registerBufferProtocol('atom', function(request, callback) { callback({mimeType: 'text/html', data: new Buffer('<h5>Response</h5>')}); }, function (error) { if (error) console.error('Failed to register protocol') }); ``` ### `protocol.registerStringProtocol(scheme, handler[, completion])` * `scheme` String * `handler` Function * `completion` Function (可選) 注冊一個 `scheme` 協議,用來發送響應 `String` . 這個方法的用法類似 `registerFileProtocol`,除非使用一個 `String` 對象,或一個有 `data`, `mimeType`, 和 `charset` 屬性的對象來調用 `callback` . ### `protocol.registerHttpProtocol(scheme, handler[, completion])` * `scheme` String * `handler` Function * `completion` Function (可選) 注冊一個 `scheme` 協議,用來發送 HTTP 請求作為響應. 這個方法的用法類似 `registerFileProtocol`,除非使用一個 `redirectRequest` 對象,或一個有 `url`, `method`, `referrer`, `uploadData` 和 `session` 屬性的對象來調用 `callback` . * `redirectRequest` Object * `url` String * `method` String * `session` Object (可選) * `uploadData` Object (可選) 默認這個 HTTP 請求會使用當前 session .如果你想使用不同的session值,你應該設置 `session` 為 `null`. POST 請求應當包含 `uploadData` 對象. * `uploadData` object * `contentType` String - 內容的 MIME type. * `data` String - 被發送的內容. ### `protocol.unregisterProtocol(scheme[, completion])` * `scheme` String * `completion` Function (可選) 注銷自定義協議 `scheme`. ### `protocol.isProtocolHandled(scheme, callback)` * `scheme` String * `callback` Function 將使用一個布爾值來調用 `callback` ,這個布爾值標識了是否已經存在 `scheme` 的句柄了. ### `protocol.interceptFileProtocol(scheme, handler[, completion])` * `scheme` String * `handler` Function * `completion` Function (可選) 攔截 `scheme` 協議并且使用 `handler` 作為協議的新的句柄來發送響應文件. ### `protocol.interceptStringProtocol(scheme, handler[, completion])` * `scheme` String * `handler` Function * `completion` Function (可選) 攔截 `scheme` 協議并且使用 `handler` 作為協議的新的句柄來發送響應 `String`. ### `protocol.interceptBufferProtocol(scheme, handler[, completion])` * `scheme` String * `handler` Function * `completion` Function (可選) 攔截 `scheme` 協議并且使用 `handler` 作為協議的新的句柄來發送響應 `Buffer`. ### `protocol.interceptHttpProtocol(scheme, handler[, completion])` * `scheme` String * `handler` Function * `completion` Function (optional) 攔截 `scheme` 協議并且使用 `handler` 作為協議的新的句柄來發送新的響應 HTTP 請求. Intercepts `scheme` protocol and uses `handler` as the protocol's new handler which sends a new HTTP request as a response. ### `protocol.uninterceptProtocol(scheme[, completion])` * `scheme` String * `completion` Function 取消對 `scheme` 的攔截,使用它的原始句柄進行處理. [net-error]: https://code.google.com/p/chromium/codesearch#chromium/src/net/base/net_error_list.h
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看