mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-23 00:35:51 +00:00
fix: 替换 web 端 crypto.randomUUID 为 uuid 库以支持 HTTP 环境
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -444,7 +444,7 @@ function AskUserPanel({
|
|||||||
const handleSubmit = () => {
|
const handleSubmit = () => {
|
||||||
const mapped: Record<string, unknown> = {};
|
const mapped: Record<string, unknown> = {};
|
||||||
for (const [qIdx, val] of Object.entries(answers)) {
|
for (const [qIdx, val] of Object.entries(answers)) {
|
||||||
const q = questions[parseInt(qIdx)];
|
const q = questions[parseInt(qIdx, 10)];
|
||||||
if (!q) continue;
|
if (!q) continue;
|
||||||
if (typeof val === "number") {
|
if (typeof val === "number") {
|
||||||
mapped[qIdx] = q.options?.[val]?.label || String(val);
|
mapped[qIdx] = q.options?.[val]?.label || String(val);
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ export function AskUserPanelView({
|
|||||||
const handleSubmit = () => {
|
const handleSubmit = () => {
|
||||||
const mapped: Record<string, unknown> = {};
|
const mapped: Record<string, unknown> = {};
|
||||||
for (const [qIdx, val] of Object.entries(answers)) {
|
for (const [qIdx, val] of Object.entries(answers)) {
|
||||||
const q = questions[parseInt(qIdx)];
|
const q = questions[parseInt(qIdx, 10)];
|
||||||
if (!q) continue;
|
if (!q) continue;
|
||||||
if (typeof val === "number") mapped[qIdx] = q.options?.[val]?.label || String(val);
|
if (typeof val === "number") mapped[qIdx] = q.options?.[val]?.label || String(val);
|
||||||
else if (Array.isArray(val)) mapped[qIdx] = val.map((i) => q.options?.[i]?.label || String(i));
|
else if (Array.isArray(val)) mapped[qIdx] = val.map((i) => q.options?.[i]?.label || String(i));
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import type { SetStateAction } from "react";
|
import type { SetStateAction } from "react";
|
||||||
|
import { v4 as uuidv4 } from "uuid";
|
||||||
import {
|
import {
|
||||||
apiFetchSession,
|
apiFetchSession,
|
||||||
apiFetchSessionHistory,
|
apiFetchSessionHistory,
|
||||||
@@ -421,7 +422,7 @@ export class RCSChatAdapter {
|
|||||||
// Send to backend
|
// Send to backend
|
||||||
await apiSendEvent(this.sessionId, {
|
await apiSendEvent(this.sessionId, {
|
||||||
type: "user",
|
type: "user",
|
||||||
uuid: crypto.randomUUID(),
|
uuid: uuidv4(),
|
||||||
content: text,
|
content: text,
|
||||||
message: { content: text },
|
message: { content: text },
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import type { ChatTransport, UIMessage, UIMessageChunk } from "ai";
|
import type { ChatTransport, UIMessage, UIMessageChunk } from "ai";
|
||||||
|
import { v4 as uuidv4 } from "uuid";
|
||||||
import { getUuid } from "../api/client";
|
import { getUuid } from "../api/client";
|
||||||
import type { SessionEvent, EventPayload } from "../types";
|
import type { SessionEvent, EventPayload } from "../types";
|
||||||
|
|
||||||
@@ -112,7 +113,7 @@ export class RCSTransport implements ChatTransport<UIMessage> {
|
|||||||
headers: { "Content-Type": "application/json" },
|
headers: { "Content-Type": "application/json" },
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
type: "user",
|
type: "user",
|
||||||
uuid: crypto.randomUUID(),
|
uuid: uuidv4(),
|
||||||
content: text,
|
content: text,
|
||||||
message: { content: text },
|
message: { content: text },
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { type ClassValue, clsx } from "clsx";
|
import { type ClassValue, clsx } from "clsx";
|
||||||
import { twMerge } from "tailwind-merge";
|
import { twMerge } from "tailwind-merge";
|
||||||
|
import { v4 as uuidv4 } from "uuid";
|
||||||
|
|
||||||
export function cn(...inputs: ClassValue[]) {
|
export function cn(...inputs: ClassValue[]) {
|
||||||
return twMerge(clsx(inputs));
|
return twMerge(clsx(inputs));
|
||||||
@@ -42,10 +43,7 @@ export function truncate(str: string | null | undefined, max: number): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function generateMessageUuid(): string {
|
export function generateMessageUuid(): string {
|
||||||
if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
|
return uuidv4();
|
||||||
return crypto.randomUUID();
|
|
||||||
}
|
|
||||||
return `msg_${Date.now()}_${Math.random().toString(16).slice(2)}`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function extractEventText(payload: Record<string, unknown> | null | undefined): string {
|
export function extractEventText(payload: Record<string, unknown> | null | undefined): string {
|
||||||
|
|||||||
Reference in New Issue
Block a user