c98d09d14c
- 新增 getSearchShortcutLabel 函数,根据平台返回搜索框的快捷键提示文案。 - 更新 SearchInput 组件,使用 getSearchShortcutLabel 显示正确的快捷键。 - 新增 constants.test.ts 测试文件,验证 getSearchShortcutLabel 函数在不同操作系统下的行为。 - 新增 features.lazy.test.ts 文件,测试懒加载功能,确保页面模块按需加载。
12 lines
466 B
TypeScript
12 lines
466 B
TypeScript
export const SEARCH_HISTORY_LIMIT = 10;
|
|
export const SEARCH_HISTORY_DISPLAY = 5;
|
|
|
|
export const isSearchHistory = (val: unknown): val is string[] =>
|
|
Array.isArray(val) && val.every((item) => typeof item === 'string');
|
|
|
|
/** 根据平台返回搜索框快捷键提示文案 */
|
|
export function getSearchShortcutLabel(): string {
|
|
if (typeof navigator === 'undefined') return 'Ctrl+K';
|
|
return /Mac|iPhone|iPad|iPod/i.test(navigator.userAgent) ? '⌘K' : 'Ctrl+K';
|
|
}
|