fix: windows locale lead to app crash, fixed #255

Signed-off-by: Innei <i@innei.in>
This commit is contained in:
Innei
2024-09-03 15:31:16 +08:00
parent 3f04f148f5
commit bb43da9818
6 changed files with 29 additions and 19 deletions
+1 -1
View File
@@ -26,7 +26,7 @@ const ymlMapsMap = {
}
const keepModules = new Set(["font-list", "vscode-languagedetection"])
const keepLanguages = new Set(["en", "en_GB", "zh_CN"])
const keepLanguages = new Set(["en", "en_GB", "zh_CN", "zh-CN", "en-GB"])
// remove folders & files not to be included in the app
async function cleanSources(
buildPath,
+2
View File
@@ -106,6 +106,8 @@ function bootsharp() {
})
const handleOpen = (url: string) => {
const isValid = URL.canParse(url)
if (!isValid) return
const urlObj = new URL(url)
if (urlObj.hostname === "auth" || urlObj.pathname === "//auth") {
+4
View File
@@ -1,8 +1,12 @@
import { app } from "electron"
import { isWindows } from "../env"
export const setDockCount = (
input: number,
) => {
// TODO use Electron Overlay API
if (isWindows) return
if (app.dock) {
if (input === 0) {
app.dock.setBadge("")
+14 -11
View File
@@ -5,6 +5,7 @@ import { Outlet } from "react-router-dom"
import { env } from "../../env.js"
import { useAppIsReady } from "./atoms/app"
import { useUISettingKey } from "./atoms/settings/ui"
import { RootPortal } from "./components/ui/portal/index.js"
import { applyAfterReadyCallbacks } from "./initialize/queue.js"
import { appLog } from "./lib/log"
import { cn, getOS } from "./lib/utils"
@@ -45,17 +46,19 @@ function App() {
const windowsElectron = window.electron && getOS() === "Windows"
return (
<RootProviders>
{window.electron && (
<div
className={cn(
"drag-region absolute inset-x-0 top-0 h-12 shrink-0",
windowsElectron && "pointer-events-none z-[9999]",
)}
aria-hidden
>
{windowsElectron && <Titlebar />}
</div>
)}
<RootPortal>
{window.electron && (
<div
className={cn(
"fixed inset-x-0 top-0 h-12 shrink-0",
windowsElectron && "pointer-events-none z-[9999]",
)}
aria-hidden
>
{windowsElectron && <Titlebar />}
</div>
)}
</RootPortal>
<AppLayer />
</RootProviders>
)
@@ -40,6 +40,7 @@ import { CurrentModalContext } from "./context"
import { useResizeableModal } from "./hooks"
import type { ModalProps } from "./types"
const DragBar = isElectronBuild ? <span className="drag-region fixed left-0 right-36 top-0 h-8" /> : null
export const ModalInternal = memo(
forwardRef<
HTMLDivElement,
@@ -259,9 +260,7 @@ export const ModalInternal = memo(
}
style={zIndexStyle}
>
{isElectronBuild && (
<div className="drag-region fixed inset-x-0 top-0 h-8" />
)}
{DragBar}
<div
className={cn("contents", modalClassName)}
onClick={stopPropagation}
@@ -302,9 +301,7 @@ export const ModalInternal = memo(
undefined
}
>
{isElectronBuild && (
<div className="drag-region fixed inset-x-0 top-0 h-8" />
)}
{DragBar}
<m.div
ref={modalElementRef}
+5 -1
View File
@@ -1,3 +1,4 @@
import { useUISettingKey } from "@renderer/atoms/settings/ui"
import { ElECTRON_CUSTOM_TITLEBAR_HEIGHT } from "@renderer/constants"
import { tipcClient } from "@renderer/lib/client"
import { useQuery } from "@tanstack/react-query"
@@ -8,11 +9,14 @@ export const Titlebar = () => {
queryKey: ["windowIsMaximized"],
})
const feedColWidth = useUISettingKey("feedColWidth")
return (
<div
className="drag-region flex w-full items-center justify-end overflow-hidden"
className="drag-region absolute right-0 flex items-center justify-end overflow-hidden"
style={{
height: `${ElECTRON_CUSTOM_TITLEBAR_HEIGHT}px`,
left: `${feedColWidth}px`,
}}
>
<button