Skip to content

Commit

Permalink
fix: compatible with windows
Browse files Browse the repository at this point in the history
Signed-off-by: The1111mp <[email protected]>
  • Loading branch information
1111mp committed Feb 2, 2024
1 parent c05f3f2 commit d767010
Show file tree
Hide file tree
Showing 9 changed files with 138 additions and 42 deletions.
12 changes: 12 additions & 0 deletions _locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -414,5 +414,17 @@
"Tour-Text": {
"message": "Click me to run the onboarding tours",
"description": "The text of the Tour-Text"
},
"Page-Reload": {
"message": "Page Reload",
"description": "The text of the Page-Reload"
},
"Data-Update": {
"message": "Data Update",
"description": "The text of the Data-Update"
},
"Tour-Tip": {
"message": "The operation is successful. The onboarding tours will be run the next time you open the client",
"description": "The text of the Tour-Tip"
}
}
12 changes: 12 additions & 0 deletions _locales/zh_CN/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -414,5 +414,17 @@
"Tour-Text": {
"message": "点我以下次运行漫游式引导",
"description": "The text of the Tour-Text"
},
"Page-Reload": {
"message": "页面刷新",
"description": "The text of the Page-Reload"
},
"Data-Update": {
"message": "更新数据",
"description": "The text of the Data-Update"
},
"Tour-Tip": {
"message": "操作成功,下次打开客户端时将会运行漫游式引导",
"description": "The text of the Tour-Tip"
}
}
2 changes: 1 addition & 1 deletion src/main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ const controllers = new Map<string, AbortController>();

// defer actions
Promise.resolve().then(() => {
if (platform === "win32") {
if (platform !== "darwin") {
ipcMain.on("window:close", (_event) => {
mainWindow && mainWindow.close();
});
Expand Down
7 changes: 4 additions & 3 deletions src/renderer/src/components/theme-customizer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Button, Label, Popover, PopoverContent, PopoverTrigger } from "./ui";
import { CheckIcon, ColorWheelIcon } from "@radix-ui/react-icons";

import { cn } from "@renderer/lib/utils";
import { useAppContext } from "@renderer/app-context";
import { useAppContext, useI18n } from "@renderer/app-context";

const themes = [
{
Expand Down Expand Up @@ -105,11 +105,12 @@ const themes = [

export function ThemeCustomizer() {
const { theme: mode, color, setColor } = useAppContext();
const i18n = useI18n();

return (
<Popover>
<PopoverTrigger asChild>
<Button className="theme-customizer" size="sm" title="Color" variant="ghost">
<Button className="theme-customizer" size="sm" title={i18n("Theme-Color")} variant="ghost">
<ColorWheelIcon />
</Button>
</PopoverTrigger>
Expand All @@ -118,7 +119,7 @@ export function ThemeCustomizer() {
className="z-40 w-[340px] rounded-[0.5rem] bg-white p-3 dark:bg-zinc-950"
>
<div className="space-y-1.5">
<Label className="text-xs">Color</Label>
<Label className="text-xs">{i18n("Theme-Color")}</Label>
<div className="grid grid-cols-3 gap-2">
{themes.map(({ name, label, activeColor }) => {
const isActive = color === name;
Expand Down
136 changes: 102 additions & 34 deletions src/renderer/src/pages/home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ import "./intro.css";
import { useState, useEffect, useMemo } from "react";
import { Outlet, Link, useLocation } from "react-router-dom";
import {
Button,
NavigationMenu,
NavigationMenuItem,
NavigationMenuLink,
NavigationMenuList,
navigationMenuTriggerStyle
} from "@renderer/components/ui";
import { ThemeCustomizer } from "@renderer/components/theme-customizer";
import { RocketIcon, HeartIcon, FaceIcon } from "@radix-ui/react-icons";
import { RocketIcon, HeartIcon, FaceIcon, MinusIcon, Cross2Icon } from "@radix-ui/react-icons";
import { Updater } from "./updater";
import { Setting } from "./setting";
import { Tip } from "./tip";
Expand Down Expand Up @@ -346,39 +347,106 @@ const Home: React.FC = () => {

return (
<>
<header className="flex items-center pt-2 pr-3 justify-between pl-24 select-none [-webkit-app-region:drag]">
<NavigationMenu>
<NavigationMenuList className="[-webkit-app-region:no-drag]">
<NavigationMenuItem>
<NavigationMenuLink asChild>
<Link to="/all" className={linkStyle} data-active={pathname === "/all"}>
{i18n("Versions")}
</Link>
</NavigationMenuLink>
</NavigationMenuItem>
<NavigationMenuItem>
<NavigationMenuLink asChild>
<Link to="/installed" className={linkStyle} data-active={pathname === "/installed"}>
{i18n("Installed")}
</Link>
</NavigationMenuLink>
</NavigationMenuItem>
<NavigationMenuItem className="nvmd-project">
<NavigationMenuLink asChild>
<Link to="/projects" className={linkStyle} data-active={pathname === "/projects"}>
{i18n("Projects")}
</Link>
</NavigationMenuLink>
</NavigationMenuItem>
</NavigationMenuList>
</NavigationMenu>
<div className="flex items-center [-webkit-app-region:no-drag]">
{platform === "win32" ? <Updater /> : null}
<ThemeCustomizer />
<Tip />
<Setting />
</div>
</header>
{platform === "darwin" ? (
<header className="flex items-center pt-2 pr-3 justify-between pl-24 select-none [-webkit-app-region:drag]">
<NavigationMenu>
<NavigationMenuList className="[-webkit-app-region:no-drag]">
<NavigationMenuItem>
<NavigationMenuLink asChild>
<Link to="/all" className={linkStyle} data-active={pathname === "/all"}>
{i18n("Versions")}
</Link>
</NavigationMenuLink>
</NavigationMenuItem>
<NavigationMenuItem>
<NavigationMenuLink asChild>
<Link
to="/installed"
className={linkStyle}
data-active={pathname === "/installed"}
>
{i18n("Installed")}
</Link>
</NavigationMenuLink>
</NavigationMenuItem>
<NavigationMenuItem className="nvmd-project">
<NavigationMenuLink asChild>
<Link to="/projects" className={linkStyle} data-active={pathname === "/projects"}>
{i18n("Projects")}
</Link>
</NavigationMenuLink>
</NavigationMenuItem>
</NavigationMenuList>
</NavigationMenu>
<div className="flex items-center [-webkit-app-region:no-drag]">
<ThemeCustomizer />
<Tip />
<Setting />
</div>
</header>
) : (
<header className="flex items-center pt-2 px-3 justify-between select-none [-webkit-app-region:drag]">
<div className="flex items-center gap-3">
<div className="flex items-center gap-1 [-webkit-app-region:no-drag]">
<Button
size="sm"
variant="secondary"
icon={<Cross2Icon />}
onClick={() => {
window.Context.windowClose();
}}
></Button>
<Button
size="sm"
variant="secondary"
icon={<MinusIcon />}
onClick={() => {
window.Context.windowMinimize();
}}
/>
</div>
<NavigationMenu>
<NavigationMenuList className="[-webkit-app-region:no-drag]">
<NavigationMenuItem>
<NavigationMenuLink asChild>
<Link to="/all" className={linkStyle} data-active={pathname === "/all"}>
{i18n("Versions")}
</Link>
</NavigationMenuLink>
</NavigationMenuItem>
<NavigationMenuItem>
<NavigationMenuLink asChild>
<Link
to="/installed"
className={linkStyle}
data-active={pathname === "/installed"}
>
{i18n("Installed")}
</Link>
</NavigationMenuLink>
</NavigationMenuItem>
<NavigationMenuItem className="nvmd-project">
<NavigationMenuLink asChild>
<Link
to="/projects"
className={linkStyle}
data-active={pathname === "/projects"}
>
{i18n("Projects")}
</Link>
</NavigationMenuLink>
</NavigationMenuItem>
</NavigationMenuList>
</NavigationMenu>
</div>
<div className="flex items-center [-webkit-app-region:no-drag]">
{platform === "win32" ? <Updater /> : null}
<ThemeCustomizer />
<Tip />
<Setting />
</div>
</header>
)}
<main className="px-6 py-4 flex-1 overflow-hidden">
<Outlet />
</main>
Expand Down
2 changes: 2 additions & 0 deletions src/renderer/src/pages/home/tip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
} from "@renderer/components/ui";
import { CookieIcon, InfoCircledIcon } from "@radix-ui/react-icons";
import { useAppContext, useI18n } from "@src/renderer/src/app-context";
import { toast } from "sonner";

export function Tip() {
const { locale } = useAppContext();
Expand Down Expand Up @@ -292,6 +293,7 @@ export function Tip() {
icon={<CookieIcon />}
onClick={() => {
localStorage.removeItem("nvmd-first");
toast.success(i18n("Tour-Tip"));
}}
>
{i18n("Tour-Text")}
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/src/pages/installed/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ export const Component: React.FC = () => {
<div className="flex items-center gap-2">
<DataTableToolbar table={table} options={statuses} />
<Button size="sm" loading={loading} icon={<ReloadIcon />} onClick={onPageReload}>
Page Reload
{i18n("Page-Reload")}
</Button>
</div>
)}
Expand Down
3 changes: 2 additions & 1 deletion src/renderer/src/pages/projects/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export const Component: React.FC = () => {
{
accessorKey: "sort",
maxSize: 50,
enableHiding: false,
header: () => null
},
{
Expand Down Expand Up @@ -247,7 +248,7 @@ export const Component: React.FC = () => {
<DataTableToolbar table={table} filterName="name" status={false} />
<div className="flex items-center gap-2">
<Button size="sm" loading={loading} icon={<ReloadIcon />} onClick={onPageReload}>
Page Reload
{i18n("Page-Reload")}
</Button>
<Button size="sm" icon={<FilePlusIcon />} onClick={onAddProject}>
{i18n("Add-Project")}
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/src/pages/versions/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ const Versions: React.FC = () => {
icon={<ReloadIcon />}
onClick={onPageReload}
>
Page Reload
{i18n("Page-Reload")}
</Button>
<Button
loading={loading}
Expand All @@ -446,7 +446,7 @@ const Versions: React.FC = () => {
icon={<UpdateIcon />}
onClick={onDataUpdate}
>
Data Update
{i18n("Data-Update")}
</Button>
</div>
</div>
Expand Down

0 comments on commit d767010

Please sign in to comment.