fix: windows file path (#3003)
* fix: tray menu * fix: file path in windows
This commit is contained in:
parent
e56505011c
commit
eda72ab5a4
|
|
@ -1,5 +1,3 @@
|
|||
import url from "node:url"
|
||||
|
||||
import { electronApp, optimizer } from "@electron-toolkit/utils"
|
||||
import { callWindowExpose } from "@follow/shared/bridge"
|
||||
import { APP_PROTOCOL } from "@follow/shared/constants"
|
||||
|
|
@ -77,7 +75,7 @@ function bootstrap() {
|
|||
protocol.handle("app", (request) => {
|
||||
try {
|
||||
const urlObj = new URL(request.url)
|
||||
return net.fetch(url.pathToFileURL(urlObj.pathname).toString())
|
||||
return net.fetch(`file://${urlObj.pathname}`)
|
||||
} catch {
|
||||
logger.error("app protocol error", request.url)
|
||||
return new Response("Not found", { status: 404 })
|
||||
|
|
|
|||
|
|
@ -32,12 +32,22 @@ export const registerAppTray = () => {
|
|||
click: showWindow,
|
||||
},
|
||||
{
|
||||
role: "help",
|
||||
label: t("menu.help"),
|
||||
submenu: [
|
||||
{ role: "reload", label: t("menu.reload") },
|
||||
{ role: "forceReload", label: t("menu.forceReload") },
|
||||
{ role: "toggleDevTools", label: t("menu.toggleDevTools") },
|
||||
{
|
||||
label: t("menu.reload"),
|
||||
click: () => {
|
||||
const mainWindow = getMainWindowOrCreate()
|
||||
mainWindow.webContents.reload()
|
||||
},
|
||||
},
|
||||
{
|
||||
label: t("menu.toggleDevTools"),
|
||||
click: () => {
|
||||
const mainWindow = getMainWindowOrCreate()
|
||||
mainWindow.webContents.toggleDevTools()
|
||||
},
|
||||
},
|
||||
{
|
||||
label: t("menu.openLogFile"),
|
||||
click: async () => {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import path from "node:path"
|
||||
import { fileURLToPath } from "node:url"
|
||||
import { fileURLToPath, pathToFileURL } from "node:url"
|
||||
|
||||
import { is } from "@electron-toolkit/utils"
|
||||
import { APP_PROTOCOL } from "@follow/shared"
|
||||
|
|
@ -150,7 +150,8 @@ export function createWindow(
|
|||
const dynamicRenderEntry = loadDynamicRenderEntry()
|
||||
logger.info("load dynamic render entry", dynamicRenderEntry)
|
||||
const appLoadFileEntry = dynamicRenderEntry || path.resolve(__dirname, "../renderer/index.html")
|
||||
const appLoadEntry = `app://follow.is${appLoadFileEntry}${options?.extraPath || ""}`
|
||||
|
||||
const appLoadEntry = `app://follow.is${pathToFileURL(appLoadFileEntry).pathname}${options?.extraPath || ""}`
|
||||
|
||||
window.loadURL(appLoadEntry)
|
||||
logger.log("load URL", appLoadEntry)
|
||||
|
|
|
|||
Loading…
Reference in New Issue