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:
1
query/query-ai/index.ts
Normal file
1
query/query-ai/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from './query-ai.ts'
|
||||
1
query/query-app/index.ts
Normal file
1
query/query-app/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from './query-app.ts'
|
||||
1
query/query-config/index.ts
Normal file
1
query/query-config/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from './query-config.ts';
|
||||
1
query/query-login/index.ts
Normal file
1
query/query-login/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from './query-login-browser.ts';
|
||||
@@ -1,5 +1,5 @@
|
||||
import { QueryClient as Query, Result } from '@kevisual/query';
|
||||
import { QueryRouterServer, App, Route } from '@kevisual/router';
|
||||
import { QueryRouterServer, type App, type Route } from '@kevisual/router/browser';
|
||||
import { filter } from '@kevisual/js-filter'
|
||||
import { EventEmitter } from 'eventemitter3';
|
||||
import { initApi } from './router-api-proxy.ts';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Query } from "@kevisual/query";
|
||||
import { RouterViewApi, RouterItem } from "./proxy.ts";
|
||||
import { App, type QueryRouterServer } from "@kevisual/router";
|
||||
import { type App, type QueryRouterServer } from "@kevisual/router";
|
||||
import { filter } from "@kevisual/js-filter";
|
||||
import { isBrowser } from "es-toolkit";
|
||||
export const initApi = async (opts: {
|
||||
|
||||
1
query/query-shop/index.ts
Normal file
1
query/query-shop/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from './query-shop.ts'
|
||||
1
query/query-upload/index.ts
Normal file
1
query/query-upload/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from './query-upload-browser.ts';
|
||||
1
query/utils/index.ts
Normal file
1
query/utils/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from './random.ts';
|
||||
@@ -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}`;
|
||||
|
||||
Reference in New Issue
Block a user