問題描述
在 Mac 中打開 Electron 應用程序時出錯:“file:///Applications/../Contents/Resources/app.asar/dist/index.html” (Error in Opening Electron App in Mac:"file:///Applications/../Contents/Resources/app.asar/dist/index.html")
我已經為 mac 構建了電子應用程序,但是當我運行它時,它給出了以下錯誤
“不允許加載本地資源:file:///Applications/e‑admin.app /Contents/Resources/app.asar/dist/index.html"。
這是我做的步驟。
1) electron‑builder build ‑‑mac 它創建了以下文件是 dist 文件夾。a) e‑admin‑0.0.0.dmg , e‑admin‑0.0.0‑mac.zip,index.html 和一個 mac 文件夾 b) 在 mac 文件夾中我可以看到 mac/e‑admin.app/Contents/Resources /app.asar 文件(不是文件夾)
2)我雙擊並安裝了 e‑admin‑0.0.0.dmg 並移至應用程序文件夾。3) 打開應用程序。
我必須對 app.asar 文件做任何事情嗎?(解壓縮或做一些事情?)或任何其他程序才能使其工作?
我的包.json
參考解法
方法 1:
After muiltple trial and error, The following changes worked for me
1) index.html
`<base href="/">`
to
<base href="./">
2) in main.ts, change the directory name dist to something else
from :
win.loadURL(url.format({
pathname: path.join(__dirname, 'dist/index.html'),
protocol: 'file:',
slashes: true
}));
To:
win.loadURL(url.format({
pathname: path.join(__dirname, 'angular_build/index.html'),
protocol: 'file:',
slashes: true
}));
3) Angular.js
"outputPath": "dist/",
to
"outputPath": "angular_build/",
Although I have seen suggesions to change step 2 & 3 , I was quite skepitcal. Looks like dist directlory some how does not work and have to change to some thing like as mentioned above
(by Raghu Vallikkat、Raghu Vallikkat)