mirror of
https://github.com/DayuanJiang/next-ai-draw-io.git
synced 2026-10-08 10:47:48 +08:00
- Bedrock: a user's AWS keys no longer go to an endpoint the server sets in AWS_ENDPOINT_URL_BEDROCK_RUNTIME / AWS_ENDPOINT_URL (read by the upgraded SDK), and admin panel keys win over AWS_BEARER_TOKEN_BEDROCK, as the Test button checks them. Checked with Bedrock. - Ollama: a server key without a base URL (admin panel, OLLAMA_API_KEY) goes to Ollama Cloud, as env.example says, instead of 127.0.0.1. - Quota: EdgeOne counts whatever key header comes along, keyless Ollama at a private address counts, and their provider texts stay in the log. - An EdgeOne server model (admin panel, ai-models.json) works: the route checked the raw provider header, which holds the name's slug. - parse-url ends downloads it does not read (too large, PDF, errors). - Desktop app: the port follows where the chats are (IndexedDB per origin) instead of a remembered port, which could hide them for good; a same-port restart tells the page to refetch the server models; a failed preset switch no longer undoes a newer choice; a presets file removed after a failed read can be saved again; .env values quoted from start to end keep their inner quotes, as dotenv reads them.
43 lines
1.4 KiB
TypeScript
43 lines
1.4 KiB
TypeScript
// @vitest-environment node
|
|
import { mkdtempSync, writeFileSync } from "node:fs"
|
|
import { tmpdir } from "node:os"
|
|
import { join } from "node:path"
|
|
import { afterEach, describe, expect, it, vi } from "vitest"
|
|
|
|
const dir = vi.hoisted(() => ({ path: "" }))
|
|
vi.mock("electron", () => ({
|
|
app: {
|
|
getPath: (name: string) =>
|
|
name === "exe" ? `${dir.path}/app/exe` : dir.path,
|
|
getAppPath: () => `${dir.path}/app`,
|
|
},
|
|
}))
|
|
|
|
import { loadEnvFile } from "@/electron/main/env-loader"
|
|
|
|
const KEYS = ["T_JSON", "T_COMMENT", "T_PLAIN", "T_DOUBLE"]
|
|
afterEach(() => {
|
|
for (const k of KEYS) delete process.env[k]
|
|
})
|
|
|
|
describe("loadEnvFile", () => {
|
|
it("reads quoted values like dotenv", () => {
|
|
dir.path = mkdtempSync(join(tmpdir(), "env-loader-"))
|
|
writeFileSync(
|
|
join(dir.path, ".env"),
|
|
[
|
|
// An apostrophe inside a single-quoted JSON value
|
|
`T_JSON='{"name":"Team's models"}'`,
|
|
`T_COMMENT="value" # a comment`,
|
|
"T_PLAIN=plain # a comment",
|
|
`T_DOUBLE="say "hi""`,
|
|
].join("\n"),
|
|
)
|
|
loadEnvFile()
|
|
expect(process.env.T_JSON).toBe(`{"name":"Team's models"}`)
|
|
expect(process.env.T_COMMENT).toBe("value")
|
|
expect(process.env.T_PLAIN).toBe("plain")
|
|
expect(process.env.T_DOUBLE).toBe(`say "hi"`)
|
|
})
|
|
})
|