diff --git a/package.json b/package.json index 9350c082..ea2994de 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ "i18next": "^23.7.7", "lodash-es": "^4.17.21", "monaco-editor": "^0.34.1", + "nanoid": "^5.0.4", "react": "^18.2.0", "react-dom": "^18.2.0", "react-error-boundary": "^3.1.4", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d607e3b8..8f10ffa2 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -56,6 +56,9 @@ dependencies: monaco-editor: specifier: ^0.34.1 version: 0.34.1 + nanoid: + specifier: ^5.0.4 + version: 5.0.4 react: specifier: ^18.2.0 version: 18.2.0 @@ -3193,6 +3196,15 @@ packages: hasBin: true dev: true + /nanoid@5.0.4: + resolution: + { + integrity: sha512-vAjmBf13gsmhXSgBrtIclinISzFFy22WwCYoyilZlsrRXNIHSwgFQ1bEdjRwMT3aoadeIF6HMuDRlOxzfXV8ig==, + } + engines: { node: ^18 || >=20 } + hasBin: true + dev: false + /no-case@3.0.4: resolution: { diff --git a/src/components/test/test-viewer.tsx b/src/components/test/test-viewer.tsx index 84277341..21918c4f 100644 --- a/src/components/test/test-viewer.tsx +++ b/src/components/test/test-viewer.tsx @@ -5,6 +5,7 @@ import { useForm, Controller } from "react-hook-form"; import { TextField } from "@mui/material"; import { useVerge } from "@/hooks/use-verge"; import { BaseDialog, Notice } from "@/components/base"; +import { nanoid } from "nanoid"; interface Props { onChange: (uid: string, patch?: Partial) => void; @@ -67,7 +68,7 @@ export const TestViewer = forwardRef((props, ref) => { let uid; if (openType === "new") { - uid = crypto.randomUUID(); + uid = nanoid(); const item = { ...form, uid }; newList = [...testList, item]; await patchVerge({ test_list: newList }); diff --git a/src/pages/test.tsx b/src/pages/test.tsx index a28545f2..523190ab 100644 --- a/src/pages/test.tsx +++ b/src/pages/test.tsx @@ -20,6 +20,7 @@ import { BasePage } from "@/components/base"; import { TestViewer, TestViewerRef } from "@/components/test/test-viewer"; import { TestItem } from "@/components/test/test-item"; import { emit } from "@tauri-apps/api/event"; +import { nanoid } from "nanoid"; const TestPage = () => { const { t } = useTranslation(); @@ -34,19 +35,19 @@ const TestPage = () => { // test list const testList = verge?.test_list ?? [ { - uid: crypto.randomUUID(), + uid: nanoid(), name: "Apple", url: "https://www.apple.com", icon: "https://www.apple.com/favicon.ico", }, { - uid: crypto.randomUUID(), + uid: nanoid(), name: "GitHub", url: "https://www.github.com", icon: ``, }, { - uid: crypto.randomUUID(), + uid: nanoid(), name: "Google", url: "https://www.google.com", icon: ``,