Skip to content

Commit 9d92722

Browse files
feat: 优化用户跳转体验
1 parent 6308ae7 commit 9d92722

File tree

1 file changed

+81
-60
lines changed

1 file changed

+81
-60
lines changed

main.js

Lines changed: 81 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -109,19 +109,27 @@ const work = () => {
109109
if (isDev) {
110110
todoWindow.loadURL("http://localhost:5173/#/desktop/customtodo");
111111
} else {
112-
// 生产模式:加载打包后的 index.html 文件,并通过哈希路由导航到特定页面
113-
todoWindow
114-
.loadFile(path.join(__dirname, "dist", "index.html"))
115-
.then(() => {
116-
// 导航到特定路由
117-
todoWindow.loadURL(
118-
`file://${path.join(
119-
__dirname,
120-
"dist",
121-
"index.html"
122-
)}#/desktop/customtodo`
123-
);
124-
});
112+
// // 生产模式:加载打包后的 index.html 文件,并通过哈希路由导航到特定页面
113+
// todoWindow
114+
// .loadFile(path.join(__dirname, "dist", "index.html"))
115+
// .then(() => {
116+
// // 导航到特定路由
117+
// todoWindow.loadURL(
118+
// `file://${path.join(
119+
// __dirname,
120+
// "dist",
121+
// "index.html"
122+
// )}#/desktop/customtodo`
123+
// );
124+
// });
125+
// 导航到特定路由
126+
todoWindow.loadURL(
127+
`file://${path.join(
128+
__dirname,
129+
"dist",
130+
"index.html"
131+
)}#/desktop/customtodo`
132+
);
125133
}
126134

127135
// 等待加载完成以后并且延迟500ms发送消息
@@ -168,20 +176,20 @@ const work = () => {
168176
if (isDev) {
169177
timerWindow.loadURL("http://localhost:5173/#/fullscreen/timer");
170178
} else {
171-
timerWindow
172-
.loadFile(path.join(__dirname, "dist", "index.html"))
173-
.then(() => {
174-
timerWindow.loadURL(
175-
`file://${path.join(
176-
__dirname,
177-
"dist",
178-
"index.html"
179-
)}#/fullscreen/timer`
180-
);
181-
});
182-
// timerWindow.loadURL(
183-
// `file://${path.join(__dirname, "dist", "index.html")}#/fullscreen/timer`
184-
// );
179+
// timerWindow
180+
// .loadFile(path.join(__dirname, "dist", "index.html"))
181+
// .then(() => {
182+
// timerWindow.loadURL(
183+
// `file://${path.join(
184+
// __dirname,
185+
// "dist",
186+
// "index.html"
187+
// )}#/fullscreen/timer`
188+
// );
189+
// });
190+
timerWindow.loadURL(
191+
`file://${path.join(__dirname, "dist", "index.html")}#/fullscreen/timer`
192+
);
185193
}
186194
timerWindow.on("closed", () => {
187195
timerWindow = null;
@@ -209,17 +217,20 @@ const work = () => {
209217
if (isDev) {
210218
timerWidgetWindow.loadURL("http://localhost:5173/#/desktop/timer");
211219
} else {
212-
timerWidgetWindow
213-
.loadFile(path.join(__dirname, "dist", "index.html"))
214-
.then(() => {
215-
timerWidgetWindow.loadURL(
216-
`file://${path.join(
217-
__dirname,
218-
"dist",
219-
"index.html"
220-
)}#/desktop/timer`
221-
);
222-
});
220+
// timerWidgetWindow
221+
// .loadFile(path.join(__dirname, "dist", "index.html"))
222+
// .then(() => {
223+
// timerWidgetWindow.loadURL(
224+
// `file://${path.join(
225+
// __dirname,
226+
// "dist",
227+
// "index.html"
228+
// )}#/desktop/timer`
229+
// );
230+
// });
231+
timerWidgetWindow.loadURL(
232+
`file://${path.join(__dirname, "dist", "index.html")}#/desktop/timer`
233+
);
223234
}
224235
timerWidgetWindow.on("closed", () => {
225236
timerWidgetWindow = null;
@@ -256,17 +267,24 @@ const work = () => {
256267
if (isDev) {
257268
pomodoroWindow.loadURL("http://localhost:5173/#/fullscreen/pomodoro");
258269
} else {
259-
pomodoroWindow
260-
.loadFile(path.join(__dirname, "dist", "index.html"))
261-
.then(() => {
262-
pomodoroWindow.loadURL(
263-
`file://${path.join(
264-
__dirname,
265-
"dist",
266-
"index.html"
267-
)}#/fullscreen/pomodoro`
268-
);
269-
});
270+
// pomodoroWindow
271+
// .loadFile(path.join(__dirname, "dist", "index.html"))
272+
// .then(() => {
273+
// pomodoroWindow.loadURL(
274+
// `file://${path.join(
275+
// __dirname,
276+
// "dist",
277+
// "index.html"
278+
// )}#/fullscreen/pomodoro`
279+
// );
280+
// });
281+
pomodoroWindow.loadURL(
282+
`file://${path.join(
283+
__dirname,
284+
"dist",
285+
"index.html"
286+
)}#/fullscreen/pomodoro`
287+
);
270288
} // 清除窗口状态
271289
pomodoroWindow.on("closed", () => {
272290
pomodoroWindow = null;
@@ -294,17 +312,20 @@ const work = () => {
294312
if (isDev) {
295313
pomodoroWidgetWindow.loadURL("http://localhost:5173/#/desktop/pomodoro");
296314
} else {
297-
pomodoroWidgetWindow
298-
.loadFile(path.join(__dirname, "dist", "index.html"))
299-
.then(() => {
300-
pomodoroWidgetWindow.loadURL(
301-
`file://${path.join(
302-
__dirname,
303-
"dist",
304-
"index.html"
305-
)}#/desktop/pomodoro`
306-
);
307-
});
315+
// pomodoroWidgetWindow
316+
// .loadFile(path.join(__dirname, "dist", "index.html"))
317+
// .then(() => {
318+
// pomodoroWidgetWindow.loadURL(
319+
// `file://${path.join(
320+
// __dirname,
321+
// "dist",
322+
// "index.html"
323+
// )}#/desktop/pomodoro`
324+
// );
325+
// });
326+
pomodoroWidgetWindow.loadURL(
327+
`file://${path.join(__dirname, "dist", "index.html")}#/desktop/pomodoro`
328+
);
308329
} // 清除窗口状态
309330
pomodoroWidgetWindow.on("closed", () => {
310331
pomodoroWidgetWindow = null;

0 commit comments

Comments
 (0)