Skip to content

Commit

Permalink
chore: movable about window & reload withou cache
Browse files Browse the repository at this point in the history
  • Loading branch information
zerosoul committed Aug 10, 2023
1 parent 68ca427 commit 228fad9
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 9 deletions.
1 change: 0 additions & 1 deletion electron/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ app.whenReady().then(() => {
winAbout = new BrowserWindow({
// alwaysOnTop: true,
autoHideMenuBar: true,
movable: false,
minimizable: false,
maximizable: false,
resizable: false,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vocechat-desktop",
"version": "0.7.12",
"version": "0.7.13",
"main": "dist-electron/main/index.js",
"description": "vocechat desktop version",
"author": "Tristan <yanggc888@163.com>",
Expand Down
34 changes: 27 additions & 7 deletions src/components/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import TitleBar from "./titlebar";
const Layout = () => {
const [removeServer, setRemoveServer] = useState<undefined | string>();
const [reloadVisible, setReloadVisible] = useState(false);
const [reloading, setReloading] = useState(false);
const [menuVisibleMap, setMenuVisibleMap] = useState<Record<string, boolean>>({});
const { servers, active, addModalVisible } = useAppSelector((store) => store.data);
const dispatch = useDispatch();
Expand All @@ -33,6 +34,18 @@ const Layout = () => {
} else {
const webviews = [...document.querySelectorAll("webview")] as WebviewTag[];
webviews.forEach((webview) => {
webview.addEventListener("did-finish-load", () => {
if (webview.dataset?.visible == "true") {
console.log("load finish reloading false", webview.src);
setReloading(false);
}
});
webview.addEventListener("did-fail-load", () => {
if (webview.dataset?.visible == "true") {
console.log("load fail reloading false", webview.src);
setReloading(false);
}
});
webview.addEventListener("dom-ready", () => {
const url = webview.dataset.src;
console.log(`${url} dom-ready`);
Expand Down Expand Up @@ -61,8 +74,10 @@ const Layout = () => {
};
const handleReload = () => {
const wv = document.querySelector("webview[data-visible='true']") as WebviewTag;
if (wv && wv.dataset.src) {
wv.loadURL(wv.dataset.src);
if (wv) {
wv.reloadIgnoringCache();
setReloading(true);
// wv.loadURL(wv.dataset.src);
}
};
const handleOpenWebviewDevTools = () => {
Expand Down Expand Up @@ -204,18 +219,23 @@ const Layout = () => {
</ServerTip>
<div className="my-1 h-[1px] w-9 bg-gray-300/50"></div>
<ServerTip content={"Refresh page"}>
<div
role="button"
<button
disabled={reloading}
onClick={handleReload}
className="app-no-drag group flex h-9 w-9 cursor-pointer items-center justify-center rounded hover:bg-gray-500/50"
>
<IconRefresh className="outline-none group-hover:stroke-white" />
</div>
<IconRefresh
className={clsx(
"outline-none group-hover:stroke-white",
reloading ? "animate-spin opacity-80" : ""
)}
/>
</button>
</ServerTip>
<button
title="Open DevTools"
onClick={handleOpenWebviewDevTools}
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"
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"
>
<IconDebug className="invisible outline-none group-hover:visible group-hover:stroke-white" />
</button>
Expand Down

0 comments on commit 228fad9

Please sign in to comment.