fix: portable flag

This commit is contained in:
MystiPanda
2023-12-15 21:39:34 +08:00
parent fa89fe3e87
commit 981f9d0b01
10 changed files with 47 additions and 18 deletions

View File

@@ -18,6 +18,7 @@ import { GuardState } from "./mods/guard-state";
import { LayoutViewer } from "./mods/layout-viewer";
import { UpdateViewer } from "./mods/update-viewer";
import getSystem from "@/utils/get-system";
import { portableFlag } from "@/pages/_layout";
interface Props {
onError?: (err: Error) => void;
@@ -213,7 +214,7 @@ const SettingVerge = ({ onError }: Props) => {
</IconButton>
</SettingItem>
{!(OS === "windows" && WIN_PORTABLE) && (
{!portableFlag && (
<SettingItem label={t("Check for Updates")}>
<IconButton
color="inherit"

View File

@@ -22,6 +22,9 @@ import { useCustomTheme } from "@/components/layout/use-custom-theme";
import getSystem from "@/utils/get-system";
import "dayjs/locale/ru";
import "dayjs/locale/zh-cn";
import { getPortableFlag } from "@/services/cmds";
export let portableFlag = false;
dayjs.extend(relativeTime);
@@ -71,10 +74,12 @@ const Layout = () => {
break;
}
});
setTimeout(() => {
void appWindow.unminimize();
void appWindow.show();
void appWindow.setFocus();
setTimeout(async () => {
portableFlag = await getPortableFlag();
await appWindow.unminimize();
await appWindow.show();
await appWindow.setFocus();
}, 50);
}, []);
@@ -119,9 +124,7 @@ const Layout = () => {
<div className="the-logo" data-windrag>
<LogoSvg />
{!(OS === "windows" && WIN_PORTABLE) && (
<UpdateButton className="the-newbtn" />
)}
{!portableFlag && <UpdateButton className="the-newbtn" />}
</div>
<List className="the-menu">

View File

@@ -191,3 +191,7 @@ export async function invoke_uwp_tool() {
Notice.error(err?.message || err.toString(), 1500)
);
}
export async function getPortableFlag() {
return invoke<boolean>("get_portable_flag");
}

View File

@@ -14,7 +14,6 @@ type Platform =
/**
* defines in `vite.config.ts`
*/
declare const WIN_PORTABLE: boolean;
declare const OS_PLATFORM: Platform;
/**