From 784aa6380eaf1171afd1d78c942f80248ef68661 Mon Sep 17 00:00:00 2001 From: abearxiong Date: Fri, 23 May 2025 11:38:33 +0800 Subject: [PATCH] save registry --- libs/registry/kevisual.json | 17 ++--------------- libs/registry/registry/utils/random.ts | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+), 15 deletions(-) create mode 100644 libs/registry/registry/utils/random.ts diff --git a/libs/registry/kevisual.json b/libs/registry/kevisual.json index 29e2e04..cedc59b 100644 --- a/libs/registry/kevisual.json +++ b/libs/registry/kevisual.json @@ -3,25 +3,12 @@ "share": "public" }, "syncDirectory": [ - { - "files": [ - "src/components/a/**/*", - "src/lib/**/*", - "src/hooks/**/*" - ], - "registry": "https://kevisual.xiongxiao.me/root/ai/code/registry", - "replace": { - "src/": "" - } - }, { "files": [ "registry/**/*" ], - "registry": "https://kevisual.xiongxiao.me/root/ai/code/registry", - "replace": { - "registry/": "components/b/" - } + "registry": "https://kevisual.xiongxiao.me/root/ai/code", + "replace": {} } ] } \ No newline at end of file diff --git a/libs/registry/registry/utils/random.ts b/libs/registry/registry/utils/random.ts new file mode 100644 index 0000000..8db5892 --- /dev/null +++ b/libs/registry/registry/utils/random.ts @@ -0,0 +1,21 @@ +import { customAlphabet } from 'nanoid'; + +export const letter = 'abcdefghijklmnopqrstuvwxyz'; +export const number = '0123456789'; +const alphanumeric = `${letter}${number}`; +export const alphanumericWithDash = `${alphanumeric}-`; +export const uuid = customAlphabet(letter); + +export const nanoid = customAlphabet(alphanumeric, 10); + +export const nanoidWithDash = customAlphabet(alphanumericWithDash, 10); + +/** + * 创建一个随机的 id,以字母开头的字符串 + * @param number + * @returns + */ +export const randomId = (number: number) => { + const _letter = uuid(1); + return `${_letter}${nanoid(number)}`; +};