完善folder页面的web接口实现
This commit is contained in:
@@ -852,7 +852,14 @@ export async function openFolderWindow(path: string): Promise<void> {
|
||||
}
|
||||
|
||||
export async function openCommitWindow(folderId: number): Promise<void> {
|
||||
return getTransport().call("open_commit_window", { folderId })
|
||||
if (getTransport().isDesktop()) {
|
||||
return getTransport().call("open_commit_window", { folderId })
|
||||
}
|
||||
const result = await getTransport().call<{ path: string }>(
|
||||
"open_commit_window",
|
||||
{ folderId },
|
||||
)
|
||||
window.location.href = result.path
|
||||
}
|
||||
|
||||
export type SettingsSection =
|
||||
@@ -871,10 +878,21 @@ export async function openSettingsWindow(
|
||||
section?: SettingsSection,
|
||||
options?: OpenSettingsWindowOptions
|
||||
): Promise<void> {
|
||||
return getTransport().call("open_settings_window", {
|
||||
section: section ?? null,
|
||||
agentType: options?.agentType ?? null,
|
||||
})
|
||||
if (getTransport().isDesktop()) {
|
||||
return getTransport().call("open_settings_window", {
|
||||
section: section ?? null,
|
||||
agentType: options?.agentType ?? null,
|
||||
})
|
||||
}
|
||||
// Web mode: get navigation path from backend and navigate
|
||||
const result = await getTransport().call<{ path: string }>(
|
||||
"open_settings_window",
|
||||
{
|
||||
section: section ?? null,
|
||||
agentType: options?.agentType ?? null,
|
||||
},
|
||||
)
|
||||
window.location.href = result.path
|
||||
}
|
||||
|
||||
export async function listOpenFolders(): Promise<FolderHistoryEntry[]> {
|
||||
|
||||
@@ -4,3 +4,21 @@ import { twMerge } from "tailwind-merge"
|
||||
export function cn(...inputs: ClassValue[]) {
|
||||
return twMerge(clsx(inputs))
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a UUID v4. Uses `crypto.randomUUID()` when available (secure
|
||||
* contexts), otherwise falls back to `crypto.getRandomValues()`.
|
||||
*/
|
||||
export function randomUUID(): string {
|
||||
if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
|
||||
return crypto.randomUUID()
|
||||
}
|
||||
// Fallback for non-secure contexts (HTTP over LAN)
|
||||
const bytes = new Uint8Array(16)
|
||||
crypto.getRandomValues(bytes)
|
||||
// Set version 4 and variant bits
|
||||
bytes[6] = (bytes[6] & 0x0f) | 0x40
|
||||
bytes[8] = (bytes[8] & 0x3f) | 0x80
|
||||
const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join("")
|
||||
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user