Skip to content

Commit eda72ab

Browse files
authored
fix: windows file path (#3003)
* fix: tray menu * fix: file path in windows
1 parent e565050 commit eda72ab

File tree

3 files changed

+18
-9
lines changed

3 files changed

+18
-9
lines changed

apps/desktop/src/main/src/index.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import url from "node:url"
2-
31
import { electronApp, optimizer } from "@electron-toolkit/utils"
42
import { callWindowExpose } from "@follow/shared/bridge"
53
import { APP_PROTOCOL } from "@follow/shared/constants"
@@ -77,7 +75,7 @@ function bootstrap() {
7775
protocol.handle("app", (request) => {
7876
try {
7977
const urlObj = new URL(request.url)
80-
return net.fetch(url.pathToFileURL(urlObj.pathname).toString())
78+
return net.fetch(`file://${urlObj.pathname}`)
8179
} catch {
8280
logger.error("app protocol error", request.url)
8381
return new Response("Not found", { status: 404 })

apps/desktop/src/main/src/lib/tray.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,22 @@ export const registerAppTray = () => {
3232
click: showWindow,
3333
},
3434
{
35-
role: "help",
3635
label: t("menu.help"),
3736
submenu: [
38-
{ role: "reload", label: t("menu.reload") },
39-
{ role: "forceReload", label: t("menu.forceReload") },
40-
{ role: "toggleDevTools", label: t("menu.toggleDevTools") },
37+
{
38+
label: t("menu.reload"),
39+
click: () => {
40+
const mainWindow = getMainWindowOrCreate()
41+
mainWindow.webContents.reload()
42+
},
43+
},
44+
{
45+
label: t("menu.toggleDevTools"),
46+
click: () => {
47+
const mainWindow = getMainWindowOrCreate()
48+
mainWindow.webContents.toggleDevTools()
49+
},
50+
},
4151
{
4252
label: t("menu.openLogFile"),
4353
click: async () => {

apps/desktop/src/main/src/window.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import path from "node:path"
2-
import { fileURLToPath } from "node:url"
2+
import { fileURLToPath, pathToFileURL } from "node:url"
33

44
import { is } from "@electron-toolkit/utils"
55
import { APP_PROTOCOL } from "@follow/shared"
@@ -150,7 +150,8 @@ export function createWindow(
150150
const dynamicRenderEntry = loadDynamicRenderEntry()
151151
logger.info("load dynamic render entry", dynamicRenderEntry)
152152
const appLoadFileEntry = dynamicRenderEntry || path.resolve(__dirname, "../renderer/index.html")
153-
const appLoadEntry = `app://follow.is${appLoadFileEntry}${options?.extraPath || ""}`
153+
154+
const appLoadEntry = `app://follow.is${pathToFileURL(appLoadFileEntry).pathname}${options?.extraPath || ""}`
154155

155156
window.loadURL(appLoadEntry)
156157
logger.log("load URL", appLoadEntry)

0 commit comments

Comments
 (0)