增加语音对话功能

This commit is contained in:
yhy
2026-08-29 22:13:55 +08:00
parent 1ffa069151
commit 3a2438f566
51 changed files with 6207 additions and 3 deletions
@@ -0,0 +1,33 @@
import { isWindows } from "./os";
/**
* Normalize user-provided executable path for the current OS.
* - Expands ~ on macOS/Linux via PathUtils (when available)
* - Ensures .exe suffix on Windows when missing
*/
export function normalizeExecutablePath(input: string): string {
const trimmed = (input || "").trim();
if (!trimmed) return "";
const path = trimmed;
if (isWindows() && !/\.(exe|cmd|bat)$/i.test(path)) {
return `${path}.exe`;
}
return path;
}
/** Join path segments using Zotero PathUtils (cross-platform). */
export function joinPath(...parts: string[]): string {
return PathUtils.join(...parts.filter(Boolean));
}
/** Convert local file path to file:// URL for <audio src>. */
export function pathToFileUrl(filePath: string): string {
const normalized = filePath.replace(/\\/g, "/");
if (normalized.startsWith("file://")) return normalized;
if (/^[A-Za-z]:\//.test(normalized)) {
return `file:///${encodeURI(normalized)}`;
}
return `file://${encodeURI(normalized)}`;
}