fix: replace crypto.randomUUID with polyfill for HTTP contexts

crypto.randomUUID() is only available in secure contexts (HTTPS/localhost).
Add uuid() utility with fallback for HTTP deployments.
This commit is contained in:
t8y2
2026-05-05 23:51:07 +08:00
parent 4e5a7cb40a
commit 0aa562f6ee
16 changed files with 48 additions and 23 deletions
+4 -3
View File
@@ -1,4 +1,5 @@
import { defineStore } from "pinia";
import { uuid } from "@/lib/utils";
import { ref, watch } from "vue";
import type { DatabaseType, QueryTab } from "@/types/database";
import { orderPinnedFirst } from "@/lib/pinnedItems";
@@ -87,7 +88,7 @@ export const useQueryStore = defineStore("query", () => {
}
}
const id = crypto.randomUUID();
const id = uuid();
const tab: QueryTab = {
id,
title: title || `Query ${tabs.value.length + 1}`,
@@ -222,7 +223,7 @@ export const useQueryStore = defineStore("query", () => {
const tab = tabs.value.find((t) => t.id === id);
if (!tab || !sql.trim()) return;
const executionId = crypto.randomUUID();
const executionId = uuid();
tab.isExecuting = true;
tab.isCancelling = false;
tab.executionId = executionId;
@@ -270,7 +271,7 @@ export const useQueryStore = defineStore("query", () => {
return built;
}
const executionId = crypto.randomUUID();
const executionId = uuid();
tab.isExplaining = true;
tab.explainExecutionId = executionId;
tab.explainError = undefined;