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 committed 2026-05-05 23:51:07 +08:00
1 parent 4e5a7cb40a
commit 0aa562f6ee
16 files changed
+48 -23

No files matched your search

+2 -1
View File
@@ -1,5 +1,6 @@
<script setup lang="ts">
import { computed, ref } from "vue";
import { uuid } from "@/lib/utils";
import { useI18n } from "vue-i18n";
import { Plus, Trash2 } from "lucide-vue-next";
import { Button } from "@/components/ui/button";
@@ -67,7 +68,7 @@ function fieldValueTone(value: string): string {
function createBlankNode(keyName: string, readonlyKey: boolean): EditNode {
return {
key: crypto.randomUUID(),
key: uuid(),
keyName,
kind: "value",
valueText: "",
+4 -3
View File
@@ -1,5 +1,6 @@
<script setup lang="ts">
import { computed, ref, onMounted } from "vue";
import { uuid } from "@/lib/utils";
import { useI18n } from "vue-i18n";
import { RefreshCw, Trash2, Plus, Save, ChevronLeft, ChevronRight } from "lucide-vue-next";
import { Button } from "@/components/ui/button";
@@ -130,7 +131,7 @@ function cancelEdit() {
function createEditNode(keyName: string, value: unknown, readonlyKey: boolean, readonlyValue: boolean): EditNode {
if (Array.isArray(value)) {
return {
key: crypto.randomUUID(),
key: uuid(),
keyName,
kind: "array",
valueText: "",
@@ -142,7 +143,7 @@ function createEditNode(keyName: string, value: unknown, readonlyKey: boolean, r
if (value && typeof value === "object") {
return {
key: crypto.randomUUID(),
key: uuid(),
keyName,
kind: "object",
valueText: "",
@@ -155,7 +156,7 @@ function createEditNode(keyName: string, value: unknown, readonlyKey: boolean, r
}
return {
key: crypto.randomUUID(),
key: uuid(),
keyName,
kind: "value",
valueText: formatForEdit(value),