This commit is contained in:
2025-10-24 03:04:06 +08:00
parent cc74dc6803
commit ac32ff9d4a
3 changed files with 32 additions and 7 deletions

View File

@@ -133,7 +133,7 @@ export class Route<U = { [key: string]: any }> {
* 是否开启debug开启后会打印错误信息
*/
isDebug?: boolean;
constructor(path: string, key: string = '', opts?: RouteOpts) {
constructor(path: string = '', key: string = '', opts?: RouteOpts) {
if (!path) {
path = nanoid(8)
}
@@ -767,6 +767,18 @@ export class QueryRouterServer extends QueryRouter {
}
return new Route(path, key, opts);
}
prompt(description: string): Route<Required<RouteContext>>;
prompt(description: Function): Route<Required<RouteContext>>;
prompt(...args: any[]) {
const [desc] = args;
let description = ''
if (typeof desc === 'string') {
description = desc;
} else if (typeof desc === 'function') {
description = desc() || ''; // 如果是Promise需要addTo App之前就要获取应有的函数了。
}
return new Route('', '', { description });
}
/**
* 等于queryRoute但是调用了handle