feat: refactor query proxy and router API, add random utilities, and create index files for queries

- Updated imports in proxy.ts to use browser-specific router.
- Refactored router-api-proxy.ts to streamline imports.
- Enhanced random.ts with additional utility functions for generating random IDs and letters.
- Created bun.config.ts for building query modules dynamically.
- Added index files for query modules (query-ai, query-app, query-config, query-login, query-shop, query-upload) to facilitate exports.
- Implemented get-query-list.ts to automate the generation of package entries for queries.
This commit is contained in:
2026-02-03 01:30:06 +08:00
parent 171847a46c
commit 2fec4dd04e
14 changed files with 83 additions and 524 deletions

View File

@@ -4,10 +4,19 @@ export const letter = 'abcdefghijklmnopqrstuvwxyz';
export const number = '0123456789';
const alphanumeric = `${letter}${number}`;
export const alphanumericWithDash = `${alphanumeric}-`;
/**
* 创建一个随机的字母字符串
*/
export const uuid = customAlphabet(letter);
/**
* 创建一个随机的 id包含字母和数字
*/
export const nanoid = customAlphabet(alphanumeric, 10);
/**
* 创建一个随机的 id包含字母、数字和短横线
*/
export const nanoidWithDash = customAlphabet(alphanumericWithDash, 10);
/**
@@ -20,6 +29,12 @@ export const randomId = (number: number) => {
return `${_letter}${nanoid(number)}`;
};
/**
* 创建一个随机的字母字符串
* @param number
* @param opts
* @returns
*/
export const randomLetter = (number: number = 8, opts?: { before?: string; after?: string }) => {
const { before = '', after = '' } = opts || {};
return `${before}${uuid(number)}${after}`;