本文整理汇总了TypeScript中@bhmb/ui.UIExtensionExports类的典型用法代码示例。如果您正苦于以下问题:TypeScript UIExtensionExports类的具体用法?TypeScript UIExtensionExports怎么用?TypeScript UIExtensionExports使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了UIExtensionExports类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: createUI
async function createUI(list: keyof WorldLists, tab: HTMLDivElement, ui: UIExtensionExports) {
// Show worlds
const { worlds, settings } = await showWorlds(tab, ui)
// Get the lists and modify as required
ui.notify('Getting lists')
const lists = await Promise.all(worlds.map(getWorldLists))
let superList = flatten(pluck(lists, list))
if (settings.alphabetical) superList.sort((a, b) => a.toLowerCase().localeCompare(b.toLowerCase()))
if (settings.removeDuplicates) superList = unique(superList)
// Let the user edit the list
superList = await displayList(tab, superList)
// Choose which worlds to push the new list to
const { worlds: pushWorlds, settings: pushSettings } = await choosePushWorlds(tab, ui)
ui.notify('Pushing lists...')
const requests = pushWorlds.map(async world => {
const api = new MessageBot.dependencies.Api(world)
const lists = await getWorldLists(world)
pushSettings.mode == 'overwrite' ? lists[list] = superList : lists[list].push(...superList)
await api.setLists(lists)
})
await Promise.all(requests)
setTimeout(createUI, 1, list, tab, ui)
}
示例2: resolve
button.addEventListener('click', () => {
const ids = Array.from(worldsDiv.querySelectorAll('input'))
.filter(input => input.checked)
.map(input => input.value)
if (ids.length < 1) {
ui.notify('Please select at least one world')
return
}
const settings: PushSettings = {
mode: (tab.querySelector('[name=mode]:checked') as HTMLInputElement).value as 'overwrite' | 'append',
}
resolve({ worlds: worlds.filter(({ id }) => ids.includes(id)), settings })
})
示例3:
worlds.forEach(world => {
ui.buildTemplate(template, worldsDiv, [
{ selector: '[data-for=worldId]', value: world.id },
{ selector: '[data-for=worldName]', text: world.name }
])
})