Skip to content

Commit 228fad9

Browse files
committed
chore: movable about window & reload withou cache
1 parent 68ca427 commit 228fad9

File tree

3 files changed

+28
-9
lines changed

3 files changed

+28
-9
lines changed

electron/main/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ app.whenReady().then(() => {
112112
winAbout = new BrowserWindow({
113113
// alwaysOnTop: true,
114114
autoHideMenuBar: true,
115-
movable: false,
116115
minimizable: false,
117116
maximizable: false,
118117
resizable: false,

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vocechat-desktop",
3-
"version": "0.7.12",
3+
"version": "0.7.13",
44
"main": "dist-electron/main/index.js",
55
"description": "vocechat desktop version",
66
"author": "Tristan <yanggc888@163.com>",

src/components/layout.tsx

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import TitleBar from "./titlebar";
2424
const Layout = () => {
2525
const [removeServer, setRemoveServer] = useState<undefined | string>();
2626
const [reloadVisible, setReloadVisible] = useState(false);
27+
const [reloading, setReloading] = useState(false);
2728
const [menuVisibleMap, setMenuVisibleMap] = useState<Record<string, boolean>>({});
2829
const { servers, active, addModalVisible } = useAppSelector((store) => store.data);
2930
const dispatch = useDispatch();
@@ -33,6 +34,18 @@ const Layout = () => {
3334
} else {
3435
const webviews = [...document.querySelectorAll("webview")] as WebviewTag[];
3536
webviews.forEach((webview) => {
37+
webview.addEventListener("did-finish-load", () => {
38+
if (webview.dataset?.visible == "true") {
39+
console.log("load finish reloading false", webview.src);
40+
setReloading(false);
41+
}
42+
});
43+
webview.addEventListener("did-fail-load", () => {
44+
if (webview.dataset?.visible == "true") {
45+
console.log("load fail reloading false", webview.src);
46+
setReloading(false);
47+
}
48+
});
3649
webview.addEventListener("dom-ready", () => {
3750
const url = webview.dataset.src;
3851
console.log(`${url} dom-ready`);
@@ -61,8 +74,10 @@ const Layout = () => {
6174
};
6275
const handleReload = () => {
6376
const wv = document.querySelector("webview[data-visible='true']") as WebviewTag;
64-
if (wv && wv.dataset.src) {
65-
wv.loadURL(wv.dataset.src);
77+
if (wv) {
78+
wv.reloadIgnoringCache();
79+
setReloading(true);
80+
// wv.loadURL(wv.dataset.src);
6681
}
6782
};
6883
const handleOpenWebviewDevTools = () => {
@@ -204,18 +219,23 @@ const Layout = () => {
204219
</ServerTip>
205220
<div className="my-1 h-[1px] w-9 bg-gray-300/50"></div>
206221
<ServerTip content={"Refresh page"}>
207-
<div
208-
role="button"
222+
<button
223+
disabled={reloading}
209224
onClick={handleReload}
210225
className="app-no-drag group flex h-9 w-9 cursor-pointer items-center justify-center rounded hover:bg-gray-500/50"
211226
>
212-
<IconRefresh className="outline-none group-hover:stroke-white" />
213-
</div>
227+
<IconRefresh
228+
className={clsx(
229+
"outline-none group-hover:stroke-white",
230+
reloading ? "animate-spin opacity-80" : ""
231+
)}
232+
/>
233+
</button>
214234
</ServerTip>
215235
<button
216236
title="Open DevTools"
217237
onClick={handleOpenWebviewDevTools}
218-
className="app-no-drag group absolute bottom-2 left-4 flex h-9 w-9 cursor-pointer items-center justify-center rounded hover:bg-gray-500/50"
238+
className="app-no-drag group absolute bottom-4 left-4 flex h-9 w-9 cursor-pointer items-center justify-center rounded hover:bg-gray-500/50"
219239
>
220240
<IconDebug className="invisible outline-none group-hover:visible group-hover:stroke-white" />
221241
</button>

0 commit comments

Comments
 (0)