修复所有lint警告和错误

This commit is contained in:
xintaofei
2026-03-26 21:47:13 +08:00
parent 5e5c48338b
commit f61f9fb025
20 changed files with 138 additions and 93 deletions

View File

@@ -20,7 +20,7 @@ pub async fn require_token(
// Check Authorization header // Check Authorization header
if let Some(auth_header) = request.headers().get("authorization") { if let Some(auth_header) = request.headers().get("authorization") {
if let Ok(auth_str) = auth_header.to_str() { if let Ok(auth_str) = auth_header.to_str() {
if auth_str.strip_prefix("Bearer ").map_or(false, |t| t == token) { if auth_str.strip_prefix("Bearer ").is_some_and(|t| t == token) {
return next.run(request).await; return next.run(request).await;
} }
} }

View File

@@ -3,7 +3,10 @@
import { Suspense, useCallback, useEffect, useState } from "react" import { Suspense, useCallback, useEffect, useState } from "react"
import { useSearchParams } from "next/navigation" import { useSearchParams } from "next/navigation"
import { useTranslations } from "next-intl" import { useTranslations } from "next-intl"
const getCurrentWindow = async () => { const m = await import("@tauri-apps/api/window"); return m.getCurrentWindow() } const getCurrentWindow = async () => {
const m = await import("@tauri-apps/api/window")
return m.getCurrentWindow()
}
import { Loader2 } from "lucide-react" import { Loader2 } from "lucide-react"
import { CommitWorkspace } from "@/components/layout/commit-dialog" import { CommitWorkspace } from "@/components/layout/commit-dialog"
import { AppTitleBar } from "@/components/layout/app-title-bar" import { AppTitleBar } from "@/components/layout/app-title-bar"
@@ -74,9 +77,7 @@ function CommitPageInner() {
} }
}, [hasValidFolderId, normalizedFolderId]) }, [hasValidFolderId, normalizedFolderId])
const pageTitle = folder const pageTitle = folder ? `${t("title")} · ${folder.name}` : t("title")
? `${t("title")} · ${folder.name}`
: t("title")
useEffect(() => { useEffect(() => {
document.title = `${pageTitle} - codeg` document.title = `${pageTitle} - codeg`

View File

@@ -73,9 +73,7 @@ export default function LoginPage() {
/> />
</div> </div>
{error && ( {error && <p className="text-sm text-destructive">{error}</p>}
<p className="text-sm text-destructive">{error}</p>
)}
<button <button
type="submit" type="submit"

View File

@@ -3,7 +3,10 @@
import { Suspense, useCallback, useEffect, useState } from "react" import { Suspense, useCallback, useEffect, useState } from "react"
import { useSearchParams } from "next/navigation" import { useSearchParams } from "next/navigation"
import { useTranslations } from "next-intl" import { useTranslations } from "next-intl"
const getCurrentWindow = async () => { const m = await import("@tauri-apps/api/window"); return m.getCurrentWindow() } const getCurrentWindow = async () => {
const m = await import("@tauri-apps/api/window")
return m.getCurrentWindow()
}
import { Loader2 } from "lucide-react" import { Loader2 } from "lucide-react"
import { MergeWorkspace } from "@/components/merge/merge-workspace" import { MergeWorkspace } from "@/components/merge/merge-workspace"
import { AppTitleBar } from "@/components/layout/app-title-bar" import { AppTitleBar } from "@/components/layout/app-title-bar"
@@ -76,9 +79,7 @@ function MergePageInner() {
} }
}, [hasValidFolderId, normalizedFolderId]) }, [hasValidFolderId, normalizedFolderId])
const pageTitle = folder const pageTitle = folder ? `${t("title")} · ${folder.name}` : t("title")
? `${t("title")} · ${folder.name}`
: t("title")
useEffect(() => { useEffect(() => {
document.title = `${pageTitle} - codeg` document.title = `${pageTitle} - codeg`

View File

@@ -3,7 +3,10 @@
import { Suspense, useCallback, useEffect, useState } from "react" import { Suspense, useCallback, useEffect, useState } from "react"
import { useSearchParams } from "next/navigation" import { useSearchParams } from "next/navigation"
import { useTranslations } from "next-intl" import { useTranslations } from "next-intl"
const getCurrentWindow = async () => { const m = await import("@tauri-apps/api/window"); return m.getCurrentWindow() } const getCurrentWindow = async () => {
const m = await import("@tauri-apps/api/window")
return m.getCurrentWindow()
}
import { Loader2 } from "lucide-react" import { Loader2 } from "lucide-react"
import { PushWorkspace } from "@/components/layout/push-workspace" import { PushWorkspace } from "@/components/layout/push-workspace"
import { AppTitleBar } from "@/components/layout/app-title-bar" import { AppTitleBar } from "@/components/layout/app-title-bar"
@@ -74,9 +77,7 @@ function PushPageInner() {
} }
}, [hasValidFolderId, normalizedFolderId]) }, [hasValidFolderId, normalizedFolderId])
const pageTitle = folder const pageTitle = folder ? `${t("title")} · ${folder.name}` : t("title")
? `${t("title")} · ${folder.name}`
: t("title")
useEffect(() => { useEffect(() => {
document.title = `${pageTitle} - codeg` document.title = `${pageTitle} - codeg`

View File

@@ -64,9 +64,7 @@ function StashPageInner() {
} }
}, [hasValidFolderId, normalizedFolderId]) }, [hasValidFolderId, normalizedFolderId])
const pageTitle = folder const pageTitle = folder ? `${t("title")} · ${folder.name}` : t("title")
? `${t("title")} · ${folder.name}`
: t("title")
useEffect(() => { useEffect(() => {
document.title = `${pageTitle} - codeg` document.title = `${pageTitle} - codeg`

View File

@@ -753,6 +753,7 @@ export function MessageInput({
const selected = await openFileDialog({ const selected = await openFileDialog({
multiple: true, multiple: true,
directory: false, directory: false,
defaultPath,
}) })
if (!selected) return if (!selected) return
const picked = Array.isArray(selected) ? selected : [selected] const picked = Array.isArray(selected) ? selected : [selected]

View File

@@ -5,7 +5,9 @@ const emitEvent = async (event: string, payload?: unknown) => {
try { try {
const { emit } = await import("@tauri-apps/api/event") const { emit } = await import("@tauri-apps/api/event")
await emit(event, payload) await emit(event, payload)
} catch { /* not in Tauri */ } } catch {
/* not in Tauri */
}
} }
import { openFileDialog, subscribe } from "@/lib/platform" import { openFileDialog, subscribe } from "@/lib/platform"
import { import {
@@ -332,9 +334,7 @@ export function BranchDropdown({
async function handleBrowseWorktreePath() { async function handleBrowseWorktreePath() {
const selected = await openFileDialog({ directory: true, multiple: false }) const selected = await openFileDialog({ directory: true, multiple: false })
if (selected) { if (selected) {
setWorktreePath( setWorktreePath(Array.isArray(selected) ? selected[0] : selected)
Array.isArray(selected) ? selected[0] : selected,
)
} }
} }

View File

@@ -52,10 +52,9 @@ export function FolderNameDropdown() {
async function handleOpenFolder() { async function handleOpenFolder() {
const selected = await openFileDialog({ directory: true, multiple: false }) const selected = await openFileDialog({ directory: true, multiple: false })
if (selected) { if (selected) {
await openFolderWindow( await openFolderWindow(Array.isArray(selected) ? selected[0] : selected, {
Array.isArray(selected) ? selected[0] : selected, newWindow: true,
{ newWindow: true }, })
)
} }
} }

View File

@@ -5,7 +5,9 @@ async function emitEvent(event: string, payload?: unknown) {
try { try {
const { emit } = await import("@tauri-apps/api/event") const { emit } = await import("@tauri-apps/api/event")
await emit(event, payload) await emit(event, payload)
} catch { /* not in Tauri */ } } catch {
/* not in Tauri */
}
} }
import { Check, FileWarning, Loader2, X, CheckCheck } from "lucide-react" import { Check, FileWarning, Loader2, X, CheckCheck } from "lucide-react"
import { useTranslations } from "next-intl" import { useTranslations } from "next-intl"

View File

@@ -1,6 +1,11 @@
"use client" "use client"
import { useCallback, useEffect, type ComponentType, type ReactNode } from "react" import {
useCallback,
useEffect,
type ComponentType,
type ReactNode,
} from "react"
import { import {
Bot, Bot,
BookOpenText, BookOpenText,

View File

@@ -192,26 +192,18 @@ export function WebServiceSettings() {
isRunning ? "bg-green-500" : "bg-muted-foreground/30" isRunning ? "bg-green-500" : "bg-muted-foreground/30"
}`} }`}
/> />
<span className="text-sm"> <span className="text-sm">{isRunning ? "运行中" : "已停止"}</span>
{isRunning ? "运行中" : "已停止"}
</span>
<button <button
onClick={isRunning ? handleStop : handleStart} onClick={isRunning ? handleStop : handleStart}
disabled={loading} disabled={loading}
className="inline-flex h-8 items-center rounded-md border border-input bg-background px-3 text-xs font-medium ring-offset-background transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50" className="inline-flex h-8 items-center rounded-md border border-input bg-background px-3 text-xs font-medium ring-offset-background transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50"
> >
{loading {loading ? "处理中..." : isRunning ? "停止" : "启动"}
? "处理中..."
: isRunning
? "停止"
: "启动"}
</button> </button>
</div> </div>
</div> </div>
{error && ( {error && <p className="text-sm text-destructive">{error}</p>}
<p className="text-sm text-destructive">{error}</p>
)}
{/* Connection info */} {/* Connection info */}
{isRunning && ( {isRunning && (

View File

@@ -120,7 +120,11 @@ export async function acpSetConfigOption(
configId: string, configId: string,
valueId: string valueId: string
): Promise<void> { ): Promise<void> {
return getTransport().call("acp_set_config_option", { connectionId, configId, valueId }) return getTransport().call("acp_set_config_option", {
connectionId,
configId,
valueId,
})
} }
export async function acpCancel(connectionId: string): Promise<void> { export async function acpCancel(connectionId: string): Promise<void> {
@@ -483,7 +487,10 @@ export async function saveFolderOpenedConversations(
folderId: number, folderId: number,
items: OpenedConversation[] items: OpenedConversation[]
): Promise<void> { ): Promise<void> {
return getTransport().call("save_folder_opened_conversations", { folderId, items }) return getTransport().call("save_folder_opened_conversations", {
folderId,
items,
})
} }
export async function setFolderParentBranch( export async function setFolderParentBranch(
@@ -528,7 +535,10 @@ export async function gitPull(
path: string, path: string,
credentials?: GitCredentials | null credentials?: GitCredentials | null
): Promise<GitPullResult> { ): Promise<GitPullResult> {
return getTransport().call("git_pull", { path, credentials: credentials ?? null }) return getTransport().call("git_pull", {
path,
credentials: credentials ?? null,
})
} }
export async function gitStartPullMerge( export async function gitStartPullMerge(
@@ -546,7 +556,10 @@ export async function gitFetch(
path: string, path: string,
credentials?: GitCredentials | null credentials?: GitCredentials | null
): Promise<string> { ): Promise<string> {
return getTransport().call("git_fetch", { path, credentials: credentials ?? null }) return getTransport().call("git_fetch", {
path,
credentials: credentials ?? null,
})
} }
export async function gitPushInfo(path: string): Promise<GitPushInfo> { export async function gitPushInfo(path: string): Promise<GitPushInfo> {
@@ -582,7 +595,11 @@ export async function gitWorktreeAdd(
branchName: string, branchName: string,
worktreePath: string worktreePath: string
): Promise<void> { ): Promise<void> {
return getTransport().call("git_worktree_add", { path, branchName, worktreePath }) return getTransport().call("git_worktree_add", {
path,
branchName,
worktreePath,
})
} }
export async function gitCheckout( export async function gitCheckout(
@@ -673,7 +690,7 @@ export async function openMergeWindow(
folderId, folderId,
operation, operation,
upstreamCommit: upstreamCommit ?? null, upstreamCommit: upstreamCommit ?? null,
}, }
) )
window.open(result.path, `merge-${folderId}`) window.open(result.path, `merge-${folderId}`)
} }
@@ -684,7 +701,7 @@ export async function openStashWindow(folderId: number): Promise<void> {
} }
const result = await getTransport().call<{ path: string }>( const result = await getTransport().call<{ path: string }>(
"open_stash_window", "open_stash_window",
{ folderId }, { folderId }
) )
window.open(result.path, `stash-${folderId}`) window.open(result.path, `stash-${folderId}`)
} }
@@ -695,7 +712,7 @@ export async function openPushWindow(folderId: number): Promise<void> {
} }
const result = await getTransport().call<{ path: string }>( const result = await getTransport().call<{ path: string }>(
"open_push_window", "open_push_window",
{ folderId }, { folderId }
) )
window.open(result.path, `push-${folderId}`) window.open(result.path, `push-${folderId}`)
} }
@@ -716,7 +733,10 @@ export async function gitStashPop(
path: string, path: string,
stashRef?: string stashRef?: string
): Promise<string> { ): Promise<string> {
return getTransport().call("git_stash_pop", { path, stashRef: stashRef ?? null }) return getTransport().call("git_stash_pop", {
path,
stashRef: stashRef ?? null,
})
} }
export async function gitStashList(path: string): Promise<GitStashEntry[]> { export async function gitStashList(path: string): Promise<GitStashEntry[]> {
@@ -818,7 +838,11 @@ export async function gitShowDiff(
commit: string, commit: string,
file?: string file?: string
): Promise<string> { ): Promise<string> {
return getTransport().call("git_show_diff", { path, commit, file: file ?? null }) return getTransport().call("git_show_diff", {
path,
commit,
file: file ?? null,
})
} }
export async function gitShowFile( export async function gitShowFile(
@@ -866,14 +890,14 @@ export async function gitAddFiles(
export async function openFolderWindow( export async function openFolderWindow(
path: string, path: string,
options?: { newWindow?: boolean }, options?: { newWindow?: boolean }
): Promise<void> { ): Promise<void> {
if (getTransport().isDesktop()) { if (getTransport().isDesktop()) {
return getTransport().call("open_folder_window", { path }) return getTransport().call("open_folder_window", { path })
} }
const entry = await getTransport().call<{ id: number }>( const entry = await getTransport().call<{ id: number }>(
"open_folder_window", "open_folder_window",
{ path }, { path }
) )
const url = `/folder?id=${entry.id}` const url = `/folder?id=${entry.id}`
if (options?.newWindow) { if (options?.newWindow) {
@@ -889,7 +913,7 @@ export async function openCommitWindow(folderId: number): Promise<void> {
} }
const result = await getTransport().call<{ path: string }>( const result = await getTransport().call<{ path: string }>(
"open_commit_window", "open_commit_window",
{ folderId }, { folderId }
) )
window.open(result.path, `commit-${folderId}`) window.open(result.path, `commit-${folderId}`)
} }
@@ -922,7 +946,7 @@ export async function openSettingsWindow(
{ {
section: section ?? null, section: section ?? null,
agentType: options?.agentType ?? null, agentType: options?.agentType ?? null,
}, }
) )
window.open(result.path, `settings-${section ?? "general"}`) window.open(result.path, `settings-${section ?? "general"}`)
} }
@@ -938,7 +962,12 @@ export async function focusFolderWindow(folderId: number): Promise<void> {
// Web mode: open empty string to focus existing named window without reload. // Web mode: open empty string to focus existing named window without reload.
// If the window doesn't exist (was closed), open the folder page. // If the window doesn't exist (was closed), open the folder page.
const win = window.open("", `folder-${folderId}`) const win = window.open("", `folder-${folderId}`)
if (!win || win.closed || !win.location.href || win.location.href === "about:blank") { if (
!win ||
win.closed ||
!win.location.href ||
win.location.href === "about:blank"
) {
window.open(`/folder?id=${folderId}`, `folder-${folderId}`) window.open(`/folder?id=${folderId}`, `folder-${folderId}`)
} }
} }
@@ -961,14 +990,20 @@ export async function updateConversationStatus(
conversationId: number, conversationId: number,
status: string status: string
): Promise<void> { ): Promise<void> {
return getTransport().call("update_conversation_status", { conversationId, status }) return getTransport().call("update_conversation_status", {
conversationId,
status,
})
} }
export async function updateConversationTitle( export async function updateConversationTitle(
conversationId: number, conversationId: number,
title: string title: string
): Promise<void> { ): Promise<void> {
return getTransport().call("update_conversation_title", { conversationId, title }) return getTransport().call("update_conversation_title", {
conversationId,
title,
})
} }
export async function updateConversationExternalId( export async function updateConversationExternalId(
@@ -1000,7 +1035,11 @@ export async function createFolderCommand(
name: string, name: string,
command: string command: string
): Promise<FolderCommand> { ): Promise<FolderCommand> {
return getTransport().call("create_folder_command", { folderId, name, command }) return getTransport().call("create_folder_command", {
folderId,
name,
command,
})
} }
export async function updateFolderCommand( export async function updateFolderCommand(
@@ -1044,7 +1083,10 @@ export async function getFileTree(
path: string, path: string,
maxDepth?: number maxDepth?: number
): Promise<FileTreeNode[]> { ): Promise<FileTreeNode[]> {
return getTransport().call("get_file_tree", { path, maxDepth: maxDepth ?? null }) return getTransport().call("get_file_tree", {
path,
maxDepth: maxDepth ?? null,
})
} }
export async function startFileTreeWatch(rootPath: string): Promise<void> { export async function startFileTreeWatch(rootPath: string): Promise<void> {
@@ -1059,7 +1101,10 @@ export async function readFileBase64(
path: string, path: string,
maxBytes?: number maxBytes?: number
): Promise<string> { ): Promise<string> {
return getTransport().call("read_file_base64", { path, maxBytes: maxBytes ?? null }) return getTransport().call("read_file_base64", {
path,
maxBytes: maxBytes ?? null,
})
} }
export async function readFilePreview( export async function readFilePreview(
@@ -1107,7 +1152,11 @@ export async function renameFileTreeEntry(
path: string, path: string,
newName: string newName: string
): Promise<string> { ): Promise<string> {
return getTransport().call("rename_file_tree_entry", { rootPath, path, newName }) return getTransport().call("rename_file_tree_entry", {
rootPath,
path,
newName,
})
} }
export async function deleteFileTreeEntry( export async function deleteFileTreeEntry(
@@ -1123,7 +1172,12 @@ export async function createFileTreeEntry(
name: string, name: string,
kind: "file" | "dir" kind: "file" | "dir"
): Promise<string> { ): Promise<string> {
return getTransport().call("create_file_tree_entry", { rootPath, path, name, kind }) return getTransport().call("create_file_tree_entry", {
rootPath,
path,
name,
kind,
})
} }
export async function gitLog( export async function gitLog(

View File

@@ -24,9 +24,7 @@ export async function subscribe<T>(
*/ */
export async function openUrl(url: string): Promise<void> { export async function openUrl(url: string): Promise<void> {
if (isDesktop()) { if (isDesktop()) {
const { openUrl: tauriOpenUrl } = await import( const { openUrl: tauriOpenUrl } = await import("@tauri-apps/plugin-opener")
"@tauri-apps/plugin-opener"
)
await tauriOpenUrl(url) await tauriOpenUrl(url)
} else { } else {
window.open(url, "_blank") window.open(url, "_blank")
@@ -39,9 +37,8 @@ export async function openUrl(url: string): Promise<void> {
*/ */
export async function openPath(path: string): Promise<void> { export async function openPath(path: string): Promise<void> {
if (isDesktop()) { if (isDesktop()) {
const { openPath: tauriOpenPath } = await import( const { openPath: tauriOpenPath } =
"@tauri-apps/plugin-opener" await import("@tauri-apps/plugin-opener")
)
await tauriOpenPath(path) await tauriOpenPath(path)
} }
} }
@@ -52,9 +49,8 @@ export async function openPath(path: string): Promise<void> {
*/ */
export async function revealItemInDir(path: string): Promise<void> { export async function revealItemInDir(path: string): Promise<void> {
if (isDesktop()) { if (isDesktop()) {
const { revealItemInDir: tauriReveal } = await import( const { revealItemInDir: tauriReveal } =
"@tauri-apps/plugin-opener" await import("@tauri-apps/plugin-opener")
)
await tauriReveal(path) await tauriReveal(path)
} }
} }
@@ -101,9 +97,8 @@ export async function openFileDialog(options?: {
*/ */
export async function getCurrentWindow() { export async function getCurrentWindow() {
if (isDesktop()) { if (isDesktop()) {
const { getCurrentWindow: tauriGetCurrentWindow } = await import( const { getCurrentWindow: tauriGetCurrentWindow } =
"@tauri-apps/api/window" await import("@tauri-apps/api/window")
)
return tauriGetCurrentWindow() return tauriGetCurrentWindow()
} }
return null return null

View File

@@ -1,10 +1,7 @@
export type TransportEnvironment = "tauri" | "web" export type TransportEnvironment = "tauri" | "web"
export function detectEnvironment(): TransportEnvironment { export function detectEnvironment(): TransportEnvironment {
if ( if (typeof window !== "undefined" && "__TAURI_INTERNALS__" in window) {
typeof window !== "undefined" &&
"__TAURI_INTERNALS__" in window
) {
return "tauri" return "tauri"
} }
return "web" return "web"

View File

@@ -10,17 +10,16 @@ export function getTransport(): Transport {
const env = detectEnvironment() const env = detectEnvironment()
if (env === "tauri") { if (env === "tauri") {
// Use dynamic require to avoid bundling tauri deps in web mode. // Use dynamic require to avoid bundling tauri deps in web mode.
// TauriTransport uses dynamic imports internally. // eslint-disable-next-line @typescript-eslint/no-require-imports
const { TauriTransport } = require("./tauri-transport") as { const { TauriTransport } = require("./tauri-transport") as {
TauriTransport: new () => Transport TauriTransport: new () => Transport
} }
_transport = new TauriTransport() _transport = new TauriTransport()
} else { } else {
// eslint-disable-next-line @typescript-eslint/no-require-imports
const { WebTransport } = require("./web-transport") as { const { WebTransport } = require("./web-transport") as {
WebTransport: new (baseUrl: string) => Transport WebTransport: new (baseUrl: string) => Transport
} }
// In web mode, the API is served from the same origin.
// Token is read from localStorage on each request.
const baseUrl = window.location.origin const baseUrl = window.location.origin
_transport = new WebTransport(baseUrl) _transport = new WebTransport(baseUrl)
} }

View File

@@ -1,10 +1,7 @@
import type { Transport, UnsubscribeFn } from "./types" import type { Transport, UnsubscribeFn } from "./types"
export class TauriTransport implements Transport { export class TauriTransport implements Transport {
async call<T>( async call<T>(command: string, args?: Record<string, unknown>): Promise<T> {
command: string,
args?: Record<string, unknown>
): Promise<T> {
const { invoke } = await import("@tauri-apps/api/core") const { invoke } = await import("@tauri-apps/api/core")
return invoke(command, args) return invoke(command, args)
} }

View File

@@ -20,10 +20,7 @@ export class WebTransport implements Transport {
this.baseUrl = baseUrl this.baseUrl = baseUrl
} }
async call<T>( async call<T>(command: string, args?: Record<string, unknown>): Promise<T> {
command: string,
args?: Record<string, unknown>
): Promise<T> {
const token = getToken() const token = getToken()
const res = await fetch(`${this.baseUrl}/api/${command}`, { const res = await fetch(`${this.baseUrl}/api/${command}`, {
method: "POST", method: "POST",

View File

@@ -23,7 +23,8 @@ export interface AppUpdateErrorInfo {
export async function getCurrentAppVersion(): Promise<string> { export async function getCurrentAppVersion(): Promise<string> {
if (!isDesktop()) { if (!isDesktop()) {
const result = await getTransport().call<AppUpdateCheckResult>("check_app_update") const result =
await getTransport().call<AppUpdateCheckResult>("check_app_update")
return result.currentVersion return result.currentVersion
} }
try { try {
@@ -44,7 +45,9 @@ export async function checkAppUpdate(): Promise<AppUpdateCheckResult> {
return { currentVersion, update } return { currentVersion, update }
} }
export async function installAppUpdate(update: NonNullable<Update>): Promise<void> { export async function installAppUpdate(
update: NonNullable<Update>
): Promise<void> {
await update.downloadAndInstall() await update.downloadAndInstall()
} }
@@ -53,7 +56,9 @@ export async function relaunchApp(): Promise<void> {
await relaunch() await relaunch()
} }
export async function closeAppUpdate(update: NonNullable<Update>): Promise<void> { export async function closeAppUpdate(
update: NonNullable<Update>
): Promise<void> {
await update.close() await update.close()
} }

View File

@@ -10,7 +10,10 @@ export function cn(...inputs: ClassValue[]) {
* contexts), otherwise falls back to `crypto.getRandomValues()`. * contexts), otherwise falls back to `crypto.getRandomValues()`.
*/ */
export function randomUUID(): string { export function randomUUID(): string {
if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") { if (
typeof crypto !== "undefined" &&
typeof crypto.randomUUID === "function"
) {
return crypto.randomUUID() return crypto.randomUUID()
} }
// Fallback for non-secure contexts (HTTP over LAN) // Fallback for non-secure contexts (HTTP over LAN)