完善folder页面的web接口实现
This commit is contained in:
@@ -29,7 +29,7 @@ import {
|
||||
DropdownMenuItem,
|
||||
DropdownMenuTrigger,
|
||||
} from "@/components/ui/dropdown-menu"
|
||||
import { cn } from "@/lib/utils"
|
||||
import { cn, randomUUID } from "@/lib/utils"
|
||||
import { matchShortcutEvent } from "@/lib/keyboard-shortcuts"
|
||||
import { useShortcutSettings } from "@/hooks/use-shortcut-settings"
|
||||
import { readFileBase64 } from "@/lib/api"
|
||||
@@ -245,7 +245,7 @@ function isTextLikeFile(file: File): boolean {
|
||||
|
||||
function buildClipboardResourceUri(name: string): string {
|
||||
const normalizedName = name.trim() || "clipboard-resource"
|
||||
return `clipboard://${encodeURIComponent(normalizedName)}-${crypto.randomUUID()}`
|
||||
return `clipboard://${encodeURIComponent(normalizedName)}-${randomUUID()}`
|
||||
}
|
||||
|
||||
function buildDataUri(base64Data: string, mimeType: string | null): string {
|
||||
@@ -491,7 +491,7 @@ export function MessageInput({
|
||||
setAttachments((prev) => [
|
||||
...prev,
|
||||
...resources.map((resource) => ({
|
||||
id: `resource-embedded:${crypto.randomUUID()}`,
|
||||
id: `resource-embedded:${randomUUID()}`,
|
||||
type: "resource" as const,
|
||||
kind: "embedded" as const,
|
||||
uri: resource.uri,
|
||||
@@ -530,7 +530,7 @@ export function MessageInput({
|
||||
|
||||
for (const file of files) {
|
||||
const path = getFilePath(file)
|
||||
const name = file.name || `resource-${crypto.randomUUID()}`
|
||||
const name = file.name || `resource-${randomUUID()}`
|
||||
const mimeType = file.type || mimeTypeFromPath(name)
|
||||
if (path) {
|
||||
const uri = toFileUri(path)
|
||||
@@ -596,7 +596,7 @@ export function MessageInput({
|
||||
: (mimeTypeFromPath(file.name) ?? "image/png")
|
||||
const base64Data = await blobToBase64(file)
|
||||
return {
|
||||
id: `image:${Date.now()}:${index}:${crypto.randomUUID()}`,
|
||||
id: `image:${Date.now()}:${index}:${randomUUID()}`,
|
||||
type: "image" as const,
|
||||
data: base64Data,
|
||||
uri: null,
|
||||
@@ -615,7 +615,7 @@ export function MessageInput({
|
||||
paths.map(async (path, index) => {
|
||||
const data = await readFileBase64(path, DRAG_DROP_IMAGE_MAX_BYTES)
|
||||
return {
|
||||
id: `image:${Date.now()}:${index}:${crypto.randomUUID()}`,
|
||||
id: `image:${Date.now()}:${index}:${randomUUID()}`,
|
||||
type: "image" as const,
|
||||
data,
|
||||
uri: toFileUri(path),
|
||||
|
||||
@@ -17,7 +17,7 @@ import { useAcpActions } from "@/contexts/acp-connections-context"
|
||||
import { useFolderContext } from "@/contexts/folder-context"
|
||||
import { useTabContext } from "@/contexts/tab-context"
|
||||
import { useSessionStats } from "@/contexts/session-stats-context"
|
||||
import { cn } from "@/lib/utils"
|
||||
import { cn, randomUUID } from "@/lib/utils"
|
||||
import { useConnectionLifecycle } from "@/hooks/use-connection-lifecycle"
|
||||
import { useMessageQueue, type QueuedMessage } from "@/hooks/use-message-queue"
|
||||
import { MessageListView } from "@/components/message/message-list-view"
|
||||
@@ -103,7 +103,7 @@ function buildOptimisticUserTurnFromDraft(
|
||||
blocks.push({ type: "text", text })
|
||||
|
||||
return {
|
||||
id: `optimistic-${crypto.randomUUID()}`,
|
||||
id: `optimistic-${randomUUID()}`,
|
||||
role: "user",
|
||||
blocks,
|
||||
timestamp: new Date().toISOString(),
|
||||
@@ -762,7 +762,7 @@ const ConversationTabView = memo(function ConversationTabView({
|
||||
(answer: string) => {
|
||||
if (connStatus !== "connected") return
|
||||
const optimisticTurn: MessageTurn = {
|
||||
id: `optimistic-${crypto.randomUUID()}`,
|
||||
id: `optimistic-${randomUUID()}`,
|
||||
role: "user",
|
||||
blocks: [{ type: "text", text: answer }],
|
||||
timestamp: new Date().toISOString(),
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
import { useCallback, useState } from "react"
|
||||
import { Eye, EyeOff } from "lucide-react"
|
||||
import { useTranslations } from "next-intl"
|
||||
import { randomUUID } from "@/lib/utils"
|
||||
import { Button } from "@/components/ui/button"
|
||||
import { Input } from "@/components/ui/input"
|
||||
import {
|
||||
@@ -72,7 +73,7 @@ export function AddGitAccountDialog({
|
||||
}
|
||||
|
||||
const account: GitHubAccount = {
|
||||
id: crypto.randomUUID(),
|
||||
id: randomUUID(),
|
||||
server_url: trimmedUrl,
|
||||
username: trimmedUser,
|
||||
scopes: [],
|
||||
|
||||
@@ -4,6 +4,7 @@ import { useCallback, useState } from "react"
|
||||
import { ExternalLink, Eye, EyeOff, Loader2 } from "lucide-react"
|
||||
import { openUrl } from "@/lib/platform"
|
||||
import { useTranslations } from "next-intl"
|
||||
import { randomUUID } from "@/lib/utils"
|
||||
import { Button } from "@/components/ui/button"
|
||||
import { Input } from "@/components/ui/input"
|
||||
import {
|
||||
@@ -91,7 +92,7 @@ export function AddGitHubAccountDialog({
|
||||
}
|
||||
|
||||
const account: GitHubAccount = {
|
||||
id: crypto.randomUUID(),
|
||||
id: randomUUID(),
|
||||
server_url: serverUrl.trim() || "https://github.com",
|
||||
username: result.username ?? "unknown",
|
||||
scopes: result.scopes,
|
||||
|
||||
Reference in New Issue
Block a user