导入

import-command.ts
import { type NuiCommand, NuiCommandPalette } from '@needless-ui/angular/command';

NuiCommandPalette

带有命令搜索框的模态对话框。

选择器
nui-command-palette
NuiCommandPalette: 属性
名称类型默认值说明
commands输入NuiCommand[]命令,以 NuiCommand 对象的形式提供。
open双向绑定booleanfalse面板是否打开。
hotkey输入string | null'mod+k'随处打开和关闭面板的快捷键;设为 null 则不使用。mod 在 Apple 设备上是 ⌘,在其他设备上是 Ctrl。
bindShortcuts输入booleanfalse还可以在页面任意位置通过命令各自的快捷键执行命令。
loop输入booleantrue在最后一个命令上按向下键会回到第一个,在第一个命令上按向上键会跳到最后一个。
filtering输入booleantrue在输入时进行过滤。由服务器过滤命令时请关闭它。
loading输入booleanfalse在结果返回之前显示加载提示行。
hints输入booleantrue在底部显示可用的按键。
virtual输入boolean | 'auto''auto'只渲染可见的行:始终、从不,或 auto(超过 200 行时启用)。
label输入string'Command palette'对话框及其搜索框的可访问名称。
placeholder输入string'Type a command or search…'搜索框为空时显示的文本。
run输出NuiCommand每执行一个命令就发出该命令。
queryChange输出string在输入时发出文本,用于服务器端搜索。
show方法() => void打开面板。
hide方法() => void关闭面板。
toggle方法() => void打开面板,或将其关闭。
back方法() => void返回上一页。

它显示或播报的所有文本也都是输入属性,因此可以翻译: emptyLabel loadingLabel backLabel closeLabel moveLabel chooseLabel

NuiCommand

一个命令,或一页命令。

NuiCommand: 属性
名称类型默认值说明
label属性string显示并用于搜索的文本。
description属性string显示在主文本下方的次要文本。
group属性string分组相同的命令会列在该分组标题下。
keywords属性string[]搜索时额外匹配的词,例如同义词。
shortcut属性string随命令一起显示的按键,例如 mod+shift+p。
disabled属性boolean会显示,但无法执行。
children属性NuiCommand[]下一级的命令:选择此命令会将它们作为一个页面打开。
run属性() => void被选中时,在面板关闭后执行。
id属性string供你自行使用,例如在 (run) 中区分命令。