久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

我們如何才能只使用特定路徑的 electron.protocol.

How can we use electron.protocol.interceptFileProtocol with only certain paths, leaving other requests untouched?(我們如何才能只使用特定路徑的 electron.protocol.interceptFileProtocol ,而不影響其他請求?) - IT屋-程序員
本文介紹了我們如何才能只使用特定路徑的 electron.protocol.interceptFileProtocol ,而不影響其他請求?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我想攔截某些 HTTP 請求并將它們替換為文件.所以我想我可以像這樣使用 electron.protocol.interceptFileProtocol :

I'd like to intercept certain HTTP requests and replace them with files. So I thought I could use electron.protocol.interceptFileProtocol like so:

protocol.interceptFileProtocol('http', (request, callback) => {
  // intercept only requests to "http://example.com"
  if (request.url.startsWith("http://example.com")) {
    callback("/path/to/file")
  }

  // otherwise, let the HTTP request behave like normal.
  // But how?
})

我們如何允許除 http://example.com 之外的其他 http 請求繼續正常工作?

How do we allow other http requests other than http://example.com to continue working as normal?

推薦答案

在使用 protocol.interceptXXXXProtocol(scheme, handler) 時,我們正在攔截方案協議,并使用 handler 作為協議的新處理程序,發送一個新的 XXXX 請求作為響應,如 在此處的文檔中所述.

When using protocol.interceptXXXXProtocol(scheme, handler), we are intercepting scheme protocol and uses handler as the protocol’s new handler which sends a new XXXX request as a response, as said in the doc here.

但是,這樣做完全破壞了這個特定協議的初始處理程序,我們在處理回調執行后需要它.因此,我們只需要將它恢復到初始狀態,它就可以繼續正常工作:)

However, doing so totally breaks the initial handler for this specific protocol, which we would need after handling the callback execution. Thus, we just need to restore it back to its initial state, so that it can continue working as normal :)

讓我們使用:protocol.uninterceptProptocol(scheme)

protocol.interceptFileProtocol('http', (request, callback) => {
  // intercept only requests to "http://example.com"
  if (request.url.startsWith("http://example.com")) {
    callback("/path/to/file")
  }

  // otherwise, let the HTTP request behave like normal.
  protocol.uninterceptProtocol('http');
})

這篇關于我們如何才能只使用特定路徑的 electron.protocol.interceptFileProtocol ,而不影響其他請求?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How to fix BrowserWindow is not a constructor error when creating child window in Electron renderer process(在 Electron 渲染器進程中創建子窗口時如何修復 BrowserWindow 不是構造函數錯誤) - IT屋-程序員軟件開發技術
mainWindow.loadURL(quot;https://localhost:3000/quot;) show white screen on Electron app(mainWindow.loadURL(https://localhost:3000/) 在 Electron 應用程序上顯示白屏)
Electron webContents executeJavaScript : Cannot execute script on second on loadURL(Electron webContents executeJavaScript:無法在第二個 loadURL 上執行腳本)
how to use electron browser window inside components in angular-cli?(如何在angular-cli的組件內使用電子瀏覽器窗口?)
ElectronJS - sharing redux store between windows?(ElectronJS - 在 Windows 之間共享 redux 存儲?)
How to access camera/webcamera inside electron app?(如何在電子應用程序中訪問相機/網絡攝像頭?)
主站蜘蛛池模板: www亚洲精品 | 久久久91精品国产一区二区三区 | 久久久精品影院 | 免费黄色a级毛片 | 夜夜久久| 狠狠夜夜 | 免费观看av | 日韩一区二区三区在线观看 | 激情五月综合 | 天天操人人干 | av黄色片在线观看 | 国产三级在线观看播放 | 欧美一区二区三区免费在线观看 | 久久亚洲一区二区三 | 韩国毛片一区二区三区 | 野狼在线社区2017入口 | 成人国产免费视频 | 久久99蜜桃综合影院免费观看 | 人人澡人人爱 | 欧美视频免费在线 | 麻豆精品国产91久久久久久 | 国产精品久久久久永久免费观看 | 在线看一区二区 | 欧美一级在线观看 | 色888www视频在线观看 | 日韩午夜在线观看 | 99久久精品国产毛片 | 国产 欧美 日韩 一区 | a在线免费观看视频 | 日本精品视频一区二区 | 国产精品国产精品 | 蜜桃日韩 | 91午夜在线 | 国产免费福利在线 | 一级黄色片在线看 | 青久草视频 | 欧美videosex性极品hd | 最新国产福利在线 | 黄色免费网址大全 | 777777777亚洲妇女 | 91精品福利 |