mirror of
https://github.com/t8y2/dbx.git
synced 2026-10-31 08:23:34 +00:00
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:
@@ -1,4 +1,5 @@
|
||||
import { defineStore } from "pinia";
|
||||
import { uuid } from "@/lib/utils";
|
||||
import { ref, watch } from "vue";
|
||||
import type { ColumnInfo, ConnectionConfig, SidebarLayout, TreeNode } from "@/types/database";
|
||||
import { orderPinnedFirst } from "@/lib/pinnedItems";
|
||||
@@ -866,7 +867,7 @@ export const useConnectionStore = defineStore("connection", () => {
|
||||
(c) => c.name === config.name && c.host === config.host && c.port === config.port,
|
||||
);
|
||||
if (!duplicate) {
|
||||
config.id = crypto.randomUUID();
|
||||
config.id = uuid();
|
||||
const normalized = normalizeConnection(config);
|
||||
await addConnection(normalized);
|
||||
count++;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { defineStore } from "pinia";
|
||||
import { uuid } from "@/lib/utils";
|
||||
import { ref } from "vue";
|
||||
import * as api from "@/lib/api";
|
||||
import type { HistoryEntry } from "@/lib/api";
|
||||
@@ -19,7 +20,7 @@ export const useHistoryStore = defineStore("history", () => {
|
||||
async function add(entry: Omit<HistoryEntry, "id" | "executed_at">) {
|
||||
const full: HistoryEntry = {
|
||||
...entry,
|
||||
id: crypto.randomUUID(),
|
||||
id: uuid(),
|
||||
executed_at: new Date().toISOString(),
|
||||
};
|
||||
await api.saveHistory(full);
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user